John6666 commited on
Commit
32c3e2d
1 Parent(s): dfd3805

Upload app.py

Browse files

Right now, the Zero GPU space is unstable overall, so I think it has to work this way, even though it is slightly awkward.

Files changed (1) hide show
  1. app.py +3 -2
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
- @spaces.GPU
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