当前位置:网站首页>yolov3 训练自己的数据集之生成train.txt
yolov3 训练自己的数据集之生成train.txt
2022-07-02 17:34:00 【FeboReigns】
from os.path import join
import os
img_dir = "images"
work_dir = os.getcwd()
print ("当前工作目录 : %s" % work_dir)
txt_file = open(work_dir+'/train.txt', 'w')
img_path = join(work_dir,img_dir)
print ("图片文件夹 :",img_path)
image_names = os.listdir('./'+ img_dir)
for file_name in image_names:
if file_name.endswith(".jpg"):
txt_file.write(img_path + "/"+ file_name+"\n")
txt_file.close()
work_dir是此py脚本的路径,比如E:\workspace\classify
img_dir 是数据集图片的路径,比如我把图片都放在了,E:\workspace\classify\images中
我这里直接把work_dir +“images”,就得到了img_dir,如果你的路径和不一样自行修改一下
然后遍历img_dir下的所有jpg图片,如果你是别的图片你把 if file_name.endswith(".jpg") 改一改,不要判断后缀了,把每张图片的绝对路径写在txt中。
注意一下,在win系统生成的txt,不能放在linux 中用,因为反斜杠的原因。
边栏推荐
- The difference between promise and observable
- UML class diagram
- The text editor hopes to mark the wrong sentences in red, and the text editor uses markdown
- 2022编译原理期末考试 回忆版
- Thoroughly understand the point cloud processing tutorial based on open3d!
- 【JVM调优实战100例】01——JVM的介绍与程序计数器
- Deep learning mathematics foundation
- [daily question] first day
- 文字编辑器 希望有错误的句子用红色标红,文字编辑器用了markdown
- 服务器php环境搭建教程,PHP服务端环境搭建图文详解
猜你喜欢
Uncover the whole link communication process of dewu customer service im
【每日一题】第一天
Distance measurement - Jaccard distance
鸿蒙第四次学习
Troubleshooting: kubectl reports an error validationerror: unknown field \u00a0
UML 类图
LightGroupButton* sender = static_ cast<LightGroupButton*>(QObject::sender());
Mysql高级篇学习总结8:InnoDB数据存储结构页的概述、页的内部结构、行格式
材质UV遮罩的技巧
开源物联网平台ThingsBoard的安装
随机推荐
AI开发调试系列第二弹:多机分布式调测探索之旅
Three ways of function parameter transfer in C language
PR曲线和ROC曲线概念及其区别
快速排序基本思路(通俗易懂+例子)「建议收藏」
Ali was wildly asked by the interviewer on three sides. Redis dared not write 'proficient' on his resume anymore
深度神经网络总结
StretchDIBits函数
options should NOT have additional properties
夜神模擬器+Fiddler抓包測試App
Web版3D可视化工具,程序员应该知道的97件事,AI前沿论文 | 资讯日报 #2022.07.01
Tips for material UV masking
M2DGR:多源多场景 地面机器人SLAM数据集(ICRA 2022 )
迷你高尔夫球场:伦敦休闲旅游好去处
R language dplyr package Na_ The if function converts the control in the vector value into the missing value Na, and converts the specified content into the missing value Na according to the mapping r
鸿蒙第四次学习
Web实时通信技术之Websocket
消除IBM P750小机上的黄色报警灯[通俗易懂]
新加坡暑假旅游攻略:一天玩转新加坡圣淘沙岛
Stretchdibits function
Uncover the whole link communication process of dewu customer service im