Code Monkey home page Code Monkey logo

data-augmentation-pytorch's Introduction

Data-Augmentation-Pytorch

Data-Augmentation example based on torchsample


1. Introduction.

This is an example which adopts torchsample package to implement data augmentation. This package provides many data augmentation methods such as rotation, zoom in or out.

2. Demo

The CIFAR-10 classification task is used to show how to utilize this package to implement data augmentation.

2.1. Run Demo:

python main.py

and

python advanced_main.py

2.2. Implementation:

Standard method: (random horizontal flip data augmentation.)

import torchvision.transforms as transforms
import torchsample as ts
train_tf= transforms.Compose([
            transforms.RandomHorizontalFlip(), # data augmentation: random horizontal flip
            transforms.Scale(256),
            transforms.CenterCrop(224),
            transforms.ToTensor(),
            transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
        ])

Adding rotation data augmentation:

import torchvision.transforms as transforms
import torchsample as ts
train_tf= transforms.Compose([
            transforms.RandomHorizontalFlip(),
            transforms.Scale(256),
            transforms.CenterCrop(224),
            transforms.ToTensor(),
            ts.transforms.Rotate(20), # data augmentation: rotation 
            ts.transforms.Rotate(-20), # data augmentation: rotation
            transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
        ])

2.3. Accuracy.

The final accuracy is shown as follows:

Network Baselines Data Augmentation/(Rotation)
AlexNet (No pretrained)

2.4. Convergence Curve.

3. Acknowledgement.

The torchsample is a very awesome package implemented by Nick Cullen.

data-augmentation-pytorch's People

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.