Metadata-Version: 2.4
Name: yolov8-tflite-imx
Version: 1.0.7
Summary: YOLOv8 INT8 TFLite webcam inference for i.MX8MP (NPU / CPU)
License-Expression: MIT
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: numpy>=1.21
Requires-Dist: opencv-python>=4.5
Provides-Extra: tflite
Requires-Dist: tflite-runtime; extra == "tflite"

# yolov8-tflite-imx

YOLOv8 INT8 TFLite webcam inference for **i.MX8MP** (phyBOARD-Pollux).  
Supports CPU and NPU acceleration via the VeriSilicon VX delegate.

---

## Included models

| Command   | Model task              | Default model path |
|-----------|-------------------------|--------------------|
| `detect`  | Object detection (COCO) | `yolov8n_saved_model/yolov8n_full_integer_quant.tflite` |
| `pose`    | Pose estimation         | `yolov8n-pose_saved_model/yolov8n-pose_full_integer_quant.tflite` |
| `obb`     | Oriented bounding box   | `yolov8n-obb_saved_model/yolov8n-obb_full_integer_quant.tflite` |
| `segment` | Instance segmentation   | `yolov8n-seg_saved_model/yolov8n-seg_full_integer_quant.tflite` |

---

## Installation

### On the i.MX8MP board (recommended)

```bash
# 1. Install tflite_runtime wheel for your Python / board combination
#    (download the correct .whl from https://github.com/google-coral/pycoral/releases
#     or build from source for your kernel)
pip install tflite_runtime-*.whl

# 2. Install this package
pip install yolov8-tflite-imx
```

### From source (development)

```bash
git clone https://github.com/yourname/yolov8-tflite-imx.git
cd yolov8-tflite-imx
pip install -e .
```

---

## Usage

### Object detection

```bash
# CPU
detect --cam 0 --model path/to/yolov8n_full_integer_quant.tflite

# NPU (VX delegate)
detect --cam 0 --npu --model path/to/yolov8n_full_integer_quant.tflite

# Custom delegate path
detect --cam 0 --delegate /usr/lib/libvx_delegate.so --model path/to/model.tflite
```

### Pose estimation

```bash
pose --cam 0                          # CPU
pose --cam 0 --npu                    # NPU
```

### Oriented bounding box (OBB)

```bash
obb --cam 0                           # CPU
obb --cam 0 --npu                     # NPU
```

### Instance segmentation

```bash
segment --cam 0                       # CPU
segment --cam 0 --npu                 # NPU
```

---

## All flags (same for every command)

| Flag | Default | Description |
|------|---------|-------------|
| `--model PATH` | see table above | Path to `.tflite` model |
| `--cam INT` | `0` | Camera device ID |
| `--conf FLOAT` | `0.25` | Confidence threshold |
| `--iou FLOAT` | `0.45` | NMS IoU threshold |
| `--npu` | off | Enable NPU via `/usr/lib/libvx_delegate.so` |
| `--delegate PATH` | None | Custom delegate `.so` (overrides `--npu`) |
| `--no-gst` | off | Disable GStreamer, use V4L2 directly |

### Keys while running

| Key | Action |
|-----|--------|
| `q` or `ESC` | Quit |
| `s` | Save current frame as `capture_<task>.jpg` |

---

## Requirements

- Python ≥ 3.8  
- `tflite_runtime` (installed separately for your board/arch)  
- `opencv-python` ≥ 4.5  
- `numpy` ≥ 1.21  
- NPU: `/usr/lib/libvx_delegate.so` present on the board  

---

## License

MIT
