0
点赞
收藏
分享

微信扫一扫

ValueError: With n_samples=0, test_size=0.15 and train_size=None, the resulting train set will be em

回溯 2022-02-19 阅读 28

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])

在这里插入图片描述
运行成功
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

举报
0 条评论