File size: 1,380 Bytes
d84a12f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import json
import numpy as np
import copy

# Load stats file
stats_file = "../meta/stats.json"
with open(stats_file, 'r') as f:
    stats = json.load(f)

print("Fixing stats.json file...")

# Create a deep copy to modify
fixed_stats = copy.deepcopy(stats)

# Fix all None std values
for key in fixed_stats:
    if "std" in fixed_stats[key] and fixed_stats[key]["std"] is None:
        # Use matching shape from mean if possible
        if "mean" in fixed_stats[key]:
            mean = fixed_stats[key]["mean"]
            if isinstance(mean, list):
                # Create a ones array with same shape as mean
                fixed_stats[key]["std"] = [1.0] * len(mean)
            else:
                # Fallback to scalar
                fixed_stats[key]["std"] = [1.0]
        else:
            # No mean to reference, use default
            fixed_stats[key]["std"] = [1.0]
        
        print(f"Fixed {key}.std: None → {fixed_stats[key]['std']}")

# Save the fixed stats file
output_file = "../meta/stats_fixed.json"
with open(output_file, 'w') as f:
    json.dump(fixed_stats, f, indent=2)

print(f"\nFIXED! New stats file saved to: {output_file}")
print("\nTo use this fixed file:")
print("1. Rename the original file as a backup: mv ../meta/stats.json ../meta/stats.json.bak")
print("2. Replace with fixed version: mv ../meta/stats_fixed.json ../meta/stats.json")