支持一次性将labelme标注的json文件转化为训练列表,使用json2trainline,传入labelme_path即可
# -*- coding: utf-8 -*-
import os
import numpy as np
import codecs
import json
from glob import glob
import cv2
import shutil
from sklearn.model_selection import train_test_split
import shutil
import xml.etree.ElementTree as ET
from os import getcwd
def myprint(strr):
print(strr)
def json2trainLine(myprint,labelme_path):
myprint('开始加载目录,生成voc格式数据集')
labelme_path=labelme_path+'/'
have_json=json_label2voc(myprint,labelme_path)
if have_json==1:
myprint('操作完成!')
myprint('开始将voc格式目录转化为训练列表文件')
voc2train_line(labelme_path)
myprint('操作完成!')
def json_label2voc(myprint,labelme_path = "pcb object detect/",saved_path = "voc_pcb/"):
if os.path.exists(saved_path):
shutil.rmtree(saved_path)
if not os.


