malcolmSQ commited on
Commit ·
2ce627e
1
Parent(s): c40d9fd
fix: ensure to_native is at the very top of app.py and always in scope
Browse files- dashboard/app.py +23 -0
dashboard/app.py
CHANGED
|
@@ -5,6 +5,29 @@ Mangrove ER Model Dashboard
|
|
| 5 |
- To add a new model, add its config to configs/ and add an entry to MODEL_CONFIGS below.
|
| 6 |
- Each tab shows the results for the base config (no parameter editing).
|
| 7 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
import gradio as gr
|
| 9 |
from pathlib import Path
|
| 10 |
from src.er_model import ERModel
|
|
|
|
| 5 |
- To add a new model, add its config to configs/ and add an entry to MODEL_CONFIGS below.
|
| 6 |
- Each tab shows the results for the base config (no parameter editing).
|
| 7 |
"""
|
| 8 |
+
def to_native(obj):
|
| 9 |
+
import numpy as np
|
| 10 |
+
import pandas as pd
|
| 11 |
+
if isinstance(obj, pd.DataFrame):
|
| 12 |
+
obj = obj.applymap(lambda x: to_native(x))
|
| 13 |
+
obj.index = obj.index.map(to_native)
|
| 14 |
+
obj.columns = obj.columns.map(to_native)
|
| 15 |
+
return obj
|
| 16 |
+
elif isinstance(obj, pd.Series):
|
| 17 |
+
obj = obj.map(to_native)
|
| 18 |
+
obj.index = obj.index.map(to_native)
|
| 19 |
+
return obj
|
| 20 |
+
elif isinstance(obj, dict):
|
| 21 |
+
return {to_native(k): to_native(v) for k, v in obj.items()}
|
| 22 |
+
elif isinstance(obj, list):
|
| 23 |
+
return [to_native(x) for x in obj]
|
| 24 |
+
elif isinstance(obj, tuple):
|
| 25 |
+
return tuple(to_native(x) for x in obj)
|
| 26 |
+
elif isinstance(obj, (np.generic, np.ndarray)):
|
| 27 |
+
return obj.item() if obj.size == 1 else obj.tolist()
|
| 28 |
+
else:
|
| 29 |
+
return obj
|
| 30 |
+
|
| 31 |
import gradio as gr
|
| 32 |
from pathlib import Path
|
| 33 |
from src.er_model import ERModel
|