YOLOv5-7.0 training data set of Chinese labels

Link: https://pan.baidu.com/s/1KSROxTwyYnNoNxI5Tk13Dg 
Extraction code: 8888

 Take the display of italics as an example (there are ttf files in Hei Ti, Song Ti, and Kai Ti in the Baidu network disk above)

(1) In metric.py:

Will

sn.set(font_scale=1.0 if nc < 50 else 0.8)  # for label size

Change to:  

sn.set(font='kaiti', font_scale=1.0 if nc < 50 else 0.8)

Windows11:

 Ubuntu 20.04: 

(2) In general.py:

Will

with open(file, errors='ignore') as f:

Change to: 

 with open(file, errors='ignore', encoding='utf-8') as f:

Windows11: 

 Ubuntu 20.04:  

  (3) In the plots.py:

Add to the header file:

plt.rcParams['font.sans-serif'] = ['kaiti']
plt.rcParams['axes.unicode_minus'] = False

Windows11: 

 Ubuntu 20.04:   

Find class Annotator in plots.py:

  Will

def __init__(self, im, line_width=None, font_size=None, font='Arial.ttf', pil=False, example='abc'):

Change to:  

def __init__(self, im, line_width=None, font_size=None,
                     font='E:/Anaconda/envs/py38/Lib/site-packages/matplotlib/mpl-data/fonts/ttf/kaiti.ttf',
                     pil=False, example='abc'):

Will

self.font = check_pil_font(font='Arial.Unicode.ttf' if non_ascii else font,
                                       size=font_size or max(round(sum(self.im.size) / 2 * 0.035), 12))

Change to:  

 self.font = check_pil_font(
                font='E:/Anaconda/envs/py38/Lib/site-packages/matplotlib/mpl-data/fonts/ttf/kaiti.ttf' if non_ascii else font,
                size=font_size or max(round(sum(self.im.size) / 2 * 0.035), 12))

The address in font is the absolute path of the Chinese font. At this time, you can use the fonts in the Baidu network disk I gave you for five years to copy to the virtual environment you use, and find it in matplotlib according to the absolute path above. , then copy it in, and then copy your absolute path to the .py file, for example:

The address below my Windows11 is like this: 

 The virtual environment under my Ubuntu20.04 is like this:

 When training, just change the name of your yaml file to Chinese, which will not be described here, it is the same as training English labels!

 Test results:

 

Guess you like

Origin blog.csdn.net/weixin_53660567/article/details/130455363