zlf18 commited on
Commit
f89bf52
·
verified ·
1 Parent(s): e073312

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -11
app.py CHANGED
@@ -85,11 +85,9 @@ def process_image(webcam_frame, camera_state, prev_hand_pos_state):
85
  if webcam_frame is None:
86
  return "Waiting...", DEFAULT_CAMERA, None, gr.update(camera_position=DEFAULT_CAMERA)
87
 
88
- # --- OPTIMIZATION 1: Pass by reference, don't copy ---
89
  image = webcam_frame
90
  image.flags.writeable = False
91
  results = hands.process(image)
92
- # No need to set writeable=True, we aren't drawing
93
 
94
  if results.multi_hand_landmarks:
95
  hand_landmarks = results.multi_hand_landmarks[0]
@@ -119,13 +117,11 @@ def process_image(webcam_frame, camera_state, prev_hand_pos_state):
119
 
120
  if current_hand_pos:
121
  new_prev_hand_pos = current_hand_pos
122
-
123
- # --- OPTIMIZATION 2: Removed mp_drawing.draw_landmarks() ---
124
 
125
  else:
126
  new_prev_hand_pos = None
127
 
128
- # --- FIX 2: Return 4 values, removing the image ---
129
  return gesture_text, new_camera_state, new_prev_hand_pos, gr.update(camera_position=new_camera_state)
130
 
131
  # 8. --- HELPER FUNCTIONS ---
@@ -173,7 +169,6 @@ with gr.Blocks(theme=gr.themes.Glass()) as demo:
173
  # --- MAIN COLUMN for 3D viewer ---
174
  with gr.Column(scale=3):
175
  default_model_path = PRELOADED_MODELS.get("Preset 1", None)
176
- # This check is now for the deployment environment
177
  if not os.path.exists(default_model_path):
178
  print(f"Warning: Default preset '{default_model_path}' not found.")
179
  default_model_path = None
@@ -193,8 +188,6 @@ with gr.Blocks(theme=gr.themes.Glass()) as demo:
193
  """
194
  )
195
 
196
- # --- OPTIMIZATION 3: Removed webcam_output component ---
197
-
198
  # --- 10. WIRE UP THE NEW CONTROLS ---
199
 
200
  # 1. Wire up the Radio buttons
@@ -227,7 +220,9 @@ with gr.Blocks(theme=gr.themes.Glass()) as demo:
227
  ]
228
  )
229
 
230
- # --- THIS IS THE FINAL, NEW LAUNCH COMMAND ---
231
- # This makes your app public but requires a password to access.
232
- # You can change "guest" to any username you want.
 
 
233
  demo.launch(auth=("guest", "Its_zion_18"))
 
85
  if webcam_frame is None:
86
  return "Waiting...", DEFAULT_CAMERA, None, gr.update(camera_position=DEFAULT_CAMERA)
87
 
 
88
  image = webcam_frame
89
  image.flags.writeable = False
90
  results = hands.process(image)
 
91
 
92
  if results.multi_hand_landmarks:
93
  hand_landmarks = results.multi_hand_landmarks[0]
 
117
 
118
  if current_hand_pos:
119
  new_prev_hand_pos = current_hand_pos
 
 
120
 
121
  else:
122
  new_prev_hand_pos = None
123
 
124
+ # Return 4 values
125
  return gesture_text, new_camera_state, new_prev_hand_pos, gr.update(camera_position=new_camera_state)
126
 
127
  # 8. --- HELPER FUNCTIONS ---
 
169
  # --- MAIN COLUMN for 3D viewer ---
170
  with gr.Column(scale=3):
171
  default_model_path = PRELOADED_MODELS.get("Preset 1", None)
 
172
  if not os.path.exists(default_model_path):
173
  print(f"Warning: Default preset '{default_model_path}' not found.")
174
  default_model_path = None
 
188
  """
189
  )
190
 
 
 
191
  # --- 10. WIRE UP THE NEW CONTROLS ---
192
 
193
  # 1. Wire up the Radio buttons
 
220
  ]
221
  )
222
 
223
+ # ---
224
+ # THIS IS THE LAUNCH COMMAND FOR HUGGING FACE
225
+ # ---
226
+ # You must provide your own password.
227
+ # "guest" is the username.
228
  demo.launch(auth=("guest", "Its_zion_18"))