Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

ImageAI’s compact Python example uses a pretrained RetinaNet model to find and label objects in a still image, save an annotated copy, and print each detected label with a model-reported probability. The ten lines cover the detection step—not installing Python packages, downloading the model, or preparing the input image.

What the 10-line object-detection example does

The example comes from Moses Olafenwa’s June 16, 2018 tutorial, “Object Detection with 10 lines of code”. It uses ImageAI’s ObjectDetection class and a pretrained RetinaNet model saved as resnet50_coco_best_v2.0.1.h5.

Object detection means more than assigning a label to an entire picture: the model identifies object locations as well as classes. In this example, the detector processes an input image, writes an annotated output image, and returns results that the script loops through to print an object name and its percentage_probability. Those percentages are model outputs for the pictured examples, not a benchmark or a guarantee that a prediction is correct.

How the code fits together

The original walkthrough’s snippet follows this sequence:

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Raspberry Pi AI Camera
  • 12.3 MP Sony IMX500 Intelligent Vision Sensor with a powerful neural network accelerator
  • Integrated low-power inference engine
  • Integrated RP2040 for neural network and firmware management
  • Pre-loaded with MobileNet machine vision model
  • Sensor modes: 4056×3040 at 10fps, 2028×1520 at 30fps
  1. Import ObjectDetection from ImageAI and Python’s os module.
  2. Get the working directory, create a detector, and select the RetinaNet detection model.
  3. Set the detector’s model path to resnet50_coco_best_v2.0.1.h5 and load the model.
  4. Call detectObjectsFromImage with the input image and the path for the output image.
  5. Loop through the returned detections and print each object name and probability percentage.

The output path is where the annotated image is written; the printed results are separate text output. The tutorial reports a default minimum-probability threshold of 50 percent and describes changing that threshold, selecting classes, changing detection speed, using different image input and output forms, and saving detected objects as separate image files. Those are descriptions from a 2018 tutorial, not a guarantee about the current API. Check the project’s README and documentation before using old parameter names or code in a new project.

What you need in addition to the snippet

The short example assumes its runtime and files are already prepared. The tutorial instructs readers to install Python and ImageAI with its dependencies, download the RetinaNet model file, and place that model and an input image alongside the script. The downloaded model is not created by the code.

Rank #2
Seeed Studio XIAO ESP32-S3 Sense Board with Camera & Microphone
  • Powerful MCU Board: Incorporate the ESP32 S3 32-bit, dual-core, Xtensa processor chip operating up to 240 MHz, mounted multiple development ports, Arduino / MicroPython supported
  • Advanced Functionality: Detachable OV2640 camera sensor for 1600*1200 resolution, compatible with OV3660 camera sensor, integrating additional digital microphone
  • Great Memory for more Possibilities: Offer 8MB PSRAM and 8MB FLASH, supporting SD card slot for external 32GB FAT memory
  • Outstanding RF performance: Support 2.4GHz Wi-Fi and BLE dual wireless communication, support 100m+ remote communication when connected with U.FL antenna
  • Thumb-sized Compact Design: 21 x 17.5mm, adopting the classic form factor of XIAO, suitable for space-limited projects like wearable devices

The tutorial’s dependency list reflects an older environment: Python 3.7.6, TensorFlow 2.4.0, Keras 2.4.3, NumPy 1.19.3, Pillow 7.0.0, SciPy 1.4.1, h5py 2.10.0, Matplotlib 3.3.2, OpenCV-Python, keras-resnet 0.2.0, ImageAI, and the separate RetinaNet model. Treat those as historical details, not a current installation recipe.

The repository README currently identifies ImageAI v3.0.3 and gives Python 3.7–3.10 installation guidance based on PyTorch dependencies. Because package and model compatibility can change, follow the README for a new setup rather than copying 2018 install commands. The README’s version and guidance are current to the repository information accessed September 30, 2026.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
DFROBOT HUSKYLENS Smart Vision Sensor for Raspberry Pi, LattePanda or Micro:bit | AI Camera Support Object/Line Tracking, Face/Object/Color/Tag Recognition
  • HuskyLens is an easy-to-use AI machine vision sensor. It can learn to detect objects, faces, lines, colors and tags just by clicking.
  • One-Click-Learn: HuskyLens is designed to be smart. Built-in algorithms allow HuskyLens to learn new things just by a single click.
  • Machine-Learning-Enabled: Equipped with advanced machine learning technology, HuskyLens is capable of recognizing faces and objects, which is far more beyond ordinary sensors.
  • Onboard Screen: HuskyLens carries a 2.0 inch IPS screen, therefore you don't need to use a PC in parameters tuning. Enjoy the convenience it brings, what you see is what you get!
  • Extreme Performance: HuskyLens adopts a new generation AI specialized chip Kendryte K210, contributing to 1,000 times faster performance compared to STM32H743 when running neural network algorithm.

Pretrained detection versus custom objects

The example loads a pretrained model; it does not teach the detector a new object category from a few lines of code. A pretrained detector recognizes the classes it was trained to detect. If your target is a specialized set of objects, you need a custom-training workflow and suitable labeled data. The 2018 article points to a separate custom-training tutorial, and the current ImageAI README describes custom detection model training.

The README lists RetinaNet, YOLOv3, and TinyYOLOv3 for object detection. That list describes project capabilities, not a tested ranking: the available sources do not establish which is most accurate or fastest for a particular dataset or device.

Rank #4
FORIOT 3Pcs ESP32-S3-CAM Development Board with OV3660 Camera, ESP32-S3-WROOM N16R8 Module with Dual Type-C Interface Support Wi-Fi and Bluetooth MCU Microcontroller for IoT, DIY and AI Project
  • Dual-core processor: The ESP32 module is based on the powerful ESP32-S3-WROOM N16R8 module and is equipped with a dual-core 32-bit LX7 processor. Its excellent AI computing performance, real-time processing capabilities, and low power consumption make it ideal for image recognition, edge AI, and complex IoT applications
  • Integrated 2-megapixel OV3660 camera: Built-in OV3660 camera to capture clear images and stream video in real time. Perfect for smart surveillance, face recognition, and AI-based computer vision projects. It is the preferred solution for DIY makers and professionals to build camera-enabled IoT systems
  • Dual Type-C ports for OTG and serial debugging: Designed with two USB Type-C interfaces - one supports USB OTG for host/device functions, and the other provides TTL serial for easy programming and debugging
  • Shared antenna: Supports IEEE 802.11b/g/n Wi-Fi (2.4GHz) and Bluetooth 5 (LE and Mesh), using shared antennas to optimize wireless performance. Enhanced 2 Mbps PHY and long-distance communication (Coded PHY) ensure stable multitasking in harsh environments
  • Multi-scenario applications: The ESP32 S3 development board maintains high stability even at high temperatures, making it ideal for industrial environments, educational purposes, and AI-driven projects. It is a versatile choice for robots, smart devices, and machine vision in lab or field applications
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Do you need a GPU?

Not for the basic one-image example as described. ImageAI’s current README says operations can run on a computer with moderate CPU capacity, but characterizes CPU detection as slow and unsuitable for real-time applications. It identifies PyTorch CPU and GPU support, including NVIDIA GPUs, for high-performance computer-vision work.

For a still image or occasional batch, CPU processing may be adequate if its latency works for your use. For a real-time or high-throughput workload, GPU processing is an option to evaluate; the README does not provide a controlled speed benchmark or a promised speedup.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Compatible with NVIDIA Jetson Nano Camera IMX219-160 8-Megapixels Camera Module 3280 × 2464 Resolution 160 Degree Wide Angle of View with IMX219 Sensor
  • IMX219-160 Camera, Supports NVIDIA Jetson Nano Developer Kit and Raspberry Pi 5/4B/3B+/3B/Zero/Zero Zero 2 W/WH Boards and Compute Module CM3 / CM3+ / CM4.,160° FOV.
  • 3280 × 2464 High Resolution ,8 Megapixels Camera
  • Sensor: IMX219
  • Light and easy to use
  • Combined with the Jetson Nano AI computer, this camera suits for AI projects such as:Face recognition,road mark detection,license plate recognition

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.