DurgaDeepak commited on
Commit
a9d8551
·
verified ·
1 Parent(s): 49d2559

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -12
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
- #from huggingface_hub import spaces
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
- # @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
 
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