Skip to content

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

bgr to rgb

roryclear6ff4b39304be
diff --git a/detection/rfdetr.py b/detection/rfdetr.py
index 0716bcd..b4bbebc 100644
--- a/detection/rfdetr.py
+++ b/detection/rfdetr.py
@@ -640,6 +640,7 @@ class RFDETR():
def preprocess(self, img):
img = img.cast(dtypes.float32)
+ img = img[:, :, ::-1] # BGR to RGB
img /= 255.0
means = Tensor([[[0.485, 0.456, 0.406]]])
stds = Tensor([[[0.229, 0.224, 0.225]]])
diff --git a/detection/yolov9.py b/detection/yolov9.py
index fbad543..287db9d 100644
--- a/detection/yolov9.py
+++ b/detection/yolov9.py
@@ -375,7 +375,7 @@ class YOLOv9():
def __call__(self, frame):
pre = self.preprocess(frame)
x = pre.unsqueeze(0)
- x = x.permute(0, 3, 1, 2)
+ x = x[..., ::-1].permute(0, 3, 1, 2) #BGR to RGB!
x = x / 255.0
y = [] # outputs
for i in range(len(self.model)):
diff --git a/test/run_mot.py b/test/run_mot.py
index ee3e340..cc049c9 100644
--- a/test/run_mot.py
+++ b/test/run_mot.py
@@ -22,7 +22,7 @@ if __name__ == "__main__":
out = cv2.VideoWriter(f"test_outputs/out_{size}.mp4", cv2.VideoWriter_fourcc(*"mp4v"), 30, (w, h))
model = YOLOv9(size, res=960) if m == "y" else RFDETR("nano")
- expected = 153 if m == "y" else 174
+ expected = 156 if m == "y" else 157
i = 0
ppl = set()