Giter VIP home page Giter VIP logo

edafa's Introduction

Edafa

GitHub contributions welcome HitCount
Edafa is a simple wrapper that implements Test Time Augmentations (TTA) on images for computer vision problems like: segmentation, classification, super-resolution, Pansharpening, etc. TTAs guarantees better results in most of the tasks.

Test Time Augmentation (TTA)

Applying different transformations to test images and then average for more robust results.

pipeline

Installation

pip install edafa

Getting started

The easiest way to get up and running is to follow example notebooks for segmentation and classification showing TTA effect on performance.

How to use Edafa

The whole process can be done in 4 steps:

  1. Import Predictor class based on your task category: Segmentation (SegPredictor) or Classification (ClassPredictor)
from edafa import SegPredictor
  1. Inherit Predictor class and implement the main function
    • predict_patches(self,patches) : where your model takes image patches (numpy.ndarray) and return prediction (numpy.ndarray)
class myPredictor(SegPredictor):
    def __init__(self,model,*args,**kwargs):
        super().__init__(*args,**kwargs)
        self.model = model

    def predict_patches(self,patches):
        return self.model.predict(patches)
  1. Create an instance of you class
p = myPredictor(model,patch_size,model_output_channels,conf_file_path)
  1. Call predict_images() to run the prediction process
p.predict_images(images,overlap=0)

Configuration file

Configuration file is a json file containing two pieces of information

  1. 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
    • BRIGHT : Change image brightness randomly
    • CONTRAST : Change image contrast randomly
    • GAUSSIAN : Add random gaussian noise
    • GAMMA : Perform gamma correction with random gamma
  2. Combination of the results (mean). Supported mean types:
    • ARITH : Arithmetic mean
    • GEO : Geometric mean
  3. Number of bits image (default is 8-bits) (bits).

Example of a conf file in json format

{
"augs":["NO",
"FLIP_UD",
"FLIP_LR"],
"mean":"ARITH",
"bits":8
}

Example of a conf file in yaml format

augs: [NO,FLIP_UD,FLIP_LR]
mean: ARITH
bits: 8

You can either pass file path (json or yaml) or the actual json text to conf parameter.

Contribution

All contributions are welcomed. Please make sure that all tests passed before pull request. To run tests

nosetests

edafa's People

Contributors

andrewekhalel avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.