Skip to content

SqueezeNet implementation with Keras Framework

License

Notifications You must be signed in to change notification settings

mpaditya/keras-squeezenet

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

keras-squeezenet

SqueezeNet v1.1 Implementation using Keras Functional Framework 1.1

This network model has AlexNet accuracy with small footprint (5.1 MB) Pretrained models are converted from original caffe network.

Library Versions

  • Keras v1.1
  • Tensorflow v10
  • Theano v0.8.2

Example Usage

  • Tensorflow backend with 'tf' dimension ordering
from scipy import misc
import copy
import numpy as np
from squeezenet import get_squeezenet

model = get_squeezenet(1000, dim_ordering='tf')
model.compile(loss="categorical_crossentropy", optimizer="adam")
model.load_weights('../model/squeezenet_weights_tf_dim_ordering_tf_kernels.h5', by_name=True)

# read and prepare image input
im = misc.imread('../images/cat.jpeg')
im = misc.imresize(im, (227, 227)).astype(np.float32)
aux = copy.copy(im)
im[:, :, 0] = aux[:, :, 2]
im[:, :, 2] = aux[:, :, 0]

# Remove image mean
im[:, :, 0] -= 104.006
im[:, :, 1] -= 116.669
im[:, :, 2] -= 122.679
im = np.expand_dims(im, axis=0)

res = model.predict(im)
  • Theano backend with 'th' dimension ordering
from scipy import misc
import copy
import numpy as np
from squeezenet import get_squeezenet

model = get_squeezenet(1000, dim_ordering='th')
model.compile(loss="categorical_crossentropy", optimizer="adam")
model.load_weights('../model/squeezenet_weights_th_dim_ordering_th_kernels.h5', by_name=True)

# read and prepare image input
im = misc.imread('../images/cat.jpeg')
im = misc.imresize(im, (227, 227)).astype(np.float32)
aux = copy.copy(im)
im[:, :, 0] = aux[:, :, 2]
im[:, :, 2] = aux[:, :, 0]

# Remove image mean
im[:, :, 0] -= 104.006
im[:, :, 1] -= 116.669
im[:, :, 2] -= 122.679
im = np.transpose(im, (2, 0, 1))
im = np.expand_dims(im, axis=0)

res = model.predict(im)

References

  1. Keras Framework

  2. SqueezeNet Official Github Repo

  3. SqueezeNet Paper

###Licence

MIT License

About

SqueezeNet implementation with Keras Framework

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%