A warning appears during yolov5 (v6.0) training: libpng warning: iCCP: known incorrect sRGB profile

1. Questions

A warning appears when yolov5 (v6.0) trains its own data set (VOC format): libpng warning: iCCP: known incorrect sRGB profile

Although it doesn't affect the training, it looks uncomfortable.

2. Solutions

Convert the '.png' image in the data set to '.jpg'.
At the same time, modify the file name in '.xml'.
before fixing

after modification

3 Appendix

The following is the code used
'.png'----->'.jpg'

import os
import cv2
path="VOC/JPEGImages/"
  # list all the files
files = os.listdir(path)
s=''
for filename in files:
      portion = os.path.splitext(filename)
      if portion[1] == ".png":
        img = cv2.imread(path+s.join(portion))
        print(path+s.join(portion))
        newname = portion[0] + ".jpg"
        cv2.imwrite(path+newname,img) 

Modify the file name in '.xml'

#修改xml里的filename
import os.path
import xml.dom.minidom
path = 'VOC2007/Annotations/'
files = os.listdir(path)  
s = []
count = 0
for xmlFile in files: 
    if not os.path.isdir(xmlFile):  
        name1 = xmlFile.split('.')[0]
        dom = xml.dom.minidom.parse(path + '/' + xmlFile)
        root = dom.documentElement
        newfilename = root.getElementsByTagName('filename')

        newfilename[0].firstChild.data = name1 + '.jpg'
        with open(os.path.join(path, xmlFile), 'w') as fh:
            dom.writexml(fh)
            print('写入name/pose OK!')
        count = count + 1

Here, I would like to thank the CSDN bloggers who provided references. Since it’s been a long time, I forgot which great god’s information I refer to, so I don’t attach the link. Thank you again. I hope the above content will be helpful to everyone!

Guess you like

Origin blog.csdn.net/qq_45160840/article/details/130421581