liuhui0401 commited on
Commit
1157ec3
·
verified ·
1 Parent(s): 99ef587

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -2
app.py CHANGED
@@ -3,7 +3,21 @@ import cv2
3
  from gradio_webrtc import WebRTC
4
  import mediapipe as mp
5
  import time
6
- import space
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
 
8
  # 初始化 MediaPipe Hands
9
  mp_hands = mp.solutions.hands
@@ -20,7 +34,6 @@ rtc_configuration = {
20
  last_process_time = time.time()
21
 
22
  # 手势检测函数
23
- @spaces.GPU
24
  def detection(image, conf_threshold=0.5):
25
  """
26
  使用 MediaPipe Hands 进行手势检测。
 
3
  from gradio_webrtc import WebRTC
4
  import mediapipe as mp
5
  import time
6
+
7
+ import os
8
+ if os.environ.get("SPACES_ZERO_GPU") is not None:
9
+ import spaces
10
+ else:
11
+ class spaces:
12
+ @staticmethod
13
+ def GPU(func):
14
+ def wrapper(*args, **kwargs):
15
+ return func(*args, **kwargs)
16
+ return wrapper
17
+
18
+ @spaces.GPU
19
+ def fake_gpu():
20
+ pass
21
 
22
  # 初始化 MediaPipe Hands
23
  mp_hands = mp.solutions.hands
 
34
  last_process_time = time.time()
35
 
36
  # 手势检测函数
 
37
  def detection(image, conf_threshold=0.5):
38
  """
39
  使用 MediaPipe Hands 进行手势检测。