Test Time Augmentation (TTA) wrapper for computer vision tasks: segmentation, super-resolution, ... etc.
Project description
Edafa
Edafa is a simple wrapper that implements Test Time Augmentations (TTA) on images for computer vision problems like: segmentation, super-resolution, Pansharpening, etc. TTAs guarantees better results in most of the tasks.
Installation
PyPI pacakage will be avaialble soon
Getting started
The easiest way to get up and running is to follow this notebook showing an example on using Edafa to improve segmentation score on PASCAL VOC dataset.
How to use Edafa
The whole process can be done in 4 steps:
- Import
BasePredictor
abstract class
from edafa import BasePredictor
- Inherit
BasePredictor
to your own class and implement the main 3 functionspreprocess(self,img)
: Implement preprocessing needed after reading image from disk (e.g. normalization, .. )postprocess(self,pred)
: Implement postprocessing needed after predicting an image (e.g. clipping, argmax, .. )predict_patches(self,patches)
: The function where your model takes image patches and return their prediction
class myPredictor(BasePredictor):
def __init__(self,model,*args,**kwargs):
super().__init__(*args,**kwargs)
self.model = model
def preprocess(self,img):
return normalize(img)
def postprocess(self,pred):
return clipping(pred)
def predict_patches(self,patches):
return self.model.predict(patches)
- Create an instance of you class
p = myPredictor(model,patch_size,model_output_channels,conf_file_path)
- Call
predict_dir()
to run the prediction process
p.predict_dir(in_dir,out_dir,overlap=0,extension='.png')
Configuration file
Configuration file is a json file containing two pieces of information
- Augmentations to apply (augs). Supported augmentations:
- NO : No augmentation
- ROT90 : Rotate 90 degrees
- ROT180 : Rotate 180 degrees
- ROT270 : Rotate 270 degrees
- FLIP_UD : Flip upside-down
- FLIP_LR : Flip left-right
- Combination of the results (mean). Supported mean types:
- ARITHMETIC : Arithmetic mean
- GEOMETRIC : Geometric mean
Example of a conf file
{
"augs":["NO",
"FLIP_UD",
"FLIP_LR"],
"mean":"ARITHMETIC"
}
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.