RuntimeError: Unsupported marker type 0x4f on 2nd epoch

I get this error when I train a resnet18 model from Torchvision on a custom dataset. It only happens on the 2nd epoch after a few dozen iterations.

RuntimeError                              Traceback (most recent call last)
<ipython-input-63-e338034a4492> in <module>()
----> 1 model_ft = train_model(model_ft, criterion, optimizer_ft, exp_lr_scheduler,num_epochs=25)

8 frames
/usr/local/lib/python3.7/dist-packages/torchvision/io/ in decode_image(input, mode)
    200         output (Tensor[image_channels, image_height, image_width])
    201     """
--> 202     output = torch.ops.image.decode_image(input, mode.value)
    203     return output

RuntimeError: Unsupported marker type 0x4f

I use these transforms:

transform = nn.Sequential(
            T.Resize([256, ]), 
            T.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])

Does anyone have an idea of what could be wrong?

The image decoding is failing and torchvision seems to reraise the error. Are you able to load the file with another library and if so, could you save it using a different file name, and try to load it again via torch.ops.image.decode_image?

I read the image and saved with PIL and it solved the problem. Thanks!

p = 'wikiart/Post_Impressionism/vincent-van-gogh_l-arlesienne-portrait-of-madame-ginoux-1890.jpg'
from PIL import Image, ImageFile
with as im:

Here is the image for context: