GithubHelp home page GithubHelp logo

magic-chao / resnet-18-tensorflow Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dalgu90/resnet-18-tensorflow

0.0 2.0 0.0 13.1 MB

ResNet-18 TensorFlow Implementation including conversion of torch .t7 weights into tensorflow ckpt

Python 96.85% Shell 3.15%

resnet-18-tensorflow's Introduction

resnet-18-tensorflow

A TensorFlow implementation of ResNet-18(https://arxiv.org/abs/1512.03385)

Prerequisite

  1. TensorFlow 1.8
  2. The ImageNet dataset
  • All image files are required to be valid JPEG files. See this gist.
  • It is highly recommened for every image to be resized so that the shorter side is 256.
  1. (Optional) Torchfile(to convert ResNet-18 .t7 checkpoint into tensorflow checkpoint. Install with a command pip install torchfile)

How To Run

  • (Optional) Convert torch .t7 into tensorflow ckpt
# Download the ResNet-18 torch checkpoint
wget https://d2j0dndfm35trm.cloudfront.net/resnet-18.t7
# Convert into tensorflow checkpoint
python extract_torch_t7.py
  1. Modify train_scratch.sh(training from scratch) or train.sh(finetune pretrained weights) to have valid values of following arguments
  • train_dataset, train_image_root, val_dataset, val_image_root: Path to the list file of train/val dataset and to the root
  • num_gpus and corresponding IDs of GPUs(CUDA_VISIBLE_DEVICES at the first line)
  1. Run!
  • ./train.sh if you want to finetune the converted ResNet(NOTE: The model needs to be finetuned for some epochs)
  • ./train_scratch.sh if you want to train ResNet from scratch
  1. Evaluate the trained model
  • ./eval.sh for evaluating the trained model(change the arguments in eval.sh to your preference)

Note

  • The extracted weights should be finetuned for several epochs(run ./train.sh) to get the full performance(If you run the evaluation code without finetuning, the single-crop top-1 validation accuracy is about 60%, which is less than the appeared in the original). I guess there is some minor issue that I have missed.

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.