MCPcopy
hub / github.com/fchollet/deep-learning-models

github.com/fchollet/deep-learning-models @v0.8 sqlite

repository ↗ · DeepWiki ↗ · release v0.8 ↗
31 symbols 221 edges 10 files 19 documented · 61%
README

Trained image classification models for Keras

THIS REPOSITORY IS DEPRECATED. USE THE MODULE keras.applications INSTEAD.

Pull requests will not be reviewed nor merged. Direct any PRs to keras.applications. Issues are not monitored either.


This repository contains code for the following Keras models:

  • VGG16
  • VGG19
  • ResNet50
  • Inception v3
  • CRNN for music tagging

All architectures are compatible with both TensorFlow and Theano, and upon instantiation the models will be built according to the image dimension ordering set in your Keras configuration file at ~/.keras/keras.json. For instance, if you have set image_dim_ordering=tf, then any model loaded from this repository will get built according to the TensorFlow dimension ordering convention, "Width-Height-Depth".

Pre-trained weights can be automatically loaded upon instantiation (weights='imagenet' argument in model constructor for all image models, weights='msd' for the music tagging model). Weights are automatically downloaded if necessary, and cached locally in ~/.keras/models/.

Examples

Classify images

from resnet50 import ResNet50
from keras.preprocessing import image
from imagenet_utils import preprocess_input, decode_predictions

model = ResNet50(weights='imagenet')

img_path = 'elephant.jpg'
img = image.load_img(img_path, target_size=(224, 224))
x = image.img_to_array(img)
x = np.expand_dims(x, axis=0)
x = preprocess_input(x)

preds = model.predict(x)
print('Predicted:', decode_predictions(preds))
# print: [[u'n02504458', u'African_elephant']]

Extract features from images

from vgg16 import VGG16
from keras.preprocessing import image
from imagenet_utils import preprocess_input

model = VGG16(weights='imagenet', include_top=False)

img_path = 'elephant.jpg'
img = image.load_img(img_path, target_size=(224, 224))
x = image.img_to_array(img)
x = np.expand_dims(x, axis=0)
x = preprocess_input(x)

features = model.predict(x)

Extract features from an arbitrary intermediate layer

from vgg19 import VGG19
from keras.preprocessing import image
from imagenet_utils import preprocess_input
from keras.models import Model

base_model = VGG19(weights='imagenet')
model = Model(input=base_model.input, output=base_model.get_layer('block4_pool').output)

img_path = 'elephant.jpg'
img = image.load_img(img_path, target_size=(224, 224))
x = image.img_to_array(img)
x = np.expand_dims(x, axis=0)
x = preprocess_input(x)

block4_pool_features = model.predict(x)

References

Additionally, don't forget to cite Keras if you use these models.

License

Core symbols most depended-on inside this repo

conv2d_bn
called by 75
inception_v3.py
conv2d_bn
called by 39
inception_resnet_v2.py
_depthwise_conv_block
called by 13
mobilenet.py
identity_block
called by 12
resnet50.py
decode_predictions
called by 7
imagenet_utils.py
conv_block
called by 4
resnet50.py
inception_resnet_block
called by 4
inception_resnet_v2.py
preprocess_input
called by 3
imagenet_utils.py

Shape

Function 25
Method 5
Class 1

Languages

Python100%

Modules by API surface

mobilenet.py11 symbols
inception_resnet_v2.py4 symbols
resnet50.py3 symbols
inception_v3.py3 symbols
audio_conv_utils.py3 symbols
xception.py2 symbols
imagenet_utils.py2 symbols
vgg19.py1 symbols
vgg16.py1 symbols
music_tagger_crnn.py1 symbols

For agents

$ claude mcp add deep-learning-models \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact