### Install Project Dependencies Source: https://github.com/danieldubinsky/yolo26_hailo/blob/main/README.md Install additional Python dependencies required for this project using pip and the requirements.txt file. ```bash pip install -r requirements.txt ``` -------------------------------- ### Initialize Hailo NPU Inference Engine Source: https://context7.com/danieldubinsky/yolo26_hailo/llms.txt Initializes the `HailoPythonInferenceEngine` to wrap the inference pipeline, handling backbone feature extraction on the Hailo-8L and Python-based detection post-processing. ```python from common import HailoPythonInferenceEngine, DetectionPostProcessor, scale_detections_to_original # Initialize engine (connects to Hailo-8L via PCIe) engine = HailoPythonInferenceEngine('models/yolo26n.hef') # ✓ Hailo engine initialized: models/yolo26n.hef # ✓ Using Python head for post-processing. # Preprocess image input_data, orig_size, scale, pad_w, pad_h = HailoPythonInferenceEngine.preprocess( 'photo.jpg', normalize=False # Keep as uint8 [0,255] for HEF ) # input_data shape: (1, 640, 640, 3), dtype=uint8 ``` -------------------------------- ### Build and Run C++ Single-Image Detection (Bash) Source: https://context7.com/danieldubinsky/yolo26_hailo/llms.txt Builds the C++ inference executable and runs single-image detection using HailoRT. Produces an annotated output image. ```bash # Build cd cpp && make && cd .. # Produces: detect_image, benchmark_inference, run_coco_inference # Run detection ./cpp/detect_image input.jpg models/yolo26n.hef 0.25 ``` -------------------------------- ### Download Pre-compiled HEF Models Source: https://github.com/danieldubinsky/yolo26_hailo/blob/main/README.md Download pre-compiled Hailo binary HEF models from the project's releases page. Use the script to download all variants or a specific one. ```bash # Download all variants bash scripts/download_hef.sh # Download a specific variant (e.g., yolo26n) bash scripts/download_hef.sh n ``` -------------------------------- ### Build C++ Inference Tools Source: https://github.com/danieldubinsky/yolo26_hailo/blob/main/README.md Compile the C++ inference and evaluation tools. This command should be run from the root directory of the project. ```bash cd cpp make cd .. # Generates: detect_image, benchmark_inference, run_coco_inference ``` -------------------------------- ### Activate Hailo Environment Source: https://github.com/danieldubinsky/yolo26_hailo/blob/main/README.md Source the Hailo environment script to activate the necessary Python virtual environment for Hailo applications. ```bash source ~/hailo-apps/venv_hailo_apps/bin/activate ``` -------------------------------- ### ONNX Runtime CPU Throughput Benchmark (Bash) Source: https://context7.com/danieldubinsky/yolo26_hailo/llms.txt Benchmarks the ONNX model's inference speed on CPU. Reports average inference time, total pipeline time, and estimated FPS. Requires `onnxruntime`. ```bash python python/onnx/benchmark.py models/yolo26n.onnx --iterations 100 --output onnx_stats.json ``` -------------------------------- ### Download YOLO26n ONNX Model Source: https://github.com/danieldubinsky/yolo26_hailo/blob/main/README.md Download the YOLO26n ONNX model and export it to the models directory. Requires the ultralytics library. ```bash # Downloads YOLO26n and exports to models/yolo26n.onnx pip install ultralytics python scripts/download_model.py ``` -------------------------------- ### Run Single-Image Detection CLI (Hailo) Source: https://context7.com/danieldubinsky/yolo26_hailo/llms.txt A command-line script for single-image detection. It loads a HEF model, preprocesses an input image, runs hybrid inference, scales detections, draws bounding boxes, and saves the output. Supports custom confidence thresholds and verbose timing. ```bash # Basic detection python python/detect_image.py input.jpg --hef models/yolo26n.hef --output result.jpg # With lower confidence threshold and verbose timing python python/detect_image.py input.jpg \ --hef models/yolo26n.hef \ --output result.jpg \ --conf-threshold 0.3 \ --verbose # Expected output: # [Loading image: input.jpg] # ✓ Original image size: 1280x720 # ✓ Preprocessed to: (1, 640, 640, 3), dtype=uint8 # [Running inference...] # ✓ Inference completed in 12.30ms # - Hailo: 11.54ms # - Python Head: 0.23ms # ✓ Found 4 detections above threshold 0.3 # [1] person - conf=0.91, bbox=[142, 88, 391, 479] # [2] car - conf=0.82, bbox=[512, 200, 740, 380] # ✓ Output image saved to: result.jpg ``` -------------------------------- ### Benchmark Inference Throughput (Hailo) Source: https://context7.com/danieldubinsky/yolo26_hailo/llms.txt Benchmarks inference throughput by running multiple iterations. It collects timing for preprocessing, Hailo backbone, and Python head, reporting mean/std FPS. Optionally saves detailed statistics to JSON. ```bash # Benchmark with random data (1 000 iterations) python python/benchmark_inference.py --hef models/yolo26n.hef --iterations 1000 # Benchmark with a real image python python/benchmark_inference.py \ --hef models/yolo26n.hef \ --image data/coco/val2017/000000001000.jpg \ --iterations 500 \ --output stats.json # Expected console output: # ============================================================ # INFERENCE SUMMARY # ============================================================ # Total Iterations: 1000 # Avg Total Time: 11.82ms ± 0.41ms # - Hailo Backbone: 11.54ms ± 0.38ms (97.6% of mean) # - Python Head: 0.23ms ± 0.04ms ( 1.9% of mean) # Throughput: 84.60 FPS ± 2.93 ``` -------------------------------- ### Preprocess Dataset for Letterboxing Source: https://github.com/danieldubinsky/yolo26_hailo/blob/main/README.md Preprocess a dataset using the same letterbox logic as the export process. Converts images to RGB, resizes with aspect ratio preserved, pads with gray, and saves as .npy files. ```bash python scripts/preprocess_dataset.py data/calib_images data/calib_npy --size 640 ``` -------------------------------- ### ONNX Runtime Single-Image Detection (Bash) Source: https://context7.com/danieldubinsky/yolo26_hailo/llms.txt Runs YOLO26 ONNX model on CPU, performing preprocessing, inference, and postprocessing. Saves an annotated image. Requires `onnxruntime`. ```bash python python/onnx/detect_image.py input.jpg --model models/yolo26n.onnx --conf 0.25 --output output_onnx.jpg ``` -------------------------------- ### Compile Quantized HAR to HEF Binary Source: https://context7.com/danieldubinsky/yolo26_hailo/llms.txt Compiles a quantized HAR file into a Hailo HEF binary using `ClientRunner.compile()`. The resulting binary is saved to `artifacts/3_compiled/model.hef`. ```python from export.steps.compile import CompileStep step = CompileStep(config) context = step.run(context) print(context['hef_path']) # experiments/test_run/artifacts/3_compiled/model.hef # Internally: # runner = ClientRunner(hw_arch='hailo8l') # runner.load_har('artifacts/2_quantized/model_quantized.har') # hef = runner.compile() # open('artifacts/3_compiled/model.hef', 'wb').write(hef) ``` -------------------------------- ### Full Image Preprocessing Pipeline Source: https://context7.com/danieldubinsky/yolo26_hailo/llms.txt Handles the complete image preprocessing chain: BGR to RGB conversion, letterboxing, and optional normalization. Returns the processed input tensor and metadata for reversing the transform. ```python # Full preprocessing pipeline (BGR→RGB + letterbox + tensor) input_tensor, (orig_h, orig_w), scale, pad_w, pad_h = load_and_preprocess_image( 'photo.jpg', target_size=640, normalize=False # uint8 for HEF; set True for ONNX models ) print(input_tensor.shape, input_tensor.dtype) # (1, 640, 640, 3) uint8 ``` -------------------------------- ### Build and Run C++ ONNX Inference Source: https://github.com/danieldubinsky/yolo26_hailo/blob/main/README.md Compile and execute ONNX models using C++ tools for detection and benchmarking on CPU. Navigate to the cpp/onnx directory to build. ```bash cd cpp/onnx make cd ../.. ``` ```bash ./cpp/onnx/detect_image input.jpg models/yolo26n.onnx ``` ```bash ./cpp/onnx/benchmark models/yolo26n.onnx 100 ``` -------------------------------- ### Run YOLOv2-26 Inference (Hailo Backbone, Python Head) Source: https://context7.com/danieldubinsky/yolo26_hailo/llms.txt Performs inference on an image using a Hailo NPU for the backbone and Python for the head. Scales detections back to original image coordinates and saves the annotated image. Inspects and prints detection details and timing statistics. ```python orig_image = HailoPythonInferenceEngine.load_image('photo.jpg') detections, stats = engine.infer(input_data, conf_threshold=0.25, verbose=True) # [STAGE 1] Running Hailo backbone... # ✓ Hailo inference: 11.54ms # [STAGE 2] Running Python Head... # ✓ Python head: 0.23ms # Scale back to original image coordinates orig_h, orig_w = orig_image.shape[:2] detections = scale_detections_to_original(detections, orig_h, orig_w, scale, pad_w, pad_h) # Draw and save annotated = DetectionPostProcessor.draw_bboxes(orig_image, detections) import cv2 cv2.imwrite('output.jpg', annotated) # Inspect detections for det in detections: print(f"{det['cls_name']} {det['conf']:.2f} [{det['x1']:.0f},{det['y1']:.0f},{det['x2']:.0f},{det['y2']:.0f}]") # person 0.87 [142,88,391,479] # car 0.74 [512,200,740,380] print(f"Total: {stats.total_time*1000:.1f}ms Hailo: {stats.hailo_inference_time*1000:.1f}ms PyHead: {stats.postprocess_time*1000:.1f}ms") # Total: 11.8ms Hailo: 11.5ms PyHead: 0.2ms ``` -------------------------------- ### Detection Post-processing and Visualization Utilities Source: https://context7.com/danieldubinsky/yolo26_hailo/llms.txt Provides utilities for parsing raw detection outputs, filtering by confidence, and drawing labeled bounding boxes on an image using OpenCV. ```python import numpy as np from common import DetectionPostProcessor ``` -------------------------------- ### Parse and Draw Detections in Python Source: https://context7.com/danieldubinsky/yolo26_hailo/llms.txt Parses raw ONNX-style output and draws bounding boxes on an image. Requires the `DetectionPostProcessor` class and OpenCV. ```python raw = np.array([ [100, 50, 400, 350, 0.91, 0], # person [300, 200, 600, 500, 0.15, 2], # car (below threshold) [10, 10, 120, 200, 0.78, 16], # dog ]) dets = DetectionPostProcessor.postprocess(raw, conf_threshold=0.25) for d in dets: print(f"{d['cls_name']:12s} conf={d['conf']:.2f} bbox=[{d['x1']:.0f},{d['y1']:.0f},{d['x2']:.0f},{d['y2']:.0f}]") # person conf=0.91 bbox=[100,50,400,350] # dog conf=0.78 bbox=[10,10,120,200]) # Draw on original image import cv2 img = cv2.imread('photo.jpg') annotated = DetectionPostProcessor.draw_bboxes(img, dets, thickness=2) cv2.imwrite('annotated.jpg', annotated) ``` -------------------------------- ### Download Calibration Images Source: https://github.com/danieldubinsky/yolo26_hailo/blob/main/README.md Download 1024 random images from COCO Train 2017 for model quantization. Requires the fiftyone library. ```bash pip install fiftyone python scripts/download_calib.py ``` -------------------------------- ### Run Python ONNX Inference Source: https://github.com/danieldubinsky/yolo26_hailo/blob/main/README.md Execute original ONNX models on CPU for verification. Requires the ONNX model file. ```bash python python/onnx/detect_image.py input.jpg --model models/yolo26n.onnx ``` ```bash python python/onnx/benchmark.py models/yolo26n.onnx --iterations 100 ``` -------------------------------- ### Run Export Pipeline Programmatically Source: https://context7.com/danieldubinsky/yolo26_hailo/llms.txt Instantiate and run the `ExportPipeline` to orchestrate the ONNX to HEF conversion process. The pipeline manages the four conversion steps and creates a timestamped run directory for artifacts and logs. ```python from export.config import ExportConfig from export.core.pipeline import ExportPipeline from pathlib import Path config = ExportConfig( variant='yolo26n', target='hailo8l', onnx_path=Path('models/yolo26n.onnx').resolve(), calib_dir=Path('data/calib_images').resolve(), tag='ci_test' ) pipeline = ExportPipeline(config) # Steps registered: ExtractSubgraphsStep, OnnxToHarStep, QuantizeStep, CompileStep pipeline.run() # Artifacts produced: # experiments/yolo26n_hailo8l_ci_test_YYYYMMDD_HHMMSS/ # run.log # model_script.alls # artifacts/ # 0_subgraphs/yolo26n_backbone.onnx # 0_subgraphs/yolo26n_head.onnx # 1_parsed/model.har ``` -------------------------------- ### High-Performance C++ Throughput Benchmark (Bash) Source: https://context7.com/danieldubinsky/yolo26_hailo/llms.txt Benchmarks inference throughput using C++/HailoRT with either random data or real COCO images. Reports latency and serial FPS. ```bash # Random data, 200 iterations ./cpp/benchmark_inference models/yolo26n.hef 200 # Real COCO images, 300 iterations, custom confidence ./cpp/benchmark_inference models/yolo26n.hef 300 --images data/coco/val2017 --conf 0.5 ``` -------------------------------- ### Export ONNX to HEF using CLI Source: https://context7.com/danieldubinsky/yolo26_hailo/llms.txt Use the CLI to convert an ONNX model to HEF format. Specify the model variant, target hardware, ONNX file path, and calibration data directory. An optional optimization script can also be provided. ```bash python -m export.cli \ --variant yolo26n \ --target hailo8l \ --onnx models/yolo26n.onnx \ --calib_dir data/coco/val2017 \ --tag production_run ``` ```bash # Expected output (abbreviated): # Starting export run for yolo26n on hailo8l # Run directory: experiments/yolo26n_hailo8l_production_run_20241201_143022 # --- Starting Step: extract_subgraphs --- # --- Starting Step: onnx_to_har --- # --- Starting Step: quantize --- # --- Starting Step: compile --- # --- Export Process Completed Successfully --- # HEF File: experiments/yolo26n_hailo8l_production_run_20241201_143022/artifacts/3_compiled/model.hef ``` ```bash # With a custom .alls optimization script python -m export.cli \ --variant yolo26s \ --target hailo8 \ --onnx models/yolo26s.onnx \ --calib_dir data/calib_images \ --alls export/yolo26n.alls \ --tag custom_quant ``` -------------------------------- ### Run C++ Inference Benchmark Source: https://github.com/danieldubinsky/yolo26_hailo/blob/main/README.md Measure performance using the C++ benchmark tool. It can use random data or real images from a specified directory and allows custom confidence thresholds. ```bash ./cpp/benchmark_inference models/yolo26n.hef 200 ``` ```bash ./cpp/benchmark_inference models/yolo26n.hef 300 --images data/coco/val2017 ``` ```bash ./cpp/benchmark_inference models/yolo26n.hef 100 --conf 0.5 ``` -------------------------------- ### Download and Export YOLO26 Model to ONNX Source: https://context7.com/danieldubinsky/yolo26_hailo/llms.txt Uses the ultralytics library to download YOLO26 checkpoints and export them to ONNX format. Specify variants and output paths as needed. Ensures models are placed in the 'models/' directory. ```bash # Download and export nano variant (default) python scripts/download_model.py # Download a specific variant python scripts/download_model.py --variant yolo26s --output models/ # Expected output: # Downloading yolo26n and exporting to ONNX in models/... # Using weights file: yolo26n.pt # Exporting to ONNX (opset=11, simplify=True)... # Success! Model saved to: models/yolo26n.onnx # Moved weights to: models/yolo26n.pt ``` -------------------------------- ### Download COCO Calibration Images Source: https://context7.com/danieldubinsky/yolo26_hailo/llms.txt Downloads calibration images from COCO Train 2017 using fiftyone.zoo. Samples a specified number of images and exports them to a flat directory for quantization. Uses a reproducible shuffle with seed=42. ```bash # Default: 1024 images to data/calib_images/ python scripts/download_calib.py # Custom count and path python scripts/download_calib.py --output data/my_calib --samples 512 # Expected output: # Downloading and sampling 1024 images from COCO training set... # Exporting to data/calib_images/... # Successfully exported 1024 images to: data/calib_images/ ``` -------------------------------- ### Run Python Hailo Inference Source: https://github.com/danieldubinsky/yolo26_hailo/blob/main/README.md Perform inference using a compiled HEF file with Python. Supports image detection and performance benchmarking. Use the --normalize flag if the model expects [0,1] float input. ```bash python python/detect_image.py input.jpg --hef models/yolo26n.hef --output output.jpg ``` ```bash python python/benchmark_inference.py --hef models/yolo26n.hef --iterations 1000 ``` -------------------------------- ### Letterbox Image Resizing and Padding Source: https://context7.com/danieldubinsky/yolo26_hailo/llms.txt Resizes an image while preserving aspect ratio and pads it to a square with gray fill. Returns the padded image, scaling factor, and padding dimensions needed for coordinate transformation. ```python import cv2 import numpy as np from common import letterbox_image, load_and_preprocess_image # Low-level letterbox img = cv2.imread('photo.jpg') # BGR, e.g. 1280x720 padded, scale, pad_w, pad_h = letterbox_image(img, target_size=640) print(padded.shape, scale, pad_w, pad_h) # (640, 640, 3) 0.5 80 0 ``` -------------------------------- ### C++ Detection Decoding with run_postprocess Source: https://context7.com/danieldubinsky/yolo26_hailo/llms.txt Identifies output tensors and decodes detections using stride and grid-size lists. Vectorizes over anchors, applies a logit threshold, and decodes regression offsets. Use for real-time object detection postprocessing in C++. ```cpp #include "postprocess.hpp" // After reading output vstreams into output_buffers (map>) std::vector cls_ptrs, reg_ptrs; if (!map_output_tensors(output_buffers, cls_ptrs, reg_ptrs)) { // Fallback: dump sizes for debugging for (auto& [name, buf] : output_buffers) std::cerr << name << ": " << buf.size() << " floats\n"; return 1; } // Decode detections with strides {8,16,32} and grids {80,40,20} std::vector dets = run_postprocess( IntList<8, 16, 32>{}, IntList<80, 40, 20>{}, cls_ptrs, reg_ptrs, 0.25f // confidence threshold ); for (const auto& d : dets) { printf("%-15s conf=%.2f [%.0f,%.0f,%.0f,%.0f]\n", d.cls_name, d.conf, d.x1, d.y1, d.x2, d.y2); } // person conf=0.91 [160,88,320,479] // traffic light conf=0.67 [512,100,560,210] ``` -------------------------------- ### Convert ONNX to Hailo Archive (HAR) Source: https://context7.com/danieldubinsky/yolo26_hailo/llms.txt Parses an ONNX model to a Hailo Archive (HAR) format using `hailo_sdk_client.ClientRunner`. The HAR is saved to `artifacts/1_parsed/model.har`. ```python from export.steps.convert import OnnxToHarStep # Assumes context already contains 'variant_config' from ExtractSubgraphsStep step = OnnxToHarStep(config) context = step.run(context) print(context['har_path']) # experiments/test_run/artifacts/1_parsed/model.har # Internally calls: # runner = ClientRunner(hw_arch='hailo8l') # runner.translate_onnx_model( # 'models/yolo26n.onnx', # 'yolo26n', # start_node_names=['images'], # end_node_names=['/model.23/one2one_cv3.0/.../Conv', ...] # ) # runner.save_har('artifacts/1_parsed/model.har') ``` -------------------------------- ### Export ONNX to HEF using CLI Source: https://github.com/danieldubinsky/yolo26_hailo/blob/main/README.md Automated process to export an ONNX model to a Hailo HEF file using the export CLI. This handles subgraph extraction, parsing, quantization, and compilation. Requires the Hailo Dataflow Compiler (DFC) environment. ```bash # Run from the repository root python -m export.cli \ --variant yolo26n \ --target hailo8l \ --onnx models/yolo26n.onnx \ --calib_dir data/coco/val2017 \ --tag my_experiment ``` -------------------------------- ### Run C++ Detection on Image Source: https://github.com/danieldubinsky/yolo26_hailo/blob/main/README.md Perform object detection on a single image using the C++ implementation with a compiled HEF file. ```bash ./cpp/detect_image input.jpg models/yolo26n.hef ``` -------------------------------- ### Evaluate Detections with COCO mAP (Bash) Source: https://context7.com/danieldubinsky/yolo26_hailo/llms.txt Evaluates detection results against COCO annotations using pycocotools. First, generate a detections JSON file with a C++ tool, then run this script. ```bash # Step 1: generate detections JSON with the C++ tool ./cpp/run_coco_inference data/coco/val2017 models/yolo26n.hef detections.json # Step 2: compute mAP python python/evaluate_detections.py \ --detections detections.json \ --coco_ann data/coco/annotations/instances_val2017.json ``` -------------------------------- ### Batch Letterbox Images to .npy Source: https://context7.com/danieldubinsky/yolo26_hailo/llms.txt Converts JPEG/PNG images to BGR→RGB, letterboxes them to a specified size (default 640x640) with gray padding, and saves as float32 .npy arrays. Useful for debugging calibration or running noise analysis. ```bash # Preprocess calibration images python scripts/preprocess_dataset.py data/calib_images data/calib_npy --size 640 # Expected output: # Found 1024 images in data/calib_images # Processing to data/calib_npy (Target size: 640x640) # 100%|████████████████| 1024/1024 [00:08<00:00, 127.3it/s] # Verify one output python -c " import numpy as np a = np.load('data/calib_npy/000000001000.npy') print(a.shape, a.dtype) # (640, 640, 3) uint8 print(a[0,0]) # [114 114 114] (padding color) " ``` -------------------------------- ### Split ONNX Model into Subgraphs Source: https://github.com/danieldubinsky/yolo26_hailo/blob/main/README.md Optionally split the ONNX model into its backbone and head components for manual inspection or running with ONNX Runtime. ```bash python export/0_extract_subgraphs.py models/yolo26n.onnx models/ ``` -------------------------------- ### Download COCO Validation Data Source: https://github.com/danieldubinsky/yolo26_hailo/blob/main/README.md Download standard COCO Val 2017 images and annotations to the specified directory. This download is approximately 1GB. ```bash bash scripts/download_coco.sh ``` -------------------------------- ### Scale Detections to Original Image Coordinates Source: https://context7.com/danieldubinsky/yolo26_hailo/llms.txt Reverses the letterboxing and scaling transformations applied during preprocessing to map detection bounding box coordinates back to the original image dimensions. ```python # Reverse coordinates after inference from common import scale_detections_to_original raw_dets = [{'x1': 221, 'y1': 44, 'x2': 276, 'y2': 240, 'conf': 0.91, 'cls_id': 0, 'cls_name': 'person'}] dets = scale_detections_to_original(raw_dets, orig_h, orig_w, scale, pad_w, pad_h) # x-coordinates divided by scale, padding removed ``` -------------------------------- ### Inspect YOLO Variant Configurations Source: https://context7.com/danieldubinsky/yolo26_hailo/llms.txt Access and inspect available YOLO variants and their configurations using Pydantic models. Fetch specific variant details like input shape and end nodes. ```python from export.config import ExportConfig, get_variant_config, VARIANTS from pathlib import Path # Inspect available variants print(list(VARIANTS.keys())) # ['yolo26n', 'yolo26s', 'yolo26m', 'yolo26l'] # Fetch a variant's node configuration cfg = get_variant_config('yolo26n') print(cfg.name) # yolo26n print(cfg.input_shape) # (640, 640) print(cfg.end_nodes[:2]) # ['/model.23/one2one_cv3.0/one2one_cv3.0.2/Conv', # '/model.23/one2one_cv3.1/one2one_cv3.1.2/Conv'] print(cfg.default_alls) # yolo26n.alls ``` ```python # Build a run config programmatically config = ExportConfig( variant='yolo26n', target='hailo8l', onnx_path=Path('models/yolo26n.onnx').resolve(), calib_dir=Path('data/calib_images').resolve(), tag='my_run' ) ``` ```python # Unsupported target is accepted with a warning (permissive validator) config_new = ExportConfig( variant='yolo26n', target='hailo10', # newer target — accepted without error onnx_path=Path('models/yolo26n.onnx').resolve(), calib_dir=Path('data/calib_images').resolve() ) ``` -------------------------------- ### Quantize HAR to INT8 Source: https://context7.com/danieldubinsky/yolo26_hailo/llms.txt Performs INT8 quantization on a HAR file using a calibration dataset. Applies model scripts for normalization, optimization, and clipping. The quantized HAR is saved to `artifacts/2_quantized/model_quantized.har`. ```python from export.steps.quantize import QuantizeStep # Calibration images in data/calib_images/ (JPEG/PNG, any resolution) step = QuantizeStep(config) context = step.run(context) print(context['quantized_har_path']) # experiments/test_run/artifacts/2_quantized/model_quantized.har # The .alls script applied (export/yolo26n.alls): # normalization1 = normalization([0.0,0.0,0.0], [255.0,255.0,255.0]) # performance_param(compiler_optimization_level=max) # model_optimization_flavor(optimization_level=2) # context_switch_param(mode=allowed) # model_optimization_config(calibration, calibset_size=1024) # pre_quantization_optimization(activation_clipping, layers={*}, mode=percentile, clipping_values=[0.01,99.99]) # pre_quantization_optimization(weights_clipping, layers={*}, mode=percentile, clipping_values=[0.01,99.99]) ``` -------------------------------- ### Evaluate C++ Inference on COCO Source: https://github.com/danieldubinsky/yolo26_hailo/blob/main/README.md Reproduce mAP accuracy results on the COCO validation set. This involves running C++ inference to generate detections and then using a Python script for evaluation. ```bash ./cpp/run_coco_inference data/coco/val2017 models/yolo26n.hef detections.json ``` ```bash python python/evaluate_detections.py --detections detections.json --coco_ann data/coco/annotations/instances_val2017.json ``` -------------------------------- ### Extract Subgraphs from ONNX Model Source: https://context7.com/danieldubinsky/yolo26_hailo/llms.txt Splits an ONNX model into backbone and head components using `onnx.utils.extract_model`. Requires `ExportConfig` and variant configuration. ```python from export.config import ExportConfig, get_variant_config from export.steps.extract import ExtractSubgraphsStep from pathlib import Path config = ExportConfig( variant='yolo26n', target='hailo8l', onnx_path=Path('models/yolo26n.onnx').resolve(), calib_dir=Path('data/calib_images').resolve(), output_dir=Path('experiments/test_run') ) config.output_dir.mkdir(parents=True, exist_ok=True) step = ExtractSubgraphsStep(config) context = { 'config': config, 'variant_config': get_variant_config('yolo26n'), 'run_dir': config.output_dir } context = step.run(context) print(context['backbone_path']) # experiments/test_run/artifacts/0_subgraphs/yolo26n_backbone.onnx print(context['head_path']) # experiments/test_run/artifacts/0_subgraphs/yolo26n_head.onnx ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.