Image classification models. Keras.
Project description
Classification models Zoo
Pretrained classification models for Keras
Models:
Model | Classes | Weights | No top | Preprocessing |
---|---|---|---|---|
ResNet18 | 1000 | imagenet |
+ | BGR |
ResNet34 | 1000 | imagenet |
+ | BGR |
ResNet50 | 1000 11586 |
imagenet imagenet11k-place365ch |
+ | BGR |
ResNet101 | 1000 | imagenet |
+ | BGR |
ResNet152 | 1000 11221 |
imagenet imagenet11k |
+ | BGR |
ResNeXt50 | 1000 | imagenet |
+ | - |
ResNeXt101 | 1000 | imagenet |
+ | - |
Example
Imagenet inference example:
import numpy as np
from skimage.io import imread
from keras.applications.imagenet_utils import decode_predictions
from classification_models import ResNet18
from classification_models.resnet import preprocess_input
# read and prepare image
x = imread('./imgs/tests/seagull.jpg')
x = preprocess_input(x, size=(224,224))
x = np.expand_dims(x, 0)
# load model
model = ResNet18(input_shape=(224,224,3), weights='imagenet', classes=1000)
# processing image
y = model.predict(x)
# result
print(decode_predictions(y))
Model fine-tuning example:
import keras
from classification_models import ResNet18
# prepare your data
X = ...
y = ...
n_classes = 10
# build model
base_model = ResNet18(input_shape=(224,224,3), weights='imagenet', include_top=False)
x = keras.layers.AveragePooling2D((7,7))(base_model.output)
x = keras.layers.Dropout(0.3)(x)
output = keras.layers.Dense(n_classes)(x)
model = keras.models.Model(inputs=[base_model.input], outputs=[output])
# train
model.compile(optimizer='SGD', loss='categorical_crossentropy', metrics=['accuracy'])
model.fit(X, y)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for image_classifiers-0.1.0rc0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 296a81db1e02e08ce1642a1153e5c113da1a7aa73fa8f7e9da15b39d82037467 |
|
MD5 | ad55c2d02bcb89c57672710afa633766 |
|
BLAKE2b-256 | cb1d64133e814e9f18c58fba4f5226ea562caca5a3c85af5e98faa919ee9b5be |
Close
Hashes for image_classifiers-0.1.0rc0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 51eaab498a68168f6dbd85f6088cb033658226995e3e467cc465ecc45c340d36 |
|
MD5 | f2df8e3d21fb108b4072bba453ae3240 |
|
BLAKE2b-256 | 551080588eb0b79b51d0eb31f47896e8b4f9588f0328cbb44f4abfb5e6a1b8be |