Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/skalskip/sketchy-vision

Each week I create sketches covering key Computer Vision concepts. If you want to learn more about CV stick around!
https://github.com/skalskip/sketchy-vision

computer-vision convolutional-neural-networks deep-learning neural-network non-maximum-suppression numpy object-detection

Last synced: 2 months ago
JSON representation

Each week I create sketches covering key Computer Vision concepts. If you want to learn more about CV stick around!

Awesome Lists containing this project

README

        

sketchy vision


























## 👋 hello

Each week I create sketches covering key Computer Vision concepts. If you want to learn more about CV stick around!


![title](https://i.imgur.com/gbhmVy9.png)

👆 click to read code snippet

```python
def box_iou_batch(boxes_a: np.ndarray, boxes_b: np.ndarray) -> np.ndarray:

def box_area(box):
return (box[2] - box[0]) * (box[3] - box[1])

area_a = box_area(boxes_a.T)
area_b = box_area(boxes_b.T)

top_left = np.maximum(boxes_a[:, None, :2], boxes_b[:, :2])
bottom_right = np.minimum(boxes_a[:, None, 2:], boxes_b[:, 2:])

area_inter = np.prod(np.clip(bottom_right - top_left, a_min=0, a_max=None), 2)
return area_inter / (area_a[:, None] + area_b - area_inter)
```

![title](https://i.imgur.com/o4CELyL.jpg)

👆 click to read code snippet

```python
def non_max_suppression(predictions: np.ndarray, iou_threshold: float = 0.5) -> np.ndarray:
rows, columns = predictions.shape

sort_index = np.flip(predictions[:, 4].argsort())
predictions = predictions[sort_index]

boxes = predictions[:, :4]
categories = predictions[:, 5]
ious = box_iou_batch(boxes, boxes)
ious = ious - np.eye(rows)

keep = np.ones(rows, dtype=bool)

for index, (iou, category) in enumerate(zip(ious, categories)):
if not keep[index]:
continue

condition = (iou > iou_threshold) & (categories == category)
keep = keep & ~condition

return keep[sort_index.argsort()]
```

![title](https://i.imgur.com/Ixiv5do.png)