|
|
import os |
|
|
import shutil |
|
|
import torch |
|
|
from concurrent.futures import ThreadPoolExecutor, as_completed |
|
|
from tqdm import tqdm |
|
|
|
|
|
|
|
|
src_dirs = [ |
|
|
"/mnt/bn/yufan-dev-my/ysh/Ckpts/Lixsp11/0_final_sekai_dataset/sekai-real-drone", |
|
|
"/mnt/bn/yufan-dev-my/ysh/Ckpts/Lixsp11/0_final_sekai_dataset/sekai-game-drone", |
|
|
"/mnt/bn/yufan-dev-my/ysh/Ckpts/Lixsp11/0_final_sekai_dataset/sekai-game-walking-193", |
|
|
"/mnt/bn/yufan-dev-my/ysh/Ckpts/Lixsp11/0_final_sekai_dataset/sekai-game-walking-386", |
|
|
"/mnt/bn/yufan-dev-my/ysh/Ckpts/Lixsp11/0_final_sekai_dataset/sekai-real-walking-hq-193", |
|
|
"/mnt/bn/yufan-dev-my/ysh/Ckpts/Lixsp11/0_final_sekai_dataset/sekai-real-walking-hq-386", |
|
|
] |
|
|
|
|
|
bad_dir = '/mnt/bn/yufan-dev-my/ysh/Datasets/bad_pt' |
|
|
|
|
|
for src_dir in src_dirs: |
|
|
|
|
|
os.makedirs(bad_dir, exist_ok=True) |
|
|
|
|
|
|
|
|
def check_and_move(file): |
|
|
file_path = os.path.join(src_dir, file) |
|
|
try: |
|
|
torch.load(file_path, map_location='cpu', weights_only=False) |
|
|
return (file, True) |
|
|
except Exception: |
|
|
shutil.move(file_path, os.path.join(bad_dir, file)) |
|
|
return (file, False) |
|
|
|
|
|
|
|
|
pt_files = [f for f in os.listdir(src_dir) if f.endswith('.pt')] |
|
|
|
|
|
|
|
|
results = [] |
|
|
with ThreadPoolExecutor(max_workers=8) as executor: |
|
|
futures = {executor.submit(check_and_move, file): file for file in pt_files} |
|
|
for future in tqdm(as_completed(futures), total=len(futures), desc="处理中"): |
|
|
file, ok = future.result() |
|
|
if not ok: |
|
|
print(f"❌ 损坏:{file}") |
|
|
|
|
|
|
|
|
|
|
|
|