{"id":21802495,"url":"https://github.com/qengineering/rpi-bullseye-dnn-image","last_synced_at":"2025-10-07T23:30:34.278Z","repository":{"id":174605573,"uuid":"652475715","full_name":"Qengineering/RPi-Bullseye-DNN-image","owner":"Qengineering","description":"Raspberry Pi 4 Bullseye 64-bit OS with deep learning examples","archived":false,"fork":false,"pushed_at":"2023-06-19T09:46:23.000Z","size":16,"stargazers_count":27,"open_issues_count":2,"forks_count":5,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-27T11:36:15.061Z","etag":null,"topics":["cpp","deep-learning","mnn","ncnn","opencv","paddle","paddle-lite","pytorch","raspberry-pi-4","raspberry-pi-64","sd-image","tensorflow","tensorflow-lite","yolov5","yolox"],"latest_commit_sha":null,"homepage":"https://qengineering.eu/deep-learning-examples-on-raspberry-32-64-os.html","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Qengineering.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-12T06:40:23.000Z","updated_at":"2024-10-30T10:57:26.000Z","dependencies_parsed_at":null,"dependency_job_id":"eef0a2ad-ce55-4cf7-8933-b6a4b5344414","html_url":"https://github.com/Qengineering/RPi-Bullseye-DNN-image","commit_stats":null,"previous_names":["qengineering/rpi-bullseye-dnn-image"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Qengineering%2FRPi-Bullseye-DNN-image","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Qengineering%2FRPi-Bullseye-DNN-image/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Qengineering%2FRPi-Bullseye-DNN-image/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Qengineering%2FRPi-Bullseye-DNN-image/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Qengineering","download_url":"https://codeload.github.com/Qengineering/RPi-Bullseye-DNN-image/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235661843,"owners_count":19025607,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp","deep-learning","mnn","ncnn","opencv","paddle","paddle-lite","pytorch","raspberry-pi-4","raspberry-pi-64","sd-image","tensorflow","tensorflow-lite","yolov5","yolox"],"created_at":"2024-11-27T11:29:05.658Z","updated_at":"2025-10-07T23:30:28.991Z","avatar_url":"https://github.com/Qengineering.png","language":null,"funding_links":["https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=CPZTM5BB3FCYL"],"categories":[],"sub_categories":[],"readme":"# Raspberry Pi 4 Bullseye DNN image\n![output image]( https://qengineering.eu/images/Water7.webp )\u003cbr/\u003e\n## A Raspberry Pi 4 Bullseye 64-OS image with deep learning examples\n[![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)\u003cbr/\u003e\u003cbr/\u003e\n## 👉 Bullseye\nThe [**'old' Buster OS**](https://github.com/Qengineering/RPi-image) is still available.\u003cbr\u003e\u003cbr\u003e\nRegularly, we get the question if we have an image of our Raspberry Pi with some frameworks and [our deep-learning examples](https://qengineering.eu/deep-learning-examples-on-raspberry-32-64-os.html). We are happy to comply with this request.\n\n------------\n\n## Installation.\n\n- Get a 32 GB SD-card which will hold the image. \n- Download the image Rpi_Bullseye_64_DNN.xz (**4 GByte !**) from [Sync](https://ln5.sync.com/dl/4083226a0/e7t6w7jp-x4vqthff-8v9fxzuh-9y84f2x4).\n- Flash the image on the SD-card with the [Imager](https://www.raspberrypi.org/software/) or [balenaEtcher](https://www.balena.io/etcher/).\n- Insert the SD-card in your Raspberry Pi 4.\n- Wait a few minutes, while the image will expand to the full size of your SD card.\n- No WiFi installed. Password: ***3.14***\n\n------------\n\n## Tips.\n\n* Default, the Raspberry Pi is been overclocked to 1850 MHz. See [overclock the Raspberry Pi](https://qengineering.eu/overclocking-the-raspberry-pi-4.html) for more information.\u003cbr/\u003e\n* If you are in need of extra space, you can delete the opencv and the opencv_contrib folder from the SD-card. There are no longer needed since all libraries are placed in the /usr/local directory.\n\n------------\n\n## Contents.\n\nClicking on the links below will direct you to our GitHub repo.\u003cbr\u003e\n\n- [OpenCV](https://github.com/Qengineering/OpenCV-Livecam-Raspberry-Pi)\n- [Classification](https://github.com/Qengineering/TensorFlow_Lite_Classification_RPi_64-bits)\n- [SSD](https://github.com/Qengineering/TensorFlow_Lite_SSD_RPi_64-bits)\n- [Segmentation](https://github.com/Qengineering/TensorFlow_Lite_Segmentation_RPi_64-bit)\n- [Segmentation YoloV5](https://github.com/Qengineering/YoloV5-segmentation-ncnn-RPi4)\n- [Pose](https://github.com/Qengineering/TensorFlow_Lite_Pose_RPi_64-bits)\n- [Face detection](https://github.com/Qengineering/Face-detection-Raspberry-Pi-32-64-bits)\n- [Face recognition](https://github.com/Qengineering/Face-Recognition-Raspberry-Pi-64-bits)\n- [YoloV5](https://github.com/Qengineering/YoloV5-ncnn-Raspberry-Pi-4)\n- [YoloX](https://github.com/Qengineering/YoloX-ncnn-Raspberry-Pi-4)\n- [PaddleOCR](https://github.com/Qengineering/PaddleOCR-Lite-Document)\n- [Background substraction](https://github.com/Qengineering/Fast-Background-Substraction)\n- [Libcamera](https://github.com/Qengineering/Libcamera-OpenCV-RPi-Bullseye-64OS)\n- [LVVC](https://github.com/Qengineering/LCCV)\n\n![image](https://github.com/Qengineering/RPi-Bullseye-DNN-image/assets/44409029/3eca9041-9f30-42d5-bed5-f3b0ddfb0726)\n\n------------\n\n## Pre-installed frameworks.\n\nClicking on the links below will direct you to our installation guide.\u003cbr\u003e\n\n- [OpenCV](https://qengineering.eu/deep-learning-with-opencv-on-raspberry-pi-4.html) 4.7.0\n- [TensorFLow](https://qengineering.eu/install-tensorflow-2.4.0-on-raspberry-64-os.html) 2.10.0\n- [TensorFlow-Lite](https://qengineering.eu/install-tensorflow-2-lite-on-raspberry-64-os.html) 2.10.0\n- [TensorFlow-Lite-Python](https://qengineering.eu/install-tensorflow-2-lite-on-raspberry-64-os.html) 2.10.0\n- [Pytorch](https://qengineering.eu/install-pytorch-on-raspberry-pi-4.html) 1.13.0\n- [TorchVision](https://qengineering.eu/install-pytorch-on-raspberry-pi-4.html) 0.14.0\n- [ncnn](https://qengineering.eu/install-ncnn-on-raspberry-pi-4.html) 20230517\n- [MNN](https://qengineering.eu/install-mnn-on-raspberry-pi-4.html) 2.5.0\n- [Paddle](https://qengineering.eu/install-paddlepaddle-on-raspberry-pi-4.html) 2.4.2\n- [Paddle-Lite](https://qengineering.eu/install-paddle-lite-on-raspberry-pi-4.html) 2.12\n\n![image](https://github.com/Qengineering/RPi-Bullseye-DNN-image/assets/44409029/d4cff548-a053-435c-8926-0f678292c337)\n\n------------\n\n## Camera.\n\nYou can connect a camera to the given C++ examples. With Buster, it was simple. You replaced the filename with a zero (0) and got the images from the RaspiCam instead of a file. Those days are gone with the introduction of Bullseye.\u003cbr\u003e\nNowadays you have two options. You can either use Gstreamer or LVVC. An example of both can be found in this SD image.\nYou can also find both methods implemented in the YoloX example.\n\n![image](https://github.com/Qengineering/RPi-Bullseye-DNN-image/assets/44409029/e203e5a1-ea5e-41f7-9e10-2f64f4f511ed)\n\n------------\n\n## WiFi.\n\nSince everyone has a unique password on their WiFi connection, we have not activated the WiFi.\u003cbr/\u003e\nTo enable the wireless LAN follow the next steps:\u003cbr/\u003e\n\n1) Left click on the Ethernet symbol.\u003cbr/\u003e\u003cbr/\u003e\n![image](https://user-images.githubusercontent.com/44409029/124445112-8eb8e880-dd7f-11eb-80e6-121dc31fd0b8.png)\u003cbr/\u003e\u003cbr/\u003e\n2) Click \"Turn on wireless LAN\", and wait a few seconds. Your RPi will scan for available networks.\u003cbr/\u003e\u003cbr/\u003e\n![image](https://user-images.githubusercontent.com/44409029/124445876-39310b80-dd80-11eb-97ff-1ef8f8c477e8.png)\u003cbr/\u003e\u003cbr/\u003e\n3) Left click again on the Ethernet symbol and choose your network.\u003cbr/\u003e\u003cbr/\u003e\n![image](https://user-images.githubusercontent.com/44409029/124446101-64b3f600-dd80-11eb-9385-eee4fd730268.png)\u003cbr/\u003e\u003cbr/\u003e\n4) Give your key, and wait a couple of seconds to let the RPi establish the connection.\u003cbr/\u003e\u003cbr/\u003e\n![image](https://user-images.githubusercontent.com/44409029/124447227-74800a00-dd81-11eb-9c47-bee6b2b84bc1.png)\u003cbr/\u003e\u003cbr/\u003e\n5) Success! \u003cbr/\u003e\u003cbr/\u003e\n![image](https://user-images.githubusercontent.com/44409029/124446775-063b4780-dd81-11eb-9fd8-2d597ad31cee.png)\n\n------------\n\n## TensorFlow-Lite.\n\nTensorflow-Lite is aimed at small, lightweight devices, such as the Raspberry Pi. Hence the use of a single C++ library.\u003cbr\u003e\nSince version 2.7, the Tensorflow team has decided to focus on Python for its Lite version. The single large C++ library has since expired.\u003cbr\u003e\nNow you only have small separate libraries. When programming you will have to specify all the necessary files separately. And these are quite a few.\nTo make working with Tensorflow-Lite easier, we have packed everything in one package.\u003cbr\u003e\n\n![image](https://github.com/Qengineering/RPi-Bullseye-DNN-image/assets/44409029/2eb572c1-a4ab-486d-8045-d7bcb6e24aa0)\u003cbr\u003e\u003cbr\u003e\nIn addition, it is now also possible to use Tensorflow-Lite in Python.\u003cbr\u003e\n![image](https://github.com/Qengineering/RPi-Bullseye-DNN-image/assets/44409029/80b81693-6d73-4aa1-9c50-e81d20926a75)\u003cbr\u003e\n```python\nfrom tflite_runtime.interpreter import Interpreter \nfrom PIL import Image\nimport numpy as np\nimport time\n\ndef load_labels(path): # Read the labels from the text file as a Python list.\n  with open(path, 'r') as f:\n    return [line.strip() for i, line in enumerate(f.readlines())]\n\ndef set_input_tensor(interpreter, image):\n  tensor_index = interpreter.get_input_details()[0]['index']\n  input_tensor = interpreter.tensor(tensor_index)()[0]\n  input_tensor[:, :] = image\n\ndef classify_image(interpreter, image, top_k=1):\n  set_input_tensor(interpreter, image)\n\n  interpreter.invoke()\n  output_details = interpreter.get_output_details()[0]\n  output = np.squeeze(interpreter.get_tensor(output_details['index']))\n\n  scale, zero_point = output_details['quantization']\n  output = scale * (output - zero_point)\n\n  ordered = np.argpartition(-output, 1)\n  return [(i, output[i]) for i in ordered[:top_k]][0]\n\ndata_folder = \"/home/pi/software/TensorFlow_Lite_Classification_RPi_64-bits/\"\n\nmodel_path = data_folder + \"mobilenet_v1_1.0_224_quant.tflite\"\nlabel_path = data_folder + \"labels.txt\"\n\ninterpreter = Interpreter(model_path)\nprint(\"Model Loaded Successfully.\")\n\ninterpreter.allocate_tensors()\n_, height, width, _ = interpreter.get_input_details()[0]['shape']\nprint(\"Image Shape (\", width, \",\", height, \")\")\n\n# Load an image to be classified.\nimage = Image.open(data_folder + \"tabby.jpeg\").convert('RGB').resize((width, height))\n\n# Classify the image.\ntime1 = time.time()\nlabel_id, prob = classify_image(interpreter, image)\ntime2 = time.time()\nclassification_time = np.round(time2-time1, 3)\nprint(\"Classificaiton Time =\", classification_time, \"seconds.\")\n\n# Read class labels.\nlabels = load_labels(label_path)\n\n# Return the classification label of the image.\nclassification_label = labels[label_id]\nprint(\"Image Label is :\", classification_label, \", with Accuracy :\", np.round(prob*100, 2), \"%.\")\n```\n\n\n\n\n------------\n\n## OpenCV + TensorFlow.\n\nImporting both TensorFlow and OpenCV in Python can throw the error: _cannot allocate memory in static TLS block_.\u003cbr/\u003e\nThis behaviour only occurs on an aarch64 system and is caused by the OpenMP memory requirements not being met.\u003cbr/\u003e\nFor more information, see GitHub ticket [#14884](https://github.com/opencv/opencv/issues/14884).\u003cbr/\u003e\n\n![output image](https://qengineering.eu/images/SwapImportOpenCVRPi.png)\n\nThere are a few solutions. The easiest is to import OpenCV at the beginning, as shown above.\u003cbr/\u003e\nThe other is disabling OpenMP by setting the -DBUILD_OPENMP and -DWITH_OPENMP flags OFF.\u003cbr/\u003e\nWhere possible, OpenCV will now use the default pthread or the TBB engine for parallelization.\u003cbr/\u003e\nWe don't recommend it. Not all OpenCV algorithms automatically switch to pthread.\u003cbr/\u003e\nOur advice is to import OpenCV into Python first before anything else.\u003cbr/\u003e\n\n------------\n\n[![paypal](https://qengineering.eu/images/TipJarSmall4.png)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=CPZTM5BB3FCYL) \n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqengineering%2Frpi-bullseye-dnn-image","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqengineering%2Frpi-bullseye-dnn-image","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqengineering%2Frpi-bullseye-dnn-image/lists"}