Giter Site home page Giter Site logo

gulfaraz / balancing-shape-texture-bias-in-imagenet-trained-vgg19 Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 1.0 67.72 MB

A study on the effect of normalization in predictions by CNN models

License: MIT License

Jupyter Notebook 99.25% Python 0.75%
artificial-intelligence deep-learning convolutional-neural-networks thesis uva bias shape-bias texture-bias normalization bilateral-filter

balancing-shape-texture-bias-in-imagenet-trained-vgg19's Introduction

BALANCING SHAPE-TEXTURE BIAS IN IMAGENET-TRAINED VGG19

This repository holds code used to run experiments for my 2019 Masters A.I. thesis research at the University of Amsterdam.

Thesis report is publicly available for download.

Presentation is publicly available on Google Drive.

Requirements

Anaconda

Then create a conda environment with torchenv.yml using,

conda env create -f torchenv.yml

torchenv conda environment should have the required packages to run the experiments.

Dataset

ImageNet200 - a subset of ImageNet was used to train and validate the models.

Use the .txt files in ImageNet200 folder to create the dataset.

Use Stylized-ImageNet to create the necessary stylized datasets.

Model Training

To train Vanilla model on non-stylized ImageNet200,

python run.py --model nonstylized_vgg19_vanilla_tune_fc --train

To train Single IN model on non-stylized ImageNet200,

python run.py --model nonstylized_vgg19_in_single_tune_all --train

To train Vanilla model on non-stylized ImageNet200 with bilateral filter,

python run.py --model nonstylized_bilateral_vgg19_vanilla_tune_fc --bilateral --train

To train VAE model with stylized target,

python run.py --model stylized_vae1024_beta0.2_gamma50.0 --numberOfEpochs 100 --zdim 1024 --beta 0.2 --gamma 50.0 --batchSize 32 --inputSize 128 --vaeImageSize 128 --dataset stylized --train

To train Single IN model with stylized latent representation as auxiliary signal,

python run.py --model stylized_latent_vgg19_in_single_tune_all --zdim 1024 --beta 0.2 --gamma 50.0 --batchSize 32 --dataset stylized --train

Model Evaluation

Run the same commands as training without the train flag.

To test Vanilla model,

python run.py --model nonstylized_vgg19_vanilla_tune_fc

Command Line Arguments

usage: run.py [-h] [--rootPath ROOTPATH] [--numberOfWorkers NUMBEROFWORKERS]
              [--bilateral] [--dataset {nonstylized,stylized,highpass}]
              [--disableCuda] [--cudaDevice CUDADEVICE]
              [--torchSeed TORCHSEED] [--inputSize INPUTSIZE]
              [--vaeImageSize VAEIMAGESIZE] [--numberOfEpochs NUMBEROFEPOCHS]
              [--batchSize BATCHSIZE] [--learningRate LEARNINGRATE]
              [--autoencoderLearningRate AUTOENCODERLEARNINGRATE]
              [--classifierLearningRate CLASSIFIERLEARNINGRATE] [--beta BETA]
              [--zdim ZDIM] [--gamma GAMMA] [--train] [--exists]
              [--model MODEL]

optional arguments:
  -h, --help            show this help message and exit
  --rootPath ROOTPATH   output path (default: /var/node433/local/gulfaraz)
  --numberOfWorkers NUMBEROFWORKERS
                        number of threads used by data loader (default: 8)
  --bilateral           apply bilateral filter at input layer (default: False)
  --dataset {nonstylized,stylized,highpass}
                        name of dataset to use for training (default:
                        nonstylized)
  --disableCuda         disable the use of CUDA (default: False)
  --cudaDevice CUDADEVICE
                        specify which GPU to use (default: 0)
  --torchSeed TORCHSEED
                        set a torch seed (default: 42)
  --inputSize INPUTSIZE
                        extent of input layer in the network (default: 224)
  --vaeImageSize VAEIMAGESIZE
                        extent of input and target layer in the autoencoder
                        (default: 128)
  --numberOfEpochs NUMBEROFEPOCHS
                        number of epochs for training (default: 50)
  --batchSize BATCHSIZE
                        batch size for training (default: 32)
  --learningRate LEARNINGRATE
                        learning rate for training (default: 0.0001)
  --autoencoderLearningRate AUTOENCODERLEARNINGRATE
                        learning rate for autoencoder training (default:
                        0.001)
  --classifierLearningRate CLASSIFIERLEARNINGRATE
                        learning rate for classifier training (default: 0.001)
  --beta BETA           beta value for the betavae loss (default: 0.2)
  --zdim ZDIM           latent space dimension size for the betavae (default:
                        128)
  --gamma GAMMA         weight of the classification loss in vae (default:
                        0.0)
  --train               train the models (default: False)
  --exists              check if the trained models exist (default: False)
  --model MODEL         name of model(s) (default: None)

Please feel free to create a GitHub issue for queries and bugs.

balancing-shape-texture-bias-in-imagenet-trained-vgg19's People

Contributors

gulfaraz avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

saikrishna197

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.