anan19990108/yolov5s_tflite
YOLOv5s TFLite — FP32 and quantized variants
TensorFlow Lite exports of YOLOv5s at 320×320 and 640×640 for edge-deployment experiments.
The quantized variants use UINT8 input tensors and FP32 output tensors, while most internal tensors are INT8. They are not full-integer input/output models.
Authorship and Scope
The YOLOv5 architecture and base weights originate from Ultralytics. Andrew Chiao prepared the TensorFlow Lite conversion, 320/640 deployment variants, quantized packaging, tensor-level verification, and Qualcomm deployment integration guidance.
Files verified on 2026-08-18
The quantized variants contain 307 INT8 tensors and 370 tensors with quantization parameters. Post-processing and NMS are not included in this repository.
Python Usage: Quantized 640 Model
import numpy as np
from PIL import Image
import tensorflow as tf
interpreter = tf.lite.Interpreter("yolov5s_int8_640.tflite")
interpreter.allocate_tensors()
inp = interpreter.get_input_details()[0]
outs = interpreter.get_output_details()
# Use production letterboxing for correct geometry. This short example only
# demonstrates the model I/O contract.
rgb = Image.open("image.jpg").convert("RGB").resize((640, 640))
input_uint8 = np.asarray(rgb, dtype=np.uint8)[None]
interpreter.set_tensor(inp["index"], input_uint8)
interpreter.invoke()
heads = [interpreter.get_tensor(item["index"]) for item in outs]
print([head.shape for head in heads])
# [(1, 80, 80, 255), (1, 40, 40, 255), (1, 20, 20, 255)]The three FP32 outputs are YOLOv5 detection heads. Decode them with the matching anchors/strides and apply confidence filtering plus NMS.
Android + Qualcomm QNN HTP
Use a QNN LiteRT delegate and runtime from the same authorized Qualcomm SDK release. The quantized variants request the quantized HTP precision:
QnnDelegate.Options qnn = new QnnDelegate.Options();
qnn.setSkelLibraryDir(context.getApplicationInfo().nativeLibraryDir);
qnn.setCacheDir(context.getCacheDir().getAbsolutePath());
qnn.setModelToken("yolov5s_int8_640");
qnn.setBackendType(QnnDelegate.Options.BackendType.HTP_BACKEND);
qnn.setHtpPerformanceMode(
QnnDelegate.Options.HtpPerformanceMode.HTP_PERFORMANCE_BURST);
qnn.setHtpPrecision(QnnDelegate.Options.HtpPrecision.HTP_PRECISION_QUANTIZED);
QnnDelegate delegate = new QnnDelegate(qnn);
Interpreter.Options options = new Interpreter.Options();
options.setUseNNAPI(false);
options.setUseXNNPACK(false);
options.addDelegate(delegate);
Interpreter interpreter = new Interpreter(modelBuffer, options);Check HTP_RUNTIME_QUANTIZED capability before construction, keep the delegate alive with the interpreter, and confirm graph delegation in the device log.
Intended use
- TFLite object-detection integration
- Android and embedded inference prototypes
- Delegate compatibility experiments
- FP32-versus-quantized pipeline comparisons
Verification status
Tensor shapes, dtypes, quantization parameters, sizes, and hashes were checked with TensorFlow Lite. This repository currently does not include a reproducible accuracy or device-latency benchmark, so no QCS8550 performance claim is made in this model card.
License
The upstream Ultralytics YOLOv5 project is offered under AGPL-3.0 or a separate Ultralytics enterprise license. This repository uses AGPL-3.0 metadata; users should review upstream terms for their deployment.
