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
|
4月前
|
存储 JavaScript Java
(Python基础)新时代语言!一起学习Python吧!(四):dict字典和set类型;切片类型、列表生成式;map和reduce迭代器;filter过滤函数、sorted排序函数;lambda函数
dict字典 Python内置了字典:dict的支持,dict全称dictionary,在其他语言中也称为map,使用键-值(key-value)存储,具有极快的查找速度。 我们可以通过声明JS对象一样的方式声明dict
317 1
|
7月前
|
存储 缓存 JavaScript
Set和Map有什么区别?
Set和Map有什么区别?
543 1
|
4月前
|
存储 算法 容器
set_map的实现+set/map加持秒杀高频算法题锻炼算法思维
`set`基于红黑树实现,支持有序存储、自动去重,增删查效率为O(logN)。通过仿函数可自定义排序规则,配合空间配置器灵活管理内存。不支持修改元素值,迭代器失效需注意。`multiset`允许重复元素。常用于去重、排序及查找场景。
|
8月前
|
存储 JavaScript 前端开发
for...of循环在遍历Set和Map时的注意事项有哪些?
for...of循环在遍历Set和Map时的注意事项有哪些?
400 121
|
11月前
|
编译器 C++ 容器
【c++丨STL】基于红黑树模拟实现set和map(附源码)
本文基于红黑树的实现,模拟了STL中的`set`和`map`容器。通过封装同一棵红黑树并进行适配修改,实现了两种容器的功能。主要步骤包括:1) 修改红黑树节点结构以支持不同数据类型;2) 使用仿函数适配键值比较逻辑;3) 实现双向迭代器支持遍历操作;4) 封装`insert`、`find`等接口,并为`map`实现`operator[]`。最终,通过测试代码验证了功能的正确性。此实现减少了代码冗余,展示了模板与仿函数的强大灵活性。
302 2
|
8月前
|
存储 C++ 容器
unordered_set、unordered_multiset、unordered_map、unordered_multimap的介绍及使用
unordered_set是不按特定顺序存储键值的关联式容器,其允许通过键值快速的索引到对应的元素。在unordered_set中,元素的值同时也是唯一地标识它的key。在内部,unordered_set中的元素没有按照任何特定的顺序排序,为了能在常数范围内找到指定的key,unordered_set将相同哈希值的键值放在相同的桶中。unordered_set容器通过key访问单个元素要比set快,但它通常在遍历元素子集的范围迭代方面效率较低。它的迭代器至少是前向迭代器。前向迭代器的特性。
361 0
|
8月前
|
编译器 C++ 容器
用一棵红黑树同时封装出map和set
再完成上面的代码后,我们的底层代码已经完成了,这时候已经是一个底层STL的红黑树了,已经已符合库里面的要求了,这时候我们是需要给他穿上对应的“衣服”,比如穿上set的“衣服”,那么这个穿上set的“衣服”,那么他就符合库里面set的要求了,同样map一样,这时候我们就需要实现set与map了。因此,上层容器map需要向底层红黑树提供一个仿函数,用于获取T当中的键值Key,这样一来,当底层红黑树当中需要比较两个结点的键值时,就可以通过这个仿函数来获取T当中的键值了。我们就可以使用仿函数了。
117 0

热门文章

最新文章