Raspberry Pi and Sony recently released a new AI camera, providing various models in their repository.
If we explore their model zoo, we can see many options—except for the popular YOLO model.
Does the SONY IMX500 support it?
The answer is yes—it does. Let's find it.
As usual, this article is available in a YouTube video:
Investigation. Where is imx500_network_yolov8n_pp.rpk ?The official documentation says that YoloV8 exists for a Raspberry PI:
Let's start by Googling 'Sony IMX500 YOLOv8.'
We find some GitHub links, and they lead to 404 pages.
This suggests it was once available, but now it has been removed.
So, what can we do?
I didn’t expect it to be so easy. We can simply check the commit history.
GitHub commit historyIt appears the model was removed from the official repository due to licensing issues with Ultralytics.
Here is the proof:
https://github.com/raspberrypi/imx500-models/commits/main/
I don’t work for Sony or Ultralytics, so I’m unsure what happened or if it will return.
What I do know is that we can still download the model from the repository 😁
How to download the YoloV8 for Sony IMX500First, I need to clone the model zoo to the laptop:
git clone https://github.com/raspberrypi/imx500-models.git
Then, copy the commit hash from a commit just before the deletion.
Then, I will use the command git checkout <hash> to revert the repository to that state.
git checkout ec3b84cd7561c743de2f3073cd4c71348e6b0e3f
Finally, I have the original+official YOLOv8 model from Ultralytics on my disk.
Let’s test it!
Sony IMX500 YoloV8 Object detection testThe standard example from the official repository using a imx500_network_yolov8n_pp.rpk model.
if __name__ == "__main__":
model = "./imx500-models-backup/imx500_network_yolov8n_pp.rpk"
# This must be called before instantiation of Picamera2
imx500 = IMX500(model)
intrinsics = imx500.network_intrinsics
picam2 = Picamera2(imx500.camera_num)
config = picam2.create_preview_configuration(
controls = {},
buffer_count=12
)
imx500.show_network_fw_progress_bar()
picam2.start(config, show_preview=False)
if intrinsics.preserve_aspect_ratio:
imx500.set_auto_aspect_ratio()
last_results = None
picam2.pre_callback = draw_detections
print("Started!")
labels = get_labels()
while True:
last_results = parse_detections(picam2.capture_metadata())
# Record file to SD card
data_folder = f"./data/images/{DateUtils.get_date()}/"
try:
picam2.capture_file(f"{data_folder}/{DateUtils.get_time()}.jpg")
except:
FileUtils.create_folders(data_folder)
if (len(last_results) > 0):
for result in last_results:
label = f"{labels[int(result.category)]} ({result.conf:.2f})"
print(f"Detected {label}")
ResultsIt works perfectly fine, so we can use it if we need YoloV8.
You can also find how to export the Yolo model into Sony IMX500 format using the same "commit history" approach:
https://github.com/Nerdy-Things/raspberry-pi-ai-camera-yolov8/tree/master/tutorials
or original:
https://github.com/sony/model_optimization/commit/ff0b795bd65beed70311e303efe829be865a0e16
Thats it.
Thank you for reading!
Comments
Please log in or sign up to comment.