没有合适的资源?快使用搜索试试~ 我知道了~
首页关于json_to_dataset时出现 module ‘labelme.utils’ has no attribute ‘draw_label’的解决
关于json_to_dataset时出现 module ‘labelme.utils’ has no attribute ‘dr...
16 下载量 77 浏览量
更新于2023-03-03
评论
收藏 321KB PDF 举报
** 关于json_to_dataset时出现 module ‘labelme.utils’ has no attribute ‘draw_label问题解决’** 相信肯定很多朋友遇到过这种问题: 终端显示模块utils缺少属性draw_label. 其实呢,这个问题我弄了两天都没有解决,最后我决定放弃这个函数。 之后怎么办呢,相信出现这种问题时大家都是从别人博客里copy过json_to_dataset这个文件的代码的。既然别人的代码修改时避不开draw_label,我选择回到最开始。 直接修改label的json_to_dataset文件初始代码 你可能会说,以前的代码已经没了,不要紧,
资源详情
资源评论
资源推荐
关于关于json_to_dataset时出现时出现 module ‘labelme.utils’ has no attribute ‘draw_label’的的
解决解决
**
关于关于json_to_dataset时出现时出现 module ‘labelme.utils’ has no attribute ‘draw_label问题解决问题解决’**
相信肯定很多朋友遇到过这种问题:
终端显示模块utils缺少属性draw_label.
其实呢,这个问题我弄了两天都没有解决,最后我决定放弃这个函数。
之后怎么办呢,相信出现这种问题时大家都是从别人博客里copy过json_to_dataset这个文件的代码的。既然别人的代码修改时避不开draw_label,我选择回到最开始。
直接修改直接修改label的的json_to_dataset文件初始代码文件初始代码
你可能会说,以前的代码已经没了,不要紧,在终端卸掉labelme再重新安装就好了。
以下是我修改的代码:
import argparse
import base64
import json
import os
import os.path as osp
import imgviz
import PIL.Image
from labelme.logger import logger
from labelme import utils
import cv2
from math import *
import numpy as np
import random
import rotate
def main():
list_path = os.listdir('F:/zkx')
for i in range(0, len(list_path)):
logger.warning('This script is aimed to demonstrate how to convert the'
'JSON file to a single image dataset, and not to handle'
'multiple JSON files to generate a real-use dataset.')
parser = argparse.ArgumentParser()
parser.add_argument('--json_file')
parser.add_argument('-o', '--out', default=None)
args = parser.parse_args()
json_file = 'F:/zkx/' + list_path[i] print(list_path[i])
if args.out is None:
out_dir = osp.basename(json_file).replace('.', '_') # 返回文件名
out_dir = osp.join(osp.dirname(json_file), out_dir) # 把目录和文件名合成一个路径
else:
out_dir = args.out
if not osp.exists(out_dir):
os.mkdir(out_dir) # 用于以数字权限模式创建目录
data = json.load(open(json_file))
imageData = data.get('imageData')
if not imageData:
imagePath = os.path.join(os.path.dirname(json_file), data['imagePath']) # os.path.dirname返回文件路径
with open(imagePath, 'rb') as f:
imageData = f.read()
imageData = base64.b64encode(imageData).decode('utf-8')
img = utils.img_b64_to_arr(imageData)
label_name_to_value = {'_background_': 0}
for shape in sorted(data['shapes'], key=lambda x: x['label']):
label_name = shape['label'] if label_name in label_name_to_value:
label_value = label_name_to_value[label_name] else:
label_value = len(label_name_to_value)
label_name_to_value[label_name] = label_value
lbl, _ = utils.shapes_to_label(
img.shape, data['shapes'], label_name_to_value
)
weixin_38747233
- 粉丝: 8
- 资源: 969
上传资源 快速赚钱
- 我的内容管理 收起
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
会员权益专享
最新资源
- RTL8188FU-Linux-v5.7.4.2-36687.20200602.tar(20765).gz
- c++校园超市商品信息管理系统课程设计说明书(含源代码) (2).pdf
- 建筑供配电系统相关课件.pptx
- 企业管理规章制度及管理模式.doc
- vb打开摄像头.doc
- 云计算-可信计算中认证协议改进方案.pdf
- [详细完整版]单片机编程4.ppt
- c语言常用算法.pdf
- c++经典程序代码大全.pdf
- 单片机数字时钟资料.doc
- 11项目管理前沿1.0.pptx
- 基于ssm的“魅力”繁峙宣传网站的设计与实现论文.doc
- 智慧交通综合解决方案.pptx
- 建筑防潮设计-PowerPointPresentati.pptx
- SPC统计过程控制程序.pptx
- SPC统计方法基础知识.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0