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

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

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文件要放在同一个目录下:2018122814580746.png

然后又报错

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

2018122814580746.png

故应该修改为

files = [i.split("\\")[-1].split(".json")[0] for i in files]

打印印证

for i in files:
    print(i.split("\\")[-1])

2018122814580746.png

运行成功

2018122814580746.png

2018122814580746.png

2018122814580746.png


相关文章
成功解决ValueError: With n_samples=0, test_size=0.3 and train_size=None, the resulting train set will be
成功解决ValueError: With n_samples=0, test_size=0.3 and train_size=None, the resulting train set will be
成功解决ValueError: With n_samples=0, test_size=0.3 and train_size=None, the resulting train set will be
成功解决ValueError: With n_samples=0, test_size=0.3 and train_size=None, the resulting train set will be
成功解决ValueError: With n_samples=0, test_size=0.3 and train_size=None, the resulting train set will be
成功解决ValueError: With n_samples=0, test_size=0.3 and train_size=None, the resulting train set will be
|
3天前
|
存储 JavaScript 索引
js开发:请解释什么是ES6的Map和Set,以及它们与普通对象和数组的区别。
ES6引入了Map和Set数据结构。Map的键可以是任意类型且有序,与对象的字符串或符号键不同;Set存储唯一值,无重复。两者皆可迭代,支持for...of循环。Map有get、set、has、delete等方法,Set有add、delete、has方法。示例展示了Map和Set的基本操作。
17 3
|
1月前
|
存储 自然语言处理 C++
map和set的简单介绍
map和set的简单介绍
20 1
|
1月前
|
存储 安全 Java
java集合框架及其特点(List、Set、Queue、Map)
java集合框架及其特点(List、Set、Queue、Map)
|
3月前
|
JavaScript 前端开发 定位技术
JavaScript 中如何代理 Set(集合) 和 Map(映射)
JavaScript 中如何代理 Set(集合) 和 Map(映射)
50 0
|
3月前
|
存储 安全 Java
Map和Set(JAVA)
Map和Set(JAVA)
50 1
|
3月前
|
编译器 C++ 容器
【C++学习手札】基于红黑树封装模拟实现map和set
【C++学习手札】基于红黑树封装模拟实现map和set
|
4天前
|
存储 搜索推荐 C++
【C++高阶(二)】熟悉STL中的map和set --了解KV模型和pair结构
【C++高阶(二)】熟悉STL中的map和set --了解KV模型和pair结构
|
24天前
|
存储 JavaScript 前端开发
set和map的区别
set和map的区别
33 4