-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug_calibration.py
More file actions
57 lines (42 loc) · 1.87 KB
/
Copy pathdebug_calibration.py
File metadata and controls
57 lines (42 loc) · 1.87 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env python3
"""
Debug Calibration Script
This script helps debug the calibration test by checking file paths and permissions.
"""
import logging
from pathlib import Path
import torch
# Configure logging
logging.basicConfig(level=logging.INFO, format="%(levelname)s: %(message)s")
logger = logging.getLogger(__name__)
def debug_calibration_issue():
"""Debug the calibration test issue."""
logger.info("🔍 Debugging calibration test issue...")
logger.info(f"Current directory: {Path.cwd()}")
checkpoint_dir = Path("test_checkpoints")
logger.info(f"test_checkpoints directory exists: {checkpoint_dir.exists()}")
if checkpoint_dir.exists():
logger.info(f"test_checkpoints contents: {list(checkpoint_dir.iterdir())}")
checkpoint_file = checkpoint_dir / "best_model.pt"
logger.info(f"best_model.pt exists: {checkpoint_file.exists()}")
if checkpoint_file.exists():
logger.info(f"File size: {checkpoint_file.stat().st_size} bytes")
logger.info(f"File permissions: {oct(checkpoint_file.stat().st_mode)}")
try:
checkpoint = torch.load(checkpoint_file, map_location="cpu", weights_only=False)
logger.info("✅ Checkpoint loaded successfully")
logger.info(
f"Checkpoint keys: {list(checkpoint.keys()) if isinstance(checkpoint, dict) else 'Not a dict'}"
)
except Exception as e:
logger.error(f"❌ Failed to load checkpoint: {e}")
else:
logger.error("❌ best_model.pt does not exist")
else:
logger.error("❌ test_checkpoints directory does not exist")
try:
logger.info("✅ PyTorch imported successfully")
except ImportError as e:
logger.error(f"❌ PyTorch import failed: {e}")
if __name__ == "__main__":
debug_calibration_issue()