diff --git a/lucid/modelzoo/caffe_models/AlexNet.py b/lucid/modelzoo/caffe_models/AlexNet.py index b635d411..cf6c1c94 100644 --- a/lucid/modelzoo/caffe_models/AlexNet.py +++ b/lucid/modelzoo/caffe_models/AlexNet.py @@ -17,39 +17,6 @@ from lucid.modelzoo.vision_base import Model, IMAGENET_MEAN_BGR -class AlexNet_caffe(Model): - """Original AlexNet weights ported to TF. - - AlexNet is the breakthrough vision model from Krizhevsky, et al (2012): - https://papers.nips.cc/paper/4824-imagenet-classification-with-deep-convolutional-neural-networks.pdf - This implementation is a caffe re-implementation: - http://www.cs.toronto.edu/~guerzhoy/tf_alexnet/ - It was converted to TensorFlow by this GitHub project: - https://github.com/huanzhang12/tensorflow-alexnet-model - It appears the parameters are the actual original parameters. - """ - - # The authors of code to convert AlexNet to TF host weights at - # http://jaina.cs.ucdavis.edu/datasets/adv/imagenet/alexnet_frozen.pb - # but it seems more polite and reliable to host our own. - model_path = 'gs://modelzoo/AlexNet.pb' - labels_path = 'gs://modelzoo/labels/ImageNet_standard.txt' - dataset = 'ImageNet' - image_shape = [227, 227, 3] - is_BGR = True - image_value_range = (-IMAGENET_MEAN_BGR, 255-IMAGENET_MEAN_BGR) - input_name = 'Placeholder' - - # TODO - Sanity check this graph and layers - layers = [ - {'type': 'conv', 'name': 'concat_2', 'size': 256}, - {'type': 'conv', 'name': 'conv5_1', 'size': 256}, - {'type': 'dense', 'name': 'Relu', 'size': 4096}, - {'type': 'dense', 'name': 'Relu_1', 'size': 4096}, - {'type': 'dense', 'name': 'Softmax', 'size': 1000}, - ] - - class AlexNet_caffe_Places365(Model): """AlexNet re-implementation trained on Places365. @@ -60,7 +27,7 @@ class AlexNet_caffe_Places365(Model): and then ported to TensorFlow using caffe-tensorflow. """ - model_path = 'gs://modelzoo/AlexNet_caffe_places365.pb' + model_path = 'gs://modelzoo/vision/caffe_models/AlexNet_places365.pb' labels_path = 'gs://modelzoo/labels/Places365.txt' dataset = 'Places365' image_shape = [227, 227, 3] diff --git a/lucid/modelzoo/caffe_models/InceptionV1.py b/lucid/modelzoo/caffe_models/InceptionV1.py index b976d196..3dcce55d 100644 --- a/lucid/modelzoo/caffe_models/InceptionV1.py +++ b/lucid/modelzoo/caffe_models/InceptionV1.py @@ -26,7 +26,7 @@ class InceptionV1_caffe(Model): https://github.com/BVLC/caffe/tree/master/models/bvlc_googlenet and then ported to TensorFlow using caffe-tensorflow. """ - model_path = 'gs://modelzoo/InceptionV1_caffe.pb' + model_path = 'gs://modelzoo/vision/caffe_models/InceptionV1.pb' labels_path = 'gs://modelzoo/labels/ImageNet_standard.txt' dataset = 'ImageNet' image_shape = [224, 224, 3] @@ -60,7 +60,7 @@ class InceptionV1_caffe_Places205(Model): http://places.csail.mit.edu/downloadCNN.html and then ported to TensorFlow using caffe-tensorflow. """ - model_path = 'gs://modelzoo/InceptionV1_caffe_places205.pb' + model_path = 'gs://modelzoo/vision/caffe_models/InceptionV1_places205.pb' labels_path = 'gs://modelzoo/labels/Places205.txt' dataset = 'Places205' image_shape = [224, 224, 3] @@ -94,7 +94,7 @@ class InceptionV1_caffe_Places365(Model): https://github.com/CSAILVision/places365 and then ported to TensorFlow using caffe-tensorflow. """ - model_path = 'gs://modelzoo/InceptionV1_caffe_places365.pb' + model_path = 'gs://modelzoo/vision/caffe_models/InceptionV1_places365.pb' labels_path = 'gs://modelzoo/labels/Places365.txt' dataset = 'Places365' image_shape = [224, 224, 3] diff --git a/lucid/modelzoo/caffe_models/others.py b/lucid/modelzoo/caffe_models/others.py index 8ad3ad1a..3276335d 100644 --- a/lucid/modelzoo/caffe_models/others.py +++ b/lucid/modelzoo/caffe_models/others.py @@ -23,7 +23,7 @@ class CaffeNet_caffe(Model): https://github.com/BVLC/caffe/tree/master/models/bvlc_reference_caffenet """ - model_path = 'gs://modelzoo/CaffeNet_caffe.pb' + model_path = 'gs://modelzoo/vision/caffe_models/CaffeNet.pb' labels_path = 'gs://modelzoo/labels/ImageNet_standard.txt' dataset = 'ImageNet' image_shape = [227, 227, 3] @@ -51,7 +51,7 @@ class VGG16_caffe(Model): https://gist.github.com/ksimonyan/211839e770f7b538e2d8#file-readme-md and convert it with caffe-tensorflow. """ - model_path = 'gs://modelzoo/VGG16_caffe.pb' + model_path = 'gs://modelzoo/vision/caffe_models/VGG16.pb' labels_path = 'gs://modelzoo/labels/ImageNet_standard.txt' dataset = 'ImageNet' image_shape = [224, 224, 3] @@ -90,7 +90,7 @@ class VGG19_caffe(Model): https://gist.github.com/ksimonyan/3785162f95cd2d5fee77#file-readme-md and convert it with caffe-tensorflow. """ - model_path = 'gs://modelzoo/VGG19_caffe.pb' + model_path = 'gs://modelzoo/vision/caffe_models/VGG19.pb' labels_path = 'gs://modelzoo/labels/ImageNet_standard.txt' dataset = 'ImageNet' image_shape = [224, 224, 3] diff --git a/lucid/modelzoo/other_models/AlexNet.py b/lucid/modelzoo/other_models/AlexNet.py new file mode 100644 index 00000000..5ecbdf98 --- /dev/null +++ b/lucid/modelzoo/other_models/AlexNet.py @@ -0,0 +1,50 @@ +# Copyright 2018 The Lucid Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============================================================================== + +from __future__ import absolute_import, division, print_function +from lucid.modelzoo.vision_base import Model, IMAGENET_MEAN_BGR + + +class AlexNet(Model): + """Original AlexNet weights ported to TF. + + AlexNet is the breakthrough vision model from Krizhevsky, et al (2012): + https://papers.nips.cc/paper/4824-imagenet-classification-with-deep-convolutional-neural-networks.pdf + This implementation is a caffe re-implementation: + http://www.cs.toronto.edu/~guerzhoy/tf_alexnet/ + It was converted to TensorFlow by this GitHub project: + https://github.com/huanzhang12/tensorflow-alexnet-model + It appears the parameters are the actual original parameters. + """ + + # The authors of code to convert AlexNet to TF host weights at + # http://jaina.cs.ucdavis.edu/datasets/adv/imagenet/alexnet_frozen.pb + # but it seems more polite and reliable to host our own. + model_path = 'gs://modelzoo/vision/other_models/AlexNet.pb' + labels_path = 'gs://modelzoo/labels/ImageNet_standard.txt' + dataset = 'ImageNet' + image_shape = [227, 227, 3] + is_BGR = True + image_value_range = (-IMAGENET_MEAN_BGR, 255-IMAGENET_MEAN_BGR) + input_name = 'Placeholder' + + # TODO - Sanity check this graph and layers + layers = [ + {'type': 'conv', 'name': 'concat_2', 'size': 256}, + {'type': 'conv', 'name': 'conv5_1', 'size': 256}, + {'type': 'dense', 'name': 'Relu', 'size': 4096}, + {'type': 'dense', 'name': 'Relu_1', 'size': 4096}, + {'type': 'dense', 'name': 'Softmax', 'size': 1000}, + ] diff --git a/lucid/modelzoo/other_models/InceptionV1.py b/lucid/modelzoo/other_models/InceptionV1.py index 88bbabcf..67c673be 100644 --- a/lucid/modelzoo/other_models/InceptionV1.py +++ b/lucid/modelzoo/other_models/InceptionV1.py @@ -48,7 +48,7 @@ class InceptionV1(Model): the original paper, where as the slim and caffe implementations have minor implementation differences (such as eliding the heads). """ - model_path = 'gs://modelzoo/InceptionV1.pb' + model_path = 'gs://modelzoo/vision/other_models/InceptionV1.pb' labels_path = 'gs://modelzoo/labels/ImageNet_alternate.txt' dataset = 'ImageNet' image_shape = [224, 224, 3] diff --git a/lucid/modelzoo/other_models/__init__.py b/lucid/modelzoo/other_models/__init__.py index 8131a895..9515640c 100644 --- a/lucid/modelzoo/other_models/__init__.py +++ b/lucid/modelzoo/other_models/__init__.py @@ -9,6 +9,7 @@ from lucid.modelzoo.vision_base import Model as _Model +from lucid.modelzoo.other_models.AlexNet import AlexNet from lucid.modelzoo.other_models.InceptionV1 import InceptionV1 diff --git a/lucid/modelzoo/slim_models/Inception.py b/lucid/modelzoo/slim_models/Inception.py index 8bacd3cc..5fd053b2 100644 --- a/lucid/modelzoo/slim_models/Inception.py +++ b/lucid/modelzoo/slim_models/Inception.py @@ -27,7 +27,7 @@ class InceptionV1_slim(Model): corresponding to the name "inception_v1". """ - model_path = 'gs://modelzoo/InceptionV1_slim.pb' + model_path = 'gs://modelzoo/vision/slim_models/InceptionV1.pb' labels_path = 'gs://modelzoo/labels/ImageNet_standard_with_dummy.txt' dataset = 'ImageNet' image_shape = [224, 224, 3] @@ -63,7 +63,7 @@ class InceptionV2_slim(Model): corresponding to the name "inception_v2". """ - model_path = 'gs://modelzoo/InceptionV2_slim.pb' + model_path = 'gs://modelzoo/vision/slim_models/InceptionV2.pb' labels_path = 'gs://modelzoo/labels/ImageNet_standard_with_dummy.txt' dataset = 'ImageNet' image_shape = [224, 224, 3] @@ -100,7 +100,7 @@ class InceptionV3_slim(Model): corresponding to the name "inception_v3". """ - model_path = 'gs://modelzoo/InceptionV3_slim.pb' + model_path = 'gs://modelzoo/vision/slim_models/InceptionV3.pb' labels_path = 'gs://modelzoo/labels/ImageNet_standard_with_dummy.txt' dataset = 'ImageNet' image_shape = [299, 299, 3] @@ -140,7 +140,7 @@ class InceptionV4_slim(Model): corresponding to the name "inception_v4". """ - model_path = 'gs://modelzoo/InceptionV4_slim.pb' + model_path = 'gs://modelzoo/vision/slim_models/InceptionV4.pb' labels_path = 'gs://modelzoo/labels/ImageNet_standard_with_dummy.txt' dataset = 'ImageNet' image_shape = [299, 299, 3] @@ -186,7 +186,7 @@ class InceptionResnetV2_slim(Model): corresponding to the name "inception_resnet_v2". """ - model_path = 'gs://modelzoo/InceptionResnetV2_slim.pb' + model_path = 'gs://modelzoo/vision/slim_models/InceptionResnetV2.pb' labels_path = 'gs://modelzoo/labels/ImageNet_standard_with_dummy.txt' dataset = 'ImageNet' image_shape = [299, 299, 3] diff --git a/lucid/modelzoo/slim_models/ResNetV1.py b/lucid/modelzoo/slim_models/ResNetV1.py index 40e8c529..bd0dd868 100644 --- a/lucid/modelzoo/slim_models/ResNetV1.py +++ b/lucid/modelzoo/slim_models/ResNetV1.py @@ -24,7 +24,7 @@ class ResnetV1_50_slim(Model): https://github.com/tensorflow/models/tree/master/research/slim """ - model_path = 'gs://modelzoo/ResnetV1_50_slim.pb' + model_path = 'gs://modelzoo/vision/slim_models/ResnetV1_50.pb' labels_path = 'gs://modelzoo/labels/ImageNet_standard.txt' dataset = 'ImageNet' image_shape = [224, 224, 3] @@ -64,7 +64,7 @@ class ResnetV1_101_slim(Model): https://github.com/tensorflow/models/tree/master/research/slim """ - model_path = 'gs://modelzoo/ResnetV1_101_slim.pb' + model_path = 'gs://modelzoo/vision/slim_models/ResnetV1_101.pb' labels_path = 'gs://modelzoo/labels/ImageNet_standard.txt' dataset = 'ImageNet' image_shape = [224, 224, 3] @@ -120,7 +120,7 @@ class ResnetV1_152_slim(Model): https://github.com/tensorflow/models/tree/master/research/slim """ - model_path = 'gs://modelzoo/ResnetV1_152_slim.pb' + model_path = 'gs://modelzoo/vision/slim_models/ResnetV1_152.pb' labels_path = 'gs://modelzoo/labels/ImageNet_standard.txt' dataset = 'ImageNet' image_shape = [224, 224, 3] diff --git a/lucid/modelzoo/slim_models/ResNetV2.py b/lucid/modelzoo/slim_models/ResNetV2.py index 4223beb1..e53e9e6f 100644 --- a/lucid/modelzoo/slim_models/ResNetV2.py +++ b/lucid/modelzoo/slim_models/ResNetV2.py @@ -27,7 +27,7 @@ class ResnetV2_50_slim(Model): corresponding to the name "resnet_v2_50". """ - model_path = 'gs://modelzoo/ResnetV2_50_slim.pb' + model_path = 'gs://modelzoo/vision/slim_models/ResnetV2_50.pb' labels_path = 'gs://modelzoo/labels/ImageNet_standard_with_dummy.txt' dataset = 'ImageNet' image_shape = [224, 224, 3] @@ -72,7 +72,7 @@ class ResnetV2_101_slim(Model): corresponding to the name "resnet_v2_101". """ - model_path = 'gs://modelzoo/ResnetV2_101_slim.pb' + model_path = 'gs://modelzoo/vision/slim_models/ResnetV2_101.pb' labels_path = 'gs://modelzoo/labels/ImageNet_standard_with_dummy.txt' dataset = 'ImageNet' image_shape = [224, 224, 3] @@ -134,7 +134,7 @@ class ResnetV2_152_slim(Model): corresponding to the name "resnet_v2_152". """ - model_path = 'gs://modelzoo/ResnetV2_152_slim.pb' + model_path = 'gs://modelzoo/vision/slim_models/ResnetV2_152.pb' labels_path = 'gs://modelzoo/labels/ImageNet_standard_with_dummy.txt' dataset = 'ImageNet' image_shape = [224, 224, 3] diff --git a/lucid/modelzoo/slim_models/others.py b/lucid/modelzoo/slim_models/others.py index a43a2f1a..a5c207ec 100644 --- a/lucid/modelzoo/slim_models/others.py +++ b/lucid/modelzoo/slim_models/others.py @@ -35,7 +35,7 @@ # We believe the weights were actually trained in caffe and ported. # """ # -# model_path = 'gs://modelzoo/VGG16_slim.pb' +# model_path = 'gs://modelzoo/VGG16.pb' # labels_path = 'gs://modelzoo/labels/ImageNet_standard_with_dummy.txt' #TODO # dataset = 'ImageNet' # image_shape = [224, 224, 3] @@ -71,7 +71,7 @@ # We believe the weights were actually trained in caffe and ported. # """ # -# model_path = 'gs://modelzoo/VGG19_slim.pb' +# model_path = 'gs://modelzoo/VGG19.pb' # labels_path = 'gs://modelzoo/labels/ImageNet_standard_with_dummy.txt' #TODO # dataset = 'ImageNet' # image_shape = [224, 224, 3] @@ -107,7 +107,7 @@ class MobilenetV1_slim(Model): https://github.com/tensorflow/models/tree/master/research/slim """ - model_path = 'gs://modelzoo/MobilenetV1_slim.pb' + model_path = 'gs://modelzoo/vision/slim_models/MobilenetV1.pb' labels_path = 'gs://modelzoo/labels/ImageNet_standard_with_dummy.txt' #TODO dataset = 'ImageNet' image_shape = [224, 224, 3] @@ -125,7 +125,7 @@ class MobilenetV1_050_slim(Model): https://github.com/tensorflow/models/tree/master/research/slim """ - model_path = 'gs://modelzoo/MobilenetV1050_slim.pb' + model_path = 'gs://modelzoo/vision/slim_models/MobilenetV1050.pb' labels_path = 'gs://modelzoo/labels/ImageNet_standard_with_dummy.txt' #TODO dataset = 'ImageNet' image_shape = [224, 224, 3] @@ -143,7 +143,7 @@ class MobilenetV1_025_slim(Model): https://github.com/tensorflow/models/tree/master/research/slim """ - model_path = 'gs://modelzoo/MobilenetV1025_slim.pb' + model_path = 'gs://modelzoo/vision/slim_models/MobilenetV1025.pb' labels_path = 'gs://modelzoo/labels/ImageNet_standard_with_dummy.txt' #TODO dataset = 'ImageNet' image_shape = [224, 224, 3] @@ -161,7 +161,7 @@ class NasnetMobile_slim(Model): https://github.com/tensorflow/models/tree/master/research/slim """ - model_path = 'gs://modelzoo/NasnetMobile_slim.pb' + model_path = 'gs://modelzoo/vision/slim_models/NasnetMobile.pb' labels_path = 'gs://modelzoo/labels/ImageNet_standard_with_dummy.txt' #TODO dataset = 'ImageNet' image_shape = [224, 224, 3] @@ -179,7 +179,7 @@ class NasnetLarge_slim(Model): https://github.com/tensorflow/models/tree/master/research/slim """ - model_path = 'gs://modelzoo/NasnetLarge_slim.pb' + model_path = 'gs://modelzoo/vision/slim_models/NasnetLarge.pb' labels_path = 'gs://modelzoo/labels/ImageNet_standard_with_dummy.txt' #TODO dataset = 'ImageNet' image_shape = [331, 331, 3] @@ -197,7 +197,7 @@ class PnasnetLarge_slim(Model): https://github.com/tensorflow/models/tree/master/research/slim """ - model_path = 'gs://modelzoo/PnasnetLarge_slim.pb' + model_path = 'gs://modelzoo/vision/slim_models/PnasnetLarge.pb' labels_path = 'gs://modelzoo/labels/ImageNet_standard_with_dummy.txt' #TODO dataset = 'ImageNet' image_shape = [331, 331, 3] @@ -215,7 +215,7 @@ class PnasnetMobile_slim(Model): https://github.com/tensorflow/models/tree/master/research/slim """ - model_path = 'gs://modelzoo/PnasnetMobile_slim.pb' + model_path = 'gs://modelzoo/vision/slim_models/PnasnetMobile.pb' labels_path = 'gs://modelzoo/labels/ImageNet_standard_with_dummy.txt' #TODO dataset = 'ImageNet' image_shape = [224, 224, 3]