Merge pull request #77 from huggingface/alexander-soare/fix_save_stats
Fix issue with saving freshly computed stats
This commit is contained in:
commit
6d78bca749
|
@ -62,7 +62,7 @@ def make_dataset(
|
|||
stats = torch.load(precomputed_stats_path)
|
||||
else:
|
||||
logging.info(f"compute_stats and save to {precomputed_stats_path}")
|
||||
# instantiate a one frame dataset with light transform
|
||||
# Create a dataset for stats computation.
|
||||
stats_dataset = clsfunc(
|
||||
dataset_id=cfg.dataset_id,
|
||||
split="train",
|
||||
|
@ -70,7 +70,8 @@ def make_dataset(
|
|||
transform=Prod(in_keys=clsfunc.image_keys, prod=1 / 255.0),
|
||||
)
|
||||
stats = compute_stats(stats_dataset)
|
||||
torch.save(stats, stats_path)
|
||||
precomputed_stats_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
torch.save(stats, precomputed_stats_path)
|
||||
else:
|
||||
stats = torch.load(stats_path)
|
||||
|
||||
|
|
Loading…
Reference in New Issue