Upload extract_bottleneck_features.py
Browse files
extract_bottleneck_features.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
|
| 5 |
+
def extract_VGG19(tensor):
|
| 6 |
+
from keras.applications.vgg19 import VGG19, preprocess_input
|
| 7 |
+
return VGG19(weights='imagenet', include_top=False).predict(preprocess_input(tensor))
|
| 8 |
+
|
| 9 |
+
def extract_Resnet50(tensor):
|
| 10 |
+
from tensorflow.keras.applications.resnet50 import ResNet50, preprocess_input
|
| 11 |
+
return ResNet50(weights='imagenet', include_top=False).predict(preprocess_input(tensor))
|
| 12 |
+
|
| 13 |
+
def extract_Xception(tensor):
|
| 14 |
+
from keras.applications.xception import Xception, preprocess_input
|
| 15 |
+
return Xception(weights='imagenet', include_top=False).predict(preprocess_input(tensor))
|
| 16 |
+
|
| 17 |
+
def extract_InceptionV3(tensor):
|
| 18 |
+
from keras.applications.inception_v3 import InceptionV3, preprocess_input
|
| 19 |
+
return InceptionV3(weights='imagenet', include_top=False).predict(preprocess_input(tensor))
|