当前位置:网站首页>Use the picture name to label the picture [tips]
Use the picture name to label the picture [tips]
2022-07-28 22:41:00 【It's too simple】
problem
When doing the second classification task , There are two types of pictures in a folder . Originally, two types of pictures are more common in different folders , This situation requires another way of thinking .
solve
Use the picture name to judge , The code snippet is as follows :
import os
path = ' Write the address of the picture folder here '
photos = os.listdir(path)# Put all picture names together, including suffixes
Y = []
for ph in photos:
x = os.path.splitext(ph)[0]# Separate picture names and suffixes , Pick up the name
# The number in the string of the picture name is ( Or use letters isalpha()) Or another way to equal a certain character '{}'.format(x[-1])=='e' To make a judgment
if (x[-1]).isdigit():
Y.append(1)
else:
Y.append(0)边栏推荐
- 2022年一级建造师考试什么时候才能报名?
- How about the actual use effect of common source oscilloscope
- 6K6w5LiA5qyh5pS75Ye75YiG5p6Q
- ssh免密登陆
- Summary of recent bugs
- Intelligent control -- fuzzy mathematics and control
- NPM switch Taobao source (NPM source)
- STM32 - memory, I2C protocol
- STM32 - reset and clock control (cubemx for clock configuration)
- Detection and tracking evaluation index
猜你喜欢

Idea generate class diagram plug-in UML (super detailed)

STM32 - systick timer (cubemx configures systick)

PaddleNLP基于ERNIR3.0文本分类以CAIL2018-SMALL数据集罪名预测任务为例【多标签】

79. Word search (medium string array matrix backtracking)

XXX port is already in use

ATT&CK 威胁情报

Intelligent control -- fuzzy mathematics and control

STM32 - memory, I2C protocol
How do we do full link grayscale on the database?

Ultra detailed visual studio 2019 running littlevgl (lvgl) simulator
随机推荐
Baidu map usage
775. Inverted words
winform跳转第二个窗体案例
ssh免密登陆
Solve the problem that TS node xxx.ts executes TS code and reports errors
DOM programming + events
XXX port is already in use
Att & CK preliminary understanding
c语言实现字符串逆序排列
Ngrok intranet penetration
STM32 - Communication
Summary of common error types in JS
75. Color classification (medium array double pointer sorting)
Log4j vulnerability elk platform processing method (logstah5.5.1)
775. 倒排单词
PaddleNLP基于ERNIR3.0文本分类:WOS数据集为例(层次分类)
CMD common commands
Use webworker to perform background tasks
Sword finger offer II 054. Sum of all values greater than or equal to nodes (medium binary search tree DFS)
JS获取当前时间(年月日时分秒)