Skip to main content

ODAch is a test-time-augmentation tool for pytorch 2d object detectors with YOLO support.

Project description

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.

:star: if it helps you! ;)

🚀 YOLO Integration (New!)

ODAch now supports YOLOv5, YOLOv8, and newer YOLO models from Ultralytics! This is the most important feature for modern object detection workflows.

Quick Start with YOLO

import odach as oda
from ultralytics import YOLO

# Load your YOLO model
model = YOLO('yolov8n.pt')  # or yolov5, yolov6, yolov7, yolov8, yolov9

# 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, YOLOv6, YOLOv7, YOLOv8, YOLOv9
  • 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.


Install

pip install odach

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

odach-0.2.0.tar.gz (19.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

odach-0.2.0-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

Details for the file odach-0.2.0.tar.gz.

File metadata

  • Download URL: odach-0.2.0.tar.gz
  • Upload date:
  • Size: 19.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.10

File hashes

Hashes for odach-0.2.0.tar.gz
Algorithm Hash digest
SHA256 d81df9f4ab7ce1aaef6970f92ad0198078a224c1fc364fbadbb9644edd26c9c8
MD5 a0d00a219f74470dd4d7aee9b58e9b30
BLAKE2b-256 eac3e4e96d13b8774a42441b373dd7827670f1f4e4ad5a4e5e78dcec53a9d039

See more details on using hashes here.

File details

Details for the file odach-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: odach-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 13.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.10

File hashes

Hashes for odach-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8218906f4ebc6c9d5ca51eefd45461635aa3d3b9aadb94a68c1c324c1062f997
MD5 4693f1e2c65b3c8b64e3d76373f52c84
BLAKE2b-256 deb76b0b0054667132a96f54c7cb8cfe77839bfada47de76293ad6ecffcb0b8c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page