RuntimeError: Unsupported marker type 0x4f on 2nd epoch

Greetings,
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/image.py 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
    204 

RuntimeError: Unsupported marker type 0x4f

I use these transforms:

transform = nn.Sequential(
            T.Resize([256, ]), 
            T.CenterCrop(224),
            T.ConvertImageDtype(torch.float),
            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
ImageFile.LOAD_TRUNCATED_IMAGES = True
with Image.open(p) as im:
    im.save(p)

Here is the image for context: