0

Currently learning reading image by csv and crop it with the data in the csv and i got I/O Error at my data image

the csv has data like below

filename    width   height  class   xmin    ymin    xmax    ymax
Data16_173_55.jpg   600 338 Membuka Smartphone  476.25  100.14815   518.125 148.03148
Data16_173_56.jpg   600 338 Membuka Smartphone  474.68753   95.14074    517.1875    153.0389
Data16_173_57.jpg   600 338 Membuka Smartphone  468.125 93.26296    518.125 149.5963
Data16_173_58.jpg   600 338 Membuka Smartphone  470.3125    101.08704   519.0625    148.34444

and i am currently trying to crop it and replace the image using looping code by reading the filename, here's the code

import shutil
import os
from PIL import Image
import cv2
import pandas as pd

data = pd.read_csv('labels.csv')
for index, row in data.iterrows():
  input_name  = os.path.join("imagesXRP", row["filename"])
  xmin  = row["xmin"]
  ymin = row['ymin']
  xmax  = row["xmax"]
  ymax = row['ymax']
  im = Image.open(input_name)
  im1 = im.crop((xmin, ymin, xmax, ymax))
  im1.save(input_name)

any answer would be help

thank you so much !

OSError: [Errno 5] Input/output error: 'imagesXRP/Data16_173_55.jpg'

8
  • Does the directory/folder imagesXRP exist and already placed in the same folder as your python file? Commented Aug 17, 2021 at 11:59
  • Yes it is exist and placed in the same folder Commented Aug 17, 2021 at 12:04
  • Probably error on the disk itself: stackoverflow.com/questions/26805025/… . Have you tried on another device such as VM or even Google Colab/Kaggle Notebook? Commented Aug 17, 2021 at 12:05
  • i run this code on collab Commented Aug 17, 2021 at 12:37
  • What about using ./imagesXRP instead of imagesXRP in the os.path.join? Commented Aug 17, 2021 at 12:43

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.