model metadata
This commit is contained in:
@@ -193,7 +193,7 @@ class AnnotationDashboard:
|
||||
def _get_best_checkpoint_info(self, model_name: str) -> Optional[Dict]:
|
||||
"""
|
||||
Get best checkpoint info for a model without loading it
|
||||
Uses filename parsing instead of torch.load to avoid crashes
|
||||
First tries database, then falls back to filename parsing
|
||||
|
||||
Args:
|
||||
model_name: Name of the model
|
||||
@@ -202,6 +202,41 @@ class AnnotationDashboard:
|
||||
Dict with checkpoint info or None if no checkpoint found
|
||||
"""
|
||||
try:
|
||||
# Try to get from database first (has full metadata)
|
||||
try:
|
||||
from utils.database_manager import DatabaseManager
|
||||
db_manager = DatabaseManager()
|
||||
|
||||
# Get active checkpoint for this model
|
||||
with db_manager._get_connection() as conn:
|
||||
cursor = conn.execute("""
|
||||
SELECT checkpoint_id, performance_metrics, timestamp, file_path
|
||||
FROM checkpoint_metadata
|
||||
WHERE model_name = ? AND is_active = TRUE
|
||||
ORDER BY performance_score DESC
|
||||
LIMIT 1
|
||||
""", (model_name.lower(),))
|
||||
|
||||
row = cursor.fetchone()
|
||||
if row:
|
||||
import json
|
||||
checkpoint_id, metrics_json, timestamp, file_path = row
|
||||
metrics = json.loads(metrics_json) if metrics_json else {}
|
||||
|
||||
checkpoint_info = {
|
||||
'filename': os.path.basename(file_path) if file_path else checkpoint_id,
|
||||
'epoch': metrics.get('epoch', 0),
|
||||
'loss': metrics.get('loss'),
|
||||
'accuracy': metrics.get('accuracy'),
|
||||
'source': 'database'
|
||||
}
|
||||
|
||||
logger.info(f"Loaded checkpoint info from database for {model_name}: E{checkpoint_info['epoch']}, Loss={checkpoint_info['loss']}, Acc={checkpoint_info['accuracy']}")
|
||||
return checkpoint_info
|
||||
except Exception as db_error:
|
||||
logger.debug(f"Could not load from database: {db_error}")
|
||||
|
||||
# Fallback to filename parsing
|
||||
import glob
|
||||
import re
|
||||
|
||||
|
||||
Reference in New Issue
Block a user