Spaces:
Running
Running
HARSHIT-hash-07 commited on
Commit ·
126af4a
1
Parent(s): e15eab8
fix: correct HF Space URL + add health endpoint + frontend retry/warmup UX
Browse files- backend/main.py +8 -0
- backend/model_loader.py +2 -1
backend/main.py
CHANGED
|
@@ -57,6 +57,14 @@ class TranslationResponse(BaseModel):
|
|
| 57 |
async def root():
|
| 58 |
return {"message": "SignBridge AI API is running"}
|
| 59 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
@app.post("/translate", response_model=TranslationResponse)
|
| 61 |
async def translate_text(request: TranslationRequest):
|
| 62 |
try:
|
|
|
|
| 57 |
async def root():
|
| 58 |
return {"message": "SignBridge AI API is running"}
|
| 59 |
|
| 60 |
+
@app.get("/health")
|
| 61 |
+
async def health():
|
| 62 |
+
return {
|
| 63 |
+
"status": "ready" if model.is_loaded else "loading",
|
| 64 |
+
"model_loaded": model.is_loaded,
|
| 65 |
+
"error": model._load_error
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
@app.post("/translate", response_model=TranslationResponse)
|
| 69 |
async def translate_text(request: TranslationRequest):
|
| 70 |
try:
|
backend/model_loader.py
CHANGED
|
@@ -104,7 +104,8 @@ class SignModel:
|
|
| 104 |
|
| 105 |
render_skeleton_to_video(skeletons, output_path, mode="standard")
|
| 106 |
|
| 107 |
-
|
|
|
|
| 108 |
|
| 109 |
return {
|
| 110 |
"skeletons": None,
|
|
|
|
| 104 |
|
| 105 |
render_skeleton_to_video(skeletons, output_path, mode="standard")
|
| 106 |
|
| 107 |
+
space_base_url = os.environ.get("HF_SPACE_URL", "https://explowebsite-sign-idd-inference.hf.space")
|
| 108 |
+
video_url = f"{space_base_url}/static/{filename}"
|
| 109 |
|
| 110 |
return {
|
| 111 |
"skeletons": None,
|