Skip to content
This repository has been archived by the owner on Apr 10, 2024. It is now read-only.

Commit

Permalink
Merge fdfd70a into 38e8af2
Browse files Browse the repository at this point in the history
  • Loading branch information
colah committed Aug 8, 2018
2 parents 38e8af2 + fdfd70a commit d033575
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 61 deletions.
35 changes: 1 addition & 34 deletions lucid/modelzoo/caffe_models/AlexNet.py
Expand Up @@ -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.
Expand All @@ -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]
Expand Down
6 changes: 3 additions & 3 deletions lucid/modelzoo/caffe_models/InceptionV1.py
Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down
6 changes: 3 additions & 3 deletions lucid/modelzoo/caffe_models/others.py
Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down
50 changes: 50 additions & 0 deletions 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},
]
2 changes: 1 addition & 1 deletion lucid/modelzoo/other_models/InceptionV1.py
Expand Up @@ -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]
Expand Down
1 change: 1 addition & 0 deletions lucid/modelzoo/other_models/__init__.py
Expand Up @@ -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


Expand Down
10 changes: 5 additions & 5 deletions lucid/modelzoo/slim_models/Inception.py
Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down
6 changes: 3 additions & 3 deletions lucid/modelzoo/slim_models/ResNetV1.py
Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down
6 changes: 3 additions & 3 deletions lucid/modelzoo/slim_models/ResNetV2.py
Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down
18 changes: 9 additions & 9 deletions lucid/modelzoo/slim_models/others.py
Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand All @@ -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]
Expand All @@ -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]
Expand All @@ -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]
Expand All @@ -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]
Expand All @@ -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]
Expand All @@ -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]
Expand Down

0 comments on commit d033575

Please sign in to comment.