Bhaskar Saranga commited on
Commit
5e262d5
1 Parent(s): e98e70e

Added weights, images and videos

Browse files
app.py CHANGED
@@ -41,18 +41,34 @@ def letterbox(im, new_shape=(640, 640), color=(114, 114, 114), auto=True, scaleu
41
  im = cv2.copyMakeBorder(im, top, bottom, left, right, cv2.BORDER_CONSTANT, value=color) # add border
42
  return im, r, (dw, dh)
43
 
44
- names = ['person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', 'train', 'truck', 'boat', 'traffic light',
45
- 'fire hydrant', 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow',
46
- 'elephant', 'bear', 'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee',
47
- 'skis', 'snowboard', 'sports ball', 'kite', 'baseball bat', 'baseball glove', 'skateboard', 'surfboard',
48
- 'tennis racket', 'bottle', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl', 'banana', 'apple',
49
- 'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza', 'donut', 'cake', 'chair', 'couch',
50
- 'potted plant', 'bed', 'dining table', 'toilet', 'tv', 'laptop', 'mouse', 'remote', 'keyboard', 'cell phone',
51
- 'microwave', 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', 'vase', 'scissors', 'teddy bear',
52
- 'hair drier', 'toothbrush']
53
-
54
-
55
- colors = [[random.randint(0, 255) for _ in range(3)] for _ in names]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
 
57
 
58
  def detect(img,model,device,iou_threshold=0.45,confidence_threshold=0.25):
@@ -134,12 +150,13 @@ def inference2(video,model_link,iou_threshold,confidence_threshold):
134
 
135
 
136
 
137
- examples_images = ['data/images/horses.jpg',
 
138
  'data/images/bus.jpg',
139
- 'data/images/zidane.jpg']
140
- examples_videos = ['data/video/input_0.mp4','data/video/input_1.mp4']
141
 
142
- models = ['yolov7','yolov7x','yolov7-w6','yolov7-d6','yolov7-e6e']
143
 
144
  with gr.Blocks() as demo:
145
  gr.Markdown("## YOLOv7 Inference")
@@ -157,8 +174,8 @@ with gr.Blocks() as demo:
157
  with gr.Tab("Video"):
158
  gr.Markdown("## YOLOv7 Inference on Video")
159
  with gr.Row():
160
- video_input = gr.Video(type='pil', label="Input Image", source="upload")
161
- video_output = gr.Video(type="pil", label="Output Image",format="mp4")
162
  fps_video = gr.Number(0,label='FPS')
163
  video_drop = gr.Dropdown(choices=models,value=models[0])
164
  video_iou_threshold = gr.Slider(label="IOU Threshold",interactive=True, minimum=0.0, maximum=1.0, value=0.45)
@@ -166,9 +183,9 @@ with gr.Blocks() as demo:
166
  gr.Examples(examples=examples_videos,inputs=video_input,outputs=video_output)
167
  video_button = gr.Button("Detect")
168
 
169
- with gr.Tab("Webcam Video"):
170
- gr.Markdown("## YOLOv7 Inference on Webcam Video")
171
- gr.Markdown("Coming Soon")
172
 
173
  text_button.click(inference, inputs=[image_input,image_drop,
174
  image_iou_threshold,image_conf_threshold],
 
41
  im = cv2.copyMakeBorder(im, top, bottom, left, right, cv2.BORDER_CONSTANT, value=color) # add border
42
  return im, r, (dw, dh)
43
 
44
+ names = ["animal",
45
+ "autorickshaw",
46
+ "bicycle",
47
+ "bus",
48
+ "car",
49
+ "motorcycle",
50
+ "person",
51
+ "rider",
52
+ "traffic light",
53
+ "traffic sign",
54
+ "truck"
55
+ ]
56
+
57
+
58
+ #colors = [[random.randint(0, 255) for _ in range(3)] for _ in names]
59
+ colors = {
60
+ "animal": [246,198, 145],
61
+ "autorickshaw": [255,204, 54],
62
+ "bicycle": [119,11, 32],
63
+ "bus": [ 0,60,100],
64
+ "car": [ 0,0,142],
65
+ "motorcycle": [ 0,0,230],
66
+ "person": [220,20, 60],
67
+ "rider": [255,0, 0],
68
+ "traffic light": [250,170, 30],
69
+ "traffic sign": [220,220, 0],
70
+ "truck": [ 0,0, 70]
71
+ }
72
 
73
 
74
  def detect(img,model,device,iou_threshold=0.45,confidence_threshold=0.25):
 
150
 
151
 
152
 
153
+ examples_images = ['data/images/1.jpg',
154
+ 'data/images/2.jpg',
155
  'data/images/bus.jpg',
156
+ 'data/images/3.jpg']
157
+ examples_videos = ['data/video/1.mp4','data/video/2.mp4']
158
 
159
+ models = ['yolov7','yolov7t']
160
 
161
  with gr.Blocks() as demo:
162
  gr.Markdown("## YOLOv7 Inference")
 
174
  with gr.Tab("Video"):
175
  gr.Markdown("## YOLOv7 Inference on Video")
176
  with gr.Row():
177
+ video_input = gr.Video(type='pil', label="Input Video", source="upload")
178
+ video_output = gr.Video(type="pil", label="Output Video",format="mp4")
179
  fps_video = gr.Number(0,label='FPS')
180
  video_drop = gr.Dropdown(choices=models,value=models[0])
181
  video_iou_threshold = gr.Slider(label="IOU Threshold",interactive=True, minimum=0.0, maximum=1.0, value=0.45)
 
183
  gr.Examples(examples=examples_videos,inputs=video_input,outputs=video_output)
184
  video_button = gr.Button("Detect")
185
 
186
+ # with gr.Tab("Webcam Video"):
187
+ # gr.Markdown("## YOLOv7 Inference on Webcam Video")
188
+ # gr.Markdown("Coming Soon")
189
 
190
  text_button.click(inference, inputs=[image_input,image_drop,
191
  image_iou_threshold,image_conf_threshold],
data/images/1.jpg ADDED
data/images/2.jpg ADDED
data/images/3.jpg ADDED
data/images/horses.jpg DELETED
Binary file (133 kB)
 
data/images/image1.jpg DELETED
Binary file (80.7 kB)
 
data/images/image2.jpg DELETED
Binary file (144 kB)
 
data/images/image3.jpg DELETED
Binary file (118 kB)
 
data/images/zidane.jpg DELETED
Binary file (169 kB)
 
data/video/{input_0.mp4 → 1.mp4} RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:0305b8ba574b0b26c8d21b70dbd80aacbba13e813a99f5c4675982063ebd18a3
3
- size 1103987
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:271041b71b046d282746f21bd857b2abc33302fed1f0818a7066880db6eff9a3
3
+ size 14396787
data/video/{input_1.mp4 → 2.mp4} RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:103c54e60a7abf381741b4bcc5e696f5d200fc2a4ff259cc779bbd511dc2dae1
3
- size 1792081
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4d755c21948e68245f43709b1219a1355a73e7644329c6527e7430ad7f53dffe
3
+ size 10771315
weights/yolov7-e6e.pt DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:b370120a414bf32b5d65fc808e5a32c8d9b3c63902d1bc41894fc9d86eccf9cb
3
- size 304425133
 
 
 
 
weights/yolov7-w6.pt DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:2be96abd35939335e5eb08bcde2685ae44c3fadd8af7d601734ba10c8737425c
3
- size 141255765
 
 
 
 
weights/yolov7.pt CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:d1ac3c74eb96a3eec77949c0f37a06bc272756606ff011d9353f7abff4e0c71d
3
- size 75587165
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0f710202260d40caed72d1ca0e4941d13b085a9421dc6af921de934a59be8dc4
3
+ size 298803327
weights/{yolov7-d6.pt → yolov7t.pt} RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:154bb05fceb4f06f062a085a7f3d99d006cf5f1f53237c3a1bdbd66b0ba1a74c
3
- size 268261125
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:79cc87831d4ec0c9a95a1c657da02480af47b0e0b268e98245ba72093b1cbc27
3
+ size 12328037
weights/yolov7x.pt DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:4873202bc3fa8b1d4c4865a37b7c61ce7b7b1cdbe6f31017c33be2bd11826e98
3
- size 143099649