You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

19 lines
669 B

import os
import torch
from pathlib import Path
src_dir = Path('exported_weights/backbone')
dst_dir = Path('exported_weights/backbone_verified')
dst_dir.mkdir(parents=True, exist_ok=True)
for file in src_dir.glob('*.pt'):
try:
obj = torch.load(file, map_location='cpu')
if not isinstance(obj, torch.Tensor):
print(f"[WARNING] {file.name} is not a tensor (type: {type(obj)}), skipping.")
continue
out_path = dst_dir / file.name
torch.save(obj, out_path)
print(f"[OK] {file.name} loaded and re-saved to {out_path}")
except Exception as e:
print(f"[ERROR] Failed to load {file.name}: {e}")