当前位置:网站首页>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 中用,因为反斜杠的原因。
边栏推荐
- Websocket of Web real-time communication technology
- 新加坡暑假旅遊攻略:一天玩轉新加坡聖淘沙島
- Night God simulator +fiddler packet capture test app
- 学生抖音宣传母校被吐槽“招生减章”,网友:哈哈哈哈哈哈
- MySQL about only_ full_ group_ By limit
- Web version 3D visualization tool, 97 things programmers should know, AI frontier paper | information daily # 2022.07.01
- 2022软件工程期末考试 回忆版
- Installation of thingsboard, an open source IOT platform
- R language uses the lsnofunction function function of epidisplay package to list all objects in the current space, except user-defined function objects
- FastDFS安装
猜你喜欢

Excel如何进行隔行复制粘贴

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

The difference between SLC, MLC, TLC and QLC NAND SSD: which is better?

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

How to play when you travel to Bangkok for the first time? Please keep this money saving strategy

【每日一题】第一天

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

UML 类图

Tips for material UV masking
![[daily question] the next day](/img/8a/18329bd9b4a3a4445c8fbbc1ce562b.png)
[daily question] the next day
随机推荐
Looking for innocence in New York -- a beautiful day at the discovery center of Legoland, New Jersey
How to clean up discarded PVs and their corresponding folders
从list转化成map的时候,如果根据某一属性可能会导致key重复而异常,可以设置处理这种重复的方式
Web version 3D visualization tool, 97 things programmers should know, AI frontier paper | information daily # 2022.07.01
LightGroupButton* sender = static_ cast<LightGroupButton*>(QObject::sender());
鸿蒙第四次学习
在支付宝账户上买基金安全吗
The difference between promise and observable
2022编译原理期末考试 回忆版
Detailed explanation of cjson usage
R language dplyr package filter function filters dataframe data. If the name of the data column (variable) to be filtered contains quotation marks, you need to use!! SYM syntax processing, otherwise n
问题包含哪些环节
STM32G0 USB DFU 升级校验出错-2
R语言dplyr包rowwise函数、mutate函数计算dataframe数据中多个数据列在每行的最大值、并生成行最大值对应的数据列(row maximum)
新加坡暑假旅遊攻略:一天玩轉新加坡聖淘沙島
R语言ggplot2可视化分面图(facet):gganimate包基于transition_time函数创建动态散点图动画(gif)
Redis (6) -- object and data structure
徹底搞懂基於Open3D的點雲處理教程!
迷你高尔夫球场:伦敦休闲旅游好去处
Stretchdibits function