AnimateDataset / output /clean_ckpt.py
jasongzy's picture
Super-squash branch 'main' using huggingface_hub
1b46ba9 verified
raw
history blame contribute delete
472 Bytes
import os
from glob import glob
import torch
from tqdm import tqdm
for ckpt_path in tqdm(sorted(glob("./**/*.pth", recursive=True)), dynamic_ncols=True):
if (not os.path.isfile(ckpt_path)) or os.path.islink(ckpt_path):
continue
ckpt = torch.load(ckpt_path, map_location="cpu")
if "model" not in ckpt or len(ckpt) == 1:
continue
for k in tuple(ckpt.keys()):
if k != "model":
del ckpt[k]
torch.save(ckpt, ckpt_path)