labelme的安装
python2.7环境
conda create --name=labelme python=2.7
source activate labelme
conda install pyqt
pip install labelme
python3环境
conda create --name=labelme python=3.6
source activate labelme
pip install labelme
如果labelme的标签是多个人打,在转换过程中需要修改路径,修改代码
import json
import os
OldJsonPath="/media/cynere/Data/坚果云/我的坚果云/json"
newJsonPath="/media/cynere/Data/坚果云/我的坚果云/newjson"
if not os.path.exists(newJsonPath):
os.makedirs(newJsonPath)
Files=os.listdir(OldJsonPath)
for file in Files:
path=OldJsonPath+'/'+file
dic=json.load(open(path,encoding='utf-8'))
dic["imagePath"]=r'/media/cynere/Data/坚果云/我的坚果云/image1'
newpath=newJsonPath+'/'+file
with open(newpath,'w',encoding='utf-8') as f:
json.dump(dic,f)
通过json生成训练数据
labelme_json_to_dataset filename.json
如果需要批量转换:这个shell即可
#!/bin/bash
dir=`ls /media/cynere/Data/坚果云/我的坚果云/newjson/` #定义遍历的目录
path="/media/cynere/Data/坚果云/我的坚果云/newjson/" #名字与上一行相同
for i in $dir
do
labelme_json_to_dataset ${path}$i
#echo $i
done