Skip to content
This repository has been archived by the owner on Jul 2, 2021. It is now read-only.

Add VGG16 #265

Merged
merged 156 commits into from
Aug 21, 2017
Merged
Show file tree
Hide file tree
Changes from 154 commits
Commits
Show all changes
156 commits
Select commit Hold shift + click to select a range
46a07fb
add wip vgg
yuyu2172 Jun 12, 2017
4a32cce
Merge remote-tracking branch 'yuyu2172/image-folder-dataset' into HEAD
yuyu2172 Jun 14, 2017
8b35001
update on classification models
yuyu2172 Jun 14, 2017
1cd87b6
fix the issue with copying vision chain
yuyu2172 Jun 14, 2017
af88d89
add tests and pass tests for feature option
yuyu2172 Jun 14, 2017
2bbece2
add predict function
yuyu2172 Jun 14, 2017
17f6333
update test
yuyu2172 Jun 14, 2017
2d4c45e
add caffe trained pretrained weight loader
yuyu2172 Jun 14, 2017
55ecaca
improve eval_imagenet
yuyu2172 Jun 14, 2017
f570a92
add pretrained_model ooption to eval_imagenet
yuyu2172 Jun 14, 2017
f479f21
small fixes
yuyu2172 Jun 14, 2017
e23e5f5
pass test_predict
yuyu2172 Jun 14, 2017
b45fe22
more informative evaluation
yuyu2172 Jun 14, 2017
1f3a999
use scale instead of resize
yuyu2172 Jun 14, 2017
1f0353a
fix a bug in scale
yuyu2172 Jun 14, 2017
d184963
move crop option to __init__
yuyu2172 Jun 14, 2017
c6d62de
fix eval_imagenet
yuyu2172 Jun 14, 2017
d1a4e46
add docs
yuyu2172 Jun 15, 2017
df66a0a
support automatic download
yuyu2172 Jun 15, 2017
84a905d
Work without setting n_class or pretrained_model
yuyu2172 Jun 15, 2017
a83d548
remove VGG16FeatureExtractor
yuyu2172 Jun 15, 2017
b696389
improve print output
yuyu2172 Jun 15, 2017
47326fb
flake8 of eval_imagenet
yuyu2172 Jun 15, 2017
30035bb
improve doc
yuyu2172 Jun 15, 2017
2ffae2b
flake8 of tests
yuyu2172 Jun 15, 2017
8b3337c
fix tests
yuyu2172 Jun 15, 2017
fab7a7c
Simplify __init__
yuyu2172 Jun 15, 2017
1ac56a1
fix tests
yuyu2172 Jun 15, 2017
86f351d
change convert_from_caffe to convert_vgg
yuyu2172 Jun 15, 2017
fdf763e
update README
yuyu2172 Jun 15, 2017
d37d08d
accept multiple types of features
yuyu2172 Jun 16, 2017
7f04616
accept multiple features as input
yuyu2172 Jun 16, 2017
ce77737
cosmetic
yuyu2172 Jun 16, 2017
2206fc8
change name of a variable
yuyu2172 Jun 16, 2017
64efbc0
fix a bug in conditional
yuyu2172 Jun 16, 2017
ab2cfee
consistency in variable names
yuyu2172 Jun 16, 2017
3caec05
change api to return tuple instead of dict
yuyu2172 Jun 16, 2017
7b2d214
fix doc
yuyu2172 Jun 16, 2017
96e285c
fix faster_rcnn_vgg
yuyu2172 Jun 16, 2017
b0b070c
fix doc
yuyu2172 Jun 16, 2017
a1d6927
fix init
yuyu2172 Jun 16, 2017
338819a
simplify functions
yuyu2172 Jun 16, 2017
700c5f4
fix links.rst
yuyu2172 Jun 16, 2017
b1983cd
Merge branch 'image-folder-dataset' into classification
yuyu2172 Jun 16, 2017
5b08bd7
fix eval_imagenet
yuyu2172 Jun 16, 2017
6a2b43c
fix vgg for python3
yuyu2172 Jun 17, 2017
724dcb5
remove predict and use SequentialFeatureExtractionChain
yuyu2172 Jun 19, 2017
49bee22
exploit the fact that functions is ordered dict
yuyu2172 Jun 19, 2017
5af7506
VGG16Layers -> VGG16
yuyu2172 Jun 19, 2017
aa18ad7
add feature_extraction_predictor
yuyu2172 Jun 19, 2017
6c5f6f9
use sequential_chain
yuyu2172 Jun 19, 2017
b703084
simplify vgg16
yuyu2172 Jun 19, 2017
75db194
simplify sequential_chain
yuyu2172 Jun 19, 2017
a36323e
sequential_chain --> extraction_chain
yuyu2172 Jun 28, 2017
a889d47
delete unnecessary constraint
yuyu2172 Jun 28, 2017
a91d29d
stop using unnecessary list
yuyu2172 Jun 28, 2017
e0d9147
use property mean
yuyu2172 Jun 28, 2017
0972d02
feature_names --> layer_names for VGG
yuyu2172 Jun 28, 2017
d7f3f52
mean doc
yuyu2172 Jun 28, 2017
e794055
fix tests
yuyu2172 Jun 28, 2017
3309415
simplify initialization
yuyu2172 Jun 28, 2017
4c8b3e6
delete redundant layerts from extraction_chain
yuyu2172 Jun 28, 2017
e51762f
extraction_chain --> sequential_extractor
yuyu2172 Jun 28, 2017
10815f7
fix comment
yuyu2172 Jun 28, 2017
3e22012
[Sequential Extractor] Change default names for layers
yuyu2172 Jun 28, 2017
c8fbda6
[Sequential Extractor] function --> layer
yuyu2172 Jun 28, 2017
7ef4623
sequential_extractor --> sequential_feature_extractor and add doc
yuyu2172 Jul 4, 2017
427f724
Merge remote-tracking branch 'origin/master' into classification
yuyu2172 Jul 4, 2017
1c49938
add doc to feature_extraction_predictor
yuyu2172 Jul 4, 2017
467c500
test_feature_extraction_predictor
yuyu2172 Jul 4, 2017
a1f43dd
reflect name changes to examples/classification
yuyu2172 Jul 4, 2017
c3af69e
Merge remote-tracking branch 'yuyu2172/image-folder-dataset' into cla…
yuyu2172 Jul 4, 2017
011b320
update eval_imagenet and README
yuyu2172 Jul 4, 2017
ae5fd2d
fix flake8
yuyu2172 Jul 4, 2017
c8cdc36
fix error for python3
yuyu2172 Jul 5, 2017
268e781
improve doc
yuyu2172 Jul 5, 2017
ebe9340
fix feature_extraction_predictor.predict
yuyu2172 Jul 5, 2017
8f65c02
fix doc
yuyu2172 Jul 5, 2017
80df6a9
reorder arguments
yuyu2172 Jul 6, 2017
320174d
use initialize at runtime
yuyu2172 Jul 6, 2017
55c50c9
make layer_names dynamically changeable
yuyu2172 Jul 6, 2017
57ab2cc
Merge remote-tracking branch 'origin/master' into HEAD
yuyu2172 Jul 15, 2017
ec8ddf7
merge sequential-feature-extractor
yuyu2172 Jul 15, 2017
a232abc
use updated interface of SequentialFeatureExtractor
yuyu2172 Jul 15, 2017
348ae85
fix doc
yuyu2172 Jul 15, 2017
f97cd49
Merge remote-tracking branch 'origin/master' into classification
yuyu2172 Jul 18, 2017
2940e0d
it is not necessary to do a trick to save initialization time
yuyu2172 Jul 18, 2017
3b24821
use block
yuyu2172 Jul 18, 2017
8b408c6
simplify init_scope
yuyu2172 Jul 18, 2017
578b3aa
add convolution_2d_block
yuyu2172 Jul 18, 2017
05b478c
change pretrained weights
yuyu2172 Jul 18, 2017
826c183
fix doc
yuyu2172 Jul 18, 2017
a5f0be7
fix test_vgg16
yuyu2172 Jul 18, 2017
23a42d9
fix doc
yuyu2172 Jul 18, 2017
775ab31
fix a mistake in vgg16
yuyu2172 Jul 18, 2017
f553948
fix faster_rcnn_vgg
yuyu2172 Jul 20, 2017
7602cc7
Merge remote-tracking branch 'yuyu2172/classification' into classific…
yuyu2172 Jul 20, 2017
b9c3f5c
fix Faster RCNN train to work
yuyu2172 Jul 20, 2017
a982c8e
fix doc
yuyu2172 Jul 20, 2017
48db171
use Zero initialization when pretrained model is used
yuyu2172 Jul 20, 2017
f78cec3
Merge branch 'classification' of https://github.com/yuyu2172/chainerc…
yuyu2172 Jul 20, 2017
459e3c6
flake8
yuyu2172 Jul 20, 2017
b8e890d
improve doc of feature_extraction_predictor
yuyu2172 Jul 20, 2017
f04cb4b
Merge remote-tracking branch 'origin/master' into classification
yuyu2172 Jul 20, 2017
d005cb9
Merge remote-tracking branch 'origin/master' into classification
yuyu2172 Jul 24, 2017
3820df9
use remove_unused
yuyu2172 Jul 24, 2017
3323ce7
use remove_unused
yuyu2172 Jul 24, 2017
9d25473
change init style of convolution_2d_block
yuyu2172 Aug 4, 2017
f615940
use crop_size && make crop_size int
yuyu2172 Aug 4, 2017
3bc3b09
fix convolution_2d_block
yuyu2172 Aug 4, 2017
4233f8e
stop using do_ten_crop
yuyu2172 Aug 4, 2017
7608809
merge master
yuyu2172 Aug 4, 2017
6b8c0da
fix doc
yuyu2172 Aug 4, 2017
b85a3ce
fix doc for VGG16
yuyu2172 Aug 4, 2017
20783d6
fix variable names in eval_imagenet
yuyu2172 Aug 4, 2017
29f8979
Merge remote-tracking branch 'yuyu2172/image-folder-dataset' into cla…
yuyu2172 Aug 4, 2017
20b6eb9
fix vgg16
yuyu2172 Aug 4, 2017
a59194a
add convolution2DBlock to doc
yuyu2172 Aug 4, 2017
9a64c9b
delete unnecessary declaration of initial_bias
yuyu2172 Aug 4, 2017
799b48b
specify n_class in eval_imagenet
yuyu2172 Aug 4, 2017
5c83e38
use directory_parsing_label_names
yuyu2172 Aug 4, 2017
aafaecc
expose crop option in eval_imagenet
yuyu2172 Aug 4, 2017
fdd6f48
fix variable names
yuyu2172 Aug 4, 2017
4bbdd5a
support tuple as an argument for shapes (FeatureExtractionPredictor)
yuyu2172 Aug 6, 2017
465f1df
use choices kwarg for eval_imagenet
yuyu2172 Aug 6, 2017
62edb90
update download link of FasterRCNNVGG16
yuyu2172 Aug 6, 2017
895ef8a
flake8
yuyu2172 Aug 6, 2017
141bc39
Convolution2DBlock -> Conv2DActiv
yuyu2172 Aug 7, 2017
6d4cf29
use activ instead of activation
yuyu2172 Aug 7, 2017
b7df511
add a note in Conv2DActiv doc
yuyu2172 Aug 7, 2017
fd0dde5
add test on forward and activ
yuyu2172 Aug 7, 2017
5b2a257
that of -> those of
yuyu2172 Aug 8, 2017
86029ef
fix doc
yuyu2172 Aug 8, 2017
93d8e67
fix doc
yuyu2172 Aug 8, 2017
53bb7c6
fix doc
yuyu2172 Aug 8, 2017
3a13b35
fix doc
yuyu2172 Aug 8, 2017
8ea45df
flake8
yuyu2172 Aug 8, 2017
c7a14ad
Merge remote-tracking branch 'origin/master' into classification
yuyu2172 Aug 8, 2017
9a18739
merge master
yuyu2172 Aug 10, 2017
26231db
merge master
yuyu2172 Aug 20, 2017
d29172e
update code
yuyu2172 Aug 20, 2017
a3a20b2
update README
yuyu2172 Aug 20, 2017
10d2e09
use default mean value when unsupecified
yuyu2172 Aug 20, 2017
3f0da8e
fix eval_imagenet
yuyu2172 Aug 20, 2017
59f53e1
fix eval_imagenet
yuyu2172 Aug 20, 2017
4cf289c
fix
yuyu2172 Aug 20, 2017
e45bc5a
change convert_vgg to use caffemodel
yuyu2172 Aug 20, 2017
49249ed
change name caffee2npz_vgg
yuyu2172 Aug 20, 2017
0dfddfe
make vgg directory
yuyu2172 Aug 20, 2017
0900011
rename
Hakuyume Aug 21, 2017
4de11f7
update conversion
Hakuyume Aug 21, 2017
9d1e8ee
fix typo
Hakuyume Aug 21, 2017
70bf30b
Merge pull request #4 from Hakuyume/vgg-conversion
yuyu2172 Aug 21, 2017
743055f
fix download link for faster_rcnn_vgg
yuyu2172 Aug 21, 2017
7bd02b0
update README vgg
yuyu2172 Aug 21, 2017
9ca4070
fix typo
yuyu2172 Aug 21, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions chainercv/links/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
from chainercv.links.model.segnet.segnet_basic import SegNetBasic # NOQA
from chainercv.links.model.ssd import SSD300 # NOQA
from chainercv.links.model.ssd import SSD512 # NOQA
from chainercv.links.model.vgg import VGG16 # NOQA
1 change: 0 additions & 1 deletion chainercv/links/model/faster_rcnn/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from chainercv.links.model.faster_rcnn.faster_rcnn import FasterRCNN # NOQA
from chainercv.links.model.faster_rcnn.faster_rcnn_train_chain import FasterRCNNTrainChain # NOQA
from chainercv.links.model.faster_rcnn.faster_rcnn_vgg import FasterRCNNVGG16 # NOQA
from chainercv.links.model.faster_rcnn.faster_rcnn_vgg import VGG16FeatureExtractor # NOQA
from chainercv.links.model.faster_rcnn.faster_rcnn_vgg import VGG16RoIHead # NOQA
from chainercv.links.model.faster_rcnn.region_proposal_network import RegionProposalNetwork # NOQA
from chainercv.links.model.faster_rcnn.utils.anchor_target_creator import AnchorTargetCreator # NOQA
Expand Down
84 changes: 8 additions & 76 deletions chainercv/links/model/faster_rcnn/faster_rcnn_vgg.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import collections
import numpy as np

import chainer
import chainer.functions as F
import chainer.links as L
from chainer.links import VGG16Layers

from chainercv.links.model.faster_rcnn.faster_rcnn import FasterRCNN
from chainercv.links.model.faster_rcnn.region_proposal_network import \
RegionProposalNetwork
from chainercv.links.model.vgg.vgg16 import VGG16
from chainercv.utils import download_model


Expand Down Expand Up @@ -74,7 +73,8 @@ class FasterRCNNVGG16(FasterRCNN):
'voc07': {
'n_fg_class': 20,
'url': 'https://github.com/yuyu2172/share-weights/releases/'
'download/0.0.3/faster_rcnn_vgg16_voc07_2017_06_06.npz'
'download/0.0.4/'
'faster_rcnn_vgg16_voc07_trained_2017_08_06.npz'
}
}
feat_stride = 16
Expand Down Expand Up @@ -103,7 +103,10 @@ def __init__(self,
if vgg_initialW is None and pretrained_model:
vgg_initialW = chainer.initializers.constant.Zero()

extractor = VGG16FeatureExtractor(initialW=vgg_initialW)
extractor = VGG16(initialW=vgg_initialW)
extractor.feature_names = 'conv5_3'
# Delete all layers after conv5_3.
extractor.remove_unused()
rpn = RegionProposalNetwork(
512, 512,
ratios=ratios,
Expand Down Expand Up @@ -139,12 +142,8 @@ def __init__(self,
chainer.serializers.load_npz(pretrained_model, self)

def _copy_imagenet_pretrained_vgg16(self):
pretrained_model = VGG16Layers()
pretrained_model = VGG16(pretrained_model='imagenet')
self.extractor.conv1_1.copyparams(pretrained_model.conv1_1)
# The pretrained weights are trained to accept BGR images.
# Convert weights so that they accept RGB images.
self.extractor.conv1_1.W.data[:] =\
self.extractor.conv1_1.W.data[:, ::-1]
self.extractor.conv1_2.copyparams(pretrained_model.conv1_2)
self.extractor.conv2_1.copyparams(pretrained_model.conv2_1)
self.extractor.conv2_2.copyparams(pretrained_model.conv2_2)
Expand Down Expand Up @@ -225,75 +224,8 @@ def __call__(self, x, rois, roi_indices):
return roi_cls_locs, roi_scores


class VGG16FeatureExtractor(chainer.Chain):
"""Truncated VGG-16 that extracts a conv5_3 feature map.

Args:
initialW (callable): Initializer for the weights.

"""

def __init__(self, initialW=None):
super(VGG16FeatureExtractor, self).__init__()
with self.init_scope():
self.conv1_1 = L.Convolution2D(3, 64, 3, 1, 1, initialW=initialW)
self.conv1_2 = L.Convolution2D(64, 64, 3, 1, 1, initialW=initialW)
self.conv2_1 = L.Convolution2D(64, 128, 3, 1, 1, initialW=initialW)
self.conv2_2 = L.Convolution2D(
128, 128, 3, 1, 1, initialW=initialW)
self.conv3_1 = L.Convolution2D(
128, 256, 3, 1, 1, initialW=initialW)
self.conv3_2 = L.Convolution2D(
256, 256, 3, 1, 1, initialW=initialW)
self.conv3_3 = L.Convolution2D(
256, 256, 3, 1, 1, initialW=initialW)
self.conv4_1 = L.Convolution2D(
256, 512, 3, 1, 1, initialW=initialW)
self.conv4_2 = L.Convolution2D(
512, 512, 3, 1, 1, initialW=initialW)
self.conv4_3 = L.Convolution2D(
512, 512, 3, 1, 1, initialW=initialW)
self.conv5_1 = L.Convolution2D(
512, 512, 3, 1, 1, initialW=initialW)
self.conv5_2 = L.Convolution2D(
512, 512, 3, 1, 1, initialW=initialW)
self.conv5_3 = L.Convolution2D(
512, 512, 3, 1, 1, initialW=initialW)

self.functions = collections.OrderedDict([
('conv1_1', [self.conv1_1, F.relu]),
('conv1_2', [self.conv1_2, F.relu]),
('pool1', [_max_pooling_2d]),
('conv2_1', [self.conv2_1, F.relu]),
('conv2_2', [self.conv2_2, F.relu]),
('pool2', [_max_pooling_2d]),
('conv3_1', [self.conv3_1, F.relu]),
('conv3_2', [self.conv3_2, F.relu]),
('conv3_3', [self.conv3_3, F.relu]),
('pool3', [_max_pooling_2d]),
('conv4_1', [self.conv4_1, F.relu]),
('conv4_2', [self.conv4_2, F.relu]),
('conv4_3', [self.conv4_3, F.relu]),
('pool4', [_max_pooling_2d]),
('conv5_1', [self.conv5_1, F.relu]),
('conv5_2', [self.conv5_2, F.relu]),
('conv5_3', [self.conv5_3, F.relu]),
])

def __call__(self, x):
h = x
for key, funcs in self.functions.items():
for func in funcs:
h = func(h)
return h


def _roi_pooling_2d_yx(x, indices_and_rois, outh, outw, spatial_scale):
xy_indices_and_rois = indices_and_rois[:, [0, 2, 1, 4, 3]]
pool = F.roi_pooling_2d(
x, xy_indices_and_rois, outh, outw, spatial_scale)
return pool


def _max_pooling_2d(x):
return F.max_pooling_2d(x, ksize=2)
1 change: 1 addition & 0 deletions chainercv/links/model/vgg/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from chainercv.links.model.vgg.vgg16 import VGG16 # NOQA
164 changes: 164 additions & 0 deletions chainercv/links/model/vgg/vgg16.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
from __future__ import division

import numpy as np

import chainer
from chainer.functions import dropout
from chainer.functions import max_pooling_2d
from chainer.functions import relu
from chainer.functions import softmax
from chainer.initializers import constant
from chainer.initializers import normal

from chainer.links import Linear

from chainercv.utils import download_model

from chainercv.links.connection.conv_2d_activ import Conv2DActiv
from chainercv.links.model.sequential_feature_extractor import \
SequentialFeatureExtractor


# RGB order
_imagenet_mean = np.array(
[123.68, 116.779, 103.939], dtype=np.float32)[:, np.newaxis, np.newaxis]


class VGG16(SequentialFeatureExtractor):

"""VGG-16 Network for classification and feature extraction.

This is a feature extraction model.
The network can choose output features from set of all
intermediate features.
The value of :obj:`VGG16.feature_names` selects the features that are going
to be collected by :meth:`__call__`.
:obj:`self.all_feature_names` is the list of the names of features
that can be collected.

Examples:

>>> model = VGG16()
# By default, __call__ returns a probability score (after Softmax).
>>> prob = model(imgs)

>>> model.feature_names = 'conv5_3'
# This is feature conv5_3 (after ReLU).
>>> feat5_3 = model(imgs)

>>> model.feature_names = ['conv5_3', 'fc6']
>>> # These are features conv5_3 (after ReLU) and fc6 (before ReLU).
>>> feat5_3, feat6 = model(imgs)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

# These are features conv5_3 (after ReLU) and fc6 (before ReLU).


.. seealso::
:class:`chainercv.links.model.SequentialFeatureExtractor`

When :obj:`pretrained_model` is the path of a pre-trained chainer model
serialized as a :obj:`.npz` file in the constructor, this chain model
automatically initializes all the parameters with it.
When a string in the prespecified set is provided, a pretrained model is
loaded from weights distributed on the Internet.
The list of pretrained models supported are as follows:

* :obj:`imagenet`: Loads weights trained with ImageNet and distributed \
at `Model Zoo \
<https://github.com/BVLC/caffe/wiki/Model-Zoo>`_.

Args:
pretrained_model (str): The destination of the pre-trained
chainer model serialized as a :obj:`.npz` file.
If this is one of the strings described
above, it automatically loads weights stored under a directory
:obj:`$CHAINER_DATASET_ROOT/pfnet/chainercv/models/`,
where :obj:`$CHAINER_DATASET_ROOT` is set as
:obj:`$HOME/.chainer/dataset` unless you specify another value
by modifying the environment variable.
n_class (int): The number of classes. If :obj:`None`,
the default values are used.
If a supported pretrained model is used,
the number of classes used to train the pretrained model
is used. Otherwise, the number of classes in ILSVRC 2012 dataset
is used.
mean (numpy.ndarray): A mean value. If :obj:`None`,
the default values are used.
If a supported pretrained model is used,
the mean value used to train the pretrained model is used.
Otherwise, the mean value calculated from ILSVRC 2012 dataset
is used.
initialW (callable): Initializer for the weights.
initial_bias (callable): Initializer for the biases.

"""

_models = {
'imagenet': {
'n_class': 1000,
'url': 'https://github.com/yuyu2172/share-weights/releases/'
'download/0.0.4/vgg16_imagenet_convert_2017_07_18.npz',
'mean': _imagenet_mean
}
}

def __init__(self,
pretrained_model=None, n_class=None, mean=None,
initialW=None, initial_bias=None):
if n_class is None:
if pretrained_model in self._models:
n_class = self._models[pretrained_model]['n_class']
else:
n_class = 1000

if mean is None:
if pretrained_model in self._models:
mean = self._models[pretrained_model]['mean']
else:
mean = _imagenet_mean
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about adding a note about these behaviours? The default values of n_class and mean.

self.mean = mean

if initialW is None:
# Employ default initializers used in the original paper.
initialW = normal.Normal(0.01)
if pretrained_model:
# As a sampling process is time-consuming,
# we employ a zero initializer for faster computation.
initialW = constant.Zero()
kwargs = {'initialW': initialW, 'initial_bias': initial_bias}

super(VGG16, self).__init__()
with self.init_scope():
self.conv1_1 = Conv2DActiv(None, 64, 3, 1, 1, **kwargs)
self.conv1_2 = Conv2DActiv(None, 64, 3, 1, 1, **kwargs)
self.pool1 = _max_pooling_2d
self.conv2_1 = Conv2DActiv(None, 128, 3, 1, 1, **kwargs)
self.conv2_2 = Conv2DActiv(None, 128, 3, 1, 1, **kwargs)
self.pool2 = _max_pooling_2d
self.conv3_1 = Conv2DActiv(None, 256, 3, 1, 1, **kwargs)
self.conv3_2 = Conv2DActiv(None, 256, 3, 1, 1, **kwargs)
self.conv3_3 = Conv2DActiv(None, 256, 3, 1, 1, **kwargs)
self.pool3 = _max_pooling_2d
self.conv4_1 = Conv2DActiv(None, 512, 3, 1, 1, **kwargs)
self.conv4_2 = Conv2DActiv(None, 512, 3, 1, 1, **kwargs)
self.conv4_3 = Conv2DActiv(None, 512, 3, 1, 1, **kwargs)
self.pool4 = _max_pooling_2d
self.conv5_1 = Conv2DActiv(None, 512, 3, 1, 1, **kwargs)
self.conv5_2 = Conv2DActiv(None, 512, 3, 1, 1, **kwargs)
self.conv5_3 = Conv2DActiv(None, 512, 3, 1, 1, **kwargs)
self.pool5 = _max_pooling_2d
self.fc6 = Linear(None, 4096, **kwargs)
self.fc6_relu = relu
self.fc6_dropout = dropout
self.fc7 = Linear(None, 4096, **kwargs)
self.fc7_relu = relu
self.fc7_dropout = dropout
self.fc8 = Linear(None, n_class, **kwargs)
self.prob = softmax

if pretrained_model in self._models:
path = download_model(self._models[pretrained_model]['url'])
chainer.serializers.load_npz(path, self)
elif pretrained_model:
chainer.serializers.load_npz(pretrained_model, self)


def _max_pooling_2d(x):
return max_pooling_2d(x, ksize=2)
26 changes: 22 additions & 4 deletions docs/source/reference/links.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
Links
=====

.. module:: chainercv.links.model.faster_rcnn

Model
-----


Feature Extraction
~~~~~~~~~~~~~~~~~~
Feature extraction models extract feature(s) from given images.

.. toctree::

links/vgg


.. autoclass:: chainercv.links.SequentialFeatureExtractor
:members:

.. autoclass:: chainercv.links.FeaturePredictor


Detection
---------
~~~~~~~~~

Detection links share a common method :meth:`predict` to detect objects in images.
For more details, please read :func:`FasterRCNN.predict`.
Expand All @@ -16,7 +34,7 @@ For more details, please read :func:`FasterRCNN.predict`.


Semantic Segmentation
---------------------
~~~~~~~~~~~~~~~~~~~~~

.. module:: chainercv.links.model.segnet

Expand All @@ -29,7 +47,7 @@ For more details, please read :func:`SegNetBasic.predict`.


Classifiers
-----------
~~~~~~~~~~~

.. toctree::

Expand Down
4 changes: 0 additions & 4 deletions docs/source/reference/links/faster_rcnn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ RegionProposalNetwork
:members:
:special-members: __call__

VGG16FeatureExtractor
~~~~~~~~~~~~~~~~~~~~~
.. autoclass:: VGG16FeatureExtractor

VGG16RoIHead
~~~~~~~~~~~~
.. autoclass:: VGG16RoIHead
Expand Down
11 changes: 11 additions & 0 deletions docs/source/reference/links/vgg.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
VGG
===

.. module:: chainercv.links.model.vgg


VGG16
-----

.. autoclass:: VGG16
:members:
Loading