aiqcamp commited on
Commit
e9f440d
Β·
verified Β·
1 Parent(s): 8abec8c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -3
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
- webcam_input = gr.Image(label="Webcam Input", sources=["webcam"], streaming=True)
 
 
 
 
 
 
 
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=lambda x: webcam_vision(x),
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
- demo.queue().launch(show_api=False, show_error=True)
 
 
 
 
 
 
 
 
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
+ )