All Projects → ecs-vlc → Fmix

ecs-vlc / Fmix

Licence: mit
Official implementation of 'FMix: Enhancing Mixed Sample Data Augmentation'

Projects that are alternatives of or similar to Fmix

Pba
Efficient Learning of Augmentation Policy Schedules
Stars: ✭ 461 (+82.94%)
Mutual labels:  jupyter-notebook, augmentation
Toolbox
various cv tools, such as label tools, data augmentation, label conversion, etc.
Stars: ✭ 279 (+10.71%)
Mutual labels:  jupyter-notebook, augmentation
Augmentor
Image augmentation library in Python for machine learning.
Stars: ✭ 4,594 (+1723.02%)
Mutual labels:  jupyter-notebook, augmentation
Deltapy
DeltaPy - Tabular Data Augmentation (by @firmai)
Stars: ✭ 344 (+36.51%)
Mutual labels:  jupyter-notebook, augmentation
Nlpaug
Data augmentation for NLP
Stars: ✭ 2,761 (+995.63%)
Mutual labels:  jupyter-notebook, augmentation
Effective python notebook
Stars: ✭ 251 (-0.4%)
Mutual labels:  jupyter-notebook
Shared
Shared Blogs and Notebooks
Stars: ✭ 252 (+0%)
Mutual labels:  jupyter-notebook
Pytorch Exercise
Practical Exercise Codes for PyTorch
Stars: ✭ 250 (-0.79%)
Mutual labels:  jupyter-notebook
Ml sagemaker studies
Case studies, examples, and exercises for learning to deploy ML models using AWS SageMaker.
Stars: ✭ 249 (-1.19%)
Mutual labels:  jupyter-notebook
Toonify
Stars: ✭ 253 (+0.4%)
Mutual labels:  jupyter-notebook
Eeap Examples
Code for Document Similarity on Reuters dataset using Encode, Embed, Attend, Predict recipe
Stars: ✭ 252 (+0%)
Mutual labels:  jupyter-notebook
Tutorials
Stars: ✭ 252 (+0%)
Mutual labels:  jupyter-notebook
Deep Learning Book
Repository for "Introduction to Artificial Neural Networks and Deep Learning: A Practical Guide with Applications in Python"
Stars: ✭ 2,705 (+973.41%)
Mutual labels:  jupyter-notebook
Coastsat
Global shoreline mapping tool from satellite imagery
Stars: ✭ 252 (+0%)
Mutual labels:  jupyter-notebook
Ai Projects
Artificial Intelligence projects, documentation and code.
Stars: ✭ 250 (-0.79%)
Mutual labels:  jupyter-notebook
Densereg
Code repository for DenseReg.
Stars: ✭ 252 (+0%)
Mutual labels:  jupyter-notebook
Ml Foundation And Ml Techniques
台大机器学习课程作业详解
Stars: ✭ 249 (-1.19%)
Mutual labels:  jupyter-notebook
Modern practical nlp
This course covers how you can use NLP to do stuff.
Stars: ✭ 252 (+0%)
Mutual labels:  jupyter-notebook
Selene
a framework for training sequence-level deep learning networks
Stars: ✭ 252 (+0%)
Mutual labels:  jupyter-notebook
Team Learning Program
主要存储Datawhale组队学习中“编程、数据结构与算法”方向的资料。
Stars: ✭ 247 (-1.98%)
Mutual labels:  jupyter-notebook

About

FMix is a variant of MixUp, CutMix, etc. introduced in our paper 'FMix: Enhancing Mixed Sampled Data Augmentation'. It uses masks sampled from Fourier space to mix training examples. Take a look at our example notebook in colab which shows how you can generate masks in two dimensions

and in three!

Experiments

Core Experiments

Shell scripts for our core experiments can be found in the experiments folder. For example,

bash cifar_experiment cifar10 resnet fmix ./data

will train a PreAct-ResNet18 on CIFAR-10 with FMix. More information can be found at the start of each of the shell files.

Additional Experiments

All additional classification experiments can be run via trainer.py

Analyses

For Grad-CAM, take a look at the Grad-CAM notebook in colab.

For the other analyses, have a look in the analysis folder.

Implementations

The core implementation of FMix uses numpy and can be found in fmix.py. We provide bindings for this in PyTorch (with Torchbearer or PyTorch-Lightning) and Tensorflow.

Torchbearer

The FMix callback in torchbearer_implementation.py can be added directly to your torchbearer code:

from implementations.torchbearer_implementation import FMix

fmix = FMix()
trial = Trial(model, optimiser, fmix.loss(), callbacks=[fmix])

See an example in test_torchbearer.py.

PyTorch-Lightning

For PyTorch-Lightning, we provide a class, FMix in lightning.py that can be used in your LightningModule:

from implementations.lightning import FMix

class CoolSystem(pl.LightningModule):
    def __init__(self):
        ...
        
        self.fmix = FMix()
    
    def training_step(self, batch, batch_nb):
        x, y = batch
        x = self.fmix(x)

        x = self.forward(x)

        loss = self.fmix.loss(x, y)
        return {'loss': loss}

See an example in test_lightning.py.

Tensorflow

For Tensorflow, we provide a class, FMix in tensorflow_implementation.py that can be used in your tensorflow code:

from implementations.tensorflow_implementation import FMix

fmix = FMix()

def loss(model, x, y, training=True):
    x = fmix(x)
    y_ = model(x, training=training)
    return tf.reduce_mean(fmix.loss(y_, y))

See an example in test_tensorflow.py.

Pre-trained Models

We provide pre-trained models via torch.hub (more coming soon). To use them, run

import torch
model = torch.hub.load('ecs-vlc/FMix:master', ARCHITECTURE, pretrained=True)

where ARCHITECTURE is one of the following:

CIFAR-10

PreAct-ResNet-18

Configuration ARCHITECTURE Accuracy
Baseline 'preact_resnet18_cifar10_baseline' --------
+ MixUp 'preact_resnet18_cifar10_mixup' --------
+ FMix 'preact_resnet18_cifar10_fmix' --------
+ Mixup + FMix 'preact_resnet18_cifar10_fmixplusmixup' --------

PyramidNet-200

Configuration ARCHITECTURE Accuracy
Baseline 'pyramidnet_cifar10_baseline' 98.31
+ MixUp 'pyramidnet_cifar10_mixup' 97.92
+ FMix 'pyramidnet_cifar10_fmix' 98.64

ImageNet

ResNet-101

Configuration ARCHITECTURE Accuracy (Top-1)
Baseline 'renset101_imagenet_baseline' 76.51
+ MixUp 'renset101_imagenet_mixup' 76.27
+ FMix 'renset101_imagenet_fmix' 76.72
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].