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! ;)
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.Rotate90(), 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.Rotate90(), 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 your detection model so that the output is similar to torchvision frcnn format: [["box":[[x,y,x2,y2], [], ..], "labels": [0,1,..], "scores": [1.0, 0.8, ..]]
-
Example for EfficientDets https://www.kaggle.com/kyoshioka47/example-of-2d-single-scale-tta-with-odach/
# wrap effdet
oda_effdet = oda.wrap_effdet(effdet)
# Declare TTA variations
tta = [oda.HorizontalFlip(), oda.VerticalFlip(), oda.Rotate90()]
# Declare scales to tta
scale = [1]
# wrap model and tta
tta_model = oda.TTAWrapper(oda_effdet, tta, scale)
Example
Global Wheat Detection
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.1.5-2011180124
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| odach-0.1.5-2011180124.tar.gz | 9.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| odach-0.1.5.post2011180124-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 20.4 kB
Release files / odach-0.1.5-2011180124.tar.gz
| Download URL | odach-0.1.5-2011180124.tar.gz |
|---|---|
| Size | 9.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0d6c59cc25419655ae225e4a90f2bd3d6abf167756def597c197dfcc19dded5d
|
|
BLAKE2b-256 checksum How to use checksums |
472db50108282f9be2000359a28548d853e15bf87a7d4230cd6f964245a21425
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.9.0
|
Release files / odach-0.1.5.post2011180124-py3-none-any.whl
| Download URL | odach-0.1.5.post2011180124-py3-none-any.whl |
|---|---|
| Size | 10.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7589a17eea1dc8c20995ed85f54350accbce25ac07775e37ade2d0e6c52b4dd3
|
|
BLAKE2b-256 checksum How to use checksums |
ad5c2a7c44cf6c4ac4e933596ca44c068b509d67bf0abb610b779e864edf1880
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.9.0
|