Giter Club home page Giter Club logo

cnn-for-food-classification's Introduction

Open in Visual Studio Code

CSE 151B PA3: CNN for Food Images Classification

Contributers: Ang Li, Fenghao Yang, Yikai Mao, Jinghao Miao

Get Data

First run get_data.sh to get Food 101 dataset

Run

To run the code, run the main.py file and there are arguments that user can input for hyperparmeters, which includes:

  • device_id (The id of the gpu to use; type=int; default=0)
  • model (Model being used including baseline, custom, resnet18, and vgg16; type=str; default='custom')
  • pt_ft (Whether model is for partial fine-tune model; type=int; default=1)
  • bz (Batch size; type=int; default=32)
  • shuffle_data (Whether shuffle the data; type=int; default=1)
  • normalization_mean (Mean value of z-scoring normalization for each channel in image; type=tuple; default=(0.485, 0.456, 0.406))
  • normalization_std (Standard deviation of z-scoring normalization for each channel in image; type=tuple; default=(0.229, 0.224, 0.225))
  • epoch (Number of epoch; type=int; default=30)
  • criterion (Which loss function to use; type=str; default='cross_entropy')
  • optimizer (Which optimizer to use; type=str; default='adam')
  • lr (Learning rate; type=float; default=1e-4)
  • weight_decay (weight decay; type=float; default=1e-4)
  • lr_scheduling (Whether enable learning rate scheduling; type=int; default=0)
  • lr_scheduler (Learning rate scheduler; type=str; default='steplr')
  • step_size (Period of learning rate decay; type=int; default=7)
  • gamma (Multiplicative factor of learning rate decay; type=float; default=0.1)

Directly run the code with

python3 main.py

will train the and test the performance of baseline model. The results will be saved in results.pkl after training is finished, and can be used by visualization.ipynb to visualize the loss/accuracy graph.

Files

  • main.py: file for the entire code
  • prepare_data.py: file to load the dataset
  • data.py: file to pre-processe data, split train, validation and test set, create dataloader
  • model.py: file with implementation of baseline, custom, resnet-18, vgg-16 model
  • engine.py: file to prepare, train, test model, and save the results to results.pkl
  • visualization.ipynb: notebook to plot graphs, visualize weight maps and feature maps

cnn-for-food-classification's People

Contributors

lapernum avatar ym820 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.