nickmuchi commited on
Commit
48ddd6a
1 Parent(s): c2a5f21

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +44 -42
app.py CHANGED
@@ -125,53 +125,55 @@ h1#title {
125
  demo = gr.Blocks(css=css)
126
 
127
  with demo:
128
- gr.Markdown(title)
129
- gr.Markdown(description)
130
- gr.Markdown(twitter_link)
131
- options = gr.Dropdown(choices=models,label='Object Detection Model',show_label=True)
132
- slider_input = gr.Slider(minimum=0.2,maximum=1,value=0.5,step=0.1,label='Prediction Threshold')
133
 
134
- with gr.Tabs():
135
- with gr.TabItem('Image URL'):
136
- with gr.Row():
137
- with gr.Column():
138
- url_input = gr.Textbox(lines=2,label='Enter valid image URL here..')
139
- original_image = gr.Image(shape=(750,750))
140
- with gr.Column():
141
- img_output_from_url = gr.Image(shape=(750,750))
 
 
 
 
 
 
 
 
 
142
 
143
- with gr.Row():
144
- example_url = gr.Dataset(components=[url_input],samples=[[str(url)] for url in urls])
145
-
146
- url_but = gr.Button('Detect')
147
-
148
- with gr.TabItem('Image Upload'):
149
- with gr.Row():
150
- img_input = gr.Image(type='pil',shape=(750,750))
151
- img_output_from_upload= gr.Image(shape=(750,750))
 
 
 
 
152
 
153
- with gr.Row():
154
- example_images = gr.Dataset(components=[img_input],
155
- samples=[[path.as_posix()] for path in sorted(pathlib.Path('images').rglob('*.j*g'))])
156
-
 
 
157
 
158
- img_but = gr.Button('Detect')
159
-
160
- with gr.TabItem('WebCam'):
161
- with gr.Row():
162
- web_input = gr.Image(source='webcam',type='pil',shape=(750,750),streaming=True)
163
- img_output_from_webcam= gr.Image(shape=(750,750))
164
-
165
- cam_but = gr.Button('Detect')
166
-
167
- url_but.click(detect_objects,inputs=[options,url_input,img_input,web_input,slider_input],outputs=[img_output_from_url],queue=True)
168
- img_but.click(detect_objects,inputs=[options,url_input,img_input,web_input,slider_input],outputs=[img_output_from_upload],queue=True)
169
- cam_but.click(detect_objects,inputs=[options,url_input,img_input,web_input,slider_input],outputs=[img_output_from_webcam],queue=True)
170
- example_images.click(fn=set_example_image,inputs=[example_images],outputs=[img_input])
171
- example_url.click(fn=set_example_url,inputs=[example_url],outputs=[url_input,original_image])
172
 
173
-
174
- gr.Markdown("![visitor badge](https://visitor-badge.glitch.me/badge?page_id=nickmuchi-face-mask-detections-with-yolos)")
175
 
176
 
177
  demo.launch(debug=True,enable_queue=True)
125
  demo = gr.Blocks(css=css)
126
 
127
  with demo:
128
+ with gr.Box():
 
 
 
 
129
 
130
+ gr.Markdown(title)
131
+ gr.Markdown(description)
132
+ gr.Markdown(twitter_link)
133
+ options = gr.Dropdown(choices=models,label='Object Detection Model',show_label=True)
134
+ slider_input = gr.Slider(minimum=0.2,maximum=1,value=0.5,step=0.1,label='Prediction Threshold')
135
+
136
+ with gr.Tabs():
137
+ with gr.TabItem('Image URL'):
138
+ with gr.Row():
139
+ with gr.Column():
140
+ url_input = gr.Textbox(lines=2,label='Enter valid image URL here..')
141
+ original_image = gr.Image(shape=(750,750))
142
+ with gr.Column():
143
+ img_output_from_url = gr.Image(shape=(750,750))
144
+
145
+ with gr.Row():
146
+ example_url = gr.Dataset(components=[url_input],samples=[[str(url)] for url in urls])
147
 
148
+ url_but = gr.Button('Detect')
149
+
150
+ with gr.TabItem('Image Upload'):
151
+ with gr.Row():
152
+ img_input = gr.Image(type='pil',shape=(750,750))
153
+ img_output_from_upload= gr.Image(shape=(750,750))
154
+
155
+ with gr.Row():
156
+ example_images = gr.Dataset(components=[img_input],
157
+ samples=[[path.as_posix()] for path in sorted(pathlib.Path('images').rglob('*.j*g'))])
158
+
159
+
160
+ img_but = gr.Button('Detect')
161
 
162
+ with gr.TabItem('WebCam'):
163
+ with gr.Row():
164
+ web_input = gr.Image(source='webcam',type='pil',shape=(750,750),streaming=True)
165
+ img_output_from_webcam= gr.Image(shape=(750,750))
166
+
167
+ cam_but = gr.Button('Detect')
168
 
169
+ url_but.click(detect_objects,inputs=[options,url_input,img_input,web_input,slider_input],outputs=[img_output_from_url],queue=True)
170
+ img_but.click(detect_objects,inputs=[options,url_input,img_input,web_input,slider_input],outputs=[img_output_from_upload],queue=True)
171
+ cam_but.click(detect_objects,inputs=[options,url_input,img_input,web_input,slider_input],outputs=[img_output_from_webcam],queue=True)
172
+ example_images.click(fn=set_example_image,inputs=[example_images],outputs=[img_input])
173
+ example_url.click(fn=set_example_url,inputs=[example_url],outputs=[url_input,original_image])
174
+
 
 
 
 
 
 
 
 
175
 
176
+ gr.Markdown("![visitor badge](https://visitor-badge.glitch.me/badge?page_id=nickmuchi-face-mask-detections-with-yolos)")
 
177
 
178
 
179
  demo.launch(debug=True,enable_queue=True)