Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -2334,17 +2334,35 @@ async def get_models():
|
|
| 2334 |
# VAE 通常是字符串
|
| 2335 |
vae_display = engine_cfg.get("local_vae_filename", "Unknown").replace(".safetensors", "")
|
| 2336 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2337 |
models_data[display_unet_name] = {
|
| 2338 |
"engine": engine,
|
| 2339 |
"defaults": engine_cfg.get("defaults", {}),
|
| 2340 |
"base_loras": base_loras_for_engine,
|
| 2341 |
"default_prompt": final_prompt,
|
| 2342 |
"te_name": te_display, # 👈 传给前端
|
| 2343 |
-
"vae_name": vae_display # 👈 传给前端
|
|
|
|
| 2344 |
}
|
| 2345 |
|
| 2346 |
return {"models": models_data}
|
| 2347 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2348 |
@app.get("/api/loras")
|
| 2349 |
async def get_loras():
|
| 2350 |
# ⚠️ load_char_loras_from_repo 里有同步 requests.get + list_repo_files(网络 IO)。
|
|
|
|
| 2334 |
# VAE 通常是字符串
|
| 2335 |
vae_display = engine_cfg.get("local_vae_filename", "Unknown").replace(".safetensors", "")
|
| 2336 |
|
| 2337 |
+
w_state = ("resident" if (warmup._resident_unet == unet_name
|
| 2338 |
+
and (time.time() - warmup._resident_at) < 600)
|
| 2339 |
+
else "warm" if warmup.ready(unet_name)
|
| 2340 |
+
else "cold")
|
| 2341 |
+
|
| 2342 |
models_data[display_unet_name] = {
|
| 2343 |
"engine": engine,
|
| 2344 |
"defaults": engine_cfg.get("defaults", {}),
|
| 2345 |
"base_loras": base_loras_for_engine,
|
| 2346 |
"default_prompt": final_prompt,
|
| 2347 |
"te_name": te_display, # 👈 传给前端
|
| 2348 |
+
"vae_name": vae_display, # 👈 传给前端
|
| 2349 |
+
"warm_state": w_state, # resident / warm / cold
|
| 2350 |
}
|
| 2351 |
|
| 2352 |
return {"models": models_data}
|
| 2353 |
|
| 2354 |
+
@app.get("/api/models/warm")
|
| 2355 |
+
async def api_models_warm():
|
| 2356 |
+
now = time.time()
|
| 2357 |
+
out = {}
|
| 2358 |
+
for name in UNET_CHOICES:
|
| 2359 |
+
out[name] = ("resident"
|
| 2360 |
+
if (warmup._resident_unet == name
|
| 2361 |
+
and (now - warmup._resident_at) < 600)
|
| 2362 |
+
else "warm" if warmup.ready(name)
|
| 2363 |
+
else "cold")
|
| 2364 |
+
return {"warm": out}
|
| 2365 |
+
|
| 2366 |
@app.get("/api/loras")
|
| 2367 |
async def get_loras():
|
| 2368 |
# ⚠️ load_char_loras_from_repo 里有同步 requests.get + list_repo_files(网络 IO)。
|