extract_bottleneck_features.py 932 B

12345678910111213141516171819
  1. def extract_VGG16(tensor):
  2. from keras.applications.vgg16 import VGG16, preprocess_input
  3. return VGG16(weights='imagenet', include_top=False).predict(preprocess_input(tensor))
  4. def extract_VGG19(tensor):
  5. from keras.applications.vgg19 import VGG19, preprocess_input
  6. return VGG19(weights='imagenet', include_top=False).predict(preprocess_input(tensor))
  7. def extract_Resnet50(tensor):
  8. from keras.applications.resnet50 import ResNet50, preprocess_input
  9. return ResNet50(weights='imagenet', include_top=False).predict(preprocess_input(tensor))
  10. def extract_Xception(tensor):
  11. from keras.applications.xception import Xception, preprocess_input
  12. return Xception(weights='imagenet', include_top=False).predict(preprocess_input(tensor))
  13. def extract_InceptionV3(tensor):
  14. from keras.applications.inception_v3 import InceptionV3, preprocess_input
  15. return InceptionV3(weights='imagenet', include_top=False).predict(preprocess_input(tensor))