Spaces:
Running
Running
Upload folder using huggingface_hub
Browse files
app.py
CHANGED
|
@@ -31,6 +31,7 @@ RESULTS_DIR = "generated_results"
|
|
| 31 |
DEFAULT_ANALYSIS_OUT = "analysis_outputs/outputs_all_models_20260325/T4"
|
| 32 |
os.makedirs(RESULTS_DIR, exist_ok=True)
|
| 33 |
_BG_JOBS = {}
|
|
|
|
| 34 |
|
| 35 |
try:
|
| 36 |
import mlflow
|
|
@@ -193,6 +194,9 @@ def _download_hf_settings_for_repo(repo_id: str):
|
|
| 193 |
|
| 194 |
|
| 195 |
def discover_checkpoints():
|
|
|
|
|
|
|
|
|
|
| 196 |
found = []
|
| 197 |
local_roots = [
|
| 198 |
("ablation_results", "cross_attention"),
|
|
@@ -234,7 +238,8 @@ def discover_checkpoints():
|
|
| 234 |
"hf_settings": settings,
|
| 235 |
}
|
| 236 |
)
|
| 237 |
-
|
|
|
|
| 238 |
|
| 239 |
|
| 240 |
def _guess_analysis_dir(experiment: str, ckpt_path: str, family: str = "cross_attention", settings: dict | None = None) -> str:
|
|
@@ -1106,6 +1111,22 @@ def auto_load_default_with_outputs():
|
|
| 1106 |
return load_selected_model_with_outputs(default_checkpoint_label())
|
| 1107 |
|
| 1108 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1109 |
CUSTOM_CSS = """
|
| 1110 |
:root {
|
| 1111 |
--bg1: #f5fbff;
|
|
@@ -1258,6 +1279,8 @@ with gr.Blocks(title="Sanskrit Diffusion Model", css=CUSTOM_CSS) as demo:
|
|
| 1258 |
)
|
| 1259 |
|
| 1260 |
def refresh_checkpoints():
|
|
|
|
|
|
|
| 1261 |
choices = list(checkpoint_map().keys())
|
| 1262 |
value = default_checkpoint_label() if choices else None
|
| 1263 |
msg = f"Found {len(choices)} checkpoint(s)." if choices else "No checkpoints found."
|
|
@@ -1265,7 +1288,7 @@ with gr.Blocks(title="Sanskrit Diffusion Model", css=CUSTOM_CSS) as demo:
|
|
| 1265 |
|
| 1266 |
refresh_btn.click(fn=refresh_checkpoints, outputs=[checkpoint_dropdown, load_status])
|
| 1267 |
load_btn.click(
|
| 1268 |
-
fn=
|
| 1269 |
inputs=[checkpoint_dropdown],
|
| 1270 |
outputs=[
|
| 1271 |
model_state,
|
|
|
|
| 31 |
DEFAULT_ANALYSIS_OUT = "analysis_outputs/outputs_all_models_20260325/T4"
|
| 32 |
os.makedirs(RESULTS_DIR, exist_ok=True)
|
| 33 |
_BG_JOBS = {}
|
| 34 |
+
_CHECKPOINT_CACHE = None
|
| 35 |
|
| 36 |
try:
|
| 37 |
import mlflow
|
|
|
|
| 194 |
|
| 195 |
|
| 196 |
def discover_checkpoints():
|
| 197 |
+
global _CHECKPOINT_CACHE
|
| 198 |
+
if _CHECKPOINT_CACHE is not None:
|
| 199 |
+
return list(_CHECKPOINT_CACHE)
|
| 200 |
found = []
|
| 201 |
local_roots = [
|
| 202 |
("ablation_results", "cross_attention"),
|
|
|
|
| 238 |
"hf_settings": settings,
|
| 239 |
}
|
| 240 |
)
|
| 241 |
+
_CHECKPOINT_CACHE = list(found)
|
| 242 |
+
return list(found)
|
| 243 |
|
| 244 |
|
| 245 |
def _guess_analysis_dir(experiment: str, ckpt_path: str, family: str = "cross_attention", settings: dict | None = None) -> str:
|
|
|
|
| 1111 |
return load_selected_model_with_outputs(default_checkpoint_label())
|
| 1112 |
|
| 1113 |
|
| 1114 |
+
def safe_load_selected_model_with_outputs(checkpoint_label):
|
| 1115 |
+
try:
|
| 1116 |
+
return load_selected_model_with_outputs(checkpoint_label)
|
| 1117 |
+
except Exception as e:
|
| 1118 |
+
outputs = _safe_refresh_task_outputs(DEFAULT_ANALYSIS_OUT)
|
| 1119 |
+
return (
|
| 1120 |
+
None,
|
| 1121 |
+
f"Load failed: {e}",
|
| 1122 |
+
{},
|
| 1123 |
+
64,
|
| 1124 |
+
DEFAULT_ANALYSIS_OUT,
|
| 1125 |
+
_build_flow_markdown(model_loaded=False, inference_ready=False, task_states={}),
|
| 1126 |
+
*outputs,
|
| 1127 |
+
)
|
| 1128 |
+
|
| 1129 |
+
|
| 1130 |
CUSTOM_CSS = """
|
| 1131 |
:root {
|
| 1132 |
--bg1: #f5fbff;
|
|
|
|
| 1279 |
)
|
| 1280 |
|
| 1281 |
def refresh_checkpoints():
|
| 1282 |
+
global _CHECKPOINT_CACHE
|
| 1283 |
+
_CHECKPOINT_CACHE = None
|
| 1284 |
choices = list(checkpoint_map().keys())
|
| 1285 |
value = default_checkpoint_label() if choices else None
|
| 1286 |
msg = f"Found {len(choices)} checkpoint(s)." if choices else "No checkpoints found."
|
|
|
|
| 1288 |
|
| 1289 |
refresh_btn.click(fn=refresh_checkpoints, outputs=[checkpoint_dropdown, load_status])
|
| 1290 |
load_btn.click(
|
| 1291 |
+
fn=safe_load_selected_model_with_outputs,
|
| 1292 |
inputs=[checkpoint_dropdown],
|
| 1293 |
outputs=[
|
| 1294 |
model_state,
|