2 Star 8 Fork 0

篠龙 / yolov7-GradCAM

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
split_data.py 870 Bytes
一键复制 编辑 原始数据 按行查看 历史
篠龙 提交于 2022-08-12 11:20 . update
import os
import shutil
sets = ['train', 'val']
file_suffix = ['.jpg', '.txt']
root_path = 'datasets/Fruit/'
txt_path = 'datasets/Fruit/ImageSets/'
# 开始遍历
for s in sets:
for fs in file_suffix:
read_and_save_path = root_path + 'images/' if fs == '.jpg' else root_path + 'labels/'
if not os.path.exists(read_and_save_path + s):
os.mkdir(read_and_save_path + s)
num = 0
with open(txt_path + s + '.txt', 'r') as f:
for name in f:
fileName = name.strip()
for file in os.listdir(read_and_save_path):
if fileName + fs == file:
num += 1
shutil.move(os.path.join(read_and_save_path, fileName + fs), read_and_save_path + s)
print("Copy complete!")
print("Total pictures copied:", num)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/xiao-dragon/yolov7-GradCAM.git
git@gitee.com:xiao-dragon/yolov7-GradCAM.git
xiao-dragon
yolov7-GradCAM
yolov7-GradCAM
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891