Package: image-classifiers
Classification models Zoo - Keras (and TensorFlow Keras)Trained onImageNetclassification models.
The library is designed to work both withKerasandTensorFlow Keras. See example below.Important!There was a huge library update05 of August. Now classification-models works with both frameworks:kerasandtensorflow.keras.
If you have models, trained before that date, to load them, please, useimage-classifiers(PyPI package name) of 0.2.2 version. You can roll back usingpip install -U image-classifiers==0.2.2.Architectures:VGG[16, 19]ResNet[18, 34, 50, 101, 152]ResNeXt[50, 101]SE-ResNet[18, 34, 50, 101, 152]SE-ResNeXt[50, 101]SE-Net[154]DenseNet[121, 169, 201]Inception ResNet V2Inception V3XceptionNASNet[large, mobile]MobileNetMobileNet v2SpecificationThe top-k accuracy were obtained using center single crop on the
2012 ILSVRC ImageNet validation set and may differ from the original ones.
The input size used was 224x224 (min size 256) for all models except:NASNetLarge 331x331 (352)InceptionV3 299x299 (324)InceptionResNetV2 299x299 (324)Xception 299x299 (324)The inference *Time was evaluated on 500 batches of size 16.
All models have been tested using same hardware and software.
Time is listed just for comparison of performance.ModelAcc@1Acc@5Time*Sourcevgg1670.7989.7424.95kerasvgg1970.8989.6924.95kerasresnet1868.2488.4916.07mxnetresnet3472.1790.7417.37mxnetresnet5074.8192.3822.62mxnetresnet10176.5893.1033.03mxnetresnet15276.6693.0842.37mxnetresnet50v269.7389.3119.56kerasresnet101v271.9390.4128.80kerasresnet152v272.2990.6141.09kerasresnext5077.3693.4837.57kerasresnext10178.4894.0060.07kerasdensenet12174.6792.0427.66kerasdensenet16975.8592.9333.71kerasdensenet20177.1393.4342.40kerasinceptionv377.5593.4838.94kerasxception78.8794.2042.18kerasinceptionresnetv280.0394.8954.77kerasseresnet1869.4188.8420.19pytorchseresnet3472.6090.9122.20pytorchseresnet5076.4493.0223.64pytorchseresnet10177.9294.0032.55pytorchseresnet15278.3494.0847.88pytorchseresnext5078.7494.3038.29pytorchseresnext10179.8894.8762.80pytorchsenet15481.0695.24137.36pytorchnasnetlarge82.1295.72116.53kerasnasnetmobile74.0491.5427.73kerasmobilenet70.3689.3915.50kerasmobilenetv271.6390.3518.31kerasWeightsNameClassesModels'imagenet'1000all models'imagenet11k-place365ch'11586resnet50'imagenet11k'11221resnet152InstallationRequirements:Keras >= 2.2.0 / TensorFlow >= 1.12keras_applications >= 1.0.7NoteThis library does not have TensorFlow in a requirements for installation. 
Please, choose suitable version (‘cpu’/’gpu’) and install it manually using 
official Guide (https://www.tensorflow.org/install/).PyPI stable package:$pipinstallimage-classifiers==0.2.2PyPI latest package:$pipinstallimage-classifiers==1.0.0b1Latest version:$pipinstallgit+https://github.com/qubvel/classification_models.gitExamplesLoading model withimagenetweights:# for kerasfromclassification_models.kerasimportClassifiers# for tensorflow.keras# from classification_models.tfkeras import ClassifiersResNet18,preprocess_input=Classifiers.get('resnet18')model=ResNet18((224,224,3),weights='imagenet')This way take one additional line of code, however if you would
like to train several models you do not need to import them directly,
just access everything throughClassifiers.You can get all model names usingClassifiers.models_names()method.Inference example:importnumpyasnpfromskimage.ioimportimreadfromskimage.transformimportresizefromkeras.applications.imagenet_utilsimportdecode_predictionsfromclassification_models.kerasimportClassifiersResNet18,preprocess_input=Classifiers.get('resnet18')# read and prepare imagex=imread('./imgs/tests/seagull.jpg')x=resize(x,(224,224))*255# cast back to 0-255 rangex=preprocess_input(x)x=np.expand_dims(x,0)# load modelmodel=ResNet18(input_shape=(224,224,3),weights='imagenet',classes=1000)# processing imagey=model.predict(x)# resultprint(decode_predictions(y))Model fine-tuning example:importkerasfromclassification_models.kerasimportClassifiersResNet18,preprocess_input=Classifiers.get('resnet18')# prepare your dataX=...y=...X=preprocess_input(X)n_classes=10# build modelbase_model=ResNet18(input_shape=(224,224,3),weights='imagenet',include_top=False)x=keras.layers.GlobalAveragePooling2D()(base_model.output)output=keras.layers.Dense(n_classes,activation='softmax')(x)model=keras.models.Model(inputs=[base_model.input],outputs=[output])# trainmodel.compile(optimizer='SGD',loss='categorical_crossentropy',metrics=['accuracy'])model.fit(X,y)