Код:
paths = "/content/train2017"
midis = os.listdir(paths)
for j in midis:
for i in imgsids:
os.renames("/content/train2017/" + j, str(i) + ".jpg")
Код ошибки:
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
<ipython-input-106-b57cb06c2dff> in <module>()
14 for j in midis:
15 for i in imgsids:
---> 16 os.renames("/content/train2017/" + j, str(i) + ".jpg")
17 catIds = coco.getCatIds(catNms=['person', "car"])
18 imgIds = coco.getImgIds(catIds=catIds );
/usr/lib/python3.7/os.py in renames(old, new)
268 if head and tail and not path.exists(head):
269 makedirs(head)
--> 270 rename(old, new)
271 head, tail = path.split(old)
272 if head and tail:
FileNotFoundError: [Errno 2] No such file or directory: '/content/train2017/000000211351.jpg' -> '522418.jpg'
Фото директории и кода ошибки, чтобы было больше понимания.