Skip to content

Add object detection, tracking, mobile notifications, and search to any security camera.

share resize

roryclear1dc9ec71181b
diff --git a/blazeface.py b/blazeface.py
index ad829ad..b1a38f7 100644
--- a/blazeface.py
+++ b/blazeface.py
@@ -1,5 +1,6 @@
from tinygrad import Tensor, nn
from tinygrad.nn.state import safe_save, safe_load, get_state_dict, load_state_dict
+from utils.helpers import resize
class BlazeBlock():
def __init__(self, c=None, channel_pad=0):
@@ -252,10 +253,4 @@ def compute_iou_matrix(boxes):
h = Tensor.maximum(Tensor(0), y2 - y1)
intersection = w * h
union = areas[:, :, None] + areas[:, None, :] - intersection
- return intersection / union
-
-def resize(img, new_size):
- img = img.permute(2,0,1)
- img = Tensor.interpolate(img, size=(new_size[1], new_size[0]), mode='linear', align_corners=False)
- img = img.permute(1, 2, 0)
- return img
\ No newline at end of file
+ return intersection / union
\ No newline at end of file
diff --git a/utils/helpers.py b/utils/helpers.py
index 0419990..c0aed40 100644
--- a/utils/helpers.py
+++ b/utils/helpers.py
@@ -118,6 +118,7 @@ def draw_bounding_boxes(orig_img_path, predictions, class_labels):
return orig_img
def resize(img, new_size):
+ print("rory shape =",img.shape, "->", new_size)
img = img.permute(2,0,1)
img = Tensor.interpolate(img, size=(new_size[1], new_size[0]), mode='linear', align_corners=False)
img = img.permute(1, 2, 0)