Skip to content

Instantly share code, notes, and snippets.

@netsatsawat
Created June 18, 2019 04:20
Show Gist options
  • Save netsatsawat/92b78caca064814ec2fe72fd471ada41 to your computer and use it in GitHub Desktop.
Save netsatsawat/92b78caca064814ec2fe72fd471ada41 to your computer and use it in GitHub Desktop.
For loading pretrained feature extractor - Malaria dataset
feature_extractor_url = "https://tfhub.dev/google/imagenet/mobilenet_v2_140_224/feature_vector/3"
def feature_extractor(x):
feature_extractor_module = hub.Module(feature_extractor_url)
return feature_extractor_module(x)
IMAGE_SIZE = hub.get_expected_image_size(hub.Module(feature_extractor_url))
print('Expected size : %s' % IMAGE_SIZE)
# Expected size : [224, 224]
features_extractor_layer = layers.Lambda(feature_extractor, input_shape=IMAGE_SIZE+[3])
features_extractor_layer.trainable = False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment