You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When attempting to use the download method, we get the following:
>>> from pycocotools.coco import COCO
>>> coco = COCO('tiny_image.json')
loading annotations into memory...
Done (t=0.00s)
creating index...
index created!
>>> coco.download('.')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/scott/NOAA/research/deep7_modeling/venv/lib/python3.11/site-packages/pycocotools/coco.py", line 390, in download
urlretrieve(img['coco_url'], fname)
File "/usr/lib/python3.11/urllib/request.py", line 251, in urlretrieve
tfp = open(filename, 'wb')
^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: './yummy/taco.jpg'
This is because the urlretrieve method does not automatically create the necessary directory structure. I think a one or two line fix of:
When I create a COCO-format file for my images, if the filenames are nested, then the
download
method fails.For example, with the following COCO-format file named 'tiny_image.json':
Note the
file_name
, which contains a nested file.When attempting to use the
download
method, we get the following:This is because the
urlretrieve
method does not automatically create the necessary directory structure. I think a one or two line fix of:On the line immediately before the call to
urlretrieve
will enable this. Happy to submit a PR if there is a maintainer willing to pull it.The text was updated successfully, but these errors were encountered: