Upload app.py
Browse filesRight now, the Zero GPU space is unstable overall, so I think it has to work this way, even though it is slightly awkward.
app.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import json
|
2 |
import os
|
3 |
from pathlib import Path
|
@@ -5,7 +6,6 @@ from typing import Callable, NoReturn
|
|
5 |
|
6 |
from asgi_correlation_id import CorrelationIdMiddleware
|
7 |
import gradio as gr
|
8 |
-
import spaces
|
9 |
from starlette.responses import JSONResponse
|
10 |
import structlog
|
11 |
import uvicorn
|
@@ -55,7 +55,7 @@ async def request_middleware(request, call_next):
|
|
55 |
|
56 |
return await logging_middleware(request, call_next)
|
57 |
|
58 |
-
|
59 |
def gpu_initialization() -> None:
|
60 |
app_logger.info("GPU initialization...")
|
61 |
|
@@ -120,6 +120,7 @@ async def health() -> JSONResponse:
|
|
120 |
return JSONResponse(status_code=200, content={"msg": "still alive..."})
|
121 |
|
122 |
|
|
|
123 |
def infer_lisa_gradio(request_input: StringPromptApiRequestBody) -> str:
|
124 |
from samgis_lisa.io_package.wrappers_helpers import get_parsed_bbox_points_with_string_prompt
|
125 |
from samgis_lisa.prediction_api import lisa
|
|
|
1 |
+
import spaces
|
2 |
import json
|
3 |
import os
|
4 |
from pathlib import Path
|
|
|
6 |
|
7 |
from asgi_correlation_id import CorrelationIdMiddleware
|
8 |
import gradio as gr
|
|
|
9 |
from starlette.responses import JSONResponse
|
10 |
import structlog
|
11 |
import uvicorn
|
|
|
55 |
|
56 |
return await logging_middleware(request, call_next)
|
57 |
|
58 |
+
#@spaces.GPU
|
59 |
def gpu_initialization() -> None:
|
60 |
app_logger.info("GPU initialization...")
|
61 |
|
|
|
120 |
return JSONResponse(status_code=200, content={"msg": "still alive..."})
|
121 |
|
122 |
|
123 |
+
@spaces.GPU
|
124 |
def infer_lisa_gradio(request_input: StringPromptApiRequestBody) -> str:
|
125 |
from samgis_lisa.io_package.wrappers_helpers import get_parsed_bbox_points_with_string_prompt
|
126 |
from samgis_lisa.prediction_api import lisa
|