当前位置:网站首页>mmclassification 标注文件生成
mmclassification 标注文件生成
2022-07-04 09:32:00 【Coding的叶子】
1 数据集构成
mmclassification数据集主要包含四个文件夹meta、train、val、test,其中meta存储了标注信息,包含train.txt、val.txt和test.txt三个文件。train、val、test存储了各个不同类别的图像。其构成如下图所示:

train.txt、val.txt和test.txt文件存储了图片路径和类别id,如下图所示:

train、val、test存储了各个不同类别的图像,相同类别的图像位于同一子文件夹下,子文件夹的名称为相应的类别名称,如下图所示:

上述示例图像中的数据来源于minist手写字体可视化数据集,已按照train、test文件夹进行存储,下载地址为:minist手写数字可视化数据集-深度学习文档类资源-CSDN下载。
2 标注文件生成
标注文件生成是指在没有meta文件夹的情况下,根据train、val、test文件夹自动生成meta文件夹,及其文件夹下的train.txt、val.txt和test.txt。
3 参考程序
# -*- coding: utf-8 -*-
"""
乐乐感知学堂公众号
@author: https://blog.csdn.net/suiyingy
"""
import os
from glob import glob
from pathlib import Path
def generate_mmcls_ann(data_dir, img_type='.png'):
data_dir = str(Path(data_dir)) + '/'
classes = ['0', '1', '2', '3', '4','5', '6', '7', '8', '9']
class2id = dict(zip(classes, range(len(classes))))
data_dir = str(Path(data_dir)) + '/'
dir_types = ['train', 'val', 'test']
sub_dirs = os.listdir(data_dir)
ann_dir = data_dir + 'meta/'
if not os.path.exists(ann_dir):
os.makedirs(ann_dir)
for sd in sub_dirs:
if sd not in dir_types:
continue
annotations = []
target_dir = data_dir + sd + '/'
for d in os.listdir(target_dir):
class_id = str(class2id[d])
images = glob(target_dir+d+'/*'+img_type)
for img in images:
img = d + '/' + os.path.basename(img)
annotations.append(img+' '+ class_id+'\n')
annotations[-1] = annotations[-1].strip()
with open(ann_dir+sd+'.txt', 'w') as f:
f.writelines(annotations)
if __name__ == '__main__':
data_dir = 'data/Minist手写数字可视化数据集/'
generate_mmcls_ann(data_dir) 4 运行结果
运行上述参考程序后,data_dir文件夹下会自动生成meta文件夹及相应的txt文件,txt文件内容如下图所示。

5 【python三维深度学习】python三维点云从基础到深度学习_Coding的叶子的博客-CSDN博客_python 三维点云
更多三维、二维感知算法和金融量化分析算法请关注“乐乐感知学堂”微信公众号,并将持续进行更新。
边栏推荐
- Opencv environment construction (I)
- After unplugging the network cable, does the original TCP connection still exist?
- Global and Chinese PCB function test scale analysis and development prospect planning report Ⓑ 2022 ~ 2027
- 2022-2028 global gasket metal plate heat exchanger industry research and trend analysis report
- Reading notes on how to connect the network - tcp/ip connection (II)
- In depth research and investment strategy report on China's hydraulic parts industry (2022 Edition)
- 26. Delete duplicates in the ordered array (fast and slow pointer de duplication)
- There are 100 people eating 100 apples, one adult eating 4 apples, and four children eating 1 apple. How can they eat exactly 100 apples? Use any high-level language you are familiar with
- Global and Chinese markets for laser assisted liposuction (LAL) devices 2022-2028: Research Report on technology, participants, trends, market size and share
- A subclass must use the super keyword to call the methods of its parent class
猜你喜欢
![C language - Introduction - Foundation - syntax - [identifier, keyword, semicolon, space, comment, input and output] (III)](/img/89/0f5f4ba07c637b09abe873016cba2d.png)
C language - Introduction - Foundation - syntax - [identifier, keyword, semicolon, space, comment, input and output] (III)

Opencv environment construction (I)

165 webmaster online toolbox website source code / hare online tool system v2.2.7 Chinese version
![C language - Introduction - Foundation - syntax - [operators, type conversion] (6)](/img/3f/4d8f4c77d9fde5dd3f53ef890ecfa8.png)
C language - Introduction - Foundation - syntax - [operators, type conversion] (6)

ArrayBuffer
![Langage C - démarrer - base - syntaxe - [opérateur, conversion de type] (vi)](/img/3f/4d8f4c77d9fde5dd3f53ef890ecfa8.png)
Langage C - démarrer - base - syntaxe - [opérateur, conversion de type] (vi)

Dede plug-in (multi-function integration)

After unplugging the network cable, does the original TCP connection still exist?

Implementation principle of redis string and sorted set

2022-2028 global industry research and trend analysis report on anterior segment and fundus OTC detectors
随机推荐
The child container margin top acts on the parent container
Logstack configuration details -- elasticstack (elk) work notes 020
How to write unit test cases
The 14th five year plan and investment risk analysis report of China's hydrogen fluoride industry 2022 ~ 2028
Basic data types in golang
Write a jison parser from scratch (3/10): a good beginning is half the success -- "politics" (Aristotle)
C language - Introduction - Foundation - syntax - data type (4)
Multilingual Wikipedia website source code development part II
China battery grade manganese sulfate Market Forecast and strategic consulting report (2022 Edition)
Explanation of closures in golang
2022-2028 global gasket plate heat exchanger industry research and trend analysis report
Development trend and market demand analysis report of high purity tin chloride in the world and China Ⓔ 2022 ~ 2027
C language - Introduction - Foundation - syntax - [operators, type conversion] (6)
Solve the problem of "Chinese garbled MySQL fields"
You can see the employment prospects of PMP project management
Leetcode (Sword finger offer) - 35 Replication of complex linked list
2022-2028 global special starch industry research and trend analysis report
Implementing expired localstorage cache with lazy deletion and scheduled deletion
Clion console output Chinese garbled code
《网络是怎么样连接的》读书笔记 - WEB服务端请求和响应(四)