代码拉取完成,页面将自动刷新
"""
读取数据
数据清洗
"""
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
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。