/
Chriss_Nickell
/
Course_Project
Обзор
Документация
Войти
/
Chriss_Nickell
/
Course_Project
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
scr.py
64 строки
1 KB
Lavrov
create: scr.py
03 июн 2026, 06:41
Верифицирован
03 июн 2026, 06:41
acca350
Код
Авторство
О чём код?
import os from collections import defaultdict folder = r"C:\Users\Norman\Desktop\UTKFaceNew" race_stats = defaultdict(int) total = 0 bad_files = [] for filename in os.listdir(folder): try: parts = filename.split("_") if len(parts) < 3: bad_files.append((filename, "too short")) continue age = int(parts[0]) gender = int(parts[1]) race = int(parts[2]) if race < 0 or race > 4: bad_files.append((filename, f"invalid race: {race}")) continue race_stats[race] += 1 total += 1 except Exception as e: bad_files.append((filename, str(e))) # ========================= # REPORT # ========================= print("\n========== CHECK REPORT ==========\n") print(f"Parsed correctly: {total}\n") race_map = { 0: "White", 1: "Black", 2: "Asian", 3: "Indian", 4: "Others" } print("----- RACE DISTRIBUTION -----") for k in sorted(race_map.keys()): print(f"{race_map[k]}: {race_stats[k]}") print("\n----- PROBLEM FILES -----") if not bad_files: print("No issues found.") else: for f, reason in bad_files: print(f"{f} -> {reason}") print(f"\nTOTAL PARSED: {total}") print(f"TOTAL FILES: {len(os.listdir(folder))}") print(f"DIFF: {len(os.listdir(folder)) - total}")