Skip to content

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

remove more np from yolo

roryclear844f18eec6b8
diff --git a/yolov8.py b/yolov8.py
index 7f9326e..92c238e 100644
--- a/yolov8.py
+++ b/yolov8.py
@@ -369,20 +369,8 @@ class YOLORequestHandler(BaseHTTPRequestHandler):
content_length = int(self.headers.get('Content-Length', 0))
img = self.rfile.read(content_length) # Read and ignore input data
- np_array = np.frombuffer(img, dtype=np.int8)
- np_array = np_array.reshape(640,640,3)
- pre_processed_image = preprocess([np_array])
-
- im = np_array
- im = Tensor(np_array)
- im = im.unsqueeze(0)
- #print("after",im)
- im = im[..., ::-1].permute(0, 3, 1, 2) # BGR to RGB, BHWC to BCHW, (n, 3, h, w)
- im = im / 255.0 # 0 - 255 to 0.0 - 1.0
- pre_processed_image = im
-
-
- pred = do_inf(pre_processed_image).numpy()
+ im = Tensor(img,dtype=dtypes.int8)
+ pred = do_inf(im).numpy()
response_data = struct.pack('<1800f', *pred)
self.send_response(200)
@@ -393,6 +381,9 @@ class YOLORequestHandler(BaseHTTPRequestHandler):
@TinyJit
def do_inf(image):
+ image = image.reshape(1,640,640,3)
+ image = image[..., ::-1].permute(0, 3, 1, 2)
+ image = image / 255.0
predictions = yolo_infer(image)
return predictions.flatten()