Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -25,7 +25,7 @@ import timeout_decorator
|
|
25 |
import socket
|
26 |
import ipaddress
|
27 |
from huggingface_hub import hf_hub_download
|
28 |
-
|
29 |
|
30 |
# Setup logging
|
31 |
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
@@ -61,17 +61,17 @@ MAX_VIDEO_MB = 50
|
|
61 |
MAX_VIDEO_DURATION = 30 # seconds
|
62 |
|
63 |
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
|
76 |
|
77 |
# Utility Functions
|
|
|
25 |
import socket
|
26 |
import ipaddress
|
27 |
from huggingface_hub import hf_hub_download
|
28 |
+
import spaces
|
29 |
|
30 |
# Setup logging
|
31 |
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
|
|
61 |
MAX_VIDEO_DURATION = 30 # seconds
|
62 |
|
63 |
|
64 |
+
@spaces.GPU
|
65 |
+
def preload_models():
|
66 |
+
"""
|
67 |
+
This function is needed to activate ZeroGPU. It must be decorated with @spaces.GPU.
|
68 |
+
It can be used to warm up models or load them into memory.
|
69 |
+
"""
|
70 |
+
from registry import get_model
|
71 |
+
print("Warming up models for ZeroGPU...")
|
72 |
+
get_model("detection", "yolov5n-seg", device="cpu")
|
73 |
+
get_model("segmentation", "deeplabv3_resnet50", device="cpu")
|
74 |
+
get_model("depth", "midas_v21_small_256", device="cpu")
|
75 |
|
76 |
|
77 |
# Utility Functions
|