@@ -85,10 +85,12 @@ When a camera sits still, most of the scene stays the same. If a handful of pixe
85
85
</ol >
86
86
87
87
<div class =" col-sm mt-3 mt-md-0 text-center " >
88
- <img src="/assets/blogs/insect_detection/motion_detection/motion_detection_mask.png"
88
+ <div style =" background : white ; padding : 10px ; display : inline-block ; border-radius : 8px ;" >
89
+ <img src="/assets/blogs/insect_detection/motion_detection/motion_detection_mask.png"
89
90
class="img-fluid rounded"
90
91
style="margin-bottom: 20px;"
91
92
alt="Motion Detection Mask">
93
+ </div >
92
94
</div >
93
95
<div class =" caption mt-2 text-center " >
94
96
Fig. 3: Difference mask obtained by subtracting the current frame from the background and then thresholding.
@@ -107,65 +109,67 @@ Motion detection is all around us. Here are a few real-world examples:
107
109
108
110
## Insect detection with YOLO
109
111
110
- Motion detection points out _ where_ to look, and ** YOLO** tells us _ what_ is moving. YOLO is an object detection model that draws boxes around objects and labels them. We use YOLO for insects because:
112
+ Motion detection points out _ where_ to look, and ** YOLO** tells us _ what_ is moving. YOLO< d-cite key = " redmon2016you " ></ d-cite > is an object detection model that draws boxes around objects and labels them. We use YOLO for insects because:
111
113
112
114
* ** Real-time:** Runs at video speed, even on small devices.
113
115
* ** All-in-one:** Finds both location and the insect’s identity in a single pass.
114
116
* ** Open-source:** Free models (YOLOv8) and easy training tools are available.
115
117
118
+ We now describe the original version of YOLO. Although many improvements have been made across subsequent versions, the core ideas outlined below remain the same.
119
+
116
120
### The quick YOLO tour
117
121
118
122
<ol >
119
123
<li >
120
124
<strong>Candidate frames</strong><br>
121
125
<em>After motion detection, we extract snapshots that might contain insects.</em>
122
- <figure class="text-center">
126
+ <div class="text-center">
123
127
<img src="/assets/blogs/insect_detection/yolo_steps/input_image.jpg"
124
- alt="Input Image"
125
- class="img-fluid rounded">
126
- <figcaption class="mt-2" style="font-size: 0.9rem; color: #555; ">
127
- Fig. 4: Input image for insect detection, obtained from motion detection.
128
- </figcaption >
129
- </figure >
128
+ alt="Input Image"
129
+ class="img-fluid rounded">
130
+ <div class="caption mt-2 text-center ">
131
+ Fig. 4: Input image for insect detection, obtained from motion detection.
132
+ </div >
133
+ </div >
130
134
</li >
131
135
132
136
<li >
133
137
<strong>Resize & grid</strong><br>
134
138
<em>Resize each snapshot to 448×448 pixels and overlay a 7×7 grid.</em>
135
- <figure class="text-center">
139
+ <div class="text-center">
136
140
<img src="/assets/blogs/insect_detection/yolo_steps/cropped_grid_image.png"
137
- alt="Cropped and 7x7 grid overlayed image"
138
- class="img-fluid rounded">
139
- <figcaption class="mt-2" style="font-size: 0.9rem; color: #555; ">
140
- Fig. 5: A 7×7 grid overlaid on the cropped image.
141
- </figcaption >
142
- </figure >
141
+ alt="Cropped and 7x7 grid overlayed image"
142
+ class="img-fluid rounded">
143
+ <div class="caption mt-2 text-center ">
144
+ Fig. 5: A 7×7 grid overlaid on the cropped image.
145
+ </div >
146
+ </div >
143
147
</li >
144
148
145
149
<li >
146
150
<strong>One glance, many predictions</strong><br>
147
151
<em>For each grid cell, YOLO’s neural network predicts several bounding boxes, confidence scores, and class probabilities for different insects.</em>
148
- <figure class="text-center">
152
+ <div class="text-center">
149
153
<img src="/assets/blogs/insect_detection/yolo_steps/grid_cell_prediction.png"
150
- alt="YOLO grid cell predictions"
151
- class="img-fluid rounded">
152
- <figcaption class="mt-2" style="font-size: 0.9rem; color: #555; ">
153
- Fig. 6: The green box has a high confidence score and class probability; the red boxes are low confidence.
154
- </figcaption >
155
- </figure >
154
+ alt="YOLO grid cell predictions"
155
+ class="img-fluid rounded">
156
+ <div class="caption mt-2 text-center ">
157
+ Fig. 6: The green box has a high confidence score and class probability; the red boxes are low confidence.
158
+ </div >
159
+ </div >
156
160
</li >
157
161
158
162
<li >
159
163
<strong>Keep the best</strong><br>
160
164
<em>Non-Maximum Suppression (NMS)<d-cite key="hosang2017learning"></d-cite> keeps the highest-scoring box and removes overlapping, lower-scoring ones.</em>
161
- <figure class="text-center">
165
+ <div class="text-center">
162
166
<img src="/assets/blogs/insect_detection/yolo_steps/non_maximum_suppression.png"
163
167
alt="Non Maximum Suppression process"
164
168
class="img-fluid rounded">
165
- <figcaption class="mt-2" style="font-size: 0.9rem; color: #555; ">
166
- Fig. 7: NMS removes duplicate boxes, leaving one clear box per object.
167
- </figcaption >
168
- </figure >
169
+ <div class="caption mt-2 text-center ">
170
+ Fig. 7: NMS removes duplicate boxes, leaving one clear box per object.
171
+ </div >
172
+ </div >
169
173
<p class="mt-2">
170
174
After predicting many boxes, NMS:
171
175
</p>
@@ -189,14 +193,16 @@ Motion detection points out _where_ to look, and **YOLO** tells us _what_ is mov
189
193
<ol >
190
194
<li >
191
195
<strong>How are the bounding boxes represented?</strong>
192
- <figure class="text-center">
193
- <img src="/assets/blogs/insect_detection/yolo_steps/bounding_box_representation.png"
194
- alt="Bounding box representation"
195
- class="img-fluid rounded">
196
- <figcaption class="mt-2" style="font-size: 0.9rem; color: #555;">
196
+ <div class="text-center">
197
+ <div style="background: white; padding: 10px; display: inline-block; border-radius: 8px;">
198
+ <img src="/assets/blogs/insect_detection/yolo_steps/bounding_box_representation.png"
199
+ alt="Bounding box representation"
200
+ class="img-fluid rounded">
201
+ </div>
202
+ <div class="caption mt-2 text-center">
197
203
Fig. 8: Bounding box representation.
198
- </figcaption >
199
- </figure >
204
+ </div >
205
+ </div >
200
206
<ul style="margin-top: 0.5rem; margin-bottom: 0;">
201
207
<li>Each box is defined by (cx, cy, w, h).</li>
202
208
<li>(cx, cy) is the box center, normalized within its grid cell.</li>
@@ -206,14 +212,14 @@ Motion detection points out _where_ to look, and **YOLO** tells us _what_ is mov
206
212
207
213
<li >
208
214
<strong>What if the insect overlaps two grid cells?</strong>
209
- <figure class="text-center">
215
+ <div class="text-center">
210
216
<img src="/assets/blogs/insect_detection/yolo_steps/overlapping_grid_cells.png"
211
217
alt="Overlapping grid cells"
212
218
class="img-fluid rounded">
213
- <figcaption class="mt-2" style="font-size: 0.9rem; color: #555; ">
214
- Fig. 9: Handling overlapping grid cells.
215
- </figcaption >
216
- </figure >
219
+ <div class="caption mt-2 text-center ">
220
+ Fig. 9: Handling overlapping grid cells.
221
+ </div >
222
+ </div >
217
223
<ul style="margin-top: 10px;">
218
224
<li>Only the cell (marked as 1) containing the insect’s center (marked by a star) makes the prediction.</li>
219
225
<li>Neighboring cells ignore this insect and focus on objects whose centers lie inside them.</li>
0 commit comments