File size: 2,055 Bytes
c1596ac
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import os
from PIL import Image

# ================================
# 1. 경로 설정
# ================================
DATA_DIR = "./data/raw"

# ================================
# 2. 최소 해상도 기준
# ================================
MIN_RES = 256

# ================================
# 3. 결과 저장 리스트
# ================================
low_resolution_images = []

# ================================
# 4. 이미지 검사
# ================================
for class_name in os.listdir(DATA_DIR):

    class_path = os.path.join(DATA_DIR, class_name)

    # 폴더만 처리
    if not os.path.isdir(class_path):
        continue

    for file_name in os.listdir(class_path):

        file_path = os.path.join(class_path, file_name)

        # 파일만 처리
        if not os.path.isfile(file_path):
            continue

        try:
            with Image.open(file_path) as img:

                width, height = img.size

                # 256 미만 이미지 찾기
                if width < MIN_RES or height < MIN_RES:

                    low_resolution_images.append({
                        "class": class_name,
                        "file": file_name,
                        "width": width,
                        "height": height
                    })

        except Exception as e:
            print(f"오류 발생: {file_path}")
            print(e)

# ================================
# 5. 결과 출력
# ================================
print(f"\n해상도 {MIN_RES}px 미만 이미지 목록\n")

if len(low_resolution_images) == 0:
    print("모든 이미지가 기준 해상도를 만족합니다.")

else:
    for item in low_resolution_images:

        print(
            f"[{item['class']}] "
            f"{item['file']} "
            f"→ {item['width']} x {item['height']}"
        )

# ================================
# 6. 총 개수 출력
# ================================
print("\n====================")
print(f"총 개수: {len(low_resolution_images)}장")
print("====================")