1 Star 0 Fork 0

hellozahn/ai_ftc

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
cleaner.py 1.27 KB
一键复制 编辑 原始数据 按行查看 历史
hellozahn 提交于 2024-02-02 15:54 . 调整参数对比可视化结果
"""
读取数据
数据清洗
"""
import os
import imghdr
import cv2
from progressbar import ProgressBar
# error_file_name = 'check_error.txt'
path = r'E:\pythonProject\ftc\images'
# path = r'E:\pythonProject\ftc\images_v2'
def error_file():
original_images = []
for root, dirs, filenames in os.walk(path):
for filename in filenames:
original_images.append(os.path.join(root, filename))
original_images = sorted(original_images)
print('total_file_num:', len(original_images))
error_images = []
progress = ProgressBar()
for filename in progress(original_images):
check = imghdr.what(filename)
if check is None:
error_images.append(filename)
os.remove(filename)
continue
img = cv2.imread(filename)
if img is None:
error_images.append(filename)
os.remove(filename)
print('error_file_num:', len(error_images))
error_file()
# E:\pythonProject\ftc\images_v1\mulberry\1706603229570325.jpg
# v1
# first
# error_file_num: 654
# second
# error_file_num: 44
# small_file_num: 0
# third
# error_file_num: 0
# small_file_num: 0
# v2
# first
# error_file_num: 1144
# second
# error_file_num: 64
# small_file_num: 0
# third
# error_file_num: 0
# small_file_num: 0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/hellozahn/ai_items.git
git@gitee.com:hellozahn/ai_items.git
hellozahn
ai_items
ai_ftc
dev

搜索帮助