10 types of datasets

This commit is contained in:
pmn 2025-05-15 21:50:15 +08:00
parent f82416c53d
commit ac18b4794d
176 changed files with 21 additions and 9 deletions

View File

@ -15,7 +15,7 @@ def calculate_clarity_score(image_path,target_size=(512, 512)):
return cv2.Laplacian(image, cv2.CV_64F).var()
def process_images(input_folder, output_folder,clarity_score_threshold):
def process_images(input_folder, output_folder,clarity_score_low,clarity_score_high):
if not os.path.exists(input_folder):
print(f"输入文件夹不存在:{input_folder}")
return
@ -28,11 +28,11 @@ def process_images(input_folder, output_folder,clarity_score_threshold):
continue
file_path = os.path.join(root, filename)
# print(f'file_path is {file_path}')
i+=1
try:
# 清晰度检测
clarity_score = calculate_clarity_score(file_path)
if clarity_score > clarity_score_threshold:
if clarity_score > clarity_score_low and clarity_score<clarity_score_high:
i+=1
# 读取图片
with Image.open(file_path) as img:
# resize
@ -46,17 +46,19 @@ def process_images(input_folder, output_folder,clarity_score_threshold):
os.makedirs(output_subfolder)
output_path = os.path.join(output_subfolder, os.path.splitext(filename)[0] + ".png")
img.save(output_path, format="PNG")
print(f"处理并保存图片{i}:{file_path} -> {output_path}")
print(f"处理并保存图片{i}:{file_path} -> {output_path}********")
else:
print(f"********图片 {file_path} 清晰度评分 {clarity_score} 不满足要求,跳过********")
print(f"********图片 {file_path} 清晰度评分 {clarity_score} 不满足要求,跳过")
except Exception as e:
print(f"********处理图片 {file_path} 时出错:{e}********")
print(f"********处理图片 {file_path} 时出错:{e}")
print(f'——————处理完毕,成功/图片数量: {i}/{len(files)}——————\n')
if __name__ == "__main__":
input_folder = 'data_process/datasets/source' # 输入文件夹路径
input_folder = 'data_process/datasets/temp' # 输入文件夹路径
output_folder = 'data_process/datasets/target' # 输出文件夹路径
clarity_score_threshold =50
process_images(input_folder, output_folder,clarity_score_threshold)
clarity_score_low = 50
clarity_score_high =3000
process_images(input_folder, output_folder,clarity_score_low,clarity_score_high)

BIN
datasets/source/1/001.jfif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

BIN
datasets/source/1/002.jfif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

BIN
datasets/source/1/003.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

BIN
datasets/source/1/004.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 KiB

BIN
datasets/source/1/005.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 KiB

BIN
datasets/source/1/006.jfif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
datasets/source/1/007.jfif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

BIN
datasets/source/1/008.jfif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
datasets/source/1/009.jfif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
datasets/source/1/010.jfif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

BIN
datasets/source/10/001.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 KiB

BIN
datasets/source/10/002.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 KiB

BIN
datasets/source/10/003.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 129 KiB

BIN
datasets/source/10/004.jfif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

BIN
datasets/source/10/005.jfif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

BIN
datasets/source/10/006.jfif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

BIN
datasets/source/10/007.jfif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

BIN
datasets/source/10/008.jfif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
datasets/source/10/009.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 280 KiB

BIN
datasets/source/10/010.jfif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 162 KiB

BIN
datasets/source/3/001.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

BIN
datasets/source/3/002.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

BIN
datasets/source/3/003.jfif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

BIN
datasets/source/3/004.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 135 KiB

BIN
datasets/source/3/005.jfif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

BIN
datasets/source/3/006.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 301 KiB

BIN
datasets/source/3/007.jfif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 240 KiB

BIN
datasets/source/3/008.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 319 KiB

BIN
datasets/source/3/009.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

BIN
datasets/source/3/010.jfif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

BIN
datasets/source/4/001.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 KiB

BIN
datasets/source/4/002.jfif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 257 KiB

BIN
datasets/source/4/003.jfif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 KiB

BIN
datasets/source/4/004.jfif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 KiB

BIN
datasets/source/4/005.jfif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

BIN
datasets/source/4/006.jfif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
datasets/source/4/007.jfif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

BIN
datasets/source/4/008.jfif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

BIN
datasets/source/4/009.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 KiB

BIN
datasets/source/4/010.jfif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

BIN
datasets/source/5/001.jfif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

BIN
datasets/source/5/002.jfif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

BIN
datasets/source/5/003.jfif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 KiB

BIN
datasets/source/5/004.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 192 KiB

BIN
datasets/source/5/005.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 122 KiB

BIN
datasets/source/5/006.jfif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

BIN
datasets/source/5/007.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 162 KiB

BIN
datasets/source/5/008.jpeg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 KiB

BIN
datasets/source/5/009.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

BIN
datasets/source/5/010.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

BIN
datasets/source/6/001.jfif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
datasets/source/6/002.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 111 KiB

BIN
datasets/source/6/003.jfif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

BIN
datasets/source/6/004.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 KiB

BIN
datasets/source/6/005.jfif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

BIN
datasets/source/6/006.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 135 KiB

BIN
datasets/source/6/007.jfif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

BIN
datasets/source/6/008.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 280 KiB

BIN
datasets/source/6/009.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 994 KiB

BIN
datasets/source/6/010.jfif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

BIN
datasets/source/7/001.jfif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 KiB

BIN
datasets/source/7/002.jfif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

BIN
datasets/source/7/003.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

BIN
datasets/source/7/004.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

BIN
datasets/source/7/005.jfif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

BIN
datasets/source/7/006.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 815 KiB

BIN
datasets/source/7/007.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

BIN
datasets/source/7/008.jfif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
datasets/source/7/009.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

BIN
datasets/source/7/010.jfif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
datasets/source/8/001.jfif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

BIN
datasets/source/8/002.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
datasets/source/8/003.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 180 KiB

BIN
datasets/source/8/004.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 722 KiB

BIN
datasets/source/8/005.jfif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

BIN
datasets/source/8/006.jfif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

BIN
datasets/source/8/007.jfif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

BIN
datasets/source/8/008.jfif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

BIN
datasets/source/8/009.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

BIN
datasets/source/8/010.jfif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
datasets/source/9/001.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 186 KiB

BIN
datasets/source/9/002.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 444 KiB

BIN
datasets/source/9/003.jfif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 171 KiB

BIN
datasets/source/9/004.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 KiB

BIN
datasets/source/9/005.jfif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 143 KiB

BIN
datasets/source/9/006.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 340 KiB

BIN
datasets/source/9/007.webp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
datasets/source/9/008.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 306 KiB

BIN
datasets/source/9/009.jfif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

BIN
datasets/source/9/010.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

BIN
datasets/target/1/001.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 252 KiB

BIN
datasets/target/1/002.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 305 KiB

BIN
datasets/target/1/003.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 189 KiB

BIN
datasets/target/1/004.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 284 KiB

BIN
datasets/target/1/005.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 262 KiB

BIN
datasets/target/1/007.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 KiB

BIN
datasets/target/1/009.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 208 KiB

BIN
datasets/target/1/010.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 322 KiB

BIN
datasets/target/10/001.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 372 KiB

Some files were not shown because too many files have changed in this diff Show More