labelme制作數(shù)據(jù)集

labelme的安裝

python2.7環(huán)境

conda create --name=labelme python=2.7
source activate labelme
conda install pyqt
pip install labelme

python3環(huán)境

conda create --name=labelme python=3.6
source activate labelme
pip install labelme

如果labelme的標(biāo)簽是多個(gè)人打,在轉(zhuǎn)換過(guò)程中需要修改路徑,修改代碼

import json
import os
OldJsonPath="/media/cynere/Data/堅(jiān)果云/我的堅(jiān)果云/json"
newJsonPath="/media/cynere/Data/堅(jiān)果云/我的堅(jiān)果云/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/堅(jiān)果云/我的堅(jiān)果云/image1'
    newpath=newJsonPath+'/'+file
    with open(newpath,'w',encoding='utf-8') as f:
        json.dump(dic,f)

通過(guò)json生成訓(xùn)練數(shù)據(jù)

labelme_json_to_dataset filename.json

如果需要批量轉(zhuǎn)換:這個(gè)shell即可

#!/bin/bash
 dir=`ls /media/cynere/Data/堅(jiān)果云/我的堅(jiān)果云/newjson/`    #定義遍歷的目錄 
 path="/media/cynere/Data/堅(jiān)果云/我的堅(jiān)果云/newjson/"      #名字與上一行相同
 for i in $dir
 do
     labelme_json_to_dataset ${path}$i
     #echo $i
 done
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容