当前位置:网站首页>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 中用,因为反斜杠的原因。
边栏推荐
- 【JVM调优实战100例】01——JVM的介绍与程序计数器
- 医院在线问诊源码 医院视频问诊源码 医院小程序源码
- Exness in-depth good article: dynamic series - Case Analysis of gold liquidity (V)
- 在纽约寻找童真——新泽西州乐高乐园探索中心的美好一天
- 哪个券商公司网上开户佣金低又安全又可靠
- What is cloud primordial? This time, I can finally understand!
- Hongmeng's fourth learning
- sql训练2
- Redis (6) -- object and data structure
- 徹底搞懂基於Open3D的點雲處理教程!
猜你喜欢

彻底搞懂基于Open3D的点云处理教程!

Mini Golf Course: a good place for leisure and tourism in London

徹底搞懂基於Open3D的點雲處理教程!

鸿蒙第四次学习
![[fluent] dart data type (VaR data type | object data type)](/img/1b/fe2529af5f6663fad1fb7861f14ab5.jpg)
[fluent] dart data type (VaR data type | object data type)
![27: Chapter 3: develop Passport Service: 10: [registration / login] interface: after the registration / login is OK, save the user session information (uid, utoken) to redis and cookies; (one main poi](/img/b9/2066a13b160252114c2881007094f8.png)
27: Chapter 3: develop Passport Service: 10: [registration / login] interface: after the registration / login is OK, save the user session information (uid, utoken) to redis and cookies; (one main poi

Comprendre complètement le tutoriel de traitement de Point Cloud basé sur open3d!

Yesterday, Alibaba senior wrote a responsibility chain model, and there were countless bugs

After 22 years in office, the father of PowerShell will leave Microsoft: he was demoted by Microsoft for developing PowerShell

如何清理废弃pv和其对应的文件夹
随机推荐
PR曲线和ROC曲线概念及其区别
Leetcode(81)——搜索旋转排序数组 II
深度神经网络总结
Use MNIST in tensorflow 2_ 784 data set for handwritten digit recognition
Excel如何进行隔行复制粘贴
材质UV遮罩的技巧
产品经理应具备的能力
Troubleshooting: kubectl reports an error validationerror: unknown field \u00a0
Web实时通信技术之Websocket
医院在线问诊源码 医院视频问诊源码 医院小程序源码
什么是云原生?这回终于能搞明白了!
Detailed explanation of cjson usage
Looking for innocence in New York -- a beautiful day at the discovery center of Legoland, New Jersey
R语言ggplot2可视化:可视化折线图、使用labs函数为折线图添加自定义的X轴标签信息
Thoroughly understand the point cloud processing tutorial based on open3d!
R语言使用epiDisplay包的lrtest函数对多个glm模型(logisti回归)执行似然比检验(Likelihood ratio test)对比两个模型的性能是否有差异、广义线性模型的似然比检
使用 Cheat Engine 修改 Kingdom Rush 中的金钱、生命、星
如何设置VSCode删除整行快捷键?
M2DGR:多源多场景 地面机器人SLAM数据集(ICRA 2022 )
第一次去曼谷旅游怎么玩?这份省钱攻略请收好