YOLO to TensorRT auto-export pipeline and smart model loader. TRT > ONNX > PyTorch priority.
Project description
⚡ yolotrt
YOLO → TensorRT Auto-Export & Smart Model Loader
Export once, load the fastest format every time.
✨ Why yolotrt?
| Feature | yolotrt | Manual Export | torch2trt |
|---|---|---|---|
| One-line auto export | ✅ | ❌ | ❌ |
| Smart format priority (TRT > ONNX > PT) | ✅ | ❌ | ❌ |
| Works with Ultralytics YOLO | ✅ | ✅ | ❌ |
| FP16 by default | ✅ | Manual | ✅ |
| Track + Predict API pass-through | ✅ | ❌ | ❌ |
| Zero config needed | ✅ | ❌ | ❌ |
📦 Installation
pip install yolotrt
Note: Requires
ultralyticsand TensorRT runtime for GPU acceleration.pip install ultralytics— the TensorRT backend is optional.
🚀 Quick Start
from yolotrt import ModelLoader
# First run: auto-exports .pt → .engine (5-10 min)
# Subsequent runs: loads .engine instantly
model = ModelLoader("models/best.pt", auto_trt=True, half=True)
# Inference (same API as ultralytics)
results = model.predict(frame, conf=0.5, verbose=False)
boxes = results[0].boxes.xyxy.cpu().numpy()
# Tracking
results = model.track(frame, persist=True, tracker="botsort.yaml")
Manual Export
from yolotrt import TRTExporter
exporter = TRTExporter("models/best.pt", half=True, imgsz=640)
if not exporter.is_exported():
engine_path = exporter.export()
print(f"Saved: {engine_path}")
🔧 API Reference
ModelLoader(model_path, auto_trt=True, half=True, device=0, imgsz=640)
Smart loader that picks the fastest available format:
| Priority | Format | Extension | Speed |
|---|---|---|---|
| 1 | TensorRT | .engine |
⚡ Fastest |
| 2 | ONNX | .onnx |
🔄 Cross-platform |
| 3 | PyTorch | .pt |
🐢 Fallback |
TRTExporter(model_path, half=True, device=0, imgsz=640)
| Method | Returns | Description |
|---|---|---|
export() |
str | Run export, return engine path |
is_exported() |
bool | Check if .engine already exists |
📜 License
MIT License — use it anywhere.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file yolotrt-1.0.0.tar.gz.
File metadata
- Download URL: yolotrt-1.0.0.tar.gz
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ee57018d2c4e467500a719de70c4634fe33d11c7757341b289beda327e99708e
|
|
| MD5 |
5a0b3da93743a948c0fa791f636b4a42
|
|
| BLAKE2b-256 |
feda316d362771c7a371676e07c6b87ca72700c4d18b9ffa15725d25f62edefe
|
File details
Details for the file yolotrt-1.0.0-py3-none-any.whl.
File metadata
- Download URL: yolotrt-1.0.0-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
90fcbd38396fe754d91825bdb8ed52ece43cfd8afedff4fb313d6f4a86d82965
|
|
| MD5 |
8fbf560d7009fc9bd8eecff1dc5121ab
|
|
| BLAKE2b-256 |
bfe1c13bcad7b7abf7dddc0e897a7db22ac857f778ef33003e258cd0863e0a1e
|