Fix missing tabulate dependency for dashboard
Browse files- Added tabulate to requirements.txt
- Added fallback for to_markdown() if tabulate missing
- Fixes ImportError on Hugging Face Spaces startup
- Dashboard now loads automatically from checkpoints/metrics.csv
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- app.py +8 -1
- app122.py +8 -1
- requirements.txt +1 -0
app.py
CHANGED
|
@@ -342,6 +342,13 @@ def load_metrics(path: str):
|
|
| 342 |
|
| 343 |
# Summary statistics
|
| 344 |
energy_col = 'save_rate' if 'save_rate' in df.columns else 'energy_savings'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 345 |
summary = f"""
|
| 346 |
### Training Summary
|
| 347 |
|
|
@@ -351,7 +358,7 @@ def load_metrics(path: str):
|
|
| 351 |
**Average Energy Savings:** {df[energy_col].mean()*100:.1f}%
|
| 352 |
|
| 353 |
#### Last 5 Epochs:
|
| 354 |
-
{
|
| 355 |
"""
|
| 356 |
|
| 357 |
fig_loss = _plot_to_pil(df, "train_loss", "Training Loss Over Time", "Loss", color='#FF5722')
|
|
|
|
| 342 |
|
| 343 |
# Summary statistics
|
| 344 |
energy_col = 'save_rate' if 'save_rate' in df.columns else 'energy_savings'
|
| 345 |
+
|
| 346 |
+
# Try markdown table, fallback to CSV format if tabulate is missing
|
| 347 |
+
try:
|
| 348 |
+
last_5_table = df.tail(5).to_markdown(index=False)
|
| 349 |
+
except ImportError:
|
| 350 |
+
last_5_table = "```\n" + df.tail(5).to_string(index=False) + "\n```"
|
| 351 |
+
|
| 352 |
summary = f"""
|
| 353 |
### Training Summary
|
| 354 |
|
|
|
|
| 358 |
**Average Energy Savings:** {df[energy_col].mean()*100:.1f}%
|
| 359 |
|
| 360 |
#### Last 5 Epochs:
|
| 361 |
+
{last_5_table}
|
| 362 |
"""
|
| 363 |
|
| 364 |
fig_loss = _plot_to_pil(df, "train_loss", "Training Loss Over Time", "Loss", color='#FF5722')
|
app122.py
CHANGED
|
@@ -342,6 +342,13 @@ def load_metrics(path: str):
|
|
| 342 |
|
| 343 |
# Summary statistics
|
| 344 |
energy_col = 'save_rate' if 'save_rate' in df.columns else 'energy_savings'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 345 |
summary = f"""
|
| 346 |
### Training Summary
|
| 347 |
|
|
@@ -351,7 +358,7 @@ def load_metrics(path: str):
|
|
| 351 |
**Average Energy Savings:** {df[energy_col].mean()*100:.1f}%
|
| 352 |
|
| 353 |
#### Last 5 Epochs:
|
| 354 |
-
{
|
| 355 |
"""
|
| 356 |
|
| 357 |
fig_loss = _plot_to_pil(df, "train_loss", "Training Loss Over Time", "Loss", color='#FF5722')
|
|
|
|
| 342 |
|
| 343 |
# Summary statistics
|
| 344 |
energy_col = 'save_rate' if 'save_rate' in df.columns else 'energy_savings'
|
| 345 |
+
|
| 346 |
+
# Try markdown table, fallback to CSV format if tabulate is missing
|
| 347 |
+
try:
|
| 348 |
+
last_5_table = df.tail(5).to_markdown(index=False)
|
| 349 |
+
except ImportError:
|
| 350 |
+
last_5_table = "```\n" + df.tail(5).to_string(index=False) + "\n```"
|
| 351 |
+
|
| 352 |
summary = f"""
|
| 353 |
### Training Summary
|
| 354 |
|
|
|
|
| 358 |
**Average Energy Savings:** {df[energy_col].mean()*100:.1f}%
|
| 359 |
|
| 360 |
#### Last 5 Epochs:
|
| 361 |
+
{last_5_table}
|
| 362 |
"""
|
| 363 |
|
| 364 |
fig_loss = _plot_to_pil(df, "train_loss", "Training Loss Over Time", "Loss", color='#FF5722')
|
requirements.txt
CHANGED
|
@@ -6,6 +6,7 @@ scikit-learn
|
|
| 6 |
matplotlib
|
| 7 |
pyyaml
|
| 8 |
pandas
|
|
|
|
| 9 |
seaborn
|
| 10 |
huggingface_hub
|
| 11 |
onnx
|
|
|
|
| 6 |
matplotlib
|
| 7 |
pyyaml
|
| 8 |
pandas
|
| 9 |
+
tabulate
|
| 10 |
seaborn
|
| 11 |
huggingface_hub
|
| 12 |
onnx
|