Skip to content

Commit

Permalink
Update yolov5_preview.py
Browse files Browse the repository at this point in the history
Use 320x320 px input size for new YOLOv5n model to increase fps to 40.
  • Loading branch information
maxsitt committed Feb 17, 2023
1 parent 0091a58 commit 0a40d3b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions yolov5_preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
This Python script does the following:
- run a custom YOLOv5 object detection model (.blob format) on-device (Luxonis OAK)
- use 4K frames downscaled to full FOV LQ frames (e.g. 416x416) as model input
- show a preview of 4K frames downscaled to full FOV LQ frames (e.g. 416x416) + model output
- use 4K frames downscaled to full FOV LQ frames (e.g. 320x320) as model input
- show a preview of 4K frames downscaled to full FOV LQ frames (e.g. 320x320) + model output
- optional argument:
"-log" print available Raspberry Pi memory (MB) and RPi CPU utilization (percent) to console
Expand All @@ -34,8 +34,8 @@
import psutil

# Set file paths to the detection model and config JSON
MODEL_PATH = Path("./insect-detect/models/yolov5n_416_openvino_2022.1_5shave.blob")
CONFIG_PATH = Path("./insect-detect/models/json/yolov5_416.json")
MODEL_PATH = Path("./insect-detect/models/yolov5n_320_openvino_2022.1_4shave.blob")
CONFIG_PATH = Path("./insect-detect/models/json/yolov5_320.json")

# Extract detection model metadata from config JSON
with CONFIG_PATH.open(encoding="utf-8") as f:
Expand All @@ -58,10 +58,10 @@
cam_rgb = pipeline.create(dai.node.ColorCamera)
#cam_rgb.setImageOrientation(dai.CameraImageOrientation.ROTATE_180_DEG)
cam_rgb.setResolution(dai.ColorCameraProperties.SensorResolution.THE_4_K)
cam_rgb.setPreviewSize(416, 416) # downscaled LQ frames for model input
cam_rgb.setPreviewSize(320, 320) # downscaled LQ frames for model input
cam_rgb.setInterleaved(False)
cam_rgb.setPreviewKeepAspectRatio(False) # squash full FOV frames to square
cam_rgb.setFps(30) # frames per second available for focus/exposure/model input
cam_rgb.setFps(40) # frames per second available for focus/exposure/model input

# Create detection network node and define input + outputs
nn = pipeline.create(dai.node.YoloDetectionNetwork)
Expand Down

0 comments on commit 0a40d3b

Please sign in to comment.