GithubHelp home page GithubHelp logo

resnet's Introduction

ResNet

Overview

ResNet serves as an extension to Keras Applications to include

  • ResNet-101
  • ResNet-152

The module is based on Felix Yu's implementation of ResNet-101 and ResNet-152, and his trained weights. Slight modifications have been made to make ResNet-101 and ResNet-152 have consistent API as those pre-trained models in Keras Applications. Code is also updated to Keras 2.0.

Installation

pip install resnet

Usuage

import resnet
import numpy as np
from keras.preprocessing.image import load_img, img_to_array

#-------------------------------------
#   Load pre-trained models
#-------------------------------------
resnet50  = resnet.ResNet50(weights='imagenet')
resnet101 = resnet.ResNet101(weights='imagenet')
resnet152 = resnet.ResNet152(weights='imagenet')

#-------------------------------------
#   Helper functions
#-------------------------------------
def path_to_tensor(image_path, target_size):
    image = load_img(image_path, target_size=target_size)
    tensor = img_to_array(image)
    tensor = np.expand_dims(tensor, axis=0)
    return tensor

#-------------------------------------
#   Make predictions
#-------------------------------------
image_path = 'examples/images/dog.jpeg'
image_tensor = path_to_tensor(image_path, (224, 224))
pred_resnet50  = np.argmax(resnet50.predict(image_tensor))
pred_resnet101 = np.argmax(resnet101.predict(image_tensor))
pred_resnet152 = np.argmax(resnet152.predict(image_tensor))

Sample dog image

The above dog image is predicted to have

  • 257: 'Great Pyrenees' by ResNet-50
  • 257: 'Great Pyrenees' by ResNet-101
  • 257: 'Great Pyrenees' by ResNet-152

Contact

If you have any questions or encounter any bugs, please contact the author (Feiyang Niu, [email protected])

References

  • He and etc 2015 Deep Residual Learning for Image Recognition arXiv:1512.03385
  • Felix Yu's original implementation of ResNet-101 is found here and ResNet-152 here.

resnet's People

Contributors

statech avatar

Stargazers

BAKHTI Yassine avatar

Watchers

James Cloos avatar paper2code - bot 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.