Skip to main content

ODAch, An Object Detection TTA tool for Pytorch

ODA is a test-time-augmentation (TTA) tool for 2d object detectors.

For use in Kaggle object detection competitions.

⭐ if it helps you! ;)

YOLO Integration

ODAch supports YOLOv5, YOLOv8, YOLOv9, YOLOv10, and YOLOv11 models from Ultralytics!

Quick Start with YOLO

import odach as oda
from ultralytics import YOLO

# Load your YOLO model
model = YOLO('yolov8n.pt')  # or yolov5, yolov9, yolov10, yolov11

# Wrap the YOLO model for ODAch
yolo_wrapper = oda.wrap_yolo(model, imsize=640, score_threshold=0.25)

# Define TTA transformations
tta = [oda.HorizontalFlip(), oda.VerticalFlip(), oda.Rotate90Left(), oda.Rotate90Right()]

# Create TTA wrapper
tta_model = oda.TTAWrapper(yolo_wrapper, tta)

# Run inference with TTA
results = tta_model(images)

YOLO Features

  • Multi-version support: YOLOv5, YOLOv8, YOLOv9, YOLOv10, YOLOv11
  • Automatic format conversion: Handles YOLO output format automatically
  • Batch processing: Process multiple images efficiently
  • Configurable thresholds: Adjust confidence and IoU thresholds
  • Seamless integration: Works with existing ODAch TTA pipeline

YOLO TTA Example

# Advanced YOLO TTA with multiple scales
tta = [
    oda.HorizontalFlip(),
    oda.VerticalFlip(),
    oda.Rotate90Left(),
    oda.Rotate90Right(),
    oda.Multiply(0.9),
    oda.Multiply(1.1)
]

# Multi-scale TTA
scale = [0.8, 0.9, 1.0, 1.1, 1.2]

# Create TTA wrapper with scales
tta_model = oda.TTAWrapper(yolo_wrapper, tta, scale)

# Run inference
results = tta_model(images)

See example_yolo_usage.py and YOLO_INTEGRATION_README.md for detailed examples.


Box Format Support

ODAch supports both VOC and COCO box formats:

Format Description Coordinates
VOC (Pascal) Default format [x1, y1, x2, y2]
COCO Alternative format [x, y, width, height]

Using Different Box Formats

import odach as oda

# VOC format (default): [x1, y1, x2, y2]
tta_model = oda.TTAWrapper(model, tta, box_format="voc")

# COCO format: [x, y, width, height]
tta_model = oda.TTAWrapper(model, tta, box_format="coco")

# Also available for wrap_yolo
yolo_wrapper = oda.wrap_yolo(model, box_format="coco")

Format Conversion Utilities

import odach as oda

# Convert VOC to COCO
coco_boxes = oda.voc_to_coco(voc_boxes)

# Convert COCO to VOC
voc_boxes = oda.coco_to_voc(coco_boxes)

Install

pip install odach

Development Installation

# Using uv (recommended)
uv sync --extra dev

# Run tests
uv run pytest tests/ -v

Usage

See Example.ipynb.

The setup is very simple, similar to ttach.

Singlescale TTA

import odach as oda
# Declare TTA variations
tta = [oda.HorizontalFlip(), oda.VerticalFlip(), oda.Rotate90Left(), oda.Multiply(0.9), oda.Multiply(1.1)]

# load image
img = loadimg(impath)
# wrap model and tta
tta_model = oda.TTAWrapper(model, tta)
# Execute TTA!
boxes, scores, labels = tta_model(img)

Multiscale TTA

import odach as oda
# Declare TTA variations
tta = [oda.HorizontalFlip(), oda.VerticalFlip(), oda.Rotate90Left(), oda.Multiply(0.9), oda.Multiply(1.1)]
# Declare scales to tta
scale = [0.8, 0.9, 1, 1.1, 1.2]

# load image
img = loadimg(impath)
# wrap model and tta
tta_model = oda.TTAWrapper(model, tta, scale)
# Execute TTA!
boxes, scores, labels = tta_model(img)
  • The boxes are also filtered by nms(wbf default).

  • The image size should be square.

Model Output Wrapping

# wrap effdet
oda_effdet = oda.wrap_effdet(effdet)
# Declare TTA variations
tta = [oda.HorizontalFlip(), oda.VerticalFlip(), oda.Rotate90Left()]
# Declare scales to tta
scale = [1]
# wrap model and tta
tta_model = oda.TTAWrapper(oda_effdet, tta, scale)

Examples

YOLO TTA Examples

  • example_yolo_usage.py - Basic YOLO integration
  • YOLO_INTEGRATION_README.md - Detailed YOLO usage guide

Global Wheat Detection

Example notebook

Thanks

nms, wbf are from https://kaggle.com/zfturbo

tta is based on https://github.com/qubvel/ttach, https://github.com/andrewekhalel/edafa/tree/master/edafa and https://www.kaggle.com/shonenkov/wbf-over-tta-single-model-efficientdet

Metadata

Release files for odach 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for odach 0.4.0
File Size Uploaded
odach-0.4.0.tar.gz 28.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for odach 0.4.0
File Interpreter ABI Platform
odach-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 43.5 kB

Release files / odach-0.4.0.tar.gz

Download URL odach-0.4.0.tar.gz
Size 28.5 kB
Tags Source
SHA-256 checksum
How to use checksums
4058e8eda4f2bec417758744f7933dc26166495626072f41a1737533e6623cc4
BLAKE2b-256 checksum
How to use checksums
15b839c35acde4eebf6d28881b0113dc350b7eb6e539d85606c8913bd6d1423e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Release files / odach-0.4.0-py3-none-any.whl

Download URL odach-0.4.0-py3-none-any.whl
Size 15.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f66f8af9c6e3689199adcfeeb865f4dfe4f3e1a07496d25ec8532a7f77ed7b38
BLAKE2b-256 checksum
How to use checksums
52e7e02dcdbc1eb60fcd2c4d498cf03a3e0f539f87b37dd2cbbc0bad94631dc6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page