ValueError: With n_samples=0, test_size=0.15 and train_size=None, the resulting train set will be empty. Adjust any of the aforementioned parameters.
错误原因:
#这两处更改为你指定的路径
#一定要注意是path的末尾是否带上/,路径是拼接出来的,如果没有调整好,仍然会报上面的错误
labelme_path = "C:/Users/Administrator/Desktop/sss/" #原始labelme标注数据路径
saved_path = "C:/Users/Administrator/Desktop/ccc/" #保存路径
注意: 通过阅读源码
json_filename = labelme_path + json_file_ + ".json"
height, width, channels = cv2.imread(labelme_path + json_file_ +".jpg").shape
可知,我们转换的jpg图片和.json文件要放在同一个目录下:
然后又报错
Traceback (most recent call last):
File “json_to_xml.py”, line 28, in
json_file = json.load(open(json_filename,“r”,encoding=“utf-8”))
FileNotFoundError: [Errno 2] No such file or directory: 'C:/Users/Administrator/Desktop/sss/sss\\000000.json'
阅读源码
files = [i.split("/")[-1].split(".json")[0] for i in files] #其分割的是"/",而Windows返回路径为"\"
打印发现
for i in files:
print(i.split("/")[-1])
故应该修改为
files = [i.split("\\")[-1].split(".json")[0] for i in files]
打印印证
for i in files:
print(i.split("\\")[-1])
运行成功