赞
踩
博主在被最新版的yolov5整痛苦面具。(中文乱码)
在detect.py上
模型挂载上出了问题(没统一用一个模型)...
def run( weights=ROOT / 'best_updated.pt', # model path or triton URL
def parse_opt(): parser = argparse.ArgumentParser() parser.add_argument('--weights', nargs='+', type=str, default=ROOT / 'best_updated.pt', help='model path or triton URL')
问题中文乱码,解决后
修改默认代码的Arial.ttf为sihei.ttf
def __init__(self, im, line_width=None, font_size=None, font='simhei.ttf', pil=False, example='abc'): """Initialize the Annotator class with image and line width along with color palette for keypoints and limbs.""" assert im.data.contiguous, 'Image not contiguous. Apply np.ascontiguousarray(im) to Annotator() input images.' non_ascii = not is_ascii(example) # non-latin labels, i.e. asian, arabic, cyrillic self.pil = pil or non_ascii self.lw = line_width or max(round(sum(im.shape) / 2 * 0.003), 2) # line width if self.pil: # use PIL self.im = im if isinstance(im, Image.Image) else Image.fromarray(im) self.draw = ImageDraw.Draw(self.im) try: font = check_font('simhei.ttf' if non_ascii else font) 省略代码
plt.rcParams['font.sans-serif'] = ['SimHei'] plt.rcParams['axes.unicode_minus'] = False
plt.rcParams['font.sans-serif'] = ['simhei'] plt.rcParams['axes.unicode_minus'] = False
def yaml_load(file='data.yaml'): # Single-line safe yaml loading with open(file, encoding='gbk', errors='ignore') as f: return yaml.safe_load(f)
【精选】YOLOv5 完美实现中文标签显示-CSDN博客 感谢大佬提供解决方案
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。