当前位置:网站首页>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 中用,因为反斜杠的原因。
边栏推荐
- 哪个券商公司网上开户佣金低又安全又可靠
- 如何优雅的写 Controller 层代码?
- 【每日一题】第一天
- 问题包含哪些环节
- Chain game system development (unity3d chain game development details) - chain game development mature technology source code
- 消除IBM P750小机上的黄色报警灯[通俗易懂]
- Eliminate the yellow alarm light on IBM p750 small computer [easy to understand]
- Industrial software lecture - core technology analysis of 3D CAD design software - the second lecture of the Forum
- 夜神模擬器+Fiddler抓包測試App
- iptable端口重定向 MASQUERADE[通俗易懂]
猜你喜欢

Simulateur nightGod + application de test de capture de paquets Fiddler

A simple PHP personal card issuing program v4.0

工业软件讲堂-三维CAD设计软件的核心技术解析----讲坛第二次讲座

UML class diagram

【每日一题】第二天
![[fluent] dart data type (VaR data type | object data type)](/img/1b/fe2529af5f6663fad1fb7861f14ab5.jpg)
[fluent] dart data type (VaR data type | object data type)

Distance measurement - Jaccard distance

Mysql高级篇学习总结6:索引的概念及理解、B+树产生过程详解、MyISAM与InnoDB的对比

新加坡暑假旅遊攻略:一天玩轉新加坡聖淘沙島

Thoroughly understand the point cloud processing tutorial based on open3d!
随机推荐
【每日一题】第二天
What are the links of the problem
快速排序基本思路(通俗易懂+例子)「建议收藏」
新加坡暑假旅遊攻略:一天玩轉新加坡聖淘沙島
页面标题组件
【每日一题】第一天
R language uses lrtest function of epidisplay package to perform likelihood ratio test on multiple GLM models (logisti regression). Compare whether the performance of the two models is different, and
Web实时通信技术之Websocket
学习八股文的知识点~~1
R语言使用epiDisplay包的cox.display函数获取cox回归模型汇总统计信息(风险率HR、调整风险率及其置信区间、模型系数的t检验的p值、Wald检验的p值和似然比检验的p值)、汇总统计
[daily question] the next day
Concepts and differences of PR curve and ROC curve
距离度量 —— 杰卡德距离(Jaccard Distance)
医院在线问诊源码 医院视频问诊源码 医院小程序源码
在支付宝账户上买基金安全吗
The text editor hopes to mark the wrong sentences in red, and the text editor uses markdown
LightGroupButton* sender = static_ cast<LightGroupButton*>(QObject::sender());
300+ documents! This article explains the latest progress of multimodal learning based on transformer
迷你高尔夫球场:伦敦休闲旅游好去处
A simple PHP personal card issuing program v4.0