bug fixes

This commit is contained in:
Linrador 2026-06-24 11:15:43 +02:00
parent 83120174a6
commit 13fe32577f
5 changed files with 30 additions and 22 deletions

View File

@ -1597,6 +1597,33 @@ def videomae_model_status() -> dict:
}
def detector_model_status(load: bool = False) -> dict:
current_model = get_model() if load else model
names = getattr(current_model, "names", {}) or {} if current_model is not None else {}
expected_text = str(DEFAULT_MODEL_PATH)
exists = False
error = _MODEL_ERROR
try:
expected = resolve_model_path()
expected_text = str(expected)
exists = True
except Exception as exc:
if not error:
error = str(exc)
return {
"modelAvailable": exists,
"modelLoaded": current_model is not None,
"model": _MODEL_PATH or (expected_text if exists else ""),
"modelError": error,
"expectedModel": expected_text,
"classCount": len(names),
"classes": list(names.values())[:80] if isinstance(names, dict) else names,
}
@app.post("/predict-batch", dependencies=[Depends(require_ai_server_auth)])
def predict_batch(req: PredictBatchRequest):
paths = [str(path).strip() for path in req.paths if str(path).strip()]
@ -1707,23 +1734,15 @@ def predict_position_clips(req: PredictPositionClipsRequest):
@app.get("/health", dependencies=[Depends(require_ai_server_auth)])
def health():
current_model = get_model()
names = getattr(current_model, "names", {}) or {} if current_model is not None else {}
status_payload = {
"ok": True,
"ready": True,
"modelAvailable": current_model is not None,
"model": _MODEL_PATH,
"modelError": _MODEL_ERROR,
"expectedModel": str(DEFAULT_MODEL_PATH),
"trainingRoot": str(TRAINING_ROOT),
"classCount": len(names),
"classes": list(names.values())[:80] if isinstance(names, dict) else names,
"labelConfig": str(DETECTION_LABELS_PATH) if DETECTION_LABELS_PATH else "",
"labelError": _LABEL_ERROR,
}
status_payload.update(detector_model_status(load=False))
status_payload.update(pose_model_status())
status_payload.update(videomae_model_status())
return status_payload
@ -1756,23 +1775,15 @@ def reload_model():
_VIDEOMAE_DEVICE_ACTIVE = ""
DETECTION_LABELS_PATH = None
current_model = get_model()
names = getattr(current_model, "names", {}) or {} if current_model is not None else {}
status_payload = {
"ok": True,
"ready": True,
"modelAvailable": current_model is not None,
"model": _MODEL_PATH,
"modelError": _MODEL_ERROR,
"expectedModel": str(DEFAULT_MODEL_PATH),
"trainingRoot": str(TRAINING_ROOT),
"classCount": len(names),
"classes": list(names.values())[:80] if isinstance(names, dict) else names,
"labelConfig": str(DETECTION_LABELS_PATH) if DETECTION_LABELS_PATH else "",
"labelError": _LABEL_ERROR,
}
status_payload.update(detector_model_status(load=True))
status_payload.update(pose_model_status())
status_payload.update(videomae_model_status())
return status_payload

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -633,10 +633,7 @@ func startAIServer(ctx context.Context) (*aiServerProcess, error) {
close(proc.done)
}()
waitCtx, cancel := context.WithTimeout(ctx, 30*time.Second)
defer cancel()
if err := waitForAIServer(waitCtx, aiServerURL(), 30*time.Second); err != nil {
if err := waitForAIServer(ctx, aiServerURL(), 120*time.Second); err != nil {
appLogln("⚠️ AI Server noch nicht bereit:", err)
// Nicht hart abbrechen. Deine Analyse kann auf den Fallback gehen.
return proc, nil