根据https://www.vvzixun.com/code/9341228137260fff2383007df8b6e027的内容解决了我的这个问题
实现labelme批量json_to_dataset方法中:
AttributeError: module ‘labelme.utils’ has no attribute 'draw_label’出现了这个问题。
由于labelme.utils中没有draw_label这个模块:
lbl_viz = utils.draw_label(lbl, img, captions)
如果出现AttributeError: module ‘labelme.utils’ has no attribute 'draw_label’这个错误,原因应该在于import中没有导入进来这个模块,所以,需要找到labelme.utils
我的安装路径:D:\TF\anaconda\Lib\site-packages\labelme
在这个安装路径下,在labelme文件夹下,有一个utils文件夹
刚开始发现里面没有draw.py文件,所以导致我刚开始draw_label导入不进来。
找到将draw.py全部代码贴出来:
import io
import numpy as np
import PIL.Image
import PIL.ImageDraw
def label_colormap(N=256):
def bitget(byteval, idx):
return (byteval & (1 << idx)) != 0
cmap = np.zeros((N, 3))
for i in range(0, N):
id = i
r, g, b = 0, 0, 0
for j in range(0, 8):
r = np.bitwise_or(r, (bitget(id, 0) << 7