

<div align="center">
<h1>YOLO-ULM</h1>
<h3>YOLO-ULM: Ultra-Lightweight Models for Real-Time Object Detection</h3>


## Installation



```
wget https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.3/flash_attn-2.7.3+cu11torch2.2cxx11abiFALSE-cp311-cp311-linux_x86_64.whl
conda create -n yolo-ulm python=3.11
conda activate yolo-ulm
pip install -r requirements.txt
pip install -e .
```

## Validation
```python
from ultralytics import YOLO

# model = YOLO('yolov12{n/s/m/l/x}-ulm.pt') # Evaluate YOLO-ULM model
model = YOLO('yolov12{n/s/m/l/x}-ulm-Turbo.pt') # Evaluate YOLO-ULM-Trubo model
model.val(data='coco.yaml', save_json=True)
```

## Training 
```python
from ultralytics import YOLO

# model = YOLO('yolov12n-ulm.yaml') # Train YOLO-ULM model
model = YOLO('yolov12n-ulm-Turbo.yaml') # Train YOLO-ULM-Turbo model

# Train the model
results = model.train(
  data='coco.yaml',
  epochs=600, 
  batch=32, 
  imgsz=640,
  scale=0.5,  # S:0.9; M:0.9; L:0.9; X:0.9
  mosaic=1.0,
  mixup=0.0,  # S:0.05; M:0.15; L:0.15; X:0.2
  copy_paste=0.1,  # S:0.15; M:0.4; L:0.5; X:0.6
  device="0",
)

# Evaluate model performance on the validation set
metrics = model.val()

# Perform object detection on an image
results = model("path/to/image.jpg")
results[0].show()

```

## Prediction
```python
from ultralytics import YOLO

# model = YOLO('yolov12{n/s/m/l/x}-ulm.pt') # YOLO-ULM model prediction
model = YOLO('yolov12{n/s/m/l/x}-ulm-Turbo.pt') # YOLO-ULM-Turbo model prediction
model.predict()
```

## Export
```python
from ultralytics import YOLO

# model = YOLO('yolov12{n/s/m/l/x}-ulm.pt') # Export YOLO-ULM model 
model = YOLO('yolov12{n/s/m/l/x}-ulm-Turbo.pt') # Export YOLO-ULM-Turbo model 
model.export(format="engine", half=True)  # or format="onnx"
```




## Acknowledgement

The code is based on [ultralytics](https://github.com/ultralytics/ultralytics). Thanks for their excellent work!



