Spaces:
Sleeping
Sleeping
iljung1106
commited on
Commit
·
e27d16d
1
Parent(s):
1262a0d
fixed no spaces.GPU function error.
Browse files- requirements.txt +1 -0
- webui_gradio.py +13 -0
requirements.txt
CHANGED
|
@@ -10,3 +10,4 @@ opencv-python-headless
|
|
| 10 |
|
| 11 |
gradio==4.29.0
|
| 12 |
gradio_client==0.16.1
|
|
|
|
|
|
| 10 |
|
| 11 |
gradio==4.29.0
|
| 12 |
gradio_client==0.16.1
|
| 13 |
+
space
|
webui_gradio.py
CHANGED
|
@@ -10,6 +10,11 @@ import numpy as np
|
|
| 10 |
import torch
|
| 11 |
from PIL import Image
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
def _patch_fastapi_starlette_middleware_unpack() -> None:
|
| 14 |
"""
|
| 15 |
Work around FastAPI/Starlette version mismatches where Starlette's Middleware
|
|
@@ -83,6 +88,14 @@ _patch_fastapi_starlette_middleware_unpack()
|
|
| 83 |
|
| 84 |
import gradio as gr
|
| 85 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
def _launch_compat(demo: gr.Blocks, **kwargs):
|
| 87 |
"""
|
| 88 |
Launch Gradio across versions by only passing supported kwargs.
|
|
|
|
| 10 |
import torch
|
| 11 |
from PIL import Image
|
| 12 |
|
| 13 |
+
try:
|
| 14 |
+
import spaces # Hugging Face Spaces helper package
|
| 15 |
+
except Exception: # noqa: BLE001
|
| 16 |
+
spaces = None
|
| 17 |
+
|
| 18 |
def _patch_fastapi_starlette_middleware_unpack() -> None:
|
| 19 |
"""
|
| 20 |
Work around FastAPI/Starlette version mismatches where Starlette's Middleware
|
|
|
|
| 88 |
|
| 89 |
import gradio as gr
|
| 90 |
|
| 91 |
+
if spaces is not None:
|
| 92 |
+
# Hugging Face GPU Spaces require at least one @spaces.GPU-decorated function.
|
| 93 |
+
# We decorate a tiny no-op marker and also (optionally) wrap inference-heavy calls.
|
| 94 |
+
@spaces.GPU
|
| 95 |
+
def _spaces_gpu_marker(): # noqa: D401
|
| 96 |
+
"""Marker function for Hugging Face GPU Spaces."""
|
| 97 |
+
return True
|
| 98 |
+
|
| 99 |
def _launch_compat(demo: gr.Blocks, **kwargs):
|
| 100 |
"""
|
| 101 |
Launch Gradio across versions by only passing supported kwargs.
|