rachana219 commited on
Commit
8ba3152
·
1 Parent(s): 4ebfc28

added seperate tab for tracking

Browse files
Files changed (1) hide show
  1. app.py +21 -9
app.py CHANGED
@@ -175,9 +175,9 @@ def inference2(video,model_link,iou_threshold,confidence_threshold):
175
  return 'output.mp4',np.mean(fps_video)
176
 
177
 
178
- def MODT(sourceVideo, model_link, trackingmethod):
179
- model_path = 'weights/'+str(model_link)+'.pt'
180
- print("Inside function MODT. Model : {model_link}, model path : {model_path}")
181
  return MOT(model_path, trackingmethod, sourceVideo), 30
182
 
183
 
@@ -192,7 +192,7 @@ trackers = ['strongsort', 'bytetrack', 'ocsort']
192
 
193
  with gr.Blocks() as demo:
194
  gr.Markdown("## IDD Inference on Yolo V7 and V8 ")
195
- with gr.Tab("Image"):
196
  gr.Markdown("## Yolo V7 and V8 Inference on Image")
197
  with gr.Row():
198
  image_input = gr.Image(type='pil', label="Input Image", source="upload")
@@ -203,19 +203,30 @@ with gr.Blocks() as demo:
203
  image_conf_threshold = gr.Slider(label="Confidence Threshold",interactive=True, minimum=0.0, maximum=1.0, value=0.25)
204
  gr.Examples(examples=examples_images,inputs=image_input,outputs=image_output)
205
  text_button = gr.Button("Detect")
206
- with gr.Tab("Video"):
207
  gr.Markdown("## Yolo V7 and V8 Inference on Video")
208
  with gr.Row():
209
  video_input = gr.Video(type='pil', label="Input Video", source="upload")
210
  video_output = gr.Video(type="pil", label="Output Video",format="mp4")
211
  fps_video = gr.Number(0,label='FPS')
212
- video_drop = gr.Dropdown(choices=models,value=models[0],label = "Select the model")
213
- tracking_drop = gr.Dropdown(choices=trackers,value=trackers[0], label="Select the tracking method")
214
  video_iou_threshold = gr.Slider(label="IOU Threshold",interactive=True, minimum=0.0, maximum=1.0, value=0.45)
215
  video_conf_threshold = gr.Slider(label="Confidence Threshold",interactive=True, minimum=0.0, maximum=1.0, value=0.25)
216
  gr.Examples(examples=examples_videos,inputs=video_input,outputs=video_output)
217
- video_button_detect = gr.Button("Detect")
 
 
 
 
 
 
 
 
 
 
 
218
  video_button_track = gr.Button("Track")
 
219
  # with gr.Tab("Webcam Video"):
220
  # gr.Markdown("## YOLOv7 Inference on Webcam Video")
221
  # gr.Markdown("Coming Soon")
@@ -226,7 +237,8 @@ with gr.Blocks() as demo:
226
  video_button_detect.click(inference2, inputs=[video_input,video_drop,
227
  video_iou_threshold,video_conf_threshold],
228
  outputs=[video_output,fps_video])
229
- video_button_track.click(MODT,inputs=[video_input,video_drop, tracking_drop],
230
  outputs=[video_output, fps_video])
 
231
 
232
  demo.launch(debug=True,enable_queue=True)
 
175
  return 'output.mp4',np.mean(fps_video)
176
 
177
 
178
+ def MODT(sourceVideo, trackingmethod):
179
+ #model_path = 'weights/'+str(model_link)+'.pt'
180
+ model_path = 'weights/yolov8m.pt'
181
  return MOT(model_path, trackingmethod, sourceVideo), 30
182
 
183
 
 
192
 
193
  with gr.Blocks() as demo:
194
  gr.Markdown("## IDD Inference on Yolo V7 and V8 ")
195
+ with gr.Tab("Image Detection"):
196
  gr.Markdown("## Yolo V7 and V8 Inference on Image")
197
  with gr.Row():
198
  image_input = gr.Image(type='pil', label="Input Image", source="upload")
 
203
  image_conf_threshold = gr.Slider(label="Confidence Threshold",interactive=True, minimum=0.0, maximum=1.0, value=0.25)
204
  gr.Examples(examples=examples_images,inputs=image_input,outputs=image_output)
205
  text_button = gr.Button("Detect")
206
+ with gr.Tab("Video Detection"):
207
  gr.Markdown("## Yolo V7 and V8 Inference on Video")
208
  with gr.Row():
209
  video_input = gr.Video(type='pil', label="Input Video", source="upload")
210
  video_output = gr.Video(type="pil", label="Output Video",format="mp4")
211
  fps_video = gr.Number(0,label='FPS')
212
+ video_drop = gr.Dropdown(choices=models,value=models[0],label = "Select the model")
 
213
  video_iou_threshold = gr.Slider(label="IOU Threshold",interactive=True, minimum=0.0, maximum=1.0, value=0.45)
214
  video_conf_threshold = gr.Slider(label="Confidence Threshold",interactive=True, minimum=0.0, maximum=1.0, value=0.25)
215
  gr.Examples(examples=examples_videos,inputs=video_input,outputs=video_output)
216
+ video_button_detect = gr.Button("Detect")
217
+ with gr.Tab("Video Tacking"):
218
+ gr.Markdown("## MOT using YoloV8 detection with tracking")
219
+ with gr.Row():
220
+ videotr_input = gr.Video(type='pil', label="Input Video", source="upload")
221
+ videotr_output = gr.Video(type="pil", label="Output Video",format="mp4")
222
+ fpstr_video = gr.Number(0,label='FPS')
223
+ videotr_input = gr.Dropdown(choices=models,value=models[0],label = "Select the model")
224
+ tracking_drop = gr.Dropdown(choices=trackers,value=trackers[0], label="Select the tracking method")
225
+ videotr_iou_threshold = gr.Slider(label="IOU Threshold",interactive=True, minimum=0.0, maximum=1.0, value=0.45)
226
+ videotr_conf_threshold = gr.Slider(label="Confidence Threshold",interactive=True, minimum=0.0, maximum=1.0, value=0.25)
227
+ gr.Examples(examples=examples_videos,inputs=video_input,outputs=video_output)
228
  video_button_track = gr.Button("Track")
229
+
230
  # with gr.Tab("Webcam Video"):
231
  # gr.Markdown("## YOLOv7 Inference on Webcam Video")
232
  # gr.Markdown("Coming Soon")
 
237
  video_button_detect.click(inference2, inputs=[video_input,video_drop,
238
  video_iou_threshold,video_conf_threshold],
239
  outputs=[video_output,fps_video])
240
+ video_button_track.click(MODT,inputs=[videotr_input, tracking_drop],
241
  outputs=[video_output, fps_video])
242
+
243
 
244
  demo.launch(debug=True,enable_queue=True)