Skip to content

Latest commit

 

History

History
174 lines (135 loc) · 6.62 KB

File metadata and controls

174 lines (135 loc) · 6.62 KB

Super resolution

This example performs super resolution using a Hailo8, Hailo8L or Hailo10H device.
It receives an input image and enhances the image quality and details.

output example

Requirements

  • hailo_platform:
    • 4.23.0 (for Hailo-8 devices)
    • 5.3.0 (for Hailo-10H devices)
  • Pillow
  • opencv-python

Supported Models

  • real_esrgan_x2

Linux Installation

Run this app in one of two ways:

  1. Standalone installation in a clean virtual environment (no TAPPAS required) — see Option 1
  2. From an installed hailo-apps repository — see Option 2

Option 1: Standalone Installation

To avoid compatibility issues, it's recommended to use a clean virtual environment.

  1. Install PyHailoRT

    • Download the HailoRT whl from the Hailo website - make sure to select the correct Python version.
    • Install whl:
    pip install hailort-X.X.X-cpXX-cpXX-linux_x86_64.whl
  2. Clone the repository:

    git clone https://github.com/hailo-ai/hailo-apps.git
    cd hailo-apps/python/standalone_apps/super_resolution
  3. Install dependencies:

    pip install -r requirements.txt

Option 2: Inside an Installed hailo-apps Repository

If you installed the full repository:

git clone https://github.com/hailo-ai/hailo-apps.git
cd hailo-apps
sudo ./install.sh
source setup_env.sh

Then the app is already ready for usage:

cd hailo-apps/python/standalone_apps/super_resolution

Windows Installation

To avoid compatibility issues, it's recommended to use a clean virtual environment.

  1. Install HailoRT (MSI) + PyHailoRT

    1. Download and install the HailoRT Windows MSI from the Hailo website.

    2. During the installation, make sure PyHailoRT is selected (in the MSI “Custom Setup” tree).

    3. After installation, the PyHailoRT wheel is located under: C:\Program Files\HailoRT\python

    4. Create and activate a virtual environment:

    python -m venv wind_venv
    .\wind_venv\Scripts\Activate.ps1
    1. Install the PyHailoRT wheel from the MSI installation folder:
    pip install "C:\Program Files\HailoRT\python\hailort-*.whl"
  2. Clone the repository:

    git clone https://github.com/hailo-ai/hailo-apps.git
    cd hailo-apps\hailo_apps\python\standalone_apps\super_resolution
  3. Install dependencies:

    pip install -r requirements.txt
    
    

Run

After completing either installation option, run from the application folder:

python .\super_resolution.py -n <model_path> -i <input_image_path> -o <output_path>

Arguments

  • --hef-path, -n:
    • A model name (e.g., real_esrgan_x2) → the script will automatically download and resolve the correct HEF for your device.
    • A file path to a local HEF → the script will use the specified network directly.
  • -i, --input:
    • An input source such as an image (bus.jpg), a video (video.mp4), a directory of images, or usb to auto-select the first available USB camera.
      • On Linux, you can also use /dev/vidoeX (e.g., /dev/video0) to select a specific camera.
      • On Windows, you can also use a camera index (0, 1, 2, ...) to select a specific camera.
      • On Raspberry Pi, you can also use rpi to enable the Raspberry Pi camera.
    • A predefined input name from resources_config.yaml (e.g., bus, street).
      • If you choose a predefined name, the input will be automatically downloaded if it doesn't already exist.
      • Use --list-inputs to display all available predefined inputs.
  • -b, --batch-size: [optional] Number of images in one batch. Defaults to 1.
  • -s, --save-output: [optional] Save the output of the inference from a stream.
  • -o, --output-dir: [optional] Directory where output images/videos will be saved.
  • cr, --camera-resolution: [optional][Camera only] Input resolution: sd (640x480), hd (1280x720), or fhd (1920x1080).
  • or, --output-resolution: [optional] Set output size using sd|hd|fhd, or pass custom width/height (e.g., --output-resolution 1920 1080).
  • --show-fps: [optional] Display FPS performance metrics for video/camera input.
  • --no-display: [optional] Run without opening a display window. Useful for headless or performance testing.
  • --video-unpaced: [optional] Process video input as fast as possible without respecting the original video FPS (no pacing).
  • -t, --timeout: [optional] Maximum runtime in seconds. Stops the application after the specified duration.
  • -f, --frame-rate: [optional][Camera only] Override the camera input framerate.
  • --list-models: [optional] Print all supported models for this application (from resources_config.yaml) and exit.
  • --list-inputs: [optional] Print the available predefined input resources (images/videos) defined in resources_config.yaml for this application, then exit.

For more information:

./super_resolution.py -h

Example

List supported networks

./super_resolution.py --list-nets

List available input resources

./super_resolution.py --list-inputs

Inference on single image

./super_resolution.py -n ./real_esrgan_x2.hef -i input_image.png

Inference on a usb camera stream

./super_resolution.py -n ./real_esrgan_x2.hef -i usb

Inference on a usb camera stream with custom frame rate

./super_resolution.py -n ./real_esrgan_x2.hef -i usb -f 1

Additional Notes

  • The script assumes that the image is in one of the following formats: .jpg, .jpeg, .png or .bmp

Disclaimer

This code example is provided by Hailo solely on an “AS IS” basis and “with all faults”. No responsibility or liability is accepted or shall be imposed upon Hailo regarding the accuracy, merchantability, completeness or suitability of the code example. Hailo shall not have any liability or responsibility for errors or omissions in, or any business decisions made by you in reliance on this code example or any part of it. If an error occurs when running this example, please open a ticket in the "Issues" tab.

This example was tested on specific versions and we can only guarantee the expected results using the exact version mentioned above on the exact environment. The example might work for other versions, other environment or other HEF file, but there is no guarantee that it will.