Weird debug messages in log when using resnet50?

I just successfully ran Pytorch’s implementation of ResNet50 with pre-trained weights on ImageNet.
However something dumped thousands of strange debug messages in my log file.
They appear to come in groups as there are recurring patterns in the tags, here is an exemplary collection of them:

2022-11-25 21:44:12,649 DEBUG: tag: Orientation (274) - type: short (3) - value: b'\x00\x01'
2022-11-25 21:44:12,649 DEBUG: tag: XResolution (282) - type: rational (5) Tag Location: 34 - Data Location: 98 - value: b'\x00\x00\x00\x1c\x00\x00\x00\x01'
2022-11-25 21:44:12,649 DEBUG: tag: YResolution (283) - type: rational (5) Tag Location: 46 - Data Location: 106 - value: b'\x00\x00\x00\x1c\x00\x00\x00\x01'
2022-11-25 21:44:12,650 DEBUG: tag: ResolutionUnit (296) - type: short (3) - value: b'\x00\x03'
2022-11-25 21:44:12,650 DEBUG: tag: Software (305) - type: string (2) Tag Location: 70 - Data Location: 114 - value: b'Adobe Photoshop 7.0\x00'
2022-11-25 21:44:12,650 DEBUG: tag: DateTime (306) - type: string (2) Tag Location: 82 - Data Location: 134 - value: b'2004:01:20 13:12:15\x00'
2022-11-25 21:44:12,650 DEBUG: tag: ExifIFD (34665) - type: long (4) - value: b'\x00\x00\x00\x9c'
2022-11-25 21:44:15,997 DEBUG: tag: Software (305) - type: string (2) Tag Location: 22 - Data Location: 62 - value: b'EXIFutils V2.7.4'
2022-11-25 21:44:15,998 DEBUG: tag: Artist (315) - type: string (2) Tag Location: 34 - Data Location: 78 - value: b'Wendy Knipe'
2022-11-25 21:44:15,998 DEBUG: tag: Copyright (33432) - type: string (2) Tag Location: 46 - Data Location: 90 - value: <table: 59 bytes>
2022-11-25 21:44:15,998 DEBUG: tag: ExifIFD (34665) - type: long (4) - value: b'\x00\x00\x00\x96'

Can someone tell me where these come from and/or how I can suppress them?

best
Lukas

I think these debug logs are raised by PIL if it cannot detect the image file format.
You might try to set the logging level a bit higher via:

logging.getLogger("PIL.PngImagePlugin").setLevel(logging.CRITICAL + 1)

and see if it helps.
Also, I’m unsure if the PIL.PngImagePlugin is raising these logs, so you might need to change it.

1 Like

Almost correct! The suggested fix didn’t work, but I then changed the log format to display the path of the file where the message was logged, and it turns out PIL.TiffImagePlugin causes the trouble.
So the solution is:

logging.getLogger("PIL.TiffImagePlugin").setLevel(51)

.