It seems there is still some problem with Image loader.
File "...\PyTorch-YOLOv3\utils\datasets.py", line 86, in __getitem__
img = transforms.ToTensor()(Image.open(img_path).convert('RGB'))
File "C:\ProgramData\Anaconda3\envs\ghimire\lib\site-packages\PIL\Image.py", line 899, in convert
self.load()
File "C:\ProgramData\Anaconda3\envs\ghimire\lib\site-packages\PIL\ImageFile.py", line 236, in load
len(b))
OSError: image file is truncated (7 bytes not processed)
Therefore i'm using cv2 image loader.
It's probably you installed Pillow instead of PIL. Try adding these to datasets.py file at line 14:
from PIL import ImageFile
ImageFile.LOAD_TRUNCATED_IMAGES = True
It's probably you installed Pillow instead of PIL. Try adding these to
datasets.pyfile at line 14:
from PIL import ImageFile
ImageFile.LOAD_TRUNCATED_IMAGES = True
@chuong , Solved
Thank you
The method about:
from PIL import ImageFile
ImageFile.LOAD_TRUNCATED_IMAGES = True
is ineffective to me, so I change the code:
img = transforms.ToTensor()(Image.open(img_path).convert('RGB'))
to this:
img = transforms.ToTensor()(cv2.cvtColor(cv2.imread(img_path), cv2.COLOR_BGR2RGB))
and it works.
Thinks!
Most helpful comment
It's probably you installed Pillow instead of PIL. Try adding these to
datasets.pyfile at line 14:from PIL import ImageFileImageFile.LOAD_TRUNCATED_IMAGES = True