Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -328,7 +328,14 @@ with gr.Blocks(analytics_enabled=False) as demo:
|
|
328 |
with gr.Tab("Webcam"):
|
329 |
with gr.Row():
|
330 |
with gr.Column():
|
331 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
332 |
with gr.Row():
|
333 |
webcam_instruction = gr.Textbox(
|
334 |
label="Instruction",
|
@@ -343,8 +350,18 @@ with gr.Blocks(analytics_enabled=False) as demo:
|
|
343 |
|
344 |
status_text = gr.Textbox(label="Status", value="Ready")
|
345 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
346 |
start_button.click(
|
347 |
-
fn=
|
348 |
inputs=[webcam_instruction],
|
349 |
outputs=[webcam_output]
|
350 |
)
|
@@ -354,4 +371,11 @@ with gr.Blocks(analytics_enabled=False) as demo:
|
|
354 |
outputs=[status_text]
|
355 |
)
|
356 |
|
357 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
328 |
with gr.Tab("Webcam"):
|
329 |
with gr.Row():
|
330 |
with gr.Column():
|
331 |
+
# μΉμΊ μ
λ ₯μ μν μ»΄ν¬λνΈ
|
332 |
+
webcam_input = gr.Image(
|
333 |
+
label="Webcam Input",
|
334 |
+
type="numpy",
|
335 |
+
sources="webcam",
|
336 |
+
streaming=True,
|
337 |
+
mirror_webcam=True
|
338 |
+
)
|
339 |
with gr.Row():
|
340 |
webcam_instruction = gr.Textbox(
|
341 |
label="Instruction",
|
|
|
350 |
|
351 |
status_text = gr.Textbox(label="Status", value="Ready")
|
352 |
|
353 |
+
def start_webcam_processing(instruction):
|
354 |
+
try:
|
355 |
+
if hasattr(webcam_vision, 'processor'):
|
356 |
+
webcam_vision.processor.stop()
|
357 |
+
webcam_vision.processor = WebcamProcessor(model, tokenizer)
|
358 |
+
status = webcam_vision.processor.start()
|
359 |
+
return webcam_vision(instruction)
|
360 |
+
except Exception as e:
|
361 |
+
return f"Error starting webcam: {str(e)}"
|
362 |
+
|
363 |
start_button.click(
|
364 |
+
fn=start_webcam_processing,
|
365 |
inputs=[webcam_instruction],
|
366 |
outputs=[webcam_output]
|
367 |
)
|
|
|
371 |
outputs=[status_text]
|
372 |
)
|
373 |
|
374 |
+
# μΉμΊ μ‘μΈμ€λ₯Ό μν μ€μ μΆκ°
|
375 |
+
demo.queue().launch(
|
376 |
+
server_name="0.0.0.0", # λͺ¨λ IPμμ μ κ·Ό κ°λ₯
|
377 |
+
server_port=7860, # ν¬νΈ μ§μ
|
378 |
+
share=True, # κ³΅κ° λ§ν¬ μμ±
|
379 |
+
show_api=False,
|
380 |
+
show_error=True
|
381 |
+
)
|