pagling commited on
Commit
c776ec4
·
verified ·
1 Parent(s): 6231e94

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -1
app.py CHANGED
@@ -76,6 +76,8 @@ with gr.Blocks() as demo:
76
  img_output = gr.Image(label="检测结果")
77
  img_conf = gr.Slider(0, 1, value=0.5, label="置信度阈值")
78
  img_button = gr.Button("执行检测")
 
 
79
 
80
  with gr.TabItem("视频检测"):
81
  with gr.Row():
@@ -83,12 +85,19 @@ with gr.Blocks() as demo:
83
  video_output = gr.Video(label="检测结果")
84
  video_conf = gr.Slider(0, 1, value=0.5, label="置信度阈值")
85
  video_button = gr.Button("执行检测")
 
 
86
 
87
  with gr.TabItem("实时摄像头"):
88
- webcam_input = gr.Webcam(label="摄像头画面") # 使用官方 Webcam 组件
89
  webcam_output = gr.Image(label="检测结果")
90
  webcam_conf = gr.Slider(0, 1, value=0.5, label="置信度阈值")
91
  webcam_button = gr.Button("开始检测")
 
 
 
 
 
92
 
93
  webcam_button.click(fn=detect_webcam, inputs=[webcam_input, webcam_conf], outputs=webcam_output)
94
 
 
76
  img_output = gr.Image(label="检测结果")
77
  img_conf = gr.Slider(0, 1, value=0.5, label="置信度阈值")
78
  img_button = gr.Button("执行检测")
79
+ # 正确缩进位置 ↓
80
+ img_button.click(fn=detect_image, inputs=[img_input, img_conf], outputs=img_output)
81
 
82
  with gr.TabItem("视频检测"):
83
  with gr.Row():
 
85
  video_output = gr.Video(label="检测结果")
86
  video_conf = gr.Slider(0, 1, value=0.5, label="置信度阈值")
87
  video_button = gr.Button("执行检测")
88
+ # 正确缩进位置 ↓
89
+ video_button.click(fn=detect_video, inputs=[video_input, video_conf], outputs=video_output)
90
 
91
  with gr.TabItem("实时摄像头"):
92
+ webcam_input = gr.Webcam(label="摄像头画面")
93
  webcam_output = gr.Image(label="检测结果")
94
  webcam_conf = gr.Slider(0, 1, value=0.5, label="置信度阈值")
95
  webcam_button = gr.Button("开始检测")
96
+ # 正确缩进位置 ↓
97
+ webcam_button.click(fn=detect_webcam, inputs=[webcam_input, webcam_conf], outputs=webcam_output)
98
+
99
+ if __name__ == "__main__":
100
+ demo.launch()
101
 
102
  webcam_button.click(fn=detect_webcam, inputs=[webcam_input, webcam_conf], outputs=webcam_output)
103