代码拉取完成,页面将自动刷新
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)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。