qqwweee / keras-yolo3

A Keras implementation of YOLOv3 (Tensorflow backend)
MIT License
7.13k stars 3.45k forks source link

FileNotFoundError: [Errno 2] No such file or directory: 'data/JPEGImages/f2669269b8aaea24.jpg' #686

Closed hernanrazo closed 4 years ago

hernanrazo commented 4 years ago

I'm trying to use the train-azureml.py script to train a custom model.

I get the following error:

Traceback (most recent call last):
  File "train_azureml.py", line 274, in <module>
    anchors_path=args.anchors_path, data_dir=args.data_dir)
  File "train_azureml.py", line 102, in main
    callbacks=[logging, LogRunMetrics()])
  File "/Users/hernanrazo/pythonProjects/package_theft_detection/theft_env/lib/python3.6/site-packages/keras/legacy/interfaces.py", line 91, in wrapper
    return func(*args, **kwargs)
  File "/Users/hernanrazo/pythonProjects/package_theft_detection/theft_env/lib/python3.6/site-packages/keras/engine/training.py", line 1418, in fit_generator
    initial_epoch=initial_epoch)
  File "/Users/hernanrazo/pythonProjects/package_theft_detection/theft_env/lib/python3.6/site-packages/keras/engine/training_generator.py", line 181, in fit_generator
    generator_output = next(output_generator)
  File "/Users/hernanrazo/pythonProjects/package_theft_detection/theft_env/lib/python3.6/site-packages/keras/utils/data_utils.py", line 709, in get
    six.reraise(*sys.exc_info())
  File "/Users/hernanrazo/pythonProjects/package_theft_detection/theft_env/lib/python3.6/site-packages/six.py", line 703, in reraise
    raise value
  File "/Users/hernanrazo/pythonProjects/package_theft_detection/theft_env/lib/python3.6/site-packages/keras/utils/data_utils.py", line 685, in get
    inputs = self.queue.get(block=True).get()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/pool.py", line 644, in get
    raise self._value
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/pool.py", line 119, in worker
    result = (True, func(*args, **kwds))
  File "/Users/hernanrazo/pythonProjects/package_theft_detection/theft_env/lib/python3.6/site-packages/keras/utils/data_utils.py", line 626, in next_sample
    return six.next(_SHARED_SEQUENCES[uid])
  File "train_azureml.py", line 221, in data_generator
    image, box = get_random_data(annotation_lines[i], input_shape, random=True)
  File "/Users/hernanrazo/pythonProjects/package_theft_detection/azureml-keras-yolov3-custom/project/yolo3/utils.py", line 39, in get_random_data
    image = Image.open(line[0])
  File "/Users/hernanrazo/pythonProjects/package_theft_detection/theft_env/lib/python3.6/site-packages/PIL/Image.py", line 2766, in open
    fp = builtins.open(filename, "rb")
FileNotFoundError: [Errno 2] No such file or directory: 'data/JPEGImages/f2669269b8aaea24.jpg

The terminal command I use to start training is:

python train_azureml.py --model yolov3-custom-base.h5 --gpu_num 1 --annot_path train_list.txt --class_path custom_class.txt --anchors_path yolo_anchors.txt

I know for a fact that the images are in my local computer and in the azure container. I don't know why it is giving me this error but I suspect I did not generate the annotations correctly.

my train_list.txt file looks like:

data/JPEGImages/c778c7822b1ede78.jpg
data/JPEGImages/55a7a10470b94030.jpg
data/JPEGImages/065e8240703f3565.jpg
data/JPEGImages/f5b03b983a4c8b51.jpg
data/JPEGImages/e29c33a280bd76f5.jpg
...
...
...

The voc_annotations.py file generated an .xml file for each image and looks like:

<annotation><folder>open_images_volume</folder><filename>0a1b99667632d5c5.jpg</filename><path>/mnt/open_images_volume/0a1b99667632d5c5.jpg</path><source><database>Unknown</database></source><size><width>1024</width><height>1024</height><depth>3</depth></size><segmented>0</segmented><object><name>Box</name><pose>Unspecified</pose><truncated>0</truncated><difficult>0</difficult><bndbox><xmin>23</xmin><ymin>308</ymin><xmax>398</xmax><ymax>648</ymax></bndbox></object></annotation>

Any help is appreciated.

Kuuuo commented 4 years ago

Have you solved the problem yet? I made a similar mistake