Upload 277 files
Browse files- backend/main.py +3 -0
- backend/services/image_service.py +5 -4
backend/main.py
CHANGED
|
@@ -11,6 +11,7 @@ from fastapi import FastAPI, Request
|
|
| 11 |
from fastapi.middleware.cors import CORSMiddleware
|
| 12 |
from fastapi.staticfiles import StaticFiles
|
| 13 |
|
|
|
|
| 14 |
from routers import auth, catalog, media, pages, segmentation
|
| 15 |
from services.sam2_service import lifespan
|
| 16 |
|
|
@@ -18,6 +19,8 @@ mimetypes.add_type("application/javascript", ".js", strict=True)
|
|
| 18 |
mimetypes.add_type("text/css", ".css", strict=True)
|
| 19 |
mimetypes.add_type("image/svg+xml", ".svg", strict=True)
|
| 20 |
|
|
|
|
|
|
|
| 21 |
app = FastAPI(title="Hyper Reality Backend", lifespan=lifespan)
|
| 22 |
|
| 23 |
app.add_middleware(
|
|
|
|
| 11 |
from fastapi.middleware.cors import CORSMiddleware
|
| 12 |
from fastapi.staticfiles import StaticFiles
|
| 13 |
|
| 14 |
+
from core.config import GRADIO_SPACE_URL, logger
|
| 15 |
from routers import auth, catalog, media, pages, segmentation
|
| 16 |
from services.sam2_service import lifespan
|
| 17 |
|
|
|
|
| 19 |
mimetypes.add_type("text/css", ".css", strict=True)
|
| 20 |
mimetypes.add_type("image/svg+xml", ".svg", strict=True)
|
| 21 |
|
| 22 |
+
logger.info("[STARTUP] GRADIO_SPACE_URL=%s", GRADIO_SPACE_URL or "(not set — using local SAM2)")
|
| 23 |
+
|
| 24 |
app = FastAPI(title="Hyper Reality Backend", lifespan=lifespan)
|
| 25 |
|
| 26 |
app.add_middleware(
|
backend/services/image_service.py
CHANGED
|
@@ -135,10 +135,11 @@ def run_upload_job(job_id: str, content: bytes, original_name: str) -> None:
|
|
| 135 |
image_path = UPLOAD_DIR / safe_name
|
| 136 |
if is_gradio_enabled():
|
| 137 |
gradio_result = segment_via_gradio_sync(image_path)
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
|
|
|
| 142 |
label_map, mask_count = gradio_result
|
| 143 |
else:
|
| 144 |
generate_label_map = _get_generate_label_map()
|
|
|
|
| 135 |
image_path = UPLOAD_DIR / safe_name
|
| 136 |
if is_gradio_enabled():
|
| 137 |
gradio_result = segment_via_gradio_sync(image_path)
|
| 138 |
+
if gradio_result is None:
|
| 139 |
+
raise RuntimeError(
|
| 140 |
+
"El Space de Gradio no respondió. "
|
| 141 |
+
"Verifica que esté activo y que GRADIO_SPACE_URL sea correcta."
|
| 142 |
+
)
|
| 143 |
label_map, mask_count = gradio_result
|
| 144 |
else:
|
| 145 |
generate_label_map = _get_generate_label_map()
|