master 8aae3d8f1135 cached
44 files
472.7 KB
140.9k tokens
485 symbols
1 requests
Download .txt
Showing preview only (492K chars total). Download the full file or copy to clipboard to get everything.
Repository: Cadene/pretrained-models.pytorch
Branch: master
Commit: 8aae3d8f1135
Files: 44
Total size: 472.7 KB

Directory structure:
gitextract_mxx490a2/

├── .gitignore
├── .travis.yml
├── LICENSE.txt
├── README.md
├── data/
│   ├── imagenet_classes.txt
│   └── imagenet_synsets.txt
├── examples/
│   ├── imagenet_eval.py
│   ├── imagenet_logits.py
│   ├── visu_arch.py
│   └── voc2007_extract.py
├── pretrainedmodels/
│   ├── __init__.py
│   ├── datasets/
│   │   ├── __init__.py
│   │   ├── utils.py
│   │   └── voc.py
│   ├── models/
│   │   ├── __init__.py
│   │   ├── bninception.py
│   │   ├── cafferesnet.py
│   │   ├── dpn.py
│   │   ├── fbresnet/
│   │   │   ├── resnet152_dump.lua
│   │   │   └── resnet152_load.py
│   │   ├── fbresnet.py
│   │   ├── inceptionresnetv2.py
│   │   ├── inceptionv4.py
│   │   ├── nasnet.py
│   │   ├── nasnet_mobile.py
│   │   ├── pnasnet.py
│   │   ├── polynet.py
│   │   ├── resnext.py
│   │   ├── resnext_features/
│   │   │   ├── __init__.py
│   │   │   ├── resnext101_32x4d_features.py
│   │   │   └── resnext101_64x4d_features.py
│   │   ├── senet.py
│   │   ├── torchvision_models.py
│   │   ├── utils.py
│   │   ├── vggm.py
│   │   ├── wideresnet.py
│   │   └── xception.py
│   ├── utils.py
│   └── version.py
├── requirements.txt
├── setup.cfg
├── setup.py
└── tests/
    ├── test_pm_imagenet.py
    └── test_torch_save.py

================================================
FILE CONTENTS
================================================

================================================
FILE: .gitignore
================================================
# Added by ~ cadene ~
.DS_Store
._.DS_Store

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
#  Usually these files are written by a python script from a template
#  before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/


================================================
FILE: .travis.yml
================================================
language: python
python:
  - "3.6"
 # - "2.7"

# cache:
#   directories:
#     - $HOME/.torch

stages:
#  - lint_check
  - test
#  - docs

install:
  - sudo apt-get update
  - wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
  - bash miniconda.sh -b -p $HOME/miniconda
  - export PATH="$HOME/miniconda/bin:$PATH"
  - hash -r
  - conda config --set always_yes yes --set changeps1 no
  - conda update -q conda
  # Useful for debugging any issues with conda
  - conda info -a
  - conda create -q -n test-environment -c pytorch python=$TRAVIS_PYTHON_VERSION numpy mock pytorch-cpu
  - if [[ $TRAVIS_PYTHON_VERSION == 2.7 ]]; then pip install enum34; fi
  - source activate test-environment
  - python setup.py install
  - pip install --upgrade pytest #codecov pytest-cov
  # Test contrib dependencies
  # - pip install scikit-learn
  # Examples dependencies
  - pip install -r requirements.txt
  #visdom torchvision tensorboardX
  #- pip install gym
  #- pip install tqdm

script:
  - python -m pytest -s tests #--cov pretrainedmodels --cov-report term-missing

  # Smoke tests for the examples
  # Mnist
  # 1) mnist.py
  #- python examples/mnist/mnist.py --epochs=1
  # 2) mnist_with_visdom.py
  # - python -c "from visdom.server import download_scripts; download_scripts()" # download scripts : https://github.com/facebookresearch/visdom/blob/master/py/server.py#L929
  # - python -m visdom.server &
  # - sleep 10
  # - python examples/mnist/mnist_with_visdom.py --epochs=1
  # - kill %1
  # # 3) mnist_with_tensorboardx.py
  # - python examples/mnist/mnist_with_tensorboardx.py --epochs=1

  # # dcgan.py
  # - python examples/gan/dcgan.py --dataset fake --dataroot /tmp/fakedata --output-dir /tmp/outputs-dcgan --batch-size 2 --epochs 2  --workers 0

  # # RL
  # # 1) Actor-Critic
  # - python examples/reinforcement_learning/actor_critic.py --max-episodes=2
  # # 1) Reinforce
  # - python examples/reinforcement_learning/reinforce.py --max-episodes=2

  # #fast-neural-style
  # #train
  # - python examples/fast_neural_style/neural_style.py train --epochs 1 --cuda 0 --dataset test --dataroot . --image_size 32 --style_image examples/fast_neural_style/images/style_images/mosaic.jpg --style_size 32

after_success:
  # Ignore codecov failures as the codecov server is not
  # very reliable but we don't want travis to report a failure
  # in the github UI just because the coverage report failed to
  # be published.
  - codecov || echo "codecov upload failed"

# jobs:
#   include:
#     - stage: lint_check
#       python: "3.6"
#       install: pip install flake8
#       script: flake8
#       after_success: # Nothing to do


#     # GitHub Pages Deployment: https://docs.travis-ci.com/user/deployment/pages/
#     - stage: docs
#       python: "3.6"
#       install:
#         # Minimal install : ignite and dependencies just to build the docs
#         - pip install -r docs/requirements.txt
#         - pip install http://download.pytorch.org/whl/cpu/torch-0.4.1-cp35-cp35m-linux_x86_64.whl
#         # Add contrib dependencies (otherwise doc is not built)
#         - pip install scikit-learn scipy
#         # `pip install .` vs `python setup.py install` : 1st works better to produce _module/ignite with source links
#         - pip install .
#       script:
#         - cd docs && make html
#         # Create .nojekyll file to serve correctly _static and friends
#         - touch build/html/.nojekyll
#       after_success: # Nothing to do
#       deploy:
#         provider: pages
#         skip-cleanup: true
#         github-token: $GITHUB_TOKEN  # Set in the settings page of your repository, as a secure variable
#         keep-history: false
#         local_dir: docs/build/html
#         on:
#           branch: master

================================================
FILE: LICENSE.txt
================================================
BSD 3-Clause License

Copyright (c) 2017, Remi Cadene
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
  list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
  this list of conditions and the following disclaimer in the documentation
  and/or other materials provided with the distribution.

* Neither the name of the copyright holder nor the names of its
  contributors may be used to endorse or promote products derived from
  this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


================================================
FILE: README.md
================================================
# Pretrained models for Pytorch (Work in progress)

The goal of this repo is:

- to help to reproduce research papers results (transfer learning setups for instance),
- to access pretrained ConvNets with a unique interface/API inspired by torchvision.

<a href="https://travis-ci.org/Cadene/pretrained-models.pytorch"><img src="https://api.travis-ci.org/Cadene/pretrained-models.pytorch.svg?branch=master"/></a>

News:
- 27/10/2018: Fix compatibility issues, Add tests, Add travis
- 04/06/2018: [PolyNet](https://github.com/CUHK-MMLAB/polynet) and [PNASNet-5-Large](https://arxiv.org/abs/1712.00559) thanks to [Alex Parinov](https://github.com/creafz)
- 16/04/2018: [SE-ResNet* and SE-ResNeXt*](https://github.com/hujie-frank/SENet) thanks to [Alex Parinov](https://github.com/creafz)
- 09/04/2018: [SENet154](https://github.com/hujie-frank/SENet) thanks to [Alex Parinov](https://github.com/creafz)
- 22/03/2018: CaffeResNet101 (good for localization with FasterRCNN)
- 21/03/2018: NASNet Mobile thanks to [Veronika Yurchuk](https://github.com/veronikayurchuk) and [Anastasiia](https://github.com/DagnyT)
- 25/01/2018: DualPathNetworks thanks to [Ross Wightman](https://github.com/rwightman/pytorch-dpn-pretrained), Xception thanks to [T Standley](https://github.com/tstandley/Xception-PyTorch), improved TransformImage API
- 13/01/2018: `pip install pretrainedmodels`, `pretrainedmodels.model_names`, `pretrainedmodels.pretrained_settings`
- 12/01/2018: `python setup.py install`
- 08/12/2017: update data url (/!\ `git pull` is needed)
- 30/11/2017: improve API (`model.features(input)`, `model.logits(features)`, `model.forward(input)`, `model.last_linear`)
- 16/11/2017: nasnet-a-large pretrained model ported by T. Durand and R. Cadene
- 22/07/2017: torchvision pretrained models
- 22/07/2017: momentum in inceptionv4 and inceptionresnetv2 to 0.1
- 17/07/2017: model.input_range attribut
- 17/07/2017: BNInception pretrained on Imagenet

## Summary

- [Installation](https://github.com/Cadene/pretrained-models.pytorch#installation)
- [Quick examples](https://github.com/Cadene/pretrained-models.pytorch#quick-examples)
- [Few use cases](https://github.com/Cadene/pretrained-models.pytorch#few-use-cases)
    - [Compute imagenet logits](https://github.com/Cadene/pretrained-models.pytorch#compute-imagenet-logits)
    - [Compute imagenet validation metrics](https://github.com/Cadene/pretrained-models.pytorch#compute-imagenet-validation-metrics)
- [Evaluation on ImageNet](https://github.com/Cadene/pretrained-models.pytorch#evaluation-on-imagenet)
    - [Accuracy on valset](https://github.com/Cadene/pretrained-models.pytorch#accuracy-on-validation-set)
    - [Reproducing results](https://github.com/Cadene/pretrained-models.pytorch#reproducing-results)
- [Documentation](https://github.com/Cadene/pretrained-models.pytorch#documentation)
    - [Available models](https://github.com/Cadene/pretrained-models.pytorch#available-models)
        - [AlexNet](https://github.com/Cadene/pretrained-models.pytorch#torchvision)
        - [BNInception](https://github.com/Cadene/pretrained-models.pytorch#bninception)
        - [CaffeResNet101](https://github.com/Cadene/pretrained-models.pytorch#caffe-resnet)
        - [DenseNet121](https://github.com/Cadene/pretrained-models.pytorch#torchvision)
        - [DenseNet161](https://github.com/Cadene/pretrained-models.pytorch#torchvision)
        - [DenseNet169](https://github.com/Cadene/pretrained-models.pytorch#torchvision)
        - [DenseNet201](https://github.com/Cadene/pretrained-models.pytorch#torchvision)
        - [DenseNet201](https://github.com/Cadene/pretrained-models.pytorch#torchvision)
        - [DualPathNet68](https://github.com/Cadene/pretrained-models.pytorch#dualpathnetworks)
        - [DualPathNet92](https://github.com/Cadene/pretrained-models.pytorch#dualpathnetworks)
        - [DualPathNet98](https://github.com/Cadene/pretrained-models.pytorch#dualpathnetworks)
        - [DualPathNet107](https://github.com/Cadene/pretrained-models.pytorch#dualpathnetworks)
        - [DualPathNet113](https://github.com/Cadene/pretrained-models.pytorch#dualpathnetworks)
        - [FBResNet152](https://github.com/Cadene/pretrained-models.pytorch#facebook-resnet)
        - [InceptionResNetV2](https://github.com/Cadene/pretrained-models.pytorch#inception)
        - [InceptionV3](https://github.com/Cadene/pretrained-models.pytorch#inception)
        - [InceptionV4](https://github.com/Cadene/pretrained-models.pytorch#inception)
        - [NASNet-A-Large](https://github.com/Cadene/pretrained-models.pytorch#nasnet)
        - [NASNet-A-Mobile](https://github.com/Cadene/pretrained-models.pytorch#nasnet)
        - [PNASNet-5-Large](https://github.com/Cadene/pretrained-models.pytorch#pnasnet)
        - [PolyNet](https://github.com/Cadene/pretrained-models.pytorch#polynet)
        - [ResNeXt101_32x4d](https://github.com/Cadene/pretrained-models.pytorch#resnext)
        - [ResNeXt101_64x4d](https://github.com/Cadene/pretrained-models.pytorch#resnext)
        - [ResNet101](https://github.com/Cadene/pretrained-models.pytorch#torchvision)
        - [ResNet152](https://github.com/Cadene/pretrained-models.pytorch#torchvision)
        - [ResNet18](https://github.com/Cadene/pretrained-models.pytorch#torchvision)
        - [ResNet34](https://github.com/Cadene/pretrained-models.pytorch#torchvision)
        - [ResNet50](https://github.com/Cadene/pretrained-models.pytorch#torchvision)
        - [SENet154](https://github.com/Cadene/pretrained-models.pytorch#senet)
        - [SE-ResNet50](https://github.com/Cadene/pretrained-models.pytorch#senet)
        - [SE-ResNet101](https://github.com/Cadene/pretrained-models.pytorch#senet)
        - [SE-ResNet152](https://github.com/Cadene/pretrained-models.pytorch#senet)
        - [SE-ResNeXt50_32x4d](https://github.com/Cadene/pretrained-models.pytorch#senet)
        - [SE-ResNeXt101_32x4d](https://github.com/Cadene/pretrained-models.pytorch#senet)
        - [SqueezeNet1_0](https://github.com/Cadene/pretrained-models.pytorch#torchvision)
        - [SqueezeNet1_1](https://github.com/Cadene/pretrained-models.pytorch#torchvision)
        - [VGG11](https://github.com/Cadene/pretrained-models.pytorch#torchvision)
        - [VGG13](https://github.com/Cadene/pretrained-models.pytorch#torchvision)
        - [VGG16](https://github.com/Cadene/pretrained-models.pytorch#torchvision)
        - [VGG19](https://github.com/Cadene/pretrained-models.pytorch#torchvision)
        - [VGG11_BN](https://github.com/Cadene/pretrained-models.pytorch#torchvision)
        - [VGG13_BN](https://github.com/Cadene/pretrained-models.pytorch#torchvision)
        - [VGG16_BN](https://github.com/Cadene/pretrained-models.pytorch#torchvision)
        - [VGG19_BN](https://github.com/Cadene/pretrained-models.pytorch#torchvision)
        - [Xception](https://github.com/Cadene/pretrained-models.pytorch#xception)
    - [Model API](https://github.com/Cadene/pretrained-models.pytorch#model-api)
        - [model.input_size](https://github.com/Cadene/pretrained-models.pytorch#modelinput_size)
        - [model.input_space](https://github.com/Cadene/pretrained-models.pytorch#modelinput_space)
        - [model.input_range](https://github.com/Cadene/pretrained-models.pytorch#modelinput_range)
        - [model.mean](https://github.com/Cadene/pretrained-models.pytorch#modelmean)
        - [model.std](https://github.com/Cadene/pretrained-models.pytorch#modelstd)
        - [model.features](https://github.com/Cadene/pretrained-models.pytorch#modelfeatures)
        - [model.logits](https://github.com/Cadene/pretrained-models.pytorch#modellogits)
        - [model.forward](https://github.com/Cadene/pretrained-models.pytorch#modelforward)
- [Reproducing porting](https://github.com/Cadene/pretrained-models.pytorch#reproducing)
    - [ResNet*](https://github.com/Cadene/pretrained-models.pytorch#hand-porting-of-resnet152)
    - [ResNeXt*](https://github.com/Cadene/pretrained-models.pytorch#automatic-porting-of-resnext)
    - [Inception*](https://github.com/Cadene/pretrained-models.pytorch#hand-porting-of-inceptionv4-and-inceptionresnetv2)

## Installation

1. [python3 with anaconda](https://www.continuum.io/downloads)
2. [pytorch with/out CUDA](http://pytorch.org)

### Install from pip

3. `pip install pretrainedmodels`

### Install from repo

3. `git clone https://github.com/Cadene/pretrained-models.pytorch.git`
4. `cd pretrained-models.pytorch`
5. `python setup.py install`


## Quick examples

- To import `pretrainedmodels`:

```python
import pretrainedmodels
```

- To print the available pretrained models:

```python
print(pretrainedmodels.model_names)
> ['fbresnet152', 'bninception', 'resnext101_32x4d', 'resnext101_64x4d', 'inceptionv4', 'inceptionresnetv2', 'alexnet', 'densenet121', 'densenet169', 'densenet201', 'densenet161', 'resnet18', 'resnet34', 'resnet50', 'resnet101', 'resnet152', 'inceptionv3', 'squeezenet1_0', 'squeezenet1_1', 'vgg11', 'vgg11_bn', 'vgg13', 'vgg13_bn', 'vgg16', 'vgg16_bn', 'vgg19_bn', 'vgg19', 'nasnetalarge', 'nasnetamobile', 'cafferesnet101', 'senet154',  'se_resnet50', 'se_resnet101', 'se_resnet152', 'se_resnext50_32x4d', 'se_resnext101_32x4d', 'cafferesnet101', 'polynet', 'pnasnet5large']
```

- To print the available pretrained settings for a chosen model:

```python
print(pretrainedmodels.pretrained_settings['nasnetalarge'])
> {'imagenet': {'url': 'http://data.lip6.fr/cadene/pretrainedmodels/nasnetalarge-a1897284.pth', 'input_space': 'RGB', 'input_size': [3, 331, 331], 'input_range': [0, 1], 'mean': [0.5, 0.5, 0.5], 'std': [0.5, 0.5, 0.5], 'num_classes': 1000}, 'imagenet+background': {'url': 'http://data.lip6.fr/cadene/pretrainedmodels/nasnetalarge-a1897284.pth', 'input_space': 'RGB', 'input_size': [3, 331, 331], 'input_range': [0, 1], 'mean': [0.5, 0.5, 0.5], 'std': [0.5, 0.5, 0.5], 'num_classes': 1001}}
```

- To load a pretrained models from imagenet:

```python
model_name = 'nasnetalarge' # could be fbresnet152 or inceptionresnetv2
model = pretrainedmodels.__dict__[model_name](num_classes=1000, pretrained='imagenet')
model.eval()
```

**Note**: By default, models will be downloaded to your `$HOME/.torch` folder. You can modify this behavior using the `$TORCH_HOME` variable as follow: `export TORCH_HOME="/local/pretrainedmodels"`

- To load an image and do a complete forward pass:

```python
import torch
import pretrainedmodels.utils as utils

load_img = utils.LoadImage()

# transformations depending on the model
# rescale, center crop, normalize, and others (ex: ToBGR, ToRange255)
tf_img = utils.TransformImage(model) 

path_img = 'data/cat.jpg'

input_img = load_img(path_img)
input_tensor = tf_img(input_img)         # 3x400x225 -> 3x299x299 size may differ
input_tensor = input_tensor.unsqueeze(0) # 3x299x299 -> 1x3x299x299
input = torch.autograd.Variable(input_tensor,
    requires_grad=False)

output_logits = model(input) # 1x1000
```

- To extract features (beware this API is not available for all networks):

```python
output_features = model.features(input) # 1x14x14x2048 size may differ
output_logits = model.logits(output_features) # 1x1000
```

## Few use cases

### Compute imagenet logits

- See [examples/imagenet_logits.py](https://github.com/Cadene/pretrained-models.pytorch/blob/master/examples/imagenet_logits.py) to compute logits of classes appearance over a single image with a pretrained model on imagenet.

```
$ python examples/imagenet_logits.py -h
> nasnetalarge, resnet152, inceptionresnetv2, inceptionv4, ...
```

```
$ python examples/imagenet_logits.py -a nasnetalarge --path_img data/cat.jpg
> 'nasnetalarge': data/cat.jpg' is a 'tiger cat' 
```

### Compute imagenet evaluation metrics

- See [examples/imagenet_eval.py](https://github.com/Cadene/pretrained-models.pytorch/blob/master/examples/imagenet_eval.py) to evaluate pretrained models on imagenet valset. 

```
$ python examples/imagenet_eval.py /local/common-data/imagenet_2012/images -a nasnetalarge -b 20 -e
> * Acc@1 82.693, Acc@5 96.13
```


## Evaluation on imagenet

### Accuracy on validation set (single model)

Results were obtained using (center cropped) images of the same size than during the training process.

Model | Version | Acc@1 | Acc@5
--- | --- | --- | ---
PNASNet-5-Large | [Tensorflow](https://github.com/tensorflow/models/tree/master/research/slim) | 82.858 | 96.182
[PNASNet-5-Large](https://github.com/Cadene/pretrained-models.pytorch#pnasnet) | Our porting | 82.736 | 95.992
NASNet-A-Large | [Tensorflow](https://github.com/tensorflow/models/tree/master/research/slim) | 82.693 | 96.163
[NASNet-A-Large](https://github.com/Cadene/pretrained-models.pytorch#nasnet) | Our porting | 82.566 | 96.086
SENet154 | [Caffe](https://github.com/hujie-frank/SENet) | 81.32 | 95.53
[SENet154](https://github.com/Cadene/pretrained-models.pytorch#senet) | Our porting | 81.304 | 95.498
PolyNet | [Caffe](https://github.com/CUHK-MMLAB/polynet) | 81.29 | 95.75
[PolyNet](https://github.com/Cadene/pretrained-models.pytorch#polynet) | Our porting | 81.002 | 95.624
InceptionResNetV2 | [Tensorflow](https://github.com/tensorflow/models/tree/master/slim) | 80.4 | 95.3
InceptionV4 | [Tensorflow](https://github.com/tensorflow/models/tree/master/slim) | 80.2 | 95.3
[SE-ResNeXt101_32x4d](https://github.com/Cadene/pretrained-models.pytorch#senet) | Our porting | 80.236 | 95.028
SE-ResNeXt101_32x4d | [Caffe](https://github.com/hujie-frank/SENet) | 80.19 | 95.04
[InceptionResNetV2](https://github.com/Cadene/pretrained-models.pytorch#inception) | Our porting | 80.170 | 95.234
[InceptionV4](https://github.com/Cadene/pretrained-models.pytorch#inception) | Our porting | 80.062 | 94.926
[DualPathNet107_5k](https://github.com/Cadene/pretrained-models.pytorch#dualpathnetworks) | Our porting | 79.746 | 94.684
ResNeXt101_64x4d | [Torch7](https://github.com/facebookresearch/ResNeXt) | 79.6 | 94.7
[DualPathNet131](https://github.com/Cadene/pretrained-models.pytorch#dualpathnetworks) | Our porting | 79.432 | 94.574
[DualPathNet92_5k](https://github.com/Cadene/pretrained-models.pytorch#dualpathnetworks) | Our porting | 79.400 | 94.620
[DualPathNet98](https://github.com/Cadene/pretrained-models.pytorch#dualpathnetworks) | Our porting | 79.224 | 94.488
[SE-ResNeXt50_32x4d](https://github.com/Cadene/pretrained-models.pytorch#senet) | Our porting | 79.076 | 94.434
SE-ResNeXt50_32x4d | [Caffe](https://github.com/hujie-frank/SENet) | 79.03 | 94.46
[Xception](https://github.com/Cadene/pretrained-models.pytorch#xception) | [Keras](https://github.com/keras-team/keras/blob/master/keras/applications/xception.py) | 79.000 | 94.500
[ResNeXt101_64x4d](https://github.com/Cadene/pretrained-models.pytorch#resnext) | Our porting | 78.956 | 94.252
[Xception](https://github.com/Cadene/pretrained-models.pytorch#xception) | Our porting | 78.888 | 94.292
ResNeXt101_32x4d | [Torch7](https://github.com/facebookresearch/ResNeXt) | 78.8 | 94.4
SE-ResNet152 | [Caffe](https://github.com/hujie-frank/SENet) | 78.66 | 94.46
[SE-ResNet152](https://github.com/Cadene/pretrained-models.pytorch#senet) | Our porting | 78.658 | 94.374
ResNet152 | [Pytorch](https://github.com/pytorch/vision#models) | 78.428 | 94.110
[SE-ResNet101](https://github.com/Cadene/pretrained-models.pytorch#senet) | Our porting | 78.396 | 94.258
SE-ResNet101 | [Caffe](https://github.com/hujie-frank/SENet) | 78.25 | 94.28
[ResNeXt101_32x4d](https://github.com/Cadene/pretrained-models.pytorch#resnext) | Our porting | 78.188 | 93.886
FBResNet152 | [Torch7](https://github.com/facebook/fb.resnet.torch) | 77.84 | 93.84
SE-ResNet50 | [Caffe](https://github.com/hujie-frank/SENet) | 77.63 | 93.64
[SE-ResNet50](https://github.com/Cadene/pretrained-models.pytorch#senet) | Our porting | 77.636 | 93.752
[DenseNet161](https://github.com/Cadene/pretrained-models.pytorch#torchvision) | [Pytorch](https://github.com/pytorch/vision#models) | 77.560 | 93.798
[ResNet101](https://github.com/Cadene/pretrained-models.pytorch#torchvision) | [Pytorch](https://github.com/pytorch/vision#models) | 77.438 | 93.672
[FBResNet152](https://github.com/Cadene/pretrained-models.pytorch#facebook-resnet) | Our porting | 77.386 | 93.594
[InceptionV3](https://github.com/Cadene/pretrained-models.pytorch#inception) | [Pytorch](https://github.com/pytorch/vision#models) | 77.294 | 93.454
[DenseNet201](https://github.com/Cadene/pretrained-models.pytorch#torchvision) | [Pytorch](https://github.com/pytorch/vision#models) | 77.152 | 93.548
[DualPathNet68b_5k](https://github.com/Cadene/pretrained-models.pytorch#dualpathnetworks) | Our porting | 77.034 | 93.590
[CaffeResnet101](https://github.com/Cadene/pretrained-models.pytorch#caffe-resnet) | [Caffe](https://github.com/KaimingHe/deep-residual-networks) | 76.400 | 92.900
[CaffeResnet101](https://github.com/Cadene/pretrained-models.pytorch#caffe-resnet) | Our porting | 76.200 | 92.766
[DenseNet169](https://github.com/Cadene/pretrained-models.pytorch#torchvision) | [Pytorch](https://github.com/pytorch/vision#models) | 76.026 | 92.992
[ResNet50](https://github.com/Cadene/pretrained-models.pytorch#torchvision) | [Pytorch](https://github.com/pytorch/vision#models) | 76.002 | 92.980
[DualPathNet68](https://github.com/Cadene/pretrained-models.pytorch#dualpathnetworks) | Our porting | 75.868 | 92.774
[DenseNet121](https://github.com/Cadene/pretrained-models.pytorch#torchvision) | [Pytorch](https://github.com/pytorch/vision#models) | 74.646 | 92.136
[VGG19_BN](https://github.com/Cadene/pretrained-models.pytorch#torchvision) | [Pytorch](https://github.com/pytorch/vision#models) | 74.266 | 92.066
NASNet-A-Mobile | [Tensorflow](https://github.com/tensorflow/models/tree/master/research/slim) | 74.0 | 91.6
[NASNet-A-Mobile](https://github.com/veronikayurchuk/pretrained-models.pytorch/blob/master/pretrainedmodels/models/nasnet_mobile.py) | Our porting | 74.080 | 91.740
[ResNet34](https://github.com/Cadene/pretrained-models.pytorch#torchvision) | [Pytorch](https://github.com/pytorch/vision#models) | 73.554 | 91.456
[BNInception](https://github.com/Cadene/pretrained-models.pytorch#bninception) | Our porting | 73.524 | 91.562
[VGG16_BN](https://github.com/Cadene/pretrained-models.pytorch#torchvision) | [Pytorch](https://github.com/pytorch/vision#models) | 73.518 | 91.608
[VGG19](https://github.com/Cadene/pretrained-models.pytorch#torchvision) | [Pytorch](https://github.com/pytorch/vision#models) | 72.080 | 90.822
[VGG16](https://github.com/Cadene/pretrained-models.pytorch#torchvision) | [Pytorch](https://github.com/pytorch/vision#models) | 71.636 | 90.354
[VGG13_BN](https://github.com/Cadene/pretrained-models.pytorch#torchvision) | [Pytorch](https://github.com/pytorch/vision#models) | 71.508 | 90.494
[VGG11_BN](https://github.com/Cadene/pretrained-models.pytorch#torchvision) | [Pytorch](https://github.com/pytorch/vision#models) | 70.452 | 89.818
[ResNet18](https://github.com/Cadene/pretrained-models.pytorch#torchvision) | [Pytorch](https://github.com/pytorch/vision#models) | 70.142 | 89.274
[VGG13](https://github.com/Cadene/pretrained-models.pytorch#torchvision) | [Pytorch](https://github.com/pytorch/vision#models) | 69.662 | 89.264
[VGG11](https://github.com/Cadene/pretrained-models.pytorch#torchvision) | [Pytorch](https://github.com/pytorch/vision#models) | 68.970 | 88.746
[SqueezeNet1_1](https://github.com/Cadene/pretrained-models.pytorch#torchvision) | [Pytorch](https://github.com/pytorch/vision#models) | 58.250 | 80.800
[SqueezeNet1_0](https://github.com/Cadene/pretrained-models.pytorch#torchvision) | [Pytorch](https://github.com/pytorch/vision#models) | 58.108 | 80.428
[Alexnet](https://github.com/Cadene/pretrained-models.pytorch#torchvision) | [Pytorch](https://github.com/pytorch/vision#models) | 56.432 | 79.194

Notes:
- the Pytorch version of ResNet152 is not a porting of the Torch7 but has been retrained by facebook.
- For the PolyNet evaluation each image was resized to 378x378 without preserving the aspect ratio and then the central 331×331 patch from the resulting image was used.

Beware, the accuracy reported here is not always representative of the transferable capacity of the network on other tasks and datasets. You must try them all! :P
    
### Reproducing results

Please see [Compute imagenet validation metrics](https://github.com/Cadene/pretrained-models.pytorch#compute-imagenet-validation-metrics)


## Documentation

### Available models

#### NASNet*

Source: [TensorFlow Slim repo](https://github.com/tensorflow/models/tree/master/research/slim)

- `nasnetalarge(num_classes=1000, pretrained='imagenet')`
- `nasnetalarge(num_classes=1001, pretrained='imagenet+background')`
- `nasnetamobile(num_classes=1000, pretrained='imagenet')`

#### FaceBook ResNet*

Source: [Torch7 repo of FaceBook](https://github.com/facebook/fb.resnet.torch)

There are a bit different from the ResNet* of torchvision. ResNet152 is currently the only one available.

- `fbresnet152(num_classes=1000, pretrained='imagenet')`

#### Caffe ResNet*

Source: [Caffe repo of KaimingHe](https://github.com/KaimingHe/deep-residual-networks)

- `cafferesnet101(num_classes=1000, pretrained='imagenet')`


#### Inception*

Source: [TensorFlow Slim repo](https://github.com/tensorflow/models/tree/master/slim) and [Pytorch/Vision repo](https://github.com/pytorch/vision/tree/master/torchvision) for `inceptionv3`

- `inceptionresnetv2(num_classes=1000, pretrained='imagenet')`
- `inceptionresnetv2(num_classes=1001, pretrained='imagenet+background')`
- `inceptionv4(num_classes=1000, pretrained='imagenet')`
- `inceptionv4(num_classes=1001, pretrained='imagenet+background')`
- `inceptionv3(num_classes=1000, pretrained='imagenet')`

#### BNInception

Source: [Trained with Caffe](https://github.com/Cadene/tensorflow-model-zoo.torch/pull/2) by [Xiong Yuanjun](http://yjxiong.me)

- `bninception(num_classes=1000, pretrained='imagenet')`

#### ResNeXt*

Source: [ResNeXt repo of FaceBook](https://github.com/facebookresearch/ResNeXt)

- `resnext101_32x4d(num_classes=1000, pretrained='imagenet')`
- `resnext101_62x4d(num_classes=1000, pretrained='imagenet')`

#### DualPathNetworks

Source: [MXNET repo of Chen Yunpeng](https://github.com/cypw/DPNs)

The porting has been made possible by [Ross Wightman](http://rwightman.com) in his [PyTorch repo](https://github.com/rwightman/pytorch-dpn-pretrained).

As you can see [here](https://github.com/rwightman/pytorch-dpn-pretrained) DualPathNetworks allows you to try different scales. The default one in this repo is 0.875 meaning that the original input size is 256 before croping to 224.

- `dpn68(num_classes=1000, pretrained='imagenet')`
- `dpn98(num_classes=1000, pretrained='imagenet')`
- `dpn131(num_classes=1000, pretrained='imagenet')`
- `dpn68b(num_classes=1000, pretrained='imagenet+5k')`
- `dpn92(num_classes=1000, pretrained='imagenet+5k')`
- `dpn107(num_classes=1000, pretrained='imagenet+5k')`

`'imagenet+5k'` means that the network has been pretrained on imagenet5k before being finetuned on imagenet1k.

#### Xception

Source: [Keras repo](https://github.com/keras-team/keras/blob/master/keras/applications/xception.py)

The porting has been made possible by [T Standley](https://github.com/tstandley/Xception-PyTorch).

- `xception(num_classes=1000, pretrained='imagenet')`


#### SENet*

Source: [Caffe repo of Jie Hu](https://github.com/hujie-frank/SENet)

- `senet154(num_classes=1000, pretrained='imagenet')`
- `se_resnet50(num_classes=1000, pretrained='imagenet')`
- `se_resnet101(num_classes=1000, pretrained='imagenet')`
- `se_resnet152(num_classes=1000, pretrained='imagenet')`
- `se_resnext50_32x4d(num_classes=1000, pretrained='imagenet')`
- `se_resnext101_32x4d(num_classes=1000, pretrained='imagenet')`

#### PNASNet*

Source: [TensorFlow Slim repo](https://github.com/tensorflow/models/tree/master/research/slim)

- `pnasnet5large(num_classes=1000, pretrained='imagenet')`
- `pnasnet5large(num_classes=1001, pretrained='imagenet+background')`

#### PolyNet

Source: [Caffe repo of the CUHK Multimedia Lab](https://github.com/CUHK-MMLAB/polynet)

- `polynet(num_classes=1000, pretrained='imagenet')`

#### TorchVision

Source: [Pytorch/Vision repo](https://github.com/pytorch/vision/tree/master/torchvision)

(`inceptionv3` included in [Inception*](https://github.com/Cadene/pretrained-models.pytorch#inception))

- `resnet18(num_classes=1000, pretrained='imagenet')`
- `resnet34(num_classes=1000, pretrained='imagenet')`
- `resnet50(num_classes=1000, pretrained='imagenet')`
- `resnet101(num_classes=1000, pretrained='imagenet')`
- `resnet152(num_classes=1000, pretrained='imagenet')`
- `densenet121(num_classes=1000, pretrained='imagenet')`
- `densenet161(num_classes=1000, pretrained='imagenet')`
- `densenet169(num_classes=1000, pretrained='imagenet')`
- `densenet201(num_classes=1000, pretrained='imagenet')`
- `squeezenet1_0(num_classes=1000, pretrained='imagenet')`
- `squeezenet1_1(num_classes=1000, pretrained='imagenet')`
- `alexnet(num_classes=1000, pretrained='imagenet')`
- `vgg11(num_classes=1000, pretrained='imagenet')`
- `vgg13(num_classes=1000, pretrained='imagenet')`
- `vgg16(num_classes=1000, pretrained='imagenet')`
- `vgg19(num_classes=1000, pretrained='imagenet')`
- `vgg11_bn(num_classes=1000, pretrained='imagenet')`
- `vgg13_bn(num_classes=1000, pretrained='imagenet')`
- `vgg16_bn(num_classes=1000, pretrained='imagenet')`
- `vgg19_bn(num_classes=1000, pretrained='imagenet')`


### Model API

Once a pretrained model has been loaded, you can use it that way.

**Important note**: All image must be loaded using `PIL` which scales the pixel values between 0 and 1.

#### `model.input_size`

Attribut of type `list` composed of 3 numbers:

- number of color channels,
- height of the input image,
- width of the input image.

Example:

- `[3, 299, 299]` for inception* networks,
- `[3, 224, 224]` for resnet* networks.


#### `model.input_space`

Attribut of type `str` representating the color space of the image. Can be `RGB` or `BGR`.


#### `model.input_range`

Attribut of type `list` composed of 2 numbers:

- min pixel value,
- max pixel value.

Example:

- `[0, 1]` for resnet* and inception* networks,
- `[0, 255]` for bninception network.


#### `model.mean`

Attribut of type `list` composed of 3 numbers which are used to normalize the input image (substract "color-channel-wise").

Example:

- `[0.5, 0.5, 0.5]` for inception* networks,
- `[0.485, 0.456, 0.406]` for resnet* networks.


#### `model.std`

Attribut of type `list` composed of 3 numbers which are used to normalize the input image (divide "color-channel-wise").

Example:

- `[0.5, 0.5, 0.5]` for inception* networks,
- `[0.229, 0.224, 0.225]` for resnet* networks.


#### `model.features`

/!\ work in progress (may not be available)

Method which is used to extract the features from the image.

Example when the model is loaded using `fbresnet152`:

```python
print(input_224.size())            # (1,3,224,224)
output = model.features(input_224) 
print(output.size())               # (1,2048,1,1)

# print(input_448.size())          # (1,3,448,448)
output = model.features(input_448)
# print(output.size())             # (1,2048,7,7)
```

#### `model.logits`

/!\ work in progress (may not be available)

Method which is used to classify the features from the image.

Example when the model is loaded using `fbresnet152`:

```python
output = model.features(input_224) 
print(output.size())               # (1,2048, 1, 1)
output = model.logits(output)
print(output.size())               # (1,1000)
```

#### `model.forward`

Method used to call `model.features` and `model.logits`. It can be overwritten as desired.

**Note**: A good practice is to use `model.__call__` as your function of choice to forward an input to your model. See the example bellow.

```python
# Without model.__call__
output = model.forward(input_224)
print(output.size())      # (1,1000)

# With model.__call__
output = model(input_224)
print(output.size())      # (1,1000)
```

#### `model.last_linear`

Attribut of type `nn.Linear`. This module is the last one to be called during the forward pass.

- Can be replaced by an adapted `nn.Linear` for fine tuning.
- Can be replaced by `pretrained.utils.Identity` for features extraction. 

Example when the model is loaded using `fbresnet152`:

```python
print(input_224.size())            # (1,3,224,224)
output = model.features(input_224) 
print(output.size())               # (1,2048,1,1)
output = model.logits(output)
print(output.size())               # (1,1000)

# fine tuning
dim_feats = model.last_linear.in_features # =2048
nb_classes = 4
model.last_linear = nn.Linear(dim_feats, nb_classes)
output = model(input_224)
print(output.size())               # (1,4)

# features extraction
model.last_linear = pretrained.utils.Identity()
output = model(input_224)
print(output.size())               # (1,2048)
```

## Reproducing

### Hand porting of ResNet152

```
th pretrainedmodels/fbresnet/resnet152_dump.lua
python pretrainedmodels/fbresnet/resnet152_load.py
```

### Automatic porting of ResNeXt

https://github.com/clcarwin/convert_torch_to_pytorch

### Hand porting of NASNet, InceptionV4 and InceptionResNetV2

https://github.com/Cadene/tensorflow-model-zoo.torch


## Acknowledgement

Thanks to the deep learning community and especially to the contributers of the pytorch ecosystem.


================================================
FILE: data/imagenet_classes.txt
================================================
n01440764
n01443537
n01484850
n01491361
n01494475
n01496331
n01498041
n01514668
n01514859
n01518878
n01530575
n01531178
n01532829
n01534433
n01537544
n01558993
n01560419
n01580077
n01582220
n01592084
n01601694
n01608432
n01614925
n01616318
n01622779
n01629819
n01630670
n01631663
n01632458
n01632777
n01641577
n01644373
n01644900
n01664065
n01665541
n01667114
n01667778
n01669191
n01675722
n01677366
n01682714
n01685808
n01687978
n01688243
n01689811
n01692333
n01693334
n01694178
n01695060
n01697457
n01698640
n01704323
n01728572
n01728920
n01729322
n01729977
n01734418
n01735189
n01737021
n01739381
n01740131
n01742172
n01744401
n01748264
n01749939
n01751748
n01753488
n01755581
n01756291
n01768244
n01770081
n01770393
n01773157
n01773549
n01773797
n01774384
n01774750
n01775062
n01776313
n01784675
n01795545
n01796340
n01797886
n01798484
n01806143
n01806567
n01807496
n01817953
n01818515
n01819313
n01820546
n01824575
n01828970
n01829413
n01833805
n01843065
n01843383
n01847000
n01855032
n01855672
n01860187
n01871265
n01872401
n01873310
n01877812
n01882714
n01883070
n01910747
n01914609
n01917289
n01924916
n01930112
n01943899
n01944390
n01945685
n01950731
n01955084
n01968897
n01978287
n01978455
n01980166
n01981276
n01983481
n01984695
n01985128
n01986214
n01990800
n02002556
n02002724
n02006656
n02007558
n02009229
n02009912
n02011460
n02012849
n02013706
n02017213
n02018207
n02018795
n02025239
n02027492
n02028035
n02033041
n02037110
n02051845
n02056570
n02058221
n02066245
n02071294
n02074367
n02077923
n02085620
n02085782
n02085936
n02086079
n02086240
n02086646
n02086910
n02087046
n02087394
n02088094
n02088238
n02088364
n02088466
n02088632
n02089078
n02089867
n02089973
n02090379
n02090622
n02090721
n02091032
n02091134
n02091244
n02091467
n02091635
n02091831
n02092002
n02092339
n02093256
n02093428
n02093647
n02093754
n02093859
n02093991
n02094114
n02094258
n02094433
n02095314
n02095570
n02095889
n02096051
n02096177
n02096294
n02096437
n02096585
n02097047
n02097130
n02097209
n02097298
n02097474
n02097658
n02098105
n02098286
n02098413
n02099267
n02099429
n02099601
n02099712
n02099849
n02100236
n02100583
n02100735
n02100877
n02101006
n02101388
n02101556
n02102040
n02102177
n02102318
n02102480
n02102973
n02104029
n02104365
n02105056
n02105162
n02105251
n02105412
n02105505
n02105641
n02105855
n02106030
n02106166
n02106382
n02106550
n02106662
n02107142
n02107312
n02107574
n02107683
n02107908
n02108000
n02108089
n02108422
n02108551
n02108915
n02109047
n02109525
n02109961
n02110063
n02110185
n02110341
n02110627
n02110806
n02110958
n02111129
n02111277
n02111500
n02111889
n02112018
n02112137
n02112350
n02112706
n02113023
n02113186
n02113624
n02113712
n02113799
n02113978
n02114367
n02114548
n02114712
n02114855
n02115641
n02115913
n02116738
n02117135
n02119022
n02119789
n02120079
n02120505
n02123045
n02123159
n02123394
n02123597
n02124075
n02125311
n02127052
n02128385
n02128757
n02128925
n02129165
n02129604
n02130308
n02132136
n02133161
n02134084
n02134418
n02137549
n02138441
n02165105
n02165456
n02167151
n02168699
n02169497
n02172182
n02174001
n02177972
n02190166
n02206856
n02219486
n02226429
n02229544
n02231487
n02233338
n02236044
n02256656
n02259212
n02264363
n02268443
n02268853
n02276258
n02277742
n02279972
n02280649
n02281406
n02281787
n02317335
n02319095
n02321529
n02325366
n02326432
n02328150
n02342885
n02346627
n02356798
n02361337
n02363005
n02364673
n02389026
n02391049
n02395406
n02396427
n02397096
n02398521
n02403003
n02408429
n02410509
n02412080
n02415577
n02417914
n02422106
n02422699
n02423022
n02437312
n02437616
n02441942
n02442845
n02443114
n02443484
n02444819
n02445715
n02447366
n02454379
n02457408
n02480495
n02480855
n02481823
n02483362
n02483708
n02484975
n02486261
n02486410
n02487347
n02488291
n02488702
n02489166
n02490219
n02492035
n02492660
n02493509
n02493793
n02494079
n02497673
n02500267
n02504013
n02504458
n02509815
n02510455
n02514041
n02526121
n02536864
n02606052
n02607072
n02640242
n02641379
n02643566
n02655020
n02666196
n02667093
n02669723
n02672831
n02676566
n02687172
n02690373
n02692877
n02699494
n02701002
n02704792
n02708093
n02727426
n02730930
n02747177
n02749479
n02769748
n02776631
n02777292
n02782093
n02783161
n02786058
n02787622
n02788148
n02790996
n02791124
n02791270
n02793495
n02794156
n02795169
n02797295
n02799071
n02802426
n02804414
n02804610
n02807133
n02808304
n02808440
n02814533
n02814860
n02815834
n02817516
n02823428
n02823750
n02825657
n02834397
n02835271
n02837789
n02840245
n02841315
n02843684
n02859443
n02860847
n02865351
n02869837
n02870880
n02871525
n02877765
n02879718
n02883205
n02892201
n02892767
n02894605
n02895154
n02906734
n02909870
n02910353
n02916936
n02917067
n02927161
n02930766
n02939185
n02948072
n02950826
n02951358
n02951585
n02963159
n02965783
n02966193
n02966687
n02971356
n02974003
n02977058
n02978881
n02979186
n02980441
n02981792
n02988304
n02992211
n02992529
n02999410
n03000134
n03000247
n03000684
n03014705
n03016953
n03017168
n03018349
n03026506
n03028079
n03032252
n03041632
n03042490
n03045698
n03047690
n03062245
n03063599
n03063689
n03065424
n03075370
n03085013
n03089624
n03095699
n03100240
n03109150
n03110669
n03124043
n03124170
n03125729
n03126707
n03127747
n03127925
n03131574
n03133878
n03134739
n03141823
n03146219
n03160309
n03179701
n03180011
n03187595
n03188531
n03196217
n03197337
n03201208
n03207743
n03207941
n03208938
n03216828
n03218198
n03220513
n03223299
n03240683
n03249569
n03250847
n03255030
n03259280
n03271574
n03272010
n03272562
n03290653
n03291819
n03297495
n03314780
n03325584
n03337140
n03344393
n03345487
n03347037
n03355925
n03372029
n03376595
n03379051
n03384352
n03388043
n03388183
n03388549
n03393912
n03394916
n03400231
n03404251
n03417042
n03424325
n03425413
n03443371
n03444034
n03445777
n03445924
n03447447
n03447721
n03450230
n03452741
n03457902
n03459775
n03461385
n03467068
n03476684
n03476991
n03478589
n03481172
n03482405
n03483316
n03485407
n03485794
n03492542
n03494278
n03495258
n03496892
n03498962
n03527444
n03529860
n03530642
n03532672
n03534580
n03535780
n03538406
n03544143
n03584254
n03584829
n03590841
n03594734
n03594945
n03595614
n03598930
n03599486
n03602883
n03617480
n03623198
n03627232
n03630383
n03633091
n03637318
n03642806
n03649909
n03657121
n03658185
n03661043
n03662601
n03666591
n03670208
n03673027
n03676483
n03680355
n03690938
n03691459
n03692522
n03697007
n03706229
n03709823
n03710193
n03710637
n03710721
n03717622
n03720891
n03721384
n03724870
n03729826
n03733131
n03733281
n03733805
n03742115
n03743016
n03759954
n03761084
n03763968
n03764736
n03769881
n03770439
n03770679
n03773504
n03775071
n03775546
n03776460
n03777568
n03777754
n03781244
n03782006
n03785016
n03786901
n03787032
n03788195
n03788365
n03791053
n03792782
n03792972
n03793489
n03794056
n03796401
n03803284
n03804744
n03814639
n03814906
n03825788
n03832673
n03837869
n03838899
n03840681
n03841143
n03843555
n03854065
n03857828
n03866082
n03868242
n03868863
n03871628
n03873416
n03874293
n03874599
n03876231
n03877472
n03877845
n03884397
n03887697
n03888257
n03888605
n03891251
n03891332
n03895866
n03899768
n03902125
n03903868
n03908618
n03908714
n03916031
n03920288
n03924679
n03929660
n03929855
n03930313
n03930630
n03933933
n03935335
n03937543
n03938244
n03942813
n03944341
n03947888
n03950228
n03954731
n03956157
n03958227
n03961711
n03967562
n03970156
n03976467
n03976657
n03977966
n03980874
n03982430
n03983396
n03991062
n03992509
n03995372
n03998194
n04004767
n04005630
n04008634
n04009552
n04019541
n04023962
n04026417
n04033901
n04033995
n04037443
n04039381
n04040759
n04041544
n04044716
n04049303
n04065272
n04067472
n04069434
n04070727
n04074963
n04081281
n04086273
n04090263
n04099969
n04111531
n04116512
n04118538
n04118776
n04120489
n04125021
n04127249
n04131690
n04133789
n04136333
n04141076
n04141327
n04141975
n04146614
n04147183
n04149813
n04152593
n04153751
n04154565
n04162706
n04179913
n04192698
n04200800
n04201297
n04204238
n04204347
n04208210
n04209133
n04209239
n04228054
n04229816
n04235860
n04238763
n04239074
n04243546
n04251144
n04252077
n04252225
n04254120
n04254680
n04254777
n04258138
n04259630
n04263257
n04264628
n04265275
n04266014
n04270147
n04273569
n04275548
n04277352
n04285008
n04286575
n04296562
n04310018
n04311004
n04311174
n04317175
n04325704
n04326547
n04328186
n04330267
n04332243
n04335435
n04336792
n04344873
n04346328
n04347754
n04350905
n04355338
n04355933
n04356056
n04357314
n04366367
n04367480
n04370456
n04371430
n04371774
n04372370
n04376876
n04380533
n04389033
n04392985
n04398044
n04399382
n04404412
n04409515
n04417672
n04418357
n04423845
n04428191
n04429376
n04435653
n04442312
n04443257
n04447861
n04456115
n04458633
n04461696
n04462240
n04465501
n04467665
n04476259
n04479046
n04482393
n04483307
n04485082
n04486054
n04487081
n04487394
n04493381
n04501370
n04505470
n04507155
n04509417
n04515003
n04517823
n04522168
n04523525
n04525038
n04525305
n04532106
n04532670
n04536866
n04540053
n04542943
n04548280
n04548362
n04550184
n04552348
n04553703
n04554684
n04557648
n04560804
n04562935
n04579145
n04579432
n04584207
n04589890
n04590129
n04591157
n04591713
n04592741
n04596742
n04597913
n04599235
n04604644
n04606251
n04612504
n04613696
n06359193
n06596364
n06785654
n06794110
n06874185
n07248320
n07565083
n07579787
n07583066
n07584110
n07590611
n07613480
n07614500
n07615774
n07684084
n07693725
n07695742
n07697313
n07697537
n07711569
n07714571
n07714990
n07715103
n07716358
n07716906
n07717410
n07717556
n07718472
n07718747
n07720875
n07730033
n07734744
n07742313
n07745940
n07747607
n07749582
n07753113
n07753275
n07753592
n07754684
n07760859
n07768694
n07802026
n07831146
n07836838
n07860988
n07871810
n07873807
n07875152
n07880968
n07892512
n07920052
n07930864
n07932039
n09193705
n09229709
n09246464
n09256479
n09288635
n09332890
n09399592
n09421951
n09428293
n09468604
n09472597
n09835506
n10148035
n10565667
n11879895
n11939491
n12057211
n12144580
n12267677
n12620546
n12768682
n12985857
n12998815
n13037406
n13040303
n13044778
n13052670
n13054560
n13133613
n15075141

================================================
FILE: data/imagenet_synsets.txt
================================================
????????? dummy class for index 0
n02119789 kit fox, Vulpes macrotis
n02100735 English setter
n02110185 Siberian husky
n02096294 Australian terrier
n02102040 English springer, English springer spaniel
n02066245 grey whale, gray whale, devilfish, Eschrichtius gibbosus, Eschrichtius robustus
n02509815 lesser panda, red panda, panda, bear cat, cat bear, Ailurus fulgens
n02124075 Egyptian cat
n02417914 ibex, Capra ibex
n02123394 Persian cat
n02125311 cougar, puma, catamount, mountain lion, painter, panther, Felis concolor
n02423022 gazelle
n02346627 porcupine, hedgehog
n02077923 sea lion
n02110063 malamute, malemute, Alaskan malamute
n02447366 badger
n02109047 Great Dane
n02089867 Walker hound, Walker foxhound
n02102177 Welsh springer spaniel
n02091134 whippet
n02092002 Scottish deerhound, deerhound
n02071294 killer whale, killer, orca, grampus, sea wolf, Orcinus orca
n02442845 mink
n02504458 African elephant, Loxodonta africana
n02092339 Weimaraner
n02098105 soft-coated wheaten terrier
n02096437 Dandie Dinmont, Dandie Dinmont terrier
n02114712 red wolf, maned wolf, Canis rufus, Canis niger
n02105641 Old English sheepdog, bobtail
n02128925 jaguar, panther, Panthera onca, Felis onca
n02091635 otterhound, otter hound
n02088466 bloodhound, sleuthhound
n02096051 Airedale, Airedale terrier
n02117135 hyena, hyaena
n02138441 meerkat, mierkat
n02097130 giant schnauzer
n02493509 titi, titi monkey
n02457408 three-toed sloth, ai, Bradypus tridactylus
n02389026 sorrel
n02443484 black-footed ferret, ferret, Mustela nigripes
n02110341 dalmatian, coach dog, carriage dog
n02089078 black-and-tan coonhound
n02086910 papillon
n02445715 skunk, polecat, wood pussy
n02093256 Staffordshire bullterrier, Staffordshire bull terrier
n02113978 Mexican hairless
n02106382 Bouvier des Flandres, Bouviers des Flandres
n02441942 weasel
n02113712 miniature poodle
n02113186 Cardigan, Cardigan Welsh corgi
n02105162 malinois
n02415577 bighorn, bighorn sheep, cimarron, Rocky Mountain bighorn, Rocky Mountain sheep, Ovis canadensis
n02356798 fox squirrel, eastern fox squirrel, Sciurus niger
n02488702 colobus, colobus monkey
n02123159 tiger cat
n02098413 Lhasa, Lhasa apso
n02422699 impala, Aepyceros melampus
n02114855 coyote, prairie wolf, brush wolf, Canis latrans
n02094433 Yorkshire terrier
n02111277 Newfoundland, Newfoundland dog
n02132136 brown bear, bruin, Ursus arctos
n02119022 red fox, Vulpes vulpes
n02091467 Norwegian elkhound, elkhound
n02106550 Rottweiler
n02422106 hartebeest
n02091831 Saluki, gazelle hound
n02120505 grey fox, gray fox, Urocyon cinereoargenteus
n02104365 schipperke
n02086079 Pekinese, Pekingese, Peke
n02112706 Brabancon griffon
n02098286 West Highland white terrier
n02095889 Sealyham terrier, Sealyham
n02484975 guenon, guenon monkey
n02137549 mongoose
n02500267 indri, indris, Indri indri, Indri brevicaudatus
n02129604 tiger, Panthera tigris
n02090721 Irish wolfhound
n02396427 wild boar, boar, Sus scrofa
n02108000 EntleBucher
n02391049 zebra
n02412080 ram, tup
n02108915 French bulldog
n02480495 orangutan, orang, orangutang, Pongo pygmaeus
n02110806 basenji
n02128385 leopard, Panthera pardus
n02107683 Bernese mountain dog
n02085936 Maltese dog, Maltese terrier, Maltese
n02094114 Norfolk terrier
n02087046 toy terrier
n02100583 vizsla, Hungarian pointer
n02096177 cairn, cairn terrier
n02494079 squirrel monkey, Saimiri sciureus
n02105056 groenendael
n02101556 clumber, clumber spaniel
n02123597 Siamese cat, Siamese
n02481823 chimpanzee, chimp, Pan troglodytes
n02105505 komondor
n02088094 Afghan hound, Afghan
n02085782 Japanese spaniel
n02489166 proboscis monkey, Nasalis larvatus
n02364673 guinea pig, Cavia cobaya
n02114548 white wolf, Arctic wolf, Canis lupus tundrarum
n02134084 ice bear, polar bear, Ursus Maritimus, Thalarctos maritimus
n02480855 gorilla, Gorilla gorilla
n02090622 borzoi, Russian wolfhound
n02113624 toy poodle
n02093859 Kerry blue terrier
n02403003 ox
n02097298 Scotch terrier, Scottish terrier, Scottie
n02108551 Tibetan mastiff
n02493793 spider monkey, Ateles geoffroyi
n02107142 Doberman, Doberman pinscher
n02096585 Boston bull, Boston terrier
n02107574 Greater Swiss Mountain dog
n02107908 Appenzeller
n02086240 Shih-Tzu
n02102973 Irish water spaniel
n02112018 Pomeranian
n02093647 Bedlington terrier
n02397096 warthog
n02437312 Arabian camel, dromedary, Camelus dromedarius
n02483708 siamang, Hylobates syndactylus, Symphalangus syndactylus
n02097047 miniature schnauzer
n02106030 collie
n02099601 golden retriever
n02093991 Irish terrier
n02110627 affenpinscher, monkey pinscher, monkey dog
n02106166 Border collie
n02326432 hare
n02108089 boxer
n02097658 silky terrier, Sydney silky
n02088364 beagle
n02111129 Leonberg
n02100236 German short-haired pointer
n02486261 patas, hussar monkey, Erythrocebus patas
n02115913 dhole, Cuon alpinus
n02486410 baboon
n02487347 macaque
n02099849 Chesapeake Bay retriever
n02108422 bull mastiff
n02104029 kuvasz
n02492035 capuchin, ringtail, Cebus capucinus
n02110958 pug, pug-dog
n02099429 curly-coated retriever
n02094258 Norwich terrier
n02099267 flat-coated retriever
n02395406 hog, pig, grunter, squealer, Sus scrofa
n02112350 keeshond
n02109961 Eskimo dog, husky
n02101388 Brittany spaniel
n02113799 standard poodle
n02095570 Lakeland terrier
n02128757 snow leopard, ounce, Panthera uncia
n02101006 Gordon setter
n02115641 dingo, warrigal, warragal, Canis dingo
n02097209 standard schnauzer
n02342885 hamster
n02097474 Tibetan terrier, chrysanthemum dog
n02120079 Arctic fox, white fox, Alopex lagopus
n02095314 wire-haired fox terrier
n02088238 basset, basset hound
n02408429 water buffalo, water ox, Asiatic buffalo, Bubalus bubalis
n02133161 American black bear, black bear, Ursus americanus, Euarctos americanus
n02328150 Angora, Angora rabbit
n02410509 bison
n02492660 howler monkey, howler
n02398521 hippopotamus, hippo, river horse, Hippopotamus amphibius
n02112137 chow, chow chow
n02510455 giant panda, panda, panda bear, coon bear, Ailuropoda melanoleuca
n02093428 American Staffordshire terrier, Staffordshire terrier, American pit bull terrier, pit bull terrier
n02105855 Shetland sheepdog, Shetland sheep dog, Shetland
n02111500 Great Pyrenees
n02085620 Chihuahua
n02123045 tabby, tabby cat
n02490219 marmoset
n02099712 Labrador retriever
n02109525 Saint Bernard, St Bernard
n02454379 armadillo
n02111889 Samoyed, Samoyede
n02088632 bluetick
n02090379 redbone
n02443114 polecat, fitch, foulmart, foumart, Mustela putorius
n02361337 marmot
n02105412 kelpie
n02483362 gibbon, Hylobates lar
n02437616 llama
n02107312 miniature pinscher
n02325366 wood rabbit, cottontail, cottontail rabbit
n02091032 Italian greyhound
n02129165 lion, king of beasts, Panthera leo
n02102318 cocker spaniel, English cocker spaniel, cocker
n02100877 Irish setter, red setter
n02074367 dugong, Dugong dugon
n02504013 Indian elephant, Elephas maximus
n02363005 beaver
n02102480 Sussex spaniel
n02113023 Pembroke, Pembroke Welsh corgi
n02086646 Blenheim spaniel
n02497673 Madagascar cat, ring-tailed lemur, Lemur catta
n02087394 Rhodesian ridgeback
n02127052 lynx, catamount
n02116738 African hunting dog, hyena dog, Cape hunting dog, Lycaon pictus
n02488291 langur
n02091244 Ibizan hound, Ibizan Podenco
n02114367 timber wolf, grey wolf, gray wolf, Canis lupus
n02130308 cheetah, chetah, Acinonyx jubatus
n02089973 English foxhound
n02105251 briard
n02134418 sloth bear, Melursus ursinus, Ursus ursinus
n02093754 Border terrier
n02106662 German shepherd, German shepherd dog, German police dog, alsatian
n02444819 otter
n01882714 koala, koala bear, kangaroo bear, native bear, Phascolarctos cinereus
n01871265 tusker
n01872401 echidna, spiny anteater, anteater
n01877812 wallaby, brush kangaroo
n01873310 platypus, duckbill, duckbilled platypus, duck-billed platypus, Ornithorhynchus anatinus
n01883070 wombat
n04086273 revolver, six-gun, six-shooter
n04507155 umbrella
n04147183 schooner
n04254680 soccer ball
n02672831 accordion, piano accordion, squeeze box
n02219486 ant, emmet, pismire
n02317335 starfish, sea star
n01968897 chambered nautilus, pearly nautilus, nautilus
n03452741 grand piano, grand
n03642806 laptop, laptop computer
n07745940 strawberry
n02690373 airliner
n04552348 warplane, military plane
n02692877 airship, dirigible
n02782093 balloon
n04266014 space shuttle
n03344393 fireboat
n03447447 gondola
n04273569 speedboat
n03662601 lifeboat
n02951358 canoe
n04612504 yawl
n02981792 catamaran
n04483307 trimaran
n03095699 container ship, containership, container vessel
n03673027 liner, ocean liner
n03947888 pirate, pirate ship
n02687172 aircraft carrier, carrier, flattop, attack aircraft carrier
n04347754 submarine, pigboat, sub, U-boat
n04606251 wreck
n03478589 half track
n04389033 tank, army tank, armored combat vehicle, armoured combat vehicle
n03773504 missile
n02860847 bobsled, bobsleigh, bob
n03218198 dogsled, dog sled, dog sleigh
n02835271 bicycle-built-for-two, tandem bicycle, tandem
n03792782 mountain bike, all-terrain bike, off-roader
n03393912 freight car
n03895866 passenger car, coach, carriage
n02797295 barrow, garden cart, lawn cart, wheelbarrow
n04204347 shopping cart
n03791053 motor scooter, scooter
n03384352 forklift
n03272562 electric locomotive
n04310018 steam locomotive
n02704792 amphibian, amphibious vehicle
n02701002 ambulance
n02814533 beach wagon, station wagon, wagon, estate car, beach waggon, station waggon, waggon
n02930766 cab, hack, taxi, taxicab
n03100240 convertible
n03594945 jeep, landrover
n03670208 limousine, limo
n03770679 minivan
n03777568 Model T
n04037443 racer, race car, racing car
n04285008 sports car, sport car
n03444034 go-kart
n03445924 golfcart, golf cart
n03785016 moped
n04252225 snowplow, snowplough
n03345487 fire engine, fire truck
n03417042 garbage truck, dustcart
n03930630 pickup, pickup truck
n04461696 tow truck, tow car, wrecker
n04467665 trailer truck, tractor trailer, trucking rig, rig, articulated lorry, semi
n03796401 moving van
n03977966 police van, police wagon, paddy wagon, patrol wagon, wagon, black Maria
n04065272 recreational vehicle, RV, R.V.
n04335435 streetcar, tram, tramcar, trolley, trolley car
n04252077 snowmobile
n04465501 tractor
n03776460 mobile home, manufactured home
n04482393 tricycle, trike, velocipede
n04509417 unicycle, monocycle
n03538406 horse cart, horse-cart
n03599486 jinrikisha, ricksha, rickshaw
n03868242 oxcart
n02804414 bassinet
n03125729 cradle
n03131574 crib, cot
n03388549 four-poster
n02870880 bookcase
n03018349 china cabinet, china closet
n03742115 medicine chest, medicine cabinet
n03016953 chiffonier, commode
n04380533 table lamp
n03337140 file, file cabinet, filing cabinet
n03891251 park bench
n02791124 barber chair
n04429376 throne
n03376595 folding chair
n04099969 rocking chair, rocker
n04344873 studio couch, day bed
n04447861 toilet seat
n03179701 desk
n03982430 pool table, billiard table, snooker table
n03201208 dining table, board
n03290653 entertainment center
n04550184 wardrobe, closet, press
n07742313 Granny Smith
n07747607 orange
n07749582 lemon
n07753113 fig
n07753275 pineapple, ananas
n07753592 banana
n07754684 jackfruit, jak, jack
n07760859 custard apple
n07768694 pomegranate
n12267677 acorn
n12620546 hip, rose hip, rosehip
n13133613 ear, spike, capitulum
n11879895 rapeseed
n12144580 corn
n12768682 buckeye, horse chestnut, conker
n03854065 organ, pipe organ
n04515003 upright, upright piano
n03017168 chime, bell, gong
n03249569 drum, membranophone, tympan
n03447721 gong, tam-tam
n03720891 maraca
n03721384 marimba, xylophone
n04311174 steel drum
n02787622 banjo
n02992211 cello, violoncello
n04536866 violin, fiddle
n03495258 harp
n02676566 acoustic guitar
n03272010 electric guitar
n03110669 cornet, horn, trumpet, trump
n03394916 French horn, horn
n04487394 trombone
n03494278 harmonica, mouth organ, harp, mouth harp
n03840681 ocarina, sweet potato
n03884397 panpipe, pandean pipe, syrinx
n02804610 bassoon
n03838899 oboe, hautboy, hautbois
n04141076 sax, saxophone
n03372029 flute, transverse flute
n11939491 daisy
n12057211 yellow lady's slipper, yellow lady-slipper, Cypripedium calceolus, Cypripedium parviflorum
n09246464 cliff, drop, drop-off
n09468604 valley, vale
n09193705 alp
n09472597 volcano
n09399592 promontory, headland, head, foreland
n09421951 sandbar, sand bar
n09256479 coral reef
n09332890 lakeside, lakeshore
n09428293 seashore, coast, seacoast, sea-coast
n09288635 geyser
n03498962 hatchet
n03041632 cleaver, meat cleaver, chopper
n03658185 letter opener, paper knife, paperknife
n03954731 plane, carpenter's plane, woodworking plane
n03995372 power drill
n03649909 lawn mower, mower
n03481172 hammer
n03109150 corkscrew, bottle screw
n02951585 can opener, tin opener
n03970156 plunger, plumber's helper
n04154565 screwdriver
n04208210 shovel
n03967562 plow, plough
n03000684 chain saw, chainsaw
n01514668 cock
n01514859 hen
n01518878 ostrich, Struthio camelus
n01530575 brambling, Fringilla montifringilla
n01531178 goldfinch, Carduelis carduelis
n01532829 house finch, linnet, Carpodacus mexicanus
n01534433 junco, snowbird
n01537544 indigo bunting, indigo finch, indigo bird, Passerina cyanea
n01558993 robin, American robin, Turdus migratorius
n01560419 bulbul
n01580077 jay
n01582220 magpie
n01592084 chickadee
n01601694 water ouzel, dipper
n01608432 kite
n01614925 bald eagle, American eagle, Haliaeetus leucocephalus
n01616318 vulture
n01622779 great grey owl, great gray owl, Strix nebulosa
n01795545 black grouse
n01796340 ptarmigan
n01797886 ruffed grouse, partridge, Bonasa umbellus
n01798484 prairie chicken, prairie grouse, prairie fowl
n01806143 peacock
n01806567 quail
n01807496 partridge
n01817953 African grey, African gray, Psittacus erithacus
n01818515 macaw
n01819313 sulphur-crested cockatoo, Kakatoe galerita, Cacatua galerita
n01820546 lorikeet
n01824575 coucal
n01828970 bee eater
n01829413 hornbill
n01833805 hummingbird
n01843065 jacamar
n01843383 toucan
n01847000 drake
n01855032 red-breasted merganser, Mergus serrator
n01855672 goose
n01860187 black swan, Cygnus atratus
n02002556 white stork, Ciconia ciconia
n02002724 black stork, Ciconia nigra
n02006656 spoonbill
n02007558 flamingo
n02009912 American egret, great white heron, Egretta albus
n02009229 little blue heron, Egretta caerulea
n02011460 bittern
n02012849 crane
n02013706 limpkin, Aramus pictus
n02018207 American coot, marsh hen, mud hen, water hen, Fulica americana
n02018795 bustard
n02025239 ruddy turnstone, Arenaria interpres
n02027492 red-backed sandpiper, dunlin, Erolia alpina
n02028035 redshank, Tringa totanus
n02033041 dowitcher
n02037110 oystercatcher, oyster catcher
n02017213 European gallinule, Porphyrio porphyrio
n02051845 pelican
n02056570 king penguin, Aptenodytes patagonica
n02058221 albatross, mollymawk
n01484850 great white shark, white shark, man-eater, man-eating shark, Carcharodon carcharias
n01491361 tiger shark, Galeocerdo cuvieri
n01494475 hammerhead, hammerhead shark
n01496331 electric ray, crampfish, numbfish, torpedo
n01498041 stingray
n02514041 barracouta, snoek
n02536864 coho, cohoe, coho salmon, blue jack, silver salmon, Oncorhynchus kisutch
n01440764 tench, Tinca tinca
n01443537 goldfish, Carassius auratus
n02526121 eel
n02606052 rock beauty, Holocanthus tricolor
n02607072 anemone fish
n02643566 lionfish
n02655020 puffer, pufferfish, blowfish, globefish
n02640242 sturgeon
n02641379 gar, garfish, garpike, billfish, Lepisosteus osseus
n01664065 loggerhead, loggerhead turtle, Caretta caretta
n01665541 leatherback turtle, leatherback, leathery turtle, Dermochelys coriacea
n01667114 mud turtle
n01667778 terrapin
n01669191 box turtle, box tortoise
n01675722 banded gecko
n01677366 common iguana, iguana, Iguana iguana
n01682714 American chameleon, anole, Anolis carolinensis
n01685808 whiptail, whiptail lizard
n01687978 agama
n01688243 frilled lizard, Chlamydosaurus kingi
n01689811 alligator lizard
n01692333 Gila monster, Heloderma suspectum
n01693334 green lizard, Lacerta viridis
n01694178 African chameleon, Chamaeleo chamaeleon
n01695060 Komodo dragon, Komodo lizard, dragon lizard, giant lizard, Varanus komodoensis
n01704323 triceratops
n01697457 African crocodile, Nile crocodile, Crocodylus niloticus
n01698640 American alligator, Alligator mississipiensis
n01728572 thunder snake, worm snake, Carphophis amoenus
n01728920 ringneck snake, ring-necked snake, ring snake
n01729322 hognose snake, puff adder, sand viper
n01729977 green snake, grass snake
n01734418 king snake, kingsnake
n01735189 garter snake, grass snake
n01737021 water snake
n01739381 vine snake
n01740131 night snake, Hypsiglena torquata
n01742172 boa constrictor, Constrictor constrictor
n01744401 rock python, rock snake, Python sebae
n01748264 Indian cobra, Naja naja
n01749939 green mamba
n01751748 sea snake
n01753488 horned viper, cerastes, sand viper, horned asp, Cerastes cornutus
n01755581 diamondback, diamondback rattlesnake, Crotalus adamanteus
n01756291 sidewinder, horned rattlesnake, Crotalus cerastes
n01629819 European fire salamander, Salamandra salamandra
n01630670 common newt, Triturus vulgaris
n01631663 eft
n01632458 spotted salamander, Ambystoma maculatum
n01632777 axolotl, mud puppy, Ambystoma mexicanum
n01641577 bullfrog, Rana catesbeiana
n01644373 tree frog, tree-frog
n01644900 tailed frog, bell toad, ribbed toad, tailed toad, Ascaphus trui
n04579432 whistle
n04592741 wing
n03876231 paintbrush
n03483316 hand blower, blow dryer, blow drier, hair dryer, hair drier
n03868863 oxygen mask
n04251144 snorkel
n03691459 loudspeaker, speaker, speaker unit, loudspeaker system, speaker system
n03759954 microphone, mike
n04152593 screen, CRT screen
n03793489 mouse, computer mouse
n03271574 electric fan, blower
n03843555 oil filter
n04332243 strainer
n04265275 space heater
n04330267 stove
n03467068 guillotine
n02794156 barometer
n04118776 rule, ruler
n03841143 odometer, hodometer, mileometer, milometer
n04141975 scale, weighing machine
n02708093 analog clock
n03196217 digital clock
n04548280 wall clock
n03544143 hourglass
n04355338 sundial
n03891332 parking meter
n04328186 stopwatch, stop watch
n03197337 digital watch
n04317175 stethoscope
n04376876 syringe
n03706229 magnetic compass
n02841315 binoculars, field glasses, opera glasses
n04009552 projector
n04356056 sunglasses, dark glasses, shades
n03692522 loupe, jeweler's loupe
n04044716 radio telescope, radio reflector
n02879718 bow
n02950826 cannon
n02749479 assault rifle, assault gun
n04090263 rifle
n04008634 projectile, missile
n03085013 computer keyboard, keypad
n04505470 typewriter keyboard
n03126707 crane
n03666591 lighter, light, igniter, ignitor
n02666196 abacus
n02977058 cash machine, cash dispenser, automated teller machine, automatic teller machine, automated teller, automatic teller, ATM
n04238763 slide rule, slipstick
n03180011 desktop computer
n03485407 hand-held computer, hand-held microcomputer
n03832673 notebook, notebook computer
n06359193 web site, website, internet site, site
n03496892 harvester, reaper
n04428191 thresher, thrasher, threshing machine
n04004767 printer
n04243546 slot, one-armed bandit
n04525305 vending machine
n04179913 sewing machine
n03602883 joystick
n04372370 switch, electric switch, electrical switch
n03532672 hook, claw
n02974003 car wheel
n03874293 paddlewheel, paddle wheel
n03944341 pinwheel
n03992509 potter's wheel
n03425413 gas pump, gasoline pump, petrol pump, island dispenser
n02966193 carousel, carrousel, merry-go-round, roundabout, whirligig
n04371774 swing
n04067472 reel
n04040759 radiator
n04019541 puck, hockey puck
n03492542 hard disc, hard disk, fixed disk
n04355933 sunglass
n03929660 pick, plectrum, plectron
n02965783 car mirror
n04258138 solar dish, solar collector, solar furnace
n04074963 remote control, remote
n03208938 disk brake, disc brake
n02910353 buckle
n03476684 hair slide
n03627232 knot
n03075370 combination lock
n03874599 padlock
n03804744 nail
n04127249 safety pin
n04153751 screw
n03803284 muzzle
n04162706 seat belt, seatbelt
n04228054 ski
n02948072 candle, taper, wax light
n03590841 jack-o'-lantern
n04286575 spotlight, spot
n04456115 torch
n03814639 neck brace
n03933933 pier
n04485082 tripod
n03733131 maypole
n03794056 mousetrap
n04275548 spider web, spider's web
n01768244 trilobite
n01770081 harvestman, daddy longlegs, Phalangium opilio
n01770393 scorpion
n01773157 black and gold garden spider, Argiope aurantia
n01773549 barn spider, Araneus cavaticus
n01773797 garden spider, Aranea diademata
n01774384 black widow, Latrodectus mactans
n01774750 tarantula
n01775062 wolf spider, hunting spider
n01776313 tick
n01784675 centipede
n01990800 isopod
n01978287 Dungeness crab, Cancer magister
n01978455 rock crab, Cancer irroratus
n01980166 fiddler crab
n01981276 king crab, Alaska crab, Alaskan king crab, Alaska king crab, Paralithodes camtschatica
n01983481 American lobster, Northern lobster, Maine lobster, Homarus americanus
n01984695 spiny lobster, langouste, rock lobster, crawfish, crayfish, sea crawfish
n01985128 crayfish, crawfish, crawdad, crawdaddy
n01986214 hermit crab
n02165105 tiger beetle
n02165456 ladybug, ladybeetle, lady beetle, ladybird, ladybird beetle
n02167151 ground beetle, carabid beetle
n02168699 long-horned beetle, longicorn, longicorn beetle
n02169497 leaf beetle, chrysomelid
n02172182 dung beetle
n02174001 rhinoceros beetle
n02177972 weevil
n02190166 fly
n02206856 bee
n02226429 grasshopper, hopper
n02229544 cricket
n02231487 walking stick, walkingstick, stick insect
n02233338 cockroach, roach
n02236044 mantis, mantid
n02256656 cicada, cicala
n02259212 leafhopper
n02264363 lacewing, lacewing fly
n02268443 dragonfly, darning needle, devil's darning needle, sewing needle, snake feeder, snake doctor, mosquito hawk, skeeter hawk
n02268853 damselfly
n02276258 admiral
n02277742 ringlet, ringlet butterfly
n02279972 monarch, monarch butterfly, milkweed butterfly, Danaus plexippus
n02280649 cabbage butterfly
n02281406 sulphur butterfly, sulfur butterfly
n02281787 lycaenid, lycaenid butterfly
n01910747 jellyfish
n01914609 sea anemone, anemone
n01917289 brain coral
n01924916 flatworm, platyhelminth
n01930112 nematode, nematode worm, roundworm
n01943899 conch
n01944390 snail
n01945685 slug
n01950731 sea slug, nudibranch
n01955084 chiton, coat-of-mail shell, sea cradle, polyplacophore
n02319095 sea urchin
n02321529 sea cucumber, holothurian
n03584829 iron, smoothing iron
n03297495 espresso maker
n03761084 microwave, microwave oven
n03259280 Dutch oven
n04111531 rotisserie
n04442312 toaster
n04542943 waffle iron
n04517823 vacuum, vacuum cleaner
n03207941 dishwasher, dish washer, dishwashing machine
n04070727 refrigerator, icebox
n04554684 washer, automatic washer, washing machine
n03133878 Crock Pot
n03400231 frying pan, frypan, skillet
n04596742 wok
n02939185 caldron, cauldron
n03063689 coffeepot
n04398044 teapot
n04270147 spatula
n02699494 altar
n04486054 triumphal arch
n03899768 patio, terrace
n04311004 steel arch bridge
n04366367 suspension bridge
n04532670 viaduct
n02793495 barn
n03457902 greenhouse, nursery, glasshouse
n03877845 palace
n03781244 monastery
n03661043 library
n02727426 apiary, bee house
n02859443 boathouse
n03028079 church, church building
n03788195 mosque
n04346328 stupa, tope
n03956157 planetarium
n04081281 restaurant, eating house, eating place, eatery
n03032252 cinema, movie theater, movie theatre, movie house, picture palace
n03529860 home theater, home theatre
n03697007 lumbermill, sawmill
n03065424 coil, spiral, volute, whorl, helix
n03837869 obelisk
n04458633 totem pole
n02980441 castle
n04005630 prison, prison house
n03461385 grocery store, grocery, food market, market
n02776631 bakery, bakeshop, bakehouse
n02791270 barbershop
n02871525 bookshop, bookstore, bookstall
n02927161 butcher shop, meat market
n03089624 confectionery, confectionary, candy store
n04200800 shoe shop, shoe-shop, shoe store
n04443257 tobacco shop, tobacconist shop, tobacconist
n04462240 toyshop
n03388043 fountain
n03042490 cliff dwelling
n04613696 yurt
n03216828 dock, dockage, docking facility
n02892201 brass, memorial tablet, plaque
n03743016 megalith, megalithic structure
n02788148 bannister, banister, balustrade, balusters, handrail
n02894605 breakwater, groin, groyne, mole, bulwark, seawall, jetty
n03160309 dam, dike, dyke
n03000134 chainlink fence
n03930313 picket fence, paling
n04604644 worm fence, snake fence, snake-rail fence, Virginia fence
n04326547 stone wall
n03459775 grille, radiator grille
n04239074 sliding door
n04501370 turnstile
n03792972 mountain tent
n04149813 scoreboard
n03530642 honeycomb
n03961711 plate rack
n03903868 pedestal, plinth, footstall
n02814860 beacon, lighthouse, beacon light, pharos
n07711569 mashed potato
n07720875 bell pepper
n07714571 head cabbage
n07714990 broccoli
n07715103 cauliflower
n07716358 zucchini, courgette
n07716906 spaghetti squash
n07717410 acorn squash
n07717556 butternut squash
n07718472 cucumber, cuke
n07718747 artichoke, globe artichoke
n07730033 cardoon
n07734744 mushroom
n04209239 shower curtain
n03594734 jean, blue jean, denim
n02971356 carton
n03485794 handkerchief, hankie, hanky, hankey
n04133789 sandal
n02747177 ashcan, trash can, garbage can, wastebin, ash bin, ash-bin, ashbin, dustbin, trash barrel, trash bin
n04125021 safe
n07579787 plate
n03814906 necklace
n03134739 croquet ball
n03404251 fur coat
n04423845 thimble
n03877472 pajama, pyjama, pj's, jammies
n04120489 running shoe
n03062245 cocktail shaker
n03014705 chest
n03717622 manhole cover
n03777754 modem
n04493381 tub, vat
n04476259 tray
n02777292 balance beam, beam
n07693725 bagel, beigel
n03998194 prayer rug, prayer mat
n03617480 kimono
n07590611 hot pot, hotpot
n04579145 whiskey jug
n03623198 knee pad
n07248320 book jacket, dust cover, dust jacket, dust wrapper
n04277352 spindle
n04229816 ski mask
n02823428 beer bottle
n03127747 crash helmet
n02877765 bottlecap
n04435653 tile roof
n03724870 mask
n03710637 maillot
n03920288 Petri dish
n03379051 football helmet
n02807133 bathing cap, swimming cap
n04399382 teddy, teddy bear
n03527444 holster
n03983396 pop bottle, soda bottle
n03924679 photocopier
n04532106 vestment
n06785654 crossword puzzle, crossword
n03445777 golf ball
n07613480 trifle
n04350905 suit, suit of clothes
n04562935 water tower
n03325584 feather boa, boa
n03045698 cloak
n07892512 red wine
n03250847 drumstick
n04192698 shield, buckler
n03026506 Christmas stocking
n03534580 hoopskirt, crinoline
n07565083 menu
n04296562 stage
n02869837 bonnet, poke bonnet
n07871810 meat loaf, meatloaf
n02799071 baseball
n03314780 face powder
n04141327 scabbard
n04357314 sunscreen, sunblock, sun blocker
n02823750 beer glass
n13052670 hen-of-the-woods, hen of the woods, Polyporus frondosus, Grifola frondosa
n07583066 guacamole
n03637318 lampshade, lamp shade
n04599235 wool, woolen, woollen
n07802026 hay
n02883205 bow tie, bow-tie, bowtie
n03709823 mailbag, postbag
n04560804 water jug
n02909870 bucket, pail
n03207743 dishrag, dishcloth
n04263257 soup bowl
n07932039 eggnog
n03786901 mortar
n04479046 trench coat
n03873416 paddle, boat paddle
n02999410 chain
n04367480 swab, swob, mop
n03775546 mixing bowl
n07875152 potpie
n04591713 wine bottle
n04201297 shoji
n02916936 bulletproof vest
n03240683 drilling platform, offshore rig
n02840245 binder, ring-binder
n02963159 cardigan
n04370456 sweatshirt
n03991062 pot, flowerpot
n02843684 birdhouse
n03482405 hamper
n03942813 ping-pong ball
n03908618 pencil box, pencil case
n03902125 pay-phone, pay-station
n07584110 consomme
n02730930 apron
n04023962 punching bag, punch bag, punching ball, punchball
n02769748 backpack, back pack, knapsack, packsack, rucksack, haversack
n10148035 groom, bridegroom
n02817516 bearskin, busby, shako
n03908714 pencil sharpener
n02906734 broom
n03788365 mosquito net
n02667093 abaya
n03787032 mortarboard
n03980874 poncho
n03141823 crutch
n03976467 Polaroid camera, Polaroid Land camera
n04264628 space bar
n07930864 cup
n04039381 racket, racquet
n06874185 traffic light, traffic signal, stoplight
n04033901 quill, quill pen
n04041544 radio, wireless
n07860988 dough
n03146219 cuirass
n03763968 military uniform
n03676483 lipstick, lip rouge
n04209133 shower cap
n03782006 monitor
n03857828 oscilloscope, scope, cathode-ray oscilloscope, CRO
n03775071 mitten
n02892767 brassiere, bra, bandeau
n07684084 French loaf
n04522168 vase
n03764736 milk can
n04118538 rugby ball
n03887697 paper towel
n13044778 earthstar
n03291819 envelope
n03770439 miniskirt, mini
n03124170 cowboy hat, ten-gallon hat
n04487081 trolleybus, trolley coach, trackless trolley
n03916031 perfume, essence
n02808440 bathtub, bathing tub, bath, tub
n07697537 hotdog, hot dog, red hot
n12985857 coral fungus
n02917067 bullet train, bullet
n03938244 pillow
n15075141 toilet tissue, toilet paper, bathroom tissue
n02978881 cassette
n02966687 carpenter's kit, tool kit
n03633091 ladle
n13040303 stinkhorn, carrion fungus
n03690938 lotion
n03476991 hair spray
n02669723 academic gown, academic robe, judge's robe
n03220513 dome
n03127925 crate
n04584207 wig
n07880968 burrito
n03937543 pill bottle
n03000247 chain mail, ring mail, mail, chain armor, chain armour, ring armor, ring armour
n04418357 theater curtain, theatre curtain
n04590129 window shade
n02795169 barrel, cask
n04553703 washbasin, handbasin, washbowl, lavabo, wash-hand basin
n02783161 ballpoint, ballpoint pen, ballpen, Biro
n02802426 basketball
n02808304 bath towel
n03124043 cowboy boot
n03450230 gown
n04589890 window screen
n12998815 agaric
n02992529 cellular telephone, cellular phone, cellphone, cell, mobile phone
n03825788 nipple
n02790996 barbell
n03710193 mailbox, letter box
n03630383 lab coat, laboratory coat
n03347037 fire screen, fireguard
n03769881 minibus
n03871628 packet
n03733281 maze, labyrinth
n03976657 pole
n03535780 horizontal bar, high bar
n04259630 sombrero
n03929855 pickelhaube
n04049303 rain barrel
n04548362 wallet, billfold, notecase, pocketbook
n02979186 cassette player
n06596364 comic book
n03935335 piggy bank, penny bank
n06794110 street sign
n02825657 bell cote, bell cot
n03388183 fountain pen
n04591157 Windsor tie
n04540053 volleyball
n03866082 overskirt
n04136333 sarong
n04026417 purse
n02865351 bolo tie, bolo, bola tie, bola
n02834397 bib
n03888257 parachute, chute
n04235860 sleeping bag
n04404412 television, television system
n04371430 swimming trunks, bathing trunks
n03733805 measuring cup
n07920052 espresso
n07873807 pizza, pizza pie
n02895154 breastplate, aegis, egis
n04204238 shopping basket
n04597913 wooden spoon
n04131690 saltshaker, salt shaker
n07836838 chocolate sauce, chocolate syrup
n09835506 ballplayer, baseball player
n03443371 goblet
n13037406 gyromitra
n04336792 stretcher
n04557648 water bottle
n03187595 dial telephone, dial phone
n04254120 soap dispenser
n03595614 jersey, T-shirt, tee shirt
n04146614 school bus
n03598930 jigsaw puzzle
n03958227 plastic bag
n04069434 reflex camera
n03188531 diaper, nappy, napkin
n02786058 Band Aid
n07615774 ice lolly, lolly, lollipop, popsicle
n04525038 velvet
n04409515 tennis ball
n03424325 gasmask, respirator, gas helmet
n03223299 doormat, welcome mat
n03680355 Loafer
n07614500 ice cream, icecream
n07695742 pretzel
n04033995 quilt, comforter, comfort, puff
n03710721 maillot, tank suit
n04392985 tape player
n03047690 clog, geta, patten, sabot
n03584254 iPod
n13054560 bolete
n10565667 scuba diver
n03950228 pitcher, ewer
n03729826 matchstick
n02837789 bikini, two-piece
n04254777 sock
n02988304 CD player
n03657121 lens cap, lens cover
n04417672 thatch, thatched roof
n04523525 vault
n02815834 beaker
n09229709 bubble
n07697313 cheeseburger
n03888605 parallel bars, bars
n03355925 flagpole, flagstaff
n03063599 coffee mug
n04116512 rubber eraser, rubber, pencil eraser
n04325704 stole
n07831146 carbonara
n03255030 dumbbell
n00001740 entity
n00001930 physical entity
n00020827 matter
n00020090 substance
n00021265 food, nutrient
n07566340 foodstuff, food product
n07566863 starches
n07710616 potato, white potato, Irish potato, murphy, spud, tater
n07679356 bread, breadstuff, staff of life
n07683786 loaf of bread, loaf
n07681926 cracker
n07680932 bun, roll
n07809096 ingredient, fixings
n07809368 flavorer, flavourer, flavoring, flavouring, seasoner, seasoning
n07810907 condiment
n07582609 dip
n07829412 sauce
n07838233 spaghetti sauce, pasta sauce
n07882497 concoction, mixture, intermixture
n07560652 fare
n07570720 nutriment, nourishment, nutrition, sustenance, aliment, alimentation, victuals
n07557434 dish
n07588947 stew
n07583197 soup
n07712382 snack food
n07695965 sandwich
n07697100 hamburger, beefburger, burger
n07556970 course
n07579575 entree, main course
n07609840 dessert, sweet, afters
n07611358 frozen dessert
n07612996 pudding, pud
n07800091 feed, provender
n07800740 fodder
n07881800 beverage, drink, drinkable, potable
n07929519 coffee, java
n07884567 alcohol, alcoholic drink, alcoholic beverage, intoxicant, inebriant
n07891726 wine, vino
n07911371 mixed drink
n07930554 punch
n14778436 agent
n03247620 drug
n03248958 drug of abuse, street drug
n03740161 medicine, medication, medicament, medicinal drug
n03994008 powder
n00019613 substance
n14580897 material, stuff
n14974264 paper
n15074962 tissue, tissue paper
n14939900 fluid
n14940386 liquid
n15046900 solid
n07555863 food, solid food
n07622061 baked goods
n07705711 produce, green goods, green groceries, garden truck
n07705931 edible fruit
n07739125 apple
n07739506 eating apple, dessert apple
n07742704 berry
n07747055 citrus, citrus fruit, citrous fruit
n07707451 vegetable, veggie, veg
n07710007 solanaceous vegetable
n07720442 pepper
n07720615 sweet pepper
n07710283 root vegetable
n07713395 cruciferous vegetable
n07713895 cabbage, chou
n07715561 squash
n07715721 summer squash
n07717070 winter squash
n00007347 causal agent, cause, causal agency
n00007846 person, individual, someone, somebody, mortal, soul
n09613191 contestant
n10439851 player, participant
n09820263 athlete, jock
n10072708 explorer, adventurer
n10019552 diver, frogman, underwater diver
n09626238 peer, equal, match, compeer
n09816771 associate
n10401829 participant
n00002684 object, physical object
n09287968 geological formation, formation
n09366017 natural depression, depression
n09366317 natural elevation, elevation
n09359803 mountain, mount
n09409512 ridge
n09214060 bar
n09406793 reef
n09433442 shore
n09443453 spring, fountain, outflow, outpouring, natural spring
n00027167 location
n08620061 point
n08578706 geographic point, geographical point
n04602044 workplace, work
n00003553 whole, unit
n00019128 natural object
n09349797 mechanism
n09214581 barrier
n13086908 plant part, plant structure
n13087625 plant organ
n11675842 reproductive structure
n13134947 fruit
n13135832 seed
n11689483 oilseed, oil-rich seed
n12156819 grain, caryopsis
n12157056 kernel
n13138842 pome, false fruit
n00004258 living thing, animate thing
n00004475 organism, being
n00017222 plant, flora, plant life
n13083586 vascular plant, tracheophyte
n11552386 spermatophyte, phanerogam, seed plant
n11665372 angiosperm, flowering plant
n11669921 flower
n12041446 orchid, orchidaceous plant
n12056217 lady's slipper, lady-slipper, ladies' slipper, slipper orchid
n12992868 fungus
n12997654 basidiomycete, basidiomycetous fungi
n00015388 animal, animate being, beast, brute, creature, fauna
n01905661 invertebrate
n01767661 arthropod
n01769347 arachnid, arachnoid
n01772222 spider
n01776192 acarine
n01974773 crustacean
n01975687 malacostracan crustacean
n01976146 decapod crustacean, decapod
n01976957 crab
n01982650 lobster
n01983048 true lobster
n02159955 insect
n02164464 beetle
n02171453 lamellicorn beetle
n02171869 scarabaeid beetle, scarabaeid, scarabaean
n02188699 dipterous insect, two-winged insects, dipteran, dipteron
n02206270 hymenopterous insect, hymenopteran, hymenopteron, hymenopter
n02226183 orthopterous insect, orthopteron, orthopteran
n02231052 phasmid, phasmid insect
n02232951 dictyopterous insect
n02246011 homopterous insect, homopteran
n02263378 neuropteron, neuropteran, neuropterous insect
n02268148 odonate
n02274024 lepidopterous insect, lepidopteron, lepidopteran
n02274259 butterfly
n02274822 nymphalid, nymphalid butterfly, brush-footed butterfly, four-footed butterfly
n02279637 danaid, danaid butterfly
n02280458 pierid, pierid butterfly
n01909422 coelenterate, cnidarian
n01914163 anthozoan, actinozoan
n01915811 coral
n01916925 stony coral, madrepore, madriporian coral
n01922303 worm
n01940736 mollusk, mollusc, shellfish
n01942177 gastropod, univalve
n01968315 cephalopod, cephalopod mollusk
n02316707 echinoderm
n01317541 domestic animal, domesticated animal
n02121808 domestic cat, house cat, Felis domesticus, Felis catus
n02084071 dog, domestic dog, Canis familiaris
n02087122 hunting dog
n02098550 sporting dog, gun dog
n02099997 pointer, Spanish pointer
n02100399 setter
n02101108 spaniel
n02102605 water spaniel
n02101861 springer spaniel, springer
n02099029 retriever
n02092468 terrier
n02095050 fox terrier
n02095412 wirehair, wirehaired terrier, wire-haired terrier
n02095727 Welsh terrier
n02096756 schnauzer
n02093056 bullterrier, bull terrier
n02087551 hound, hound dog
n02090475 wolfhound
n02088839 coonhound
n02089555 foxhound
n02090827 greyhound
n02112826 corgi, Welsh corgi
n02113335 poodle, poodle dog
n02112497 griffon, Brussels griffon, Belgian griffon
n02103406 working dog
n02104523 shepherd dog, sheepdog, sheep dog
n02104882 Belgian sheepdog, Belgian shepherd
n02103841 watchdog, guard dog
n02106966 pinscher
n02109811 sled dog, sledge dog
n02107420 Sennenhunde
n02108254 mastiff
n02108672 bulldog, English bulldog
n02111626 spitz
n02085374 toy dog, toy
n02086346 toy spaniel
n02086478 English toy spaniel
n02152991 game
n02153203 game bird
n01795088 grouse
n01802721 phasianid
n01803078 pheasant
n01805801 peafowl, bird of Juno
n02384858 racer
n01466257 chordate
n01471682 vertebrate, craniate
n01861778 mammal, mammalian
n01886756 placental, placental mammal, eutherian, eutherian mammal
n02323449 lagomorph, gnawing mammal
n02323902 leporid, leporid mammal
n02324045 rabbit, coney, cony
n02469914 primate
n02496913 lemur
n02470325 ape
n02470899 anthropoid ape
n02480153 great ape, pongid
n02483092 lesser ape
n02484322 monkey
n02489589 New World monkey, platyrrhine, platyrrhinian
n02484473 Old World monkey, catarrhine
n02503127 proboscidean, proboscidian
n02503517 elephant
n02075296 carnivore
n02131653 bear
n02441326 musteline mammal, mustelid, musteline
n02507649 procyonid
n02134971 viverrine, viverrine mammal
n02083346 canine, canid
n02115335 wild dog
n02118333 fox
n02114100 wolf
n02120997 feline, felid
n02121620 cat, true cat
n02124623 wildcat
n02127808 big cat, cat
n02062017 aquatic mammal
n02073250 sea cow, sirenian mammal, sirenian
n02075927 pinniped mammal, pinniped, pinnatiped
n02076196 seal
n02076779 eared seal
n02062430 cetacean, cetacean mammal, blower
n02062744 whale
n02066707 toothed whale
n02068974 dolphin
n02063224 baleen whale, whalebone whale
n02370806 ungulate, hoofed mammal
n02373336 odd-toed ungulate, perissodactyl, perissodactyl mammal
n02374149 equine, equid
n02374451 horse, Equus caballus
n02394477 even-toed ungulate, artiodactyl, artiodactyl mammal
n02437136 camel
n02399000 ruminant
n02401031 bovid
n02411705 sheep
n02419796 antelope
n02414578 wild sheep
n02415435 mountain sheep
n02416519 goat, caprine animal
n02417534 wild goat
n02407959 Old World buffalo, buffalo
n02402010 bovine
n02402425 cattle, cows, kine, oxen, Bos taurus
n02395003 swine
n02453611 edentate
n02456962 sloth, tree sloth
n02453108 pachyderm
n02329401 rodent, gnawer
n02364520 cavy
n02355227 squirrel
n02355477 tree squirrel
n01871543 prototherian
n01871875 monotreme, egg-laying mammal
n01873982 metatherian
n01874434 marsupial, pouched mammal
n01881171 phalanger, opossum, possum
n01877134 kangaroo
n01503061 bird
n01517565 ratite, ratite bird, flightless bird
n01524359 passerine, passeriform bird
n01525720 oscine, oscine bird
n01529672 finch
n01537134 bunting
n01557185 thrush
n01560105 nightingale, Luscinia megarhynchos
n01578575 corvine bird
n01591697 titmouse, tit
n01604330 bird of prey, raptor, raptorial bird
n01605630 hawk
n01613294 eagle, bird of Jove
n01621127 owl, bird of Minerva, bird of night, hooter
n01789386 gallinaceous bird, gallinacean
n01816887 parrot
n01819115 cockatoo
n01820348 lory
n01822602 cuculiform bird
n01823013 cuckoo
n01825930 coraciiform bird
n01831712 apodiform bird
n01838038 piciform bird
n01844917 aquatic bird
n01845132 waterfowl, water bird, waterbird
n01845477 anseriform bird
n01846331 duck
n01852861 sea duck
n01854415 merganser, fish duck, sawbill, sheldrake
n01858441 swan
n02000954 wading bird, wader
n02002075 stork
n02008041 heron
n02008796 egret
n02014941 rail
n02018027 coot
n02022684 shorebird, shore bird, limicoline bird
n02023341 plover
n02025043 turnstone
n02026059 sandpiper
n02031934 snipe
n02016358 gallinule, marsh hen, water hen, swamphen
n02016956 purple gallinule
n02021795 seabird, sea bird, seafowl
n02051474 pelecaniform seabird
n02055658 sphenisciform seabird
n02055803 penguin
n02057731 pelagic bird, oceanic bird
n01661091 reptile, reptilian
n01661592 anapsid, anapsid reptile
n01662622 chelonian, chelonian reptile
n01662784 turtle
n01663401 sea turtle, marine turtle
n01661818 diapsid, diapsid reptile
n01674216 saurian
n01674464 lizard
n01674990 gecko
n01676755 iguanid, iguanid lizard
n01685439 teiid lizard, teiid
n01687665 agamid, agamid lizard
n01689411 anguid lizard
n01691951 venomous lizard
n01692864 lacertid lizard, lacertid
n01693783 chameleon, chamaeleon
n01694709 monitor, monitor lizard, varan
n01695681 archosaur, archosaurian, archosaurian reptile
n01699831 dinosaur
n01700470 ornithischian, ornithischian dinosaur
n01703569 ceratopsian, horned dinosaur
n01696633 crocodilian reptile, crocodilian
n01698434 alligator, gator
n01697178 crocodile
n01726692 snake, serpent, ophidian
n01727646 colubrid snake, colubrid
n01741562 constrictor
n01741943 boa
n01743605 python
n01745125 elapid, elapid snake
n01747885 cobra
n01749582 mamba
n01749742 black mamba, Dendroaspis augusticeps
n01752165 viper
n01753959 pit viper
n01754876 rattlesnake, rattler
n01627424 amphibian
n01639765 frog, toad, toad frog, anuran, batrachian, salientian
n01640846 true frog, ranid
n01629276 salamander
n01630284 newt, triton
n01632047 ambystomid, ambystomid salamander
n01473806 aquatic vertebrate
n02512053 fish
n01480516 cartilaginous fish, chondrichthian
n01482071 elasmobranch, selachian
n01482330 shark
n01483522 mackerel shark
n01488918 requiem shark
n01495701 ray
n02512938 food fish
n02534734 salmon
n02514825 bony fish
n02528163 teleost fish, teleost, teleostan
n01428580 soft-finned fish, malacopterygian
n01438208 cypriniform fish
n01439121 cyprinid, cyprinid fish
n02534559 salmonid
n02552171 spiny-finned fish, acanthopterygian
n02554730 percoid fish, percoid, percoidean
n02605316 butterfly fish
n02606384 damselfish, demoiselle
n02642107 scorpaenoid, scorpaenoid fish
n02642644 scorpaenid, scorpaenid fish
n02652668 plectognath, plectognath fish
n02638596 ganoid, ganoid fish
n00021939 artifact, artefact
n03575240 instrumentality, instrumentation
n03183080 device
n03800933 musical instrument, instrument
n03614532 keyboard instrument
n03928116 piano, pianoforte, forte-piano
n03915437 percussion instrument, percussive instrument
n04338517 stringed instrument
n02880546 bowed stringed instrument, string
n03025886 chordophone
n03467517 guitar
n04586932 wind instrument, wind
n02891788 brass, brass instrument
n03393324 free-reed instrument
n03945615 pipe
n04598582 woodwind, woodwind instrument, wood
n02817799 beating-reed instrument, reed instrument, reed
n03228016 double-reed instrument, double reed
n04222847 single-reed instrument, single-reed woodwind
n02676261 acoustic device
n02688443 airfoil, aerofoil, control surface, surface
n02730265 applicator, applier
n02855089 blower
n02895606 breathing device, breathing apparatus, breathing machine, ventilator
n03269401 electrical device
n04470953 transducer
n03274561 electro-acoustic transducer
n03277771 electronic device
n03211117 display, video display
n03320046 fan
n03339643 filter
n03508101 heater, warmer
n03574816 instrument
n03575691 instrument of execution
n03733925 measuring instrument, measuring system, measuring device
n03735637 measuring stick, measure, measuring rod
n03753077 meter
n04437953 timepiece, timekeeper, horologe
n04555897 watch, ticker
n03046257 clock
n04134632 sandglass
n04438304 timer
n03739693 medical instrument
n03813176 navigational instrument
n03080497 compass
n03852280 optical instrument
n04272054 spectacles, specs, eyeglasses, glasses
n04147495 scientific instrument
n03709206 magnifier
n03760671 microscope
n03667829 light microscope
n03484931 hand glass, simple microscope, magnifying glass
n04403638 telescope, scope
n02751295 astronomical telescope
n04565375 weapon, arm, weapon system
n03467984 gun
n03343853 firearm, piece, small-arm
n02759963 autoloader, self-loader
n02760429 automatic firearm, automatic gun, automatic weapon
n02760855 automatic rifle, automatic, machine rifle
n03701391 machine gun
n03948459 pistol, handgun, side arm, shooting iron
n03614007 keyboard
n03664675 lifting device
n03699975 machine
n03997484 power tool
n03996145 power saw, saw, sawing machine
n02938886 calculator, calculating machine
n03082979 computer, computing machine, computing device, data processor, electronic computer, information processing system
n02708224 analog computer, analogue computer
n03196324 digital computer
n03918480 personal computer, PC, microcomputer
n03985232 portable computer
n03322940 farm machine
n04004475 printer, printing machine
n04243941 slot machine, coin machine
n04417180 textile machine
n03738472 mechanism
n03096960 control, controller
n03736970 mechanical device
n03700963 machine, simple machine
n04574999 wheel
n04021798 pump
n04088797 ride
n04586421 winder
n04110955 rotating mechanism
n03032811 circle, round
n03208556 disk, disc
n03744840 memory device, storage device
n03706653 magnetic disk, magnetic disc, disk, disc
n03851341 optical device
n03656484 lens, lense, lens system
n03099771 converging lens, convex lens
n04069276 reflector
n03773035 mirror
n04081844 restraint, constraint
n02889425 brake
n02891188 brake system, brakes
n03551084 hydraulic brake, hydraulic brakes
n03323703 fastener, fastening, holdfast, fixing
n03043958 clip
n03682487 lock
n03940256 pin
n04125853 safety belt, life belt, safety harness
n04120093 runner
n04217718 signaling device
n04263760 source of illumination
n03636248 lamp
n03640988 lantern
n03665366 light, light source
n04336034 strengthener, reinforcement
n02887209 brace
n04359589 support
n04038440 rack, stand
n04341414 structural member
n04515129 upright, vertical
n03988170 post
n04474466 trap
n04568557 web, entanglement
n03563967 implement
n04451818 tool
n03154446 cutting implement
n03154073 cutter, cutlery, cutting tool
n03265032 edge tool
n02764044 ax, axe
n03623556 knife
n03239726 drill
n03418242 garden tool, lawn tool
n03489162 hand tool
n03848348 opener
n02877962 bottle opener
n04516672 utensil
n03621049 kitchen utensil
n03101986 cooking utensil, cookware
n03101156 cooker
n03880531 pan, cooking pan
n03990474 pot
n04500060 turner, food turner
n03039947 cleaning implement, cleaning device, cleaning equipment
n02908217 brush
n03294833 eraser
n04185071 sharpener
n03837422 oar
n04100174 rod
n04608567 writing implement
n03906997 pen
n04317420 stick
n04296261 staff
n02788689 bar
n03659292 lever
n03613592 key
n04285622 sports implement
n03094503 container
n04576211 wheeled vehicle
n02834778 bicycle, bike, wheel, cycle
n02959942 car, railcar, railway car, railroad car
n03484083 handcart, pushcart, cart, go-cart
n04170037 self-propelled vehicle
n02740533 armored vehicle, armoured vehicle
n03684823 locomotive, engine, locomotive engine, railway locomotive
n03791235 motor vehicle, automotive vehicle
n02958343 car, auto, automobile, machine, motorcar
n03790512 motorcycle, bike
n03769722 minibike, motorbike
n04490091 truck, motortruck
n04520170 van
n03896419 passenger van
n04464852 tracked vehicle
n04467099 trailer, house trailer
n04543158 wagon, waggon
n02970849 cart
n02801938 basket, handbasket
n02773037 bag
n04284002 spoon
n04139859 savings bank, coin bank, money box, bank
n03206908 dish
n02880940 bowl
n02839910 bin
n04183329 shaker
n04531098 vessel
n02801525 basin
n03593526 jar
n02876657 bottle
n03603722 jug
n04388743 tank, storage tank
n04078574 reservoir
n03035510 cistern
n03241496 drinking vessel
n03797390 mug
n02946921 can, tin, tin can
n03438257 glass, drinking glass
n04060904 receptacle
n03210683 dispenser
n03871083 package, parcel
n02883344 box
n04340750 strongbox, deedbox
n03733644 measure
n02974697 case
n03294048 equipment
n04285146 sports equipment
n03446832 golf equipment
n02799897 baseball equipment
n03472232 gymnastic apparatus, exerciser
n02802721 basketball equipment
n03134853 croquet equipment
n04571292 weight, free weight, exercising weight
n03414162 game equipment
n03413828 game
n04028315 puzzle
n02778669 ball
n03926148 photographic equipment
n02942699 camera, photographic camera
n03430959 gear, paraphernalia, appurtenance
n03619396 kit, outfit
n04091097 rig
n03241093 drill rig, drilling rig, oilrig, oil rig
n04137444 satellite, artificial satellite, orbiter
n04264914 spacecraft, ballistic capsule, space vehicle
n03278248 electronic equipment
n02757462 audio system, sound system
n04077430 reproducer
n04315948 stereo, stereophony, stereo system, stereophonic system
n03916720 peripheral, computer peripheral, peripheral device
n03163973 data input device, input device
n04401088 telephone, phone, telephone set
n04044498 radiotelephone, radiophone, wireless telephone
n02727825 apparatus, setup
n03257586 duplicator, copier
n04077734 rescue equipment
n04447443 toiletry, toilet articles
n03128519 cream, ointment, emollient
n03113152 cosmetic
n03714235 makeup, make-up, war paint
n03100490 conveyance, transport
n04524313 vehicle
n03125870 craft
n02686568 aircraft
n03510583 heavier-than-air craft
n02691156 airplane, aeroplane, plane
n03666917 lighter-than-air craft
n04530566 vessel, watercraft
n02858304 boat
n03790230 motorboat, powerboat
n04158807 sea boat
n04244997 small boat
n04128837 sailing vessel, sailing ship
n04128499 sailboat, sailing boat
n04194289 ship
n02965300 cargo ship, cargo vessel
n03896103 passenger ship
n04552696 warship, war vessel, combat ship
n04348184 submersible, submersible warship
n03764276 military vehicle
n04099429 rocket, projectile
n04235291 sled, sledge, sleigh
n03678362 litter
n04019101 public transport
n04468005 train, railroad train
n03896233 passenger train
n02924116 bus, autobus, coach, charabanc, double-decker, jitney, motorbus, motorcoach, omnibus, passenger vehicle
n03091374 connection, connexion, connector, connecter, connective
n02755352 attachment, bond
n03664943 ligament
n03405265 furnishing
n03405725 furniture, piece of furniture, article of furniture
n02766320 baby bed, baby's bed
n02821943 bedroom furniture
n02818832 bed
n02933112 cabinet
n03015254 chest of drawers, chest, bureau, dresser
n03636649 lamp
n03842156 office furniture
n04161981 seat
n02828884 bench
n03001627 chair
n03002210 chair of state
n04256520 sofa, couch, lounge
n03100346 convertible, sofa bed
n04379243 table
n04379964 table
n04549122 wall unit
n04118021 rug, carpet, carpeting
n03151077 curtain, drape, drapery, mantle, pall
n06254669 medium
n06263609 print media
n06263369 press, public press
n06595351 magazine, mag
n04377057 system
n03078287 communication system
n04400289 telecommunication system, telecom system, telecommunication equipment, telecom equipment
n04341686 structure, construction
n02733524 arch
n02735688 area
n02898711 bridge, span
n02913152 building, edifice
n03322570 farm building
n03544360 house
n04079244 residence
n04073948 religious residence, cloister
n03859280 outbuilding
n04187547 shed
n03953416 place of worship, house of prayer, house of God, house of worship
n04210390 shrine
n04417809 theater, theatre, house
n02914991 building complex, complex
n03956922 plant, works, industrial plant
n03316406 factory, mill, manufacturing plant, manufactory
n03074380 column, pillar
n03171356 defensive structure, defense, defence
n03385557 fortification, munition
n03297735 establishment
n03574555 institution
n03907654 penal institution, penal facility
n03111690 correctional institution
n03953020 place of business, business establishment
n03748162 mercantile establishment, retail store, sales outlet, outlet
n03722288 marketplace, market place, mart, market
n04202417 shop, store
n03546340 housing, lodging, living accommodations
n03259505 dwelling, home, domicile, abode, habitation, dwelling house
n03638321 landing, landing place
n03743902 memorial, monument
n03839993 obstruction, obstructor, obstructer, impediment, impedimenta
n02796623 barrier
n03327234 fence, fencing
n04046974 rail fence
n03454707 grate, grating
n03795580 movable barrier
n03221720 door
n03427296 gate
n04191595 shelter
n04411264 tent, collapsible shelter
n04217882 signboard, sign
n04361095 supporting structure
n03391770 framework
n04038727 rack
n04360501 support
n04460130 tower
n03129123 creation
n04007894 product, production
n04599396 work, piece of work
n06589574 publication
n04188643 sheet, flat solid
n02856463 board
n03959936 plate
n03309808 fabric, cloth, material, textile
n03932670 piece of cloth, piece of material
n04459362 towel
n03122748 covering
n04605726 wrapping, wrap, wrapper
n03590306 jacket
n04151940 screen, cover, covert, concealment
n03380867 footwear, footgear
n04199027 shoe
n02872752 boot
n03050026 cloth covering
n03237639 dressing, medical dressing
n02785648 bandage, patch
n02680110 adhesive bandage
n02820210 bedclothes, bed clothing, bedding
n03366823 floor cover, floor covering
n03727837 mat
n03051540 clothing, article of clothing, vesture, wear, wearable, habiliment
n02756098 attire, garb, dress
n03206718 disguise
n03476083 hairpiece, false hair, postiche
n04015204 protective garment
n02671780 accessory, accoutrement, accouterment
n02827606 belt
n03859495 outerwear, overclothes
n03450516 gown, robe
n03419014 garment
n04531873 vest, waistcoat
n04371563 swimsuit, swimwear, bathing suit, swimming costume, bathing costume
n04489008 trouser, pant
n04143897 scarf
n03816005 neckwear
n03815615 necktie, tie
n04230808 skirt
n03863923 overgarment, outer garment
n03045337 cloak
n03057021 coat
n04049405 raincoat, waterproof
n04370048 sweater, jumper
n04021028 pullover, slipover
n04097866 robe
n04197391 shirt
n04508163 undergarment, unmentionable
n03490324 handwear, hand wear
n03441112 glove
n03502509 headdress, headgear
n03513137 helmet
n02954340 cap
n03497657 hat, chapeau, lid
n03381126 footwear
n03540267 hosiery, hose
n04434932 tights, leotards
n04323819 stocking
n04509592 uniform
n03825080 nightwear, sleepwear, nightclothes
n02728440 apparel, wearing apparel, dress, clothes
n04603872 workwear
n04596852 woman's clothing
n03236735 dress, frock
n04014297 protective covering, protective cover, protection
n04192858 shield
n03959701 plate, scale, shell
n02740764 armor plate, armour plate, armor plating, plate armor, plate armour
n03513376 helmet
n02955065 cap
n04105068 roof
n02851099 blind, screen
n04589190 window blind
n04181718 shade
n04151581 screen
n02739668 armor, armour
n02862048 body armor, body armour, suit of armor, suit of armour, coat of mail, cataphract
n03725035 mask
n03314378 face mask
n04187061 sheath
n04191943 shelter
n02951843 canopy
n04453910 top, cover
n02954938 cap
n03873064 padding, cushioning
n03151500 cushion
n03076708 commodity, trade good, good
n03093574 consumer goods
n03257877 durables, durable goods, consumer durables
n02729837 appliance
n03251766 dryer, drier
n03528263 home appliance, household appliance
n03620052 kitchen appliance
n03063338 coffee maker
n03862676 oven
n04580493 white goods
n03252064 drygoods, soft goods
n04580298 white goods, household linen
n03672352 linen
n02807260 bath linen
n03302121 excavation
n03982060 pool
n03169390 decoration, ornament, ornamentation
n02681518 adornment
n03597469 jewelry, jewellery
n03178782 design, pattern, figure
n03282591 emblem
n03964744 plaything, toy
n00022903 article
n04550840 ware
n04597804 woodenware
n04381994 tableware
n03153375 cutlery, eating utensil
n03133538 crockery, dishware
n04362025 surface
n03536348 horizontal surface, level
n03961939 platform
n03892891 part, portion
n03932203 piece
n00002137 abstraction, abstract entity
n00024264 attribute
n00027807 shape, form
n13865483 round shape
n13899200 sphere
n13899404 ball, globe, orb
n09289709 globule
n00033020 communication
n06793231 sign
n06791372 signal, signaling, sign
n06873571 visual signal
n06874019 light
n00031921 relation
n13809207 part, portion, component part, component, constituent


================================================
FILE: examples/imagenet_eval.py
================================================
from __future__ import print_function, division, absolute_import
import argparse
import os
import shutil
import time

import torch
import torch.nn as nn
import torch.nn.parallel
import torch.backends.cudnn as cudnn
import torch.optim
import torch.utils.data
import torchvision.transforms as transforms
import torchvision.datasets as datasets

import sys

sys.path.append('.')
import pretrainedmodels
import pretrainedmodels.utils

model_names = sorted(name for name in pretrainedmodels.__dict__
                     if not name.startswith("__")
                     and name.islower()
                     and callable(pretrainedmodels.__dict__[name]))

parser = argparse.ArgumentParser(description='PyTorch ImageNet Training')
parser.add_argument('--data', metavar='DIR', default="path_to_imagenet",
                    help='path to dataset')
parser.add_argument('--arch', '-a', metavar='ARCH', default='nasnetamobile',
                    choices=model_names,
                    help='model architecture: ' +
                         ' | '.join(model_names) +
                         ' (default: fbresnet152)')
parser.add_argument('-j', '--workers', default=4, type=int, metavar='N',
                    help='number of data loading workers (default: 4)')
parser.add_argument('--epochs', default=90, type=int, metavar='N',
                    help='number of total epochs to run')
parser.add_argument('--start-epoch', default=0, type=int, metavar='N',
                    help='manual epoch number (useful on restarts)')
parser.add_argument('-b', '--batch-size', default=1256, type=int,
                    metavar='N', help='mini-batch size (default: 256)')
parser.add_argument('--lr', '--learning-rate', default=0.1, type=float,
                    metavar='LR', help='initial learning rate')
parser.add_argument('--momentum', default=0.9, type=float, metavar='M',
                    help='momentum')
parser.add_argument('--weight-decay', '--wd', default=1e-4, type=float,
                    metavar='W', help='weight decay (default: 1e-4)')
parser.add_argument('--print-freq', '-p', default=10, type=int,
                    metavar='N', help='print frequency (default: 10)')
parser.add_argument('--resume', default='', type=str, metavar='PATH',
                    help='path to latest checkpoint (default: none)')
parser.add_argument('-e', '--evaluate', dest='evaluate', default=True,
                    action='store_true', help='evaluate model on validation set')
parser.add_argument('--pretrained', default='imagenet', help='use pre-trained model')
parser.add_argument('--do-not-preserve-aspect-ratio',
                    dest='preserve_aspect_ratio',
                    help='do not preserve the aspect ratio when resizing an image',
                    action='store_false')
parser.set_defaults(preserve_aspect_ratio=True)
best_prec1 = 0


def main():
    global args, best_prec1
    args = parser.parse_args()

    # create model
    print("=> creating model '{}'".format(args.arch))
    if args.pretrained.lower() not in ['false', 'none', 'not', 'no', '0']:
        print("=> using pre-trained parameters '{}'".format(args.pretrained))
        model = pretrainedmodels.__dict__[args.arch](num_classes=1000,
                                                     pretrained=args.pretrained)
    else:
        model = pretrainedmodels.__dict__[args.arch]()

    # optionally resume from a checkpoint
    if args.resume:
        if os.path.isfile(args.resume):
            print("=> loading checkpoint '{}'".format(args.resume))
            checkpoint = torch.load(args.resume)
            args.start_epoch = checkpoint['epoch']
            best_prec1 = checkpoint['best_prec1']
            model.load_state_dict(checkpoint['state_dict'])
            print("=> loaded checkpoint '{}' (epoch {})"
                  .format(args.resume, checkpoint['epoch']))
        else:
            print("=> no checkpoint found at '{}'".format(args.resume))

    cudnn.benchmark = True

    # Data loading code
    # traindir = os.path.join(args.data, 'train')
    valdir = os.path.join(args.data, 'val')

    # train_loader = torch.utils.data.DataLoader(
    #     datasets.ImageFolder(traindir, transforms.Compose([
    #         transforms.RandomSizedCrop(max(model.input_size)),
    #         transforms.RandomHorizontalFlip(),
    #         transforms.ToTensor(),
    #         normalize,
    #     ])),
    #     batch_size=args.batch_size, shuffle=True,
    #     num_workers=args.workers, pin_memory=True)



    # if 'scale' in pretrainedmodels.pretrained_settings[args.arch][args.pretrained]:
    #     scale = pretrainedmodels.pretrained_settings[args.arch][args.pretrained]['scale']
    # else:
    #     scale = 0.875
    scale = 0.875

    print('Images transformed from size {} to {}'.format(
        int(round(max(model.input_size) / scale)),
        model.input_size))

    val_tf = pretrainedmodels.utils.TransformImage(
        model,
        scale=scale,
        preserve_aspect_ratio=args.preserve_aspect_ratio
    )

    val_loader = torch.utils.data.DataLoader(
        datasets.ImageFolder(valdir, val_tf),
        batch_size=args.batch_size, shuffle=False,
        num_workers=args.workers, pin_memory=True)

    # define loss function (criterion) and optimizer
    criterion = nn.CrossEntropyLoss().cuda()

    optimizer = torch.optim.SGD(model.parameters(), args.lr,
                                momentum=args.momentum,
                                weight_decay=args.weight_decay)

    model = torch.nn.DataParallel(model).cuda()

    if args.evaluate:
        validate(val_loader, model, criterion)
        return

    for epoch in range(args.start_epoch, args.epochs):
        adjust_learning_rate(optimizer, epoch)

        # train for one epoch
        train(train_loader, model, criterion, optimizer, epoch)

        # evaluate on validation set
        prec1 = validate(val_loader, model, criterion)

        # remember best prec@1 and save checkpoint
        is_best = prec1 > best_prec1
        best_prec1 = max(prec1, best_prec1)
        save_checkpoint({
            'epoch': epoch + 1,
            'arch': args.arch,
            'state_dict': model.state_dict(),
            'best_prec1': best_prec1,
        }, is_best)


def train(train_loader, model, criterion, optimizer, epoch):
    batch_time = AverageMeter()
    data_time = AverageMeter()
    losses = AverageMeter()
    top1 = AverageMeter()
    top5 = AverageMeter()

    # switch to train mode
    model.train()

    end = time.time()
    for i, (input, target) in enumerate(train_loader):
        # measure data loading time
        data_time.update(time.time() - end)

        target = target.cuda()
        input_var = torch.autograd.Variable(input)
        target_var = torch.autograd.Variable(target)

        # compute output
        output = model(input_var)
        loss = criterion(output, target_var)

        # measure accuracy and record loss
        prec1, prec5 = accuracy(output.data, target, topk=(1, 5))
        losses.update(loss.data[0], input.size(0))
        top1.update(prec1[0], input.size(0))
        top5.update(prec5[0], input.size(0))

        # compute gradient and do SGD step
        optimizer.zero_grad()
        loss.backward()
        optimizer.step()

        # measure elapsed time
        batch_time.update(time.time() - end)
        end = time.time()

        if i % args.print_freq == 0:
            print('Epoch: [{0}][{1}/{2}]\t'
                  'Time {batch_time.val:.3f} ({batch_time.avg:.3f})\t'
                  'Data {data_time.val:.3f} ({data_time.avg:.3f})\t'
                  'Loss {loss.val:.4f} ({loss.avg:.4f})\t'
                  'Acc@1 {top1.val:.3f} ({top1.avg:.3f})\t'
                  'Acc@5 {top5.val:.3f} ({top5.avg:.3f})'.format(
                epoch, i, len(train_loader), batch_time=batch_time,
                data_time=data_time, loss=losses, top1=top1, top5=top5))


def validate(val_loader, model, criterion):
    with torch.no_grad():
        batch_time = AverageMeter()
        losses = AverageMeter()
        top1 = AverageMeter()
        top5 = AverageMeter()

        # switch to evaluate mode
        model.eval()

        end = time.time()
        for i, (input, target) in enumerate(val_loader):
            target = target.cuda()
            input = input.cuda()

            # compute output
            output = model(input)
            loss = criterion(output, target)

            # measure accuracy and record loss
            prec1, prec5 = accuracy(output.data, target.data, topk=(1, 5))
            losses.update(loss.data.item(), input.size(0))
            top1.update(prec1.item(), input.size(0))
            top5.update(prec5.item(), input.size(0))

            # measure elapsed time
            batch_time.update(time.time() - end)
            end = time.time()

            if i % args.print_freq == 0:
                print('Test: [{0}/{1}]\t'
                      'Time {batch_time.val:.3f} ({batch_time.avg:.3f})\t'
                      'Loss {loss.val:.4f} ({loss.avg:.4f})\t'
                      'Acc@1 {top1.val:.3f} ({top1.avg:.3f})\t'
                      'Acc@5 {top5.val:.3f} ({top5.avg:.3f})'.format(
                       i, len(val_loader), batch_time=batch_time, loss=losses,
                       top1=top1, top5=top5))

        print(' * Acc@1 {top1.avg:.3f} Acc@5 {top5.avg:.3f}'
              .format(top1=top1, top5=top5))

        return top1.avg, top5.avg


def save_checkpoint(state, is_best, filename='checkpoint.pth.tar'):
    torch.save(state, filename)
    if is_best:
        shutil.copyfile(filename, 'model_best.pth.tar')


class AverageMeter(object):
    """Computes and stores the average and current value"""

    def __init__(self):
        self.reset()

    def reset(self):
        self.val = 0
        self.avg = 0
        self.sum = 0
        self.count = 0

    def update(self, val, n=1):
        self.val = val
        self.sum += val * n
        self.count += n
        self.avg = self.sum / self.count


def adjust_learning_rate(optimizer, epoch):
    """Sets the learning rate to the initial LR decayed by 10 every 30 epochs"""
    lr = args.lr * (0.1 ** (epoch // 30))
    for param_group in optimizer.param_groups:
        param_group['lr'] = lr


def accuracy(output, target, topk=(1,)):
    """Computes the precision@k for the specified values of k"""
    maxk = max(topk)
    batch_size = target.size(0)

    _, pred = output.topk(maxk, 1, True, True)
    pred = pred.t()
    correct = pred.eq(target.view(1, -1).expand_as(pred))

    res = []
    for k in topk:
        correct_k = correct[:k].view(-1).float().sum(0)
        res.append(correct_k.mul_(100.0 / batch_size))
    return res


if __name__ == '__main__':
    main()

================================================
FILE: examples/imagenet_logits.py
================================================
from __future__ import print_function, division, absolute_import
import argparse

from PIL import Image
import torch
import torchvision.transforms as transforms

import sys
sys.path.append('.')
import pretrainedmodels
import pretrainedmodels.utils as utils

model_names = sorted(name for name in pretrainedmodels.__dict__
    if not name.startswith("__")
    and name.islower()
    and callable(pretrainedmodels.__dict__[name]))

parser = argparse.ArgumentParser(description='PyTorch ImageNet Training')
parser.add_argument('--arch', '-a', metavar='ARCH', default='nasnetalarge',
                    choices=model_names,
                    help='model architecture: ' +
                        ' | '.join(model_names) +
                        ' (default: nasnetalarge)',
                    nargs='+')
parser.add_argument('--path_img', type=str, default='data/cat.jpg')

def main():
    global args
    args = parser.parse_args()

    for arch in args.arch:
        # Load Model
        model = pretrainedmodels.__dict__[arch](num_classes=1000,
                                                pretrained='imagenet')
        model.eval()

        path_img = args.path_img
        # Load and Transform one input image
        load_img = utils.LoadImage()
        tf_img = utils.TransformImage(model)

        input_data = load_img(args.path_img) # 3x400x225
        input_data = tf_img(input_data)      # 3x299x299
        input_data = input_data.unsqueeze(0) # 1x3x299x299
        input = torch.autograd.Variable(input_data)

        # Load Imagenet Synsets
        with open('data/imagenet_synsets.txt', 'r') as f:
            synsets = f.readlines()

        # len(synsets)==1001
        # sysnets[0] == background
        synsets = [x.strip() for x in synsets]
        splits = [line.split(' ') for line in synsets]
        key_to_classname = {spl[0]:' '.join(spl[1:]) for spl in splits}

        with open('data/imagenet_classes.txt', 'r') as f:
            class_id_to_key = f.readlines()

        class_id_to_key = [x.strip() for x in class_id_to_key]

        # Make predictions
        output = model(input) # size(1, 1000)
        max, argmax = output.data.squeeze().max(0)
        class_id = argmax[0]
        class_key = class_id_to_key[class_id]
        classname = key_to_classname[class_key]

        print("'{}': '{}' is a '{}'".format(arch, path_img, classname))

if __name__ == '__main__':
    main()


================================================
FILE: examples/visu_arch.py
================================================
from __future__ import print_function, division, absolute_import
import os

import torch # http://pytorch.org/about/
from torch.autograd import Variable
from torch.utils import model_zoo

import torchvision # https://github.com/pytorch/vision
import torchvision.models as models
import torchvision.transforms as transforms

from lib.voc import Voc2007Classification
from lib.util import load_imagenet_classes

model_urls = {
    # Alexnet
    # Paper: https://papers.nips.cc/paper/4824-imagenet-classification-with-deep-convolutional-neural-networks.pdf
    # https://github.com/pytorch/vision/blob/master/torchvision/models/alexnet.py
    'alexnet': 'https://download.pytorch.org/models/alexnet-owt-4df8aa71.pth',
    # VGG
    # Paper: https://arxiv.org/abs/1409.1556
    # https://github.com/pytorch/vision/blob/master/torchvision/models/vgg.py
    'vgg16': 'https://download.pytorch.org/models/vgg16-397923af.pth',
    # VGG BatchNorm
    # Paper: https://arxiv.org/abs/1502.03167
    # https://github.com/pytorch/vision/blob/master/torchvision/models/vgg.py
    'vgg16_bn': 'https://download.pytorch.org/models/vgg16_bn-6c64b313.pth',
    # Inception
    # Paper: https://arxiv.org/abs/1602.07261
    # https://github.com/pytorch/vision/blob/master/torchvision/models/inception.py
    'inception_v3': 'https://download.pytorch.org/models/inception_v3_google-1a9a5a14.pth',
    # Resnet
    # Paper: https://arxiv.org/abs/1512.03385
    # https://github.com/pytorch/vision/blob/master/torchvision/models/resnet.py
    'resnet18': 'https://download.pytorch.org/models/resnet18-5c106cde.pth',
    'resnet50': 'https://download.pytorch.org/models/resnet50-19c8e357.pth',
    'resnet152': 'https://download.pytorch.org/models/resnet152-b121ed2d.pth'
}

if __name__ == '__main__':

    model_name = 'alexnet'

    dir_datasets = '/home/sasl/shared/EI-SE5-CS/datasets' # '/tmp/torch/datasets'
    dir_models = '/home/sasl/shared/EI-SE5-CS/models' # '/tmp/torch/models'
    dir_outputs = '/tmp/outputs/' + model_name

    print('Create network')
    model = models.__dict__[model_name]() # https://stackoverflow.com/questions/19907442/python-explain-dict-attribute
    model.eval() # http://pytorch.org/docs/master/nn.html?highlight=eval#torch.nn.Module.eval
    print('')

    ##########################################################################

    print('Display modules')
    print(model)
    print('')

    ##########################################################################

    print('Display parameters')
    state_dict = model.state_dict() # http://pytorch.org/docs/master/_modules/torch/nn/modules/module.html#Module.state_dict
    for key, value in state_dict.items():
        print(key, value.size())
    print('')

    print('Display features.0.weight')
    print(state_dict['features.0.weight'])
    print('')

    ##########################################################################

    print('Display inputs/outputs')

    def print_info(self, input, output):
        print('Inside '+ self.__class__.__name__+ ' forward')
        print('input size', input[0].size())
        print('output size', output.data.size())
        print('')

    handles = []
    for m in model.features:
        handles.append(m.register_forward_hook(print_info)) # http://pytorch.org/docs/master/_modules/torch/nn/modules/module.html#Module.register_forward_pre_hook

    for m in model.classifier:
        handles.append(m.register_forward_hook(print_info))

    input = Variable(torch.randn(1,3,224,224).float(), requires_grad=False) # http://pytorch.org/tutorials/beginner/blitz/autograd_tutorial.html#sphx-glr-beginner-blitz-autograd-tutorial-py
    output = model(input) # model(input) calls model.__call__(input) which calls model.forward(hook) and then calls the hooks

    for h in handles:
        h.remove() # to remove the hooks

    print('')

    ##########################################################################

    print('Load dataset Voc2007')

    train_data = Voc2007Classification(dir_datasets, 'train') # or val, test, trainval

    print('Voc2007 trainset has {} images'.format(len(train_data)))

    print('Voc2007 has {} classes'.format(len(train_data.classes)))
    print(train_data.classes)

    item = train_data[0] # train_data contains a list of items (image, name, target)
    img_data = item[0] # PIL.Image.Image
    img_name = item[1] # string
    target = item[2] #  torch.Tensor of size=20 (=nb_classes), contains 3 values: -1 (absence of class), 1 (presence of class), 0 (hard example)

    os.system('mkdir -p ' + dir_outputs) # create a directory
    path_img = os.path.join(dir_outputs, img_name+'.png')
    img_data.save(path_img) # save image using PIL

    print('Write image to ' + path_img)
    for class_id, has_class in enumerate(target):
        if has_class == 1:
            print('image {} has object of class {}'.format(img_name, train_data.classes[class_id]))

    ##########################################################################

    print('Load pretrained model on Imagenet')
    model.load_state_dict(model_zoo.load_url(model_urls[model_name],
                                   model_dir=dir_models))

    print('Display predictions')

    tf = transforms.Compose([
        transforms.Scale(224), # rescale an RGB image to size 224^ (not a square)
        transforms.CenterCrop(224), # extract a square of size 224 at the center of the image
        transforms.ToTensor(), # convert the PIL.Image into a torch.Tensor
        transforms.Normalize(
            mean=[0.485, 0.456, 0.406], # mean pixel value per channel
            std=[0.229, 0.224, 0.225] # standard deviation value per channel
        )
    ])

    input_data = tf(img_data)
    input_data = input_data.unsqueeze(0) # (3,224,224) -> (1,3,224,224)
    print('input size', input_data.size())
    print(input_data)

    input = Variable(input_data, requires_grad=False)
    output = model(input)

    print('output size', output.data.size())
    print(output.data)

    # Load Imagenet Synsets
    imagenet_classes = load_imagenet_classes()
    print('Imagenet has {} classes'.format(imagenet_classes))

    max, argmax = output.data.squeeze().max(0)
    class_id = argmax[0]
    print('Image {} is of class "{}"'.format(img_name, imagenet_classes[class_id]))

    #############################################################################

    print('Save normalized input as RGB image')

    dir_activations = os.path.join(dir_outputs,'activations')
    os.system('mkdir -p ' + dir_activations)

    path_img_input = os.path.join(dir_activations, 'input.png')
    print('save input activation to ' + path_img_input)
    transforms.ToPILImage()(input_data[0]).save(path_img_input) # save image using PIL

    print('')

    #############################################################################

    print('Save activations as Gray images')

    layer_id = 0

    def save_activation(self, input, output):
        global layer_id

        for i in range(10):#output.data.size(1)):
            path_img_output = os.path.join(dir_activations, 'layer{}_{}_channel{}.png'.format(layer_id, self.__class__.__name__, i))
            print('save output activation to ' + path_img_output)
            torchvision.utils.save_image(output.data.squeeze(0)[i], path_img_output) # save image (of type Tensor) using torchvision

        layer_id += 1

    handles = []
    for m in model.features:
        handles.append(m.register_forward_hook(save_activation))

    input = Variable(input_data, requires_grad=False)
    output = model(input)

    for h in handles:
        h.remove()

    print('')

    #############################################################################

    dir_parameters = os.path.join(dir_outputs, 'parameters')
    os.system('mkdir -p ' + dir_parameters)
    state_dict = model.state_dict()

    print('Save first layer parameters as RGB images')

    weight = state_dict['features.0.weight']
    for filter_id in range(weight.size(0)):
        path_param = os.path.join(dir_parameters, 'features.0.weight_filter{}.png'.format(filter_id))
        print('save ' + path_param)
        torchvision.utils.save_image(weight[filter_id], path_param)

    print('')


    print('Save other layer parameters as Gray images')

    for key in state_dict:
        if 'features' in key and 'weight' in key:
            for filter_id in range(3):
                for channel_id in range(3):
                    path_param = os.path.join(dir_parameters, '{}_filter{}_channel{}.png'.format(key, filter_id, channel_id))
                    print('save ' + path_param)
                    torchvision.utils.save_image(state_dict[key][filter_id][channel_id], path_param)

    print('')



================================================
FILE: examples/voc2007_extract.py
================================================
from __future__ import print_function, division, absolute_import
import os
import argparse
from tqdm import tqdm

import torch
from torch.autograd import Variable
from torch.utils import model_zoo

# http://scikit-learn.org
from sklearn.metrics import accuracy_score
from sklearn.metrics import average_precision_score
from sklearn.svm import LinearSVC
from sklearn.svm import SVC

import sys
sys.path.append('.')
import pretrainedmodels
import pretrainedmodels.utils
import pretrainedmodels.datasets

model_names = sorted(name for name in pretrainedmodels.__dict__
    if not name.startswith("__")
    and name.islower()
    and callable(pretrainedmodels.__dict__[name]))

def extract_features_targets(model, features_size, loader, path_data, cuda=False):
    if os.path.isfile(path_data):
        print('Load features from {}'.format(path_data))
        return torch.load(path_data)

    print('\nExtract features on {}set'.format(loader.dataset.set))

    features = torch.Tensor(len(loader.dataset), features_size)
    targets = torch.Tensor(len(loader.dataset), len(loader.dataset.classes))

    for batch_id, batch in enumerate(tqdm(loader)):
        img = batch[0]
        target = batch[2]
        current_bsize = img.size(0)
        from_ = int(batch_id * loader.batch_size)
        to_ = int(from_ + current_bsize)

        if cuda:
            img = img.cuda(async=True)

        input = Variable(img, requires_grad=False)
        output = model(input)

        features[from_:to_] = output.data.cpu()
        targets[from_:to_] = target

    os.system('mkdir -p {}'.format(os.path.dirname(path_data)))
    print('save ' + path_data)
    torch.save((features, targets), path_data)
    print('')
    return features, targets

def train_multilabel(features, targets, classes, train_split, test_split, C=1.0, ignore_hard_examples=True, after_ReLU=False, normalize_L2=False):
    print('\nHyperparameters:\n - C: {}\n - after_ReLU: {}\n - normL2: {}'.format(C, after_ReLU, normalize_L2))
    train_APs = []
    test_APs = []
    for class_id in range(len(classes)):

        classifier = SVC(C=C, kernel='linear') # http://scikit-learn.org/stable/modules/generated/sklearn.svm.SVC.html

        if ignore_hard_examples:
            train_masks = (targets[train_split][:,class_id] != 0).view(-1, 1)
            train_features = torch.masked_select(features[train_split], train_masks.expand_as(features[train_split])).view(-1,features[train_split].size(1))
            train_targets = torch.masked_select(targets[train_split], train_masks.expand_as(targets[train_split])).view(-1,targets[train_split].size(1))
            test_masks = (targets[test_split][:,class_id] != 0).view(-1, 1)
            test_features = torch.masked_select(features[test_split], test_masks.expand_as(features[test_split])).view(-1,features[test_split].size(1))
            test_targets = torch.masked_select(targets[test_split], test_masks.expand_as(targets[test_split])).view(-1,targets[test_split].size(1))
        else:
            train_features = features[train_split]
            train_targets = targets[train_split]
            test_features = features[test_split]
            test_targets = features[test_split]

        if after_ReLU:
            train_features[train_features < 0] = 0
            test_features[test_features < 0] = 0

        if normalize_L2:
            train_norm = torch.norm(train_features, p=2, dim=1).unsqueeze(1)
            train_features = train_features.div(train_norm.expand_as(train_features))
            test_norm = torch.norm(test_features, p=2, dim=1).unsqueeze(1)
            test_features = test_features.div(test_norm.expand_as(test_features))

        train_X = train_features.numpy()
        train_y = (train_targets[:,class_id] != -1).numpy() # uses hard examples if not ignored

        test_X = test_features.numpy()
        test_y = (test_targets[:,class_id] != -1).numpy()

        classifier.fit(train_X, train_y) # train parameters of the classifier

        train_preds = classifier.predict(train_X)
        train_acc = accuracy_score(train_y, train_preds) * 100
        train_AP = average_precision_score(train_y, train_preds) * 100
        train_APs.append(train_AP)

        test_preds = classifier.predict(test_X)
        test_acc = accuracy_score(test_y, test_preds) * 100
        test_AP = average_precision_score(test_y, test_preds) * 100
        test_APs.append(test_AP)

        print('class "{}" ({}/{}):'.format(classes[class_id], test_y.sum(), test_y.shape[0]))
        print('  - {:8}: acc {:.2f}, AP {:.2f}'.format(train_split, train_acc, train_AP))
        print('  - {:8}: acc {:.2f}, AP {:.2f}'.format(test_split, test_acc, test_AP))

    print('all classes:')
    print('  - {:8}: mAP {:.4f}'.format(train_split, sum(train_APs)/len(classes)))
    print('  - {:8}: mAP {:.4f}'.format(test_split, sum(test_APs)/len(classes)))

##########################################################################
# main
##########################################################################

parser = argparse.ArgumentParser(
    description='Train/Evaluate models',
    formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('--dir_outputs', default='/tmp/outputs', type=str, help='')
parser.add_argument('--dir_datasets', default='/tmp/datasets', type=str, help='')
parser.add_argument('--C', default=1, type=float, help='')
parser.add_argument('-b', '--batch_size', default=50, type=float, help='')
parser.add_argument('-a', '--arch', default='alexnet', choices=model_names,
                    help='model architecture: ' +
                        ' | '.join(model_names) +
                        ' (default: alexnet)')
parser.add_argument('--train_split', default='train', type=str, help='')
parser.add_argument('--test_split', default='val', type=str, help='')
parser.add_argument('--cuda', const=True, nargs='?', type=bool, help='')

def main ():
    global args
    args = parser.parse_args()
    print('\nCUDA status: {}'.format(args.cuda))

    print('\nLoad pretrained model on Imagenet')
    model = pretrainedmodels.__dict__[args.arch](num_classes=1000, pretrained='imagenet')
    model.eval()
    if args.cuda:
        model.cuda()

    features_size = model.last_linear.in_features
    model.last_linear = pretrainedmodels.utils.Identity() # Trick to get inputs (features) from last_linear

    print('\nLoad datasets')
    tf_img = pretrainedmodels.utils.TransformImage(model)
    train_set = pretrainedmodels.datasets.Voc2007Classification(args.dir_datasets, 'train', transform=tf_img)
    val_set = pretrainedmodels.datasets.Voc2007Classification(args.dir_datasets, 'val', transform=tf_img)
    test_set = pretrainedmodels.datasets.Voc2007Classification(args.dir_datasets, 'test', transform=tf_img)

    train_loader = torch.utils.data.DataLoader(train_set, batch_size=args.batch_size, shuffle=False, num_workers=2)
    val_loader = torch.utils.data.DataLoader(val_set, batch_size=args.batch_size, shuffle=False, num_workers=2)
    test_loader = torch.utils.data.DataLoader(test_set, batch_size=args.batch_size, shuffle=False, num_workers=2)

    print('\nLoad features')
    dir_features = os.path.join(args.dir_outputs, 'data/{}'.format(args.arch))
    path_train_data = '{}/{}set.pth'.format(dir_features, 'train')
    path_val_data = '{}/{}set.pth'.format(dir_features, 'val')
    path_test_data = '{}/{}set.pth'.format(dir_features, 'test')

    features = {}
    targets = {}
    features['train'], targets['train'] = extract_features_targets(model, features_size, train_loader, path_train_data, args.cuda)
    features['val'], targets['val'] = extract_features_targets(model, features_size, val_loader, path_val_data, args.cuda)
    features['test'], targets['test'] = extract_features_targets(model, features_size, test_loader, path_test_data, args.cuda)
    features['trainval'] = torch.cat([features['train'], features['val']], 0)
    targets['trainval'] = torch.cat([targets['train'], targets['val']], 0)

    print('\nTrain Support Vector Machines')
    if args.train_split == 'train' and args.test_split == 'val':
        print('\nHyperparameters search: train multilabel classifiers (on-versus-all) on train/val')
    elif args.train_split == 'trainval' and args.test_split == 'test':
        print('\nEvaluation: train a multilabel classifier on trainval/test')
    else:
        raise ValueError('Trying to train on {} and eval on {}'.format(args.train_split, args.test_split))

    train_multilabel(features, targets, train_set.classes, args.train_split, args.test_split, C=args.C)


if __name__ == '__main__':
    main()

================================================
FILE: pretrainedmodels/__init__.py
================================================
from .version import __version__

from . import models
from . import datasets

from .models.utils import pretrained_settings
from .models.utils import model_names

# to support pretrainedmodels.__dict__['nasnetalarge']
# but depreciated
from .models.fbresnet import fbresnet152
from .models.cafferesnet import cafferesnet101
from .models.bninception import bninception
from .models.resnext import resnext101_32x4d
from .models.resnext import resnext101_64x4d
from .models.inceptionv4 import inceptionv4
from .models.inceptionresnetv2 import inceptionresnetv2
from .models.nasnet import nasnetalarge
from .models.nasnet_mobile import nasnetamobile
from .models.torchvision_models import alexnet
from .models.torchvision_models import densenet121
from .models.torchvision_models import densenet169
from .models.torchvision_models import densenet201
from .models.torchvision_models import densenet161
from .models.torchvision_models import resnet18
from .models.torchvision_models import resnet34
from .models.torchvision_models import resnet50
from .models.torchvision_models import resnet101
from .models.torchvision_models import resnet152
from .models.torchvision_models import inceptionv3
from .models.torchvision_models import squeezenet1_0
from .models.torchvision_models import squeezenet1_1
from .models.torchvision_models import vgg11
from .models.torchvision_models import vgg11_bn
from .models.torchvision_models import vgg13
from .models.torchvision_models import vgg13_bn
from .models.torchvision_models import vgg16
from .models.torchvision_models import vgg16_bn
from .models.torchvision_models import vgg19_bn
from .models.torchvision_models import vgg19
from .models.dpn import dpn68
from .models.dpn import dpn68b
from .models.dpn import dpn92
from .models.dpn import dpn98
from .models.dpn import dpn131
from .models.dpn import dpn107
from .models.xception import xception
from .models.senet import senet154
from .models.senet import se_resnet50
from .models.senet import se_resnet101
from .models.senet import se_resnet152
from .models.senet import se_resnext50_32x4d
from .models.senet import se_resnext101_32x4d
from .models.pnasnet import pnasnet5large
from .models.polynet import polynet


================================================
FILE: pretrainedmodels/datasets/__init__.py
================================================
from __future__ import print_function, division, absolute_import
from .voc import Voc2007Classification

================================================
FILE: pretrainedmodels/datasets/utils.py
================================================
from __future__ import print_function, division, absolute_import
import math
from six.moves.urllib.request import urlretrieve

import torch
from PIL import Image
from tqdm import tqdm

def load_imagenet_classes(path_synsets='data/imagenet_synsets.txt',
                          path_classes='data/imagenet_classes.txt'):
    with open(path_synsets, 'r') as f:
        synsets = f.readlines()

    synsets = [x.strip() for x in synsets]
    splits = [line.split(' ') for line in synsets]
    key_to_classname = {spl[0]:' '.join(spl[1:]) for spl in splits}

    with open(path_classes, 'r') as f:
        class_id_to_key = f.readlines()

    class_id_to_key = [x.strip() for x in class_id_to_key]

    cid_to_cname = []
    for i in range(len(class_id_to_key)):
        key = class_id_to_key[i]
        cname = key_to_classname[key]
        cid_to_cname.append(cname)

    return cid_to_cname


class Warp(object):
    def __init__(self, size, interpolation=Image.BILINEAR):
        self.size = int(size)
        self.interpolation = interpolation

    def __call__(self, img):
        return img.resize((self.size, self.size), self.interpolation)

    def __str__(self):
        return self.__class__.__name__ + ' (size={size}, interpolation={interpolation})'.format(size=self.size,
                                                                                                interpolation=self.interpolation)


def download_url(url, destination=None, progress_bar=True):
    """Download a URL to a local file.

    Parameters
    ----------
    url : str
        The URL to download.
    destination : str, None
        The destination of the file. If None is given the file is saved to a temporary directory.
    progress_bar : bool
        Whether to show a command-line progress bar while downloading.

    Returns
    -------
    filename : str
        The location of the downloaded file.

    Notes
    -----
    Progress bar use/example adapted from tqdm documentation: https://github.com/tqdm/tqdm
    """

    def my_hook(t):
        last_b = [0]

        def inner(b=1, bsize=1, tsize=None):
            if tsize is not None:
                t.total = tsize
            if b > 0:
                t.update((b - last_b[0]) * bsize)
            last_b[0] = b

        return inner

    if progress_bar:
        with tqdm(unit='B', unit_scale=True, miniters=1, desc=url.split('/')[-1]) as t:
            filename, _ = urlretrieve(url, filename=destination, reporthook=my_hook(t))
    else:
        filename, _ = urlretrieve(url, filename=destination)


class AveragePrecisionMeter(object):
    """
    The APMeter measures the average precision per class.
    The APMeter is designed to operate on `NxK` Tensors `output` and
    `target`, and optionally a `Nx1` Tensor weight where (1) the `output`
    contains model output scores for `N` examples and `K` classes that ought to
    be higher when the model is more convinced that the example should be
    positively labeled, and smaller when the model believes the example should
    be negatively labeled (for instance, the output of a sigmoid function); (2)
    the `target` contains only values 0 (for negative examples) and 1
    (for positive examples); and (3) the `weight` ( > 0) represents weight for
    each sample.
    """

    def __init__(self, difficult_examples=False):
        super(AveragePrecisionMeter, self).__init__()
        self.reset()
        self.difficult_examples = difficult_examples

    def reset(self):
        """Resets the meter with empty member variables"""
        self.scores = torch.FloatTensor(torch.FloatStorage())
        self.targets = torch.LongTensor(torch.LongStorage())

    def add(self, output, target):
        """
        Args:
            output (Tensor): NxK tensor that for each of the N examples
                indicates the probability of the example belonging to each of
                the K classes, according to the model. The probabilities should
                sum to one over all classes
            target (Tensor): binary NxK tensort that encodes which of the K
                classes are associated with the N-th input
                    (eg: a row [0, 1, 0, 1] indicates that the example is
                         associated with classes 2 and 4)
            weight (optional, Tensor): Nx1 tensor representing the weight for
                each example (each weight > 0)
        """
        if not torch.is_tensor(output):
            output = torch.from_numpy(output)
        if not torch.is_tensor(target):
            target = torch.from_numpy(target)

        if output.dim() == 1:
            output = output.view(-1, 1)
        else:
            assert output.dim() == 2, \
                'wrong output size (should be 1D or 2D with one column \
                per class)'
        if target.dim() == 1:
            target = target.view(-1, 1)
        else:
            assert target.dim() == 2, \
                'wrong target size (should be 1D or 2D with one column \
                per class)'
        if self.scores.numel() > 0:
            assert target.size(1) == self.targets.size(1), \
                'dimensions for output should match previously added examples.'

        # make sure storage is of sufficient size
        if self.scores.storage().size() < self.scores.numel() + output.numel():
            new_size = math.ceil(self.scores.storage().size() * 1.5)
            self.scores.storage().resize_(int(new_size + output.numel()))
            self.targets.storage().resize_(int(new_size + output.numel()))

        # store scores and targets
        offset = self.scores.size(0) if self.scores.dim() > 0 else 0
        self.scores.resize_(offset + output.size(0), output.size(1))
        self.targets.resize_(offset + target.size(0), target.size(1))
        self.scores.narrow(0, offset, output.size(0)).copy_(output)
        self.targets.narrow(0, offset, target.size(0)).copy_(target)

    def value(self):
        """Returns the model's average precision for each class
        Return:
            ap (FloatTensor): 1xK tensor, with avg precision for each class k
        """

        if self.scores.numel() == 0:
            return 0
        ap = torch.zeros(self.scores.size(1))
        rg = torch.arange(1, self.scores.size(0)).float()

        # compute average precision for each class
        for k in range(self.scores.size(1)):
            # sort scores
            scores = self.scores[:, k]
            targets = self.targets[:, k]

            # compute average precision
            ap[k] = AveragePrecisionMeter.average_precision(scores, targets, self.difficult_examples)
        return ap

    @staticmethod
    def average_precision(output, target, difficult_examples=True):

        # sort examples
        sorted, indices = torch.sort(output, dim=0, descending=True)

        # Computes prec@i
        pos_count = 0.
        total_count = 0.
        precision_at_i = 0.
        for i in indices:
            label = target[i]
            if difficult_examples and label == 0:
                continue
            if label == 1:
                pos_count += 1
            total_count += 1
            if label == 1:
                precision_at_i += pos_count / total_count
        precision_at_i /= pos_count
        return precision_at_i

================================================
FILE: pretrainedmodels/datasets/voc.py
================================================
from __future__ import print_function, division, absolute_import
import csv
import os
import os.path
import tarfile
from six.moves.urllib.parse import urlparse

import numpy as np
import torch
import torch.utils.data as data
from PIL import Image

from . import utils

object_categories = ['aeroplane', 'bicycle', 'bird', 'boat',
                     'bottle', 'bus', 'car', 'cat', 'chair',
                     'cow', 'diningtable', 'dog', 'horse',
                     'motorbike', 'person', 'pottedplant',
                     'sheep', 'sofa', 'train', 'tvmonitor']

urls = {
    'devkit': 'http://host.robots.ox.ac.uk/pascal/VOC/voc2012/VOCdevkit_18-May-2011.tar',
    'trainval_2007': 'http://host.robots.ox.ac.uk/pascal/VOC/voc2007/VOCtrainval_06-Nov-2007.tar',
    'test_images_2007': 'http://host.robots.ox.ac.uk/pascal/VOC/voc2007/VOCtest_06-Nov-2007.tar',
    'test_anno_2007': 'http://host.robots.ox.ac.uk/pascal/VOC/voc2007/VOCtestnoimgs_06-Nov-2007.tar',
}


def read_image_label(file):
    print('[dataset] read ' + file)
    data = dict()
    with open(file, 'r') as f:
        for line in f:
            tmp = line.split(' ')
            name = tmp[0]
            label = int(tmp[-1])
            data[name] = label
            # data.append([name, label])
            # print('%s  %d' % (name, label))
    return data


def read_object_labels(root, dataset, set):
    path_labels = os.path.join(root, 'VOCdevkit', dataset, 'ImageSets', 'Main')
    labeled_data = dict()
    num_classes = len(object_categories)

    for i in range(num_classes):
        file = os.path.join(path_labels, object_categories[i] + '_' + set + '.txt')
        data = read_image_label(file)

        if i == 0:
            for (name, label) in data.items():
                labels = np.zeros(num_classes)
                labels[i] = label
                labeled_data[name] = labels
        else:
            for (name, label) in data.items():
                labeled_data[name][i] = label

    return labeled_data


def write_object_labels_csv(file, labeled_data):
    # write a csv file
    print('[dataset] write file %s' % file)
    with open(file, 'w') as csvfile:
        fieldnames = ['name']
        fieldnames.extend(object_categories)
        writer = csv.DictWriter(csvfile, fieldnames=fieldnames)

        writer.writeheader()
        for (name, labels) in labeled_data.items():
            example = {'name': name}
            for i in range(20):
                example[fieldnames[i + 1]] = int(labels[i])
            writer.writerow(example)

    csvfile.close()


def read_object_labels_csv(file, header=True):
    images = []
    num_categories = 0
    print('[dataset] read', file)
    with open(file, 'r') as f:
        reader = csv.reader(f)
        rownum = 0
        for row in reader:
            if header and rownum == 0:
                header = row
            else:
                if num_categories == 0:
                    num_categories = len(row) - 1
                name = row[0]
                labels = (np.asarray(row[1:num_categories + 1])).astype(np.float32)
                labels = torch.from_numpy(labels)
                item = (name, labels)
                images.append(item)
            rownum += 1
    return images


def find_images_classification(root, dataset, set):
    path_labels = os.path.join(root, 'VOCdevkit', dataset, 'ImageSets', 'Main')
    images = []
    file = os.path.join(path_labels, set + '.txt')
    with open(file, 'r') as f:
        for line in f:
            images.append(line)
    return images


def download_voc2007(root):
    path_devkit = os.path.join(root, 'VOCdevkit')
    path_images = os.path.join(root, 'VOCdevkit', 'VOC2007', 'JPEGImages')
    tmpdir = os.path.join(root, 'tmp')

    # create directory
    if not os.path.exists(root):
        os.makedirs(root)

    if not os.path.exists(path_devkit):

        if not os.path.exists(tmpdir):
            os.makedirs(tmpdir)

        parts = urlparse(urls['devkit'])
        filename = os.path.basename(parts.path)
        cached_file = os.path.join(tmpdir, filename)

        if not os.path.exists(cached_file):
            print('Downloading: "{}" to {}\n'.format(urls['devkit'], cached_file))
            utils.download_url(urls['devkit'], cached_file)

        # extract file
        print('[dataset] Extracting tar file {file} to {path}'.format(file=cached_file, path=root))
        cwd = os.getcwd()
        tar = tarfile.open(cached_file, "r")
        os.chdir(root)
        tar.extractall()
        tar.close()
        os.chdir(cwd)
        print('[dataset] Done!')

    # train/val images/annotations
    if not os.path.exists(path_images):

        # download train/val images/annotations
        parts = urlparse(urls['trainval_2007'])
        filename = os.path.basename(parts.path)
        cached_file = os.path.join(tmpdir, filename)

        if not os.path.exists(cached_file):
            print('Downloading: "{}" to {}\n'.format(urls['trainval_2007'], cached_file))
            utils.download_url(urls['trainval_2007'], cached_file)

        # extract file
        print('[dataset] Extracting tar file {file} to {path}'.format(file=cached_file, path=root))
        cwd = os.getcwd()
        tar = tarfile.open(cached_file, "r")
        os.chdir(root)
        tar.extractall()
        tar.close()
        os.chdir(cwd)
        print('[dataset] Done!')

    # test annotations
    test_anno = os.path.join(path_devkit, 'VOC2007/ImageSets/Main/aeroplane_test.txt')
    if not os.path.exists(test_anno):

        # download test annotations
        parts = urlparse(urls['test_images_2007'])
        filename = os.path.basename(parts.path)
        cached_file = os.path.join(tmpdir, filename)

        if not os.path.exists(cached_file):
            print('Downloading: "{}" to {}\n'.format(urls['test_images_2007'], cached_file))
            utils.download_url(urls['test_images_2007'], cached_file)

        # extract file
        print('[dataset] Extracting tar file {file} to {path}'.format(file=cached_file, path=root))
        cwd = os.getcwd()
        tar = tarfile.open(cached_file, "r")
        os.chdir(root)
        tar.extractall()
        tar.close()
        os.chdir(cwd)
        print('[dataset] Done!')

    # test images
    test_image = os.path.join(path_devkit, 'VOC2007/JPEGImages/000001.jpg')
    if not os.path.exists(test_image):

        # download test images
        parts = urlparse(urls['test_anno_2007'])
        filename = os.path.basename(parts.path)
        cached_file = os.path.join(tmpdir, filename)

        if not os.path.exists(cached_file):
            print('Downloading: "{}" to {}\n'.format(urls['test_anno_2007'], cached_file))
            utils.download_url(urls['test_anno_2007'], cached_file)

        # extract file
        print('[dataset] Extracting tar file {file} to {path}'.format(file=cached_file, path=root))
        cwd = os.getcwd()
        tar = tarfile.open(cached_file, "r")
        os.chdir(root)
        tar.extractall()
        tar.close()
        os.chdir(cwd)
        print('[dataset] Done!')


class Voc2007Classification(data.Dataset):

    def __init__(self, root, set, transform=None, target_transform=None):
        self.root = root
        self.path_devkit = os.path.join(root, 'VOCdevkit')
        self.path_images = os.path.join(root, 'VOCdevkit', 'VOC2007', 'JPEGImages')
        self.set = set
        self.transform = transform
        self.target_transform = target_transform

        # download dataset
        download_voc2007(self.root)

        # define path of csv file
        path_csv = os.path.join(self.root, 'files', 'VOC2007')
        # define filename of csv file
        file_csv = os.path.join(path_csv, 'classification_' + set + '.csv')

        # create the csv file if necessary
        if not os.path.exists(file_csv):
            if not os.path.exists(path_csv):  # create dir if necessary
                os.makedirs(path_csv)
            # generate csv file
            labeled_data = read_object_labels(self.root, 'VOC2007', self.set)
            # write csv file
            write_object_labels_csv(file_csv, labeled_data)

        self.classes = object_categories
        self.images = read_object_labels_csv(file_csv)

        print('[dataset] VOC 2007 classification set=%s number of classes=%d  number of images=%d' % (
            set, len(self.classes), len(self.images)))

    def __getitem__(self, index):
        path, target = self.images[index]
        img = Image.open(os.path.join(self.path_images, path + '.jpg')).convert('RGB')
        if self.transform is not None:
            img = self.transform(img)
        if self.target_transform is not None:
            target = self.target_transform(target)
        return img, path, target

    def __len__(self):
        return len(self.images)

    def get_number_classes(self):
        return len(self.classes)


================================================
FILE: pretrainedmodels/models/__init__.py
================================================
from __future__ import print_function, division, absolute_import
from .fbresnet import fbresnet152

from .cafferesnet import cafferesnet101

from .bninception import bninception

from .resnext import resnext101_32x4d
from .resnext import resnext101_64x4d

from .inceptionv4 import inceptionv4

from .inceptionresnetv2 import inceptionresnetv2

from .nasnet import nasnetalarge

from .nasnet_mobile import nasnetamobile

from .torchvision_models import alexnet
from .torchvision_models import densenet121
from .torchvision_models import densenet169
from .torchvision_models import densenet201
from .torchvision_models import densenet161
from .torchvision_models import resnet18
from .torchvision_models import resnet34
from .torchvision_models import resnet50
from .torchvision_models import resnet101
from .torchvision_models import resnet152
from .torchvision_models import inceptionv3
from .torchvision_models import squeezenet1_0
from .torchvision_models import squeezenet1_1
from .torchvision_models import vgg11
from .torchvision_models import vgg11_bn
from .torchvision_models import vgg13
from .torchvision_models import vgg13_bn
from .torchvision_models import vgg16
from .torchvision_models import vgg16_bn
from .torchvision_models import vgg19_bn
from .torchvision_models import vgg19

from .dpn import dpn68
from .dpn import dpn68b
from .dpn import dpn92
from .dpn import dpn98
from .dpn import dpn131
from .dpn import dpn107

from .xception import xception

from .senet import senet154
from .senet import se_resnet50
from .senet import se_resnet101
from .senet import se_resnet152
from .senet import se_resnext50_32x4d
from .senet import se_resnext101_32x4d

from .pnasnet import pnasnet5large
from .polynet import polynet


================================================
FILE: pretrainedmodels/models/bninception.py
================================================
from __future__ import print_function, division, absolute_import
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.model_zoo as model_zoo
import os
import sys

__all__ = ['BNInception', 'bninception']

pretrained_settings = {
    'bninception': {
        'imagenet': {
            # Was ported using python2 (may trigger warning)
            'url': 'http://data.lip6.fr/cadene/pretrainedmodels/bn_inception-52deb4733.pth',
            # 'url': 'http://yjxiong.me/others/bn_inception-9f5701afb96c8044.pth',
            'input_space': 'BGR',
            'input_size': [3, 224, 224],
            'input_range': [0, 255],
            'mean': [104, 117, 128],
            'std': [1, 1, 1],
            'num_classes': 1000
        }
    }
}

class BNInception(nn.Module):

    def __init__(self, num_classes=1000):
        super(BNInception, self).__init__()
        inplace = True
        self.conv1_7x7_s2 = nn.Conv2d(3, 64, kernel_size=(7, 7), stride=(2, 2), padding=(3, 3))
        self.conv1_7x7_s2_bn = nn.BatchNorm2d(64, affine=True)
        self.conv1_relu_7x7 = nn.ReLU (inplace)
        self.pool1_3x3_s2 = nn.MaxPool2d ((3, 3), stride=(2, 2), dilation=(1, 1), ceil_mode=True)
        self.conv2_3x3_reduce = nn.Conv2d(64, 64, kernel_size=(1, 1), stride=(1, 1))
        self.conv2_3x3_reduce_bn = nn.BatchNorm2d(64, affine=True)
        self.conv2_relu_3x3_reduce = nn.ReLU (inplace)
        self.conv2_3x3 = nn.Conv2d(64, 192, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
        self.conv2_3x3_bn = nn.BatchNorm2d(192, affine=True)
        self.conv2_relu_3x3 = nn.ReLU (inplace)
        self.pool2_3x3_s2 = nn.MaxPool2d ((3, 3), stride=(2, 2), dilation=(1, 1), ceil_mode=True)
        self.inception_3a_1x1 = nn.Conv2d(192, 64, kernel_size=(1, 1), stride=(1, 1))
        self.inception_3a_1x1_bn = nn.BatchNorm2d(64, affine=True)
        self.inception_3a_relu_1x1 = nn.ReLU (inplace)
        self.inception_3a_3x3_reduce = nn.Conv2d(192, 64, kernel_size=(1, 1), stride=(1, 1))
        self.inception_3a_3x3_reduce_bn = nn.BatchNorm2d(64, affine=True)
        self.inception_3a_relu_3x3_reduce = nn.ReLU (inplace)
        self.inception_3a_3x3 = nn.Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
        self.inception_3a_3x3_bn = nn.BatchNorm2d(64, affine=True)
        self.inception_3a_relu_3x3 = nn.ReLU (inplace)
        self.inception_3a_double_3x3_reduce = nn.Conv2d(192, 64, kernel_size=(1, 1), stride=(1, 1))
        self.inception_3a_double_3x3_reduce_bn = nn.BatchNorm2d(64, affine=True)
        self.inception_3a_relu_double_3x3_reduce = nn.ReLU (inplace)
        self.inception_3a_double_3x3_1 = nn.Conv2d(64, 96, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
        self.inception_3a_double_3x3_1_bn = nn.BatchNorm2d(96, affine=True)
        self.inception_3a_relu_double_3x3_1 = nn.ReLU (inplace)
        self.inception_3a_double_3x3_2 = nn.Conv2d(96, 96, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
        self.inception_3a_double_3x3_2_bn = nn.BatchNorm2d(96, affine=True)
        self.inception_3a_relu_double_3x3_2 = nn.ReLU (inplace)
        self.inception_3a_pool = nn.AvgPool2d (3, stride=1, padding=1, ceil_mode=True, count_include_pad=True)
        self.inception_3a_pool_proj = nn.Conv2d(192, 32, kernel_size=(1, 1), stride=(1, 1))
        self.inception_3a_pool_proj_bn = nn.BatchNorm2d(32, affine=True)
        self.inception_3a_relu_pool_proj = nn.ReLU (inplace)
        self.inception_3b_1x1 = nn.Conv2d(256, 64, kernel_size=(1, 1), stride=(1, 1))
        self.inception_3b_1x1_bn = nn.BatchNorm2d(64, affine=True)
        self.inception_3b_relu_1x1 = nn.ReLU (inplace)
        self.inception_3b_3x3_reduce = nn.Conv2d(256, 64, kernel_size=(1, 1), stride=(1, 1))
        self.inception_3b_3x3_reduce_bn = nn.BatchNorm2d(64, affine=True)
        self.inception_3b_relu_3x3_reduce = nn.ReLU (inplace)
        self.inception_3b_3x3 = nn.Conv2d(64, 96, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
        self.inception_3b_3x3_bn = nn.BatchNorm2d(96, affine=True)
        self.inception_3b_relu_3x3 = nn.ReLU (inplace)
        self.inception_3b_double_3x3_reduce = nn.Conv2d(256, 64, kernel_size=(1, 1), stride=(1, 1))
        self.inception_3b_double_3x3_reduce_bn = nn.BatchNorm2d(64, affine=True)
        self.inception_3b_relu_double_3x3_reduce = nn.ReLU (inplace)
        self.inception_3b_double_3x3_1 = nn.Conv2d(64, 96, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
        self.inception_3b_double_3x3_1_bn = nn.BatchNorm2d(96, affine=True)
        self.inception_3b_relu_double_3x3_1 = nn.ReLU (inplace)
        self.inception_3b_double_3x3_2 = nn.Conv2d(96, 96, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
        self.inception_3b_double_3x3_2_bn = nn.BatchNorm2d(96, affine=True)
        self.inception_3b_relu_double_3x3_2 = nn.ReLU (inplace)
        self.inception_3b_pool = nn.AvgPool2d (3, stride=1, padding=1, ceil_mode=True, count_include_pad=True)
        self.inception_3b_pool_proj = nn.Conv2d(256, 64, kernel_size=(1, 1), stride=(1, 1))
        self.inception_3b_pool_proj_bn = nn.BatchNorm2d(64, affine=True)
        self.inception_3b_relu_pool_proj = nn.ReLU (inplace)
        self.inception_3c_3x3_reduce = nn.Conv2d(320, 128, kernel_size=(1, 1), stride=(1, 1))
        self.inception_3c_3x3_reduce_bn = nn.BatchNorm2d(128, affine=True)
        self.inception_3c_relu_3x3_reduce = nn.ReLU (inplace)
        self.inception_3c_3x3 = nn.Conv2d(128, 160, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1))
        self.inception_3c_3x3_bn = nn.BatchNorm2d(160, affine=True)
        self.inception_3c_relu_3x3 = nn.ReLU (inplace)
        self.inception_3c_double_3x3_reduce = nn.Conv2d(320, 64, kernel_size=(1, 1), stride=(1, 1))
        self.inception_3c_double_3x3_reduce_bn = nn.BatchNorm2d(64, affine=True)
        self.inception_3c_relu_double_3x3_reduce = nn.ReLU (inplace)
        self.inception_3c_double_3x3_1 = nn.Conv2d(64, 96, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
        self.inception_3c_double_3x3_1_bn = nn.BatchNorm2d(96, affine=True)
        self.inception_3c_relu_double_3x3_1 = nn.ReLU (inplace)
        self.inception_3c_double_3x3_2 = nn.Conv2d(96, 96, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1))
        self.inception_3c_double_3x3_2_bn = nn.BatchNorm2d(96, affine=True)
        self.inception_3c_relu_double_3x3_2 = nn.ReLU (inplace)
        self.inception_3c_pool = nn.MaxPool2d ((3, 3), stride=(2, 2), dilation=(1, 1), ceil_mode=True)
        self.inception_4a_1x1 = nn.Conv2d(576, 224, kernel_size=(1, 1), stride=(1, 1))
        self.inception_4a_1x1_bn = nn.BatchNorm2d(224, affine=True)
        self.inception_4a_relu_1x1 = nn.ReLU (inplace)
        self.inception_4a_3x3_reduce = nn.Conv2d(576, 64, kernel_size=(1, 1), stride=(1, 1))
        self.inception_4a_3x3_reduce_bn = nn.BatchNorm2d(64, affine=True)
        self.inception_4a_relu_3x3_reduce = nn.ReLU (inplace)
        self.inception_4a_3x3 = nn.Conv2d(64, 96, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
        self.inception_4a_3x3_bn = nn.BatchNorm2d(96, affine=True)
        self.inception_4a_relu_3x3 = nn.ReLU (inplace)
        self.inception_4a_double_3x3_reduce = nn.Conv2d(576, 96, kernel_size=(1, 1), stride=(1, 1))
        self.inception_4a_double_3x3_reduce_bn = nn.BatchNorm2d(96, affine=True)
        self.inception_4a_relu_double_3x3_reduce = nn.ReLU (inplace)
        self.inception_4a_double_3x3_1 = nn.Conv2d(96, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
        self.inception_4a_double_3x3_1_bn = nn.BatchNorm2d(128, affine=True)
        self.inception_4a_relu_double_3x3_1 = nn.ReLU (inplace)
        self.inception_4a_double_3x3_2 = nn.Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
        self.inception_4a_double_3x3_2_bn = nn.BatchNorm2d(128, affine=True)
        self.inception_4a_relu_double_3x3_2 = nn.ReLU (inplace)
        self.inception_4a_pool = nn.AvgPool2d (3, stride=1, padding=1, ceil_mode=True, count_include_pad=True)
        self.inception_4a_pool_proj = nn.Conv2d(576, 128, kernel_size=(1, 1), stride=(1, 1))
        self.inception_4a_pool_proj_bn = nn.BatchNorm2d(128, affine=True)
        self.inception_4a_relu_pool_proj = nn.ReLU (inplace)
        self.inception_4b_1x1 = nn.Conv2d(576, 192, kernel_size=(1, 1), stride=(1, 1))
        self.inception_4b_1x1_bn = nn.BatchNorm2d(192, affine=True)
        self.inception_4b_relu_1x1 = nn.ReLU (inplace)
        self.inception_4b_3x3_reduce = nn.Conv2d(576, 96, kernel_size=(1, 1), stride=(1, 1))
        self.inception_4b_3x3_reduce_bn = nn.BatchNorm2d(96, affine=True)
        self.inception_4b_relu_3x3_reduce = nn.ReLU (inplace)
        self.inception_4b_3x3 = nn.Conv2d(96, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
        self.inception_4b_3x3_bn = nn.BatchNorm2d(128, affine=True)
        self.inception_4b_relu_3x3 = nn.ReLU (inplace)
        self.inception_4b_double_3x3_reduce = nn.Conv2d(576, 96, kernel_size=(1, 1), stride=(1, 1))
        self.inception_4b_double_3x3_reduce_bn = nn.BatchNorm2d(96, affine=True)
        self.inception_4b_relu_double_3x3_reduce = nn.ReLU (inplace)
        self.inception_4b_double_3x3_1 = nn.Conv2d(96, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
        self.inception_4b_double_3x3_1_bn = nn.BatchNorm2d(128, affine=True)
        self.inception_4b_relu_double_3x3_1 = nn.ReLU (inplace)
        self.inception_4b_double_3x3_2 = nn.Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
        self.inception_4b_double_3x3_2_bn = nn.BatchNorm2d(128, affine=True)
        self.inception_4b_relu_double_3x3_2 = nn.ReLU (inplace)
        self.inception_4b_pool = nn.AvgPool2d (3, stride=1, padding=1, ceil_mode=True, count_include_pad=True)
        self.inception_4b_pool_proj = nn.Conv2d(576, 128, kernel_size=(1, 1), stride=(1, 1))
        self.inception_4b_pool_proj_bn = nn.BatchNorm2d(128, affine=True)
        self.inception_4b_relu_pool_proj = nn.ReLU (inplace)
        self.inception_4c_1x1 = nn.Conv2d(576, 160, kernel_size=(1, 1), stride=(1, 1))
        self.inception_4c_1x1_bn = nn.BatchNorm2d(160, affine=True)
        self.inception_4c_relu_1x1 = nn.ReLU (inplace)
        self.inception_4c_3x3_reduce = nn.Conv2d(576, 128, kernel_size=(1, 1), stride=(1, 1))
        self.inception_4c_3x3_reduce_bn = nn.BatchNorm2d(128, affine=True)
        self.inception_4c_relu_3x3_reduce = nn.ReLU (inplace)
        self.inception_4c_3x3 = nn.Conv2d(128, 160, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
        self.inception_4c_3x3_bn = nn.BatchNorm2d(160, affine=True)
        self.inception_4c_relu_3x3 = nn.ReLU (inplace)
        self.inception_4c_double_3x3_reduce = nn.Conv2d(576, 128, kernel_size=(1, 1), stride=(1, 1))
        self.inception_4c_double_3x3_reduce_bn = nn.BatchNorm2d(128, affine=True)
        self.inception_4c_relu_double_3x3_reduce = nn.ReLU (inplace)
        self.inception_4c_double_3x3_1 = nn.Conv2d(128, 160, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
        self.inception_4c_double_3x3_1_bn = nn.BatchNorm2d(160, affine=True)
        self.inception_4c_relu_double_3x3_1 = nn.ReLU (inplace)
        self.inception_4c_double_3x3_2 = nn.Conv2d(160, 160, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
        self.inception_4c_double_3x3_2_bn = nn.BatchNorm2d(160, affine=True)
        self.inception_4c_relu_double_3x3_2 = nn.ReLU (inplace)
        self.inception_4c_pool = nn.AvgPool2d (3, stride=1, padding=1, ceil_mode=True, count_include_pad=True)
        self.inception_4c_pool_proj = nn.Conv2d(576, 128, kernel_size=(1, 1), stride=(1, 1))
        self.inception_4c_pool_proj_bn = nn.BatchNorm2d(128, affine=True)
        self.inception_4c_relu_pool_proj = nn.ReLU (inplace)
        self.inception_4d_1x1 = nn.Conv2d(608, 96, kernel_size=(1, 1), stride=(1, 1))
        self.inception_4d_1x1_bn = nn.BatchNorm2d(96, affine=True)
        self.inception_4d_relu_1x1 = nn.ReLU (inplace)
        self.inception_4d_3x3_reduce = nn.Conv2d(608, 128, kernel_size=(1, 1), stride=(1, 1))
        self.inception_4d_3x3_reduce_bn = nn.BatchNorm2d(128, affine=True)
        self.inception_4d_relu_3x3_reduce = nn.ReLU (inplace)
        self.inception_4d_3x3 = nn.Conv2d(128, 192, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
        self.inception_4d_3x3_bn = nn.BatchNorm2d(192, affine=True)
        self.inception_4d_relu_3x3 = nn.ReLU (inplace)
        self.inception_4d_double_3x3_reduce = nn.Conv2d(608, 160, kernel_size=(1, 1), stride=(1, 1))
        self.inception_4d_double_3x3_reduce_bn = nn.BatchNorm2d(160, affine=True)
        self.inception_4d_relu_double_3x3_reduce = nn.ReLU (inplace)
        self.inception_4d_double_3x3_1 = nn.Conv2d(160, 192, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
        self.inception_4d_double_3x3_1_bn = nn.BatchNorm2d(192, affine=True)
        self.inception_4d_relu_double_3x3_1 = nn.ReLU (inplace)
        self.inception_4d_double_3x3_2 = nn.Conv2d(192, 192, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
        self.inception_4d_double_3x3_2_bn = nn.BatchNorm2d(192, affine=True)
        self.inception_4d_relu_double_3x3_2 = nn.ReLU (inplace)
        self.inception_4d_pool = nn.AvgPool2d (3, stride=1, padding=1, ceil_mode=True, count_include_pad=True)
        self.inception_4d_pool_proj = nn.Conv2d(608, 128, kernel_size=(1, 1), stride=(1, 1))
        self.inception_4d_pool_proj_bn = nn.BatchNorm2d(128, affine=True)
        self.inception_4d_relu_pool_proj = nn.ReLU (inplace)
        self.inception_4e_3x3_reduce = nn.Conv2d(608, 128, kernel_size=(1, 1), stride=(1, 1))
        self.inception_4e_3x3_reduce_bn = nn.BatchNorm2d(128, affine=True)
        self.inception_4e_relu_3x3_reduce = nn.ReLU (inplace)
        self.inception_4e_3x3 = nn.Conv2d(128, 192, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1))
        self.inception_4e_3x3_bn = nn.BatchNorm2d(192, affine=True)
        self.inception_4e_relu_3x3 = nn.ReLU (inplace)
        self.inception_4e_double_3x3_reduce = nn.Conv2d(608, 192, kernel_size=(1, 1), stride=(1, 1))
        self.inception_4e_double_3x3_reduce_bn = nn.BatchNorm2d(192, affine=True)
        self.inception_4e_relu_double_3x3_reduce = nn.ReLU (inplace)
        self.inception_4e_double_3x3_1 = nn.Conv2d(192, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
        self.inception_4e_double_3x3_1_bn = nn.BatchNorm2d(256, affine=True)
        self.inception_4e_relu_double_3x3_1 = nn.ReLU (inplace)
        self.inception_4e_double_3x3_2 = nn.Conv2d(256, 256, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1))
        self.inception_4e_double_3x3_2_bn = nn.BatchNorm2d(256, affine=True)
        self.inception_4e_relu_double_3x3_2 = nn.ReLU (inplace)
        self.inception_4e_pool = nn.MaxPool2d ((3, 3), stride=(2, 2), dilation=(1, 1), ceil_mode=True)
        self.inception_5a_1x1 = nn.Conv2d(1056, 352, kernel_size=(1, 1), stride=(1, 1))
        self.inception_5a_1x1_bn = nn.BatchNorm2d(352, affine=True)
        self.inception_5a_relu_1x1 = nn.ReLU (inplace)
        self.inception_5a_3x3_reduce = nn.Conv2d(1056, 192, kernel_size=(1, 1), stride=(1, 1))
        self.inception_5a_3x3_reduce_bn = nn.BatchNorm2d(192, affine=True)
        self.inception_5a_relu_3x3_reduce = nn.ReLU (inplace)
        self.inception_5a_3x3 = nn.Conv2d(192, 320, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
        self.inception_5a_3x3_bn = nn.BatchNorm2d(320, affine=True)
        self.inception_5a_relu_3x3 = nn.ReLU (inplace)
        self.inception_5a_double_3x3_reduce = nn.Conv2d(1056, 160, kernel_size=(1, 1), stride=(1, 1))
        self.inception_5a_double_3x3_reduce_bn = nn.BatchNorm2d(160, affine=True)
        self.inception_5a_relu_double_3x3_reduce = nn.ReLU (inplace)
        self.inception_5a_double_3x3_1 = nn.Conv2d(160, 224, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
        self.inception_5a_double_3x3_1_bn = nn.BatchNorm2d(224, affine=True)
        self.inception_5a_relu_double_3x3_1 = nn.ReLU (inplace)
        self.inception_5a_double_3x3_2 = nn.Conv2d(224, 224, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
        self.inception_5a_double_3x3_2_bn = nn.BatchNorm2d(224, affine=True)
        self.inception_5a_relu_double_3x3_2 = nn.ReLU (inplace)
        self.inception_5a_pool = nn.AvgPool2d (3, stride=1, padding=1, ceil_mode=True, count_include_pad=True)
        self.inception_5a_pool_proj = nn.Conv2d(1056, 128, kernel_size=(1, 1), stride=(1, 1))
        self.inception_5a_pool_proj_bn = nn.BatchNorm2d(128, affine=True)
        self.inception_5a_relu_pool_proj = nn.ReLU (inplace)
        self.inception_5b_1x1 = nn.Conv2d(1024, 352, kernel_size=(1, 1), stride=(1, 1))
        self.inception_5b_1x1_bn = nn.BatchNorm2d(352, affine=True)
        self.inception_5b_relu_1x1 = nn.ReLU (inplace)
        self.inception_5b_3x3_reduce = nn.Conv2d(1024, 192, kernel_size=(1, 1), stride=(1, 1))
        self.inception_5b_3x3_reduce_bn = nn.BatchNorm2d(192, affine=True)
        self.inception_5b_relu_3x3_reduce = nn.ReLU (inplace)
        self.inception_5b_3x3 = nn.Conv2d(192, 320, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
        self.inception_5b_3x3_bn = nn.BatchNorm2d(320, affine=True)
        self.inception_5b_relu_3x3 = nn.ReLU (inplace)
        self.inception_5b_double_3x3_reduce = nn.Conv2d(1024, 192, kernel_size=(1, 1), stride=(1, 1))
        self.inception_5b_double_3x3_reduce_bn = nn.BatchNorm2d(192, affine=True)
        self.inception_5b_relu_double_3x3_reduce = nn.ReLU (inplace)
        self.inception_5b_double_3x3_1 = nn.Conv2d(192, 224, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
        self.inception_5b_double_3x3_1_bn = nn.BatchNorm2d(224, affine=True)
        self.inception_5b_relu_double_3x3_1 = nn.ReLU (inplace)
        self.inception_5b_double_3x3_2 = nn.Conv2d(224, 224, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
        self.inception_5b_double_3x3_2_bn = nn.BatchNorm2d(224, affine=True)
        self.inception_5b_relu_double_3x3_2 = nn.ReLU (inplace)
        self.inception_5b_pool = nn.MaxPool2d ((3, 3), stride=(1, 1), padding=(1, 1), dilation=(1, 1), ceil_mode=True)
        self.inception_5b_pool_proj = nn.Conv2d(1024, 128, kernel_size=(1, 1), stride=(1, 1))
        self.inception_5b_pool_proj_bn = nn.BatchNorm2d(128, affine=True)
        self.inception_5b_relu_pool_proj = nn.ReLU (inplace)
        self.last_linear = nn.Linear (1024, num_classes)

    def features(self, input):
        conv1_7x7_s2_out = self.conv1_7x7_s2(input)
        conv1_7x7_s2_bn_out = self.conv1_7x7_s2_bn(conv1_7x7_s2_out)
        conv1_relu_7x7_out = self.conv1_relu_7x7(conv1_7x7_s2_bn_out)
        pool1_3x3_s2_out = self.pool1_3x3_s2(conv1_relu_7x7_out)
        conv2_3x3_reduce_out = self.conv2_3x3_reduce(pool1_3x3_s2_out)
        conv2_3x3_reduce_bn_out = self.conv2_3x3_reduce_bn(conv2_3x3_reduce_out)
        conv2_relu_3x3_reduce_out = self.conv2_relu_3x3_reduce(conv2_3x3_reduce_bn_out)
        conv2_3x3_out = self.conv2_3x3(conv2_relu_3x3_reduce_out)
        conv2_3x3_bn_out = self.conv2_3x3_bn(conv2_3x3_out)
        conv2_relu_3x3_out = self.conv2_relu_3x3(conv2_3x3_bn_out)
        pool2_3x3_s2_out = self.pool2_3x3_s2(conv2_relu_3x3_out)
        inception_3a_1x1_out = self.inception_3a_1x1(pool2_3x3_s2_out)
        inception_3a_1x1_bn_out = self.inception_3a_1x1_bn(inception_3a_1x1_out)
        inception_3a_relu_1x1_out = self.inception_3a_relu_1x1(inception_3a_1x1_bn_out)
        inception_3a_3x3_reduce_out = self.inception_3a_3x3_reduce(pool2_3x3_s2_out)
        inception_3a_3x3_reduce_bn_out = self.inception_3a_3x3_reduce_bn(inception_3a_3x3_reduce_out)
        inception_3a_relu_3x3_reduce_out = self.inception_3a_relu_3x3_reduce(inception_3a_3x3_reduce_bn_out)
        inception_3a_3x3_out = self.inception_3a_3x3(inception_3a_relu_3x3_reduce_out)
        inception_3a_3x3_bn_out = self.inception_3a_3x3_bn(inception_3a_3x3_out)
        inception_3a_relu_3x3_out = self.inception_3a_relu_3x3(inception_3a_3x3_bn_out)
        inception_3a_double_3x3_reduce_out = self.inception_3a_double_3x3_reduce(pool2_3x3_s2_out)
        inception_3a_double_3x3_reduce_bn_out = self.inception_3a_double_3x3_reduce_bn(inception_3a_double_3x3_reduce_out)
        inception_3a_relu_double_3x3_reduce_out = self.inception_3a_relu_double_3x3_reduce(inception_3a_double_3x3_reduce_bn_out)
        inception_3a_double_3x3_1_out = self.inception_3a_double_3x3_1(inception_3a_relu_double_3x3_reduce_out)
        inception_3a_double_3x3_1_bn_out = self.inception_3a_double_3x3_1_bn(inception_3a_double_3x3_1_out)
        inception_3a_relu_double_3x3_1_out = self.inception_3a_relu_double_3x3_1(inception_3a_double_3x3_1_bn_out)
        inception_3a_double_3x3_2_out = self.inception_3a_double_3x3_2(inception_3a_relu_double_3x3_1_out)
        inception_3a_double_3x3_2_bn_out = self.inception_3a_double_3x3_2_bn(inception_3a_double_3x3_2_out)
        inception_3a_relu_double_3x3_2_out = self.inception_3a_relu_double_3x3_2(inception_3a_double_3x3_2_bn_out)
        inception_3a_pool_out = self.inception_3a_pool(pool2_3x3_s2_out)
        inception_3a_pool_proj_out = self.inception_3a_pool_proj(inception_3a_pool_out)
        inception_3a_pool_proj_bn_out = self.inception_3a_pool_proj_bn(inception_3a_pool_proj_out)
        inception_3a_relu_pool_proj_out = self.inception_3a_relu_pool_proj(inception_3a_pool_proj_bn_out)
        inception_3a_output_out = torch.cat([inception_3a_relu_1x1_out,inception_3a_relu_3x3_out,inception_3a_relu_double_3x3_2_out ,inception_3a_relu_pool_proj_out], 1)
        inception_3b_1x1_out = self.inception_3b_1x1(inception_3a_output_out)
        inception_3b_1x1_bn_out = self.inception_3b_1x1_bn(inception_3b_1x1_out)
        inception_3b_relu_1x1_out = self.inception_3b_relu_1x1(inception_3b_1x1_bn_out)
        inception_3b_3x3_reduce_out = self.inception_3b_3x3_reduce(inception_3a_output_out)
        inception_3b_3x3_reduce_bn_out = self.inception_3b_3x3_reduce_bn(inception_3b_3x3_reduce_out)
        inception_3b_relu_3x3_reduce_out = self.inception_3b_relu_3x3_reduce(inception_3b_3x3_reduce_bn_out)
        inception_3b_3x3_out = self.inception_3b_3x3(inception_3b_relu_3x3_reduce_out)
        inception_3b_3x3_bn_out = self.inception_3b_3x3_bn(inception_3b_3x3_out)
        inception_3b_relu_3x3_out = self.inception_3b_relu_3x3(inception_3b_3x3_bn_out)
        inception_3b_double_3x3_reduce_out = self.inception_3b_double_3x3_reduce(inception_3a_output_out)
        inception_3b_double_3x3_reduce_bn_out = self.inception_3b_double_3x3_reduce_bn(inception_3b_double_3x3_reduce_out)
        inception_3b_relu_double_3x3_reduce_out = self.inception_3b_relu_double_3x3_reduce(inception_3b_double_3x3_reduce_bn_out)
        inception_3b_double_3x3_1_out = self.inception_3b_double_3x3_1(inception_3b_relu_double_3x3_reduce_out)
        inception_3b_double_3x3_1_bn_out = self.inception_3b_double_3x3_1_bn(inception_3b_double_3x3_1_out)
        inception_3b_relu_double_3x3_1_out = self.inception_3b_relu_double_3x3_1(inception_3b_double_3x3_1_bn_out)
        inception_3b_double_3x3_2_out = self.inception_3b_double_3x3_2(inception_3b_relu_double_3x3_1_out)
        inception_3b_double_3x3_2_bn_out = self.inception_3b_double_3x3_2_bn(inception_3b_double_3x3_2_out)
        inception_3b_relu_double_3x3_2_out = self.inception_3b_relu_double_3x3_2(inception_3b_double_3x3_2_bn_out)
        inception_3b_pool_out = self.inception_3b_pool(inception_3a_output_out)
        inception_3b_pool_proj_out = self.inception_3b_pool_proj(inception_3b_pool_out)
        inception_3b_pool_proj_bn_out = self.inception_3b_pool_proj_bn(inception_3b_pool_proj_out)
        inception_3b_relu_pool_proj_out = self.inception_3b_relu_pool_proj(inception_3b_pool_proj_bn_out)
        inception_3b_output_out = torch.cat([inception_3b_relu_1x1_out,inception_3b_relu_3x3_out,inception_3b_relu_double_3x3_2_out,inception_3b_relu_pool_proj_out], 1)
        inception_3c_3x3_reduce_out = self.inception_3c_3x3_reduce(inception_3b_output_out)
        inception_3c_3x3_reduce_bn_out = self.inception_3c_3x3_reduce_bn(inception_3c_3x3_reduce_out)
        inception_3c_relu_3x3_reduce_out = self.inception_3c_relu_3x3_reduce(inception_3c_3x3_reduce_bn_out)
        inception_3c_3x3_out = self.inception_3c_3x3(inception_3c_relu_3x3_reduce_out)
        inception_3c_3x3_bn_out = self.inception_3c_3x3_bn(inception_3c_3x3_out)
        inception_3c_relu_3x3_out = self.inception_3c_relu_3x3(inception_3c_3x3_bn_out)
        inception_3c_double_3x3_reduce_out = self.inception_3c_double_3x3_reduce(inception_3b_output_out)
        inception_3c_double_3x3_reduce_bn_out = self.inception_3c_double_3x3_reduce_bn(inception_3c_double_3x3_reduce_out)
        inception_3c_relu_double_3x3_reduce_out = self.inception_3c_relu_double_3x3_reduce(inception_3c_double_3x3_reduce_bn_out)
        inception_3c_double_3x3_1_out = self.inception_3c_double_3x3_1(inception_3c_relu_double_3x3_reduce_out)
        inception_3c_double_3x3_1_bn_out = self.inception_3c_double_3x3_1_bn(inception_3c_double_3x3_1_out)
        inception_3c_relu_double_3x3_1_out = self.inception_3c_relu_double_3x3_1(inception_3c_double_3x3_1_bn_out)
        inception_3c_double_3x3_2_out = self.inception_3c_double_3x3_2(inception_3c_relu_double_3x3_1_out)
        inception_3c_double_3x3_2_bn_out = self.inception_3c_double_3x3_2_bn(inception_3c_double_3x3_2_out)
        inception_3c_relu_double_3x3_2_out = self.inception_3c_relu_double_3x3_2(inception_3c_double_3x3_2_bn_out)
        inception_3c_pool_out = self.inception_3c_pool(inception_3b_output_out)
        inception_3c_output_out = torch.cat([inception_3c_relu_3x3_out,inception_3c_relu_double_3x3_2_out,inception_3c_pool_out], 1)
        inception_4a_1x1_out = self.inception_4a_1x1(inception_3c_output_out)
        inception_4a_1x1_bn_out = self.inception_4a_1x1_bn(inception_4a_1x1_out)
        inception_4a_relu_1x1_out = self.inception_4a_relu_1x1(inception_4a_1x1_bn_out)
        inception_4a_3x3_reduce_out = self.inception_4a_3x3_reduce(inception_3c_output_out)
        inception_4a_3x3_reduce_bn_out = self.inception_4a_3x3_reduce_bn(inception_4a_3x3_reduce_out)
        inception_4a_relu_3x3_reduce_out = self.inception_4a_relu_3x3_reduce(inception_4a_3x3_reduce_bn_out)
        inception_4a_3x3_out = self.inception_4a_3x3(inception_4a_relu_3x3_reduce_out)
        inception_4a_3x3_bn_out = self.inception_4a_3x3_bn(inception_4a_3x3_out)
        inception_4a_relu_3x3_out = self.inception_4a_relu_3x3(inception_4a_3x3_bn_out)
        inception_4a_double_3x3_reduce_out = self.inception_4a_double_3x3_reduce(inception_3c_output_out)
        inception_4a_double_3x3_reduce_bn_out = self.inception_4a_double_3x3_reduce_bn(inception_4a_double_3x3_reduce_out)
        inception_4a_relu_double_3x3_reduce_out = self.inception_4a_relu_double_3x3_reduce(inception_4a_double_3x3_reduce_bn_out)
        inception_4a_double_3x3_1_out = self.inception_4a_double_3x3_1(inception_4a_relu_double_3x3_reduce_out)
        inception_4a_double_3x3_1_bn_out = self.inception_4a_double_3x3_1_bn(inception_4a_double_3x3_1_out)
        inception_4a_relu_double_3x3_1_out = self.inception_4a_relu_double_3x3_1(inception_4a_double_3x3_1_bn_out)
        inception_4a_double_3x3_2_out = self.inception_4a_double_3x3_2(inception_4a_relu_double_3x3_1_out)
        inception_4a_double_3x3_2_bn_out = self.inception_4a_double_3x3_2_bn(inception_4a_double_3x3_2_out)
        inception_4a_relu_double_3x3_2_out = self.inception_4a_relu_double_3x3_2(inception_4a_double_3x3_2_bn_out)
        inception_4a_pool_out = self.inception_4a_pool(inception_3c_output_out)
        inception_4a_pool_proj_out = self.inception_4a_pool_proj(inception_4a_pool_out)
        inception_4a_pool_proj_bn_out = self.inception_4a_pool_proj_bn(inception_4a_pool_proj_out)
        inception_4a_relu_pool_proj_out = self.inception_4a_relu_pool_proj(inception_4a_pool_proj_bn_out)
        inception_4a_output_out = torch.cat([inception_4a_relu_1x1_out,inception_4a_relu_3x3_out,inception_4a_relu_double_3x3_2_out,inception_4a_relu_pool_proj_out], 1)
        inception_4b_1x1_out = self.inception_4b_1x1(inception_4a_output_out)
        inception_4b_1x1_bn_out = self.inception_4b_1x1_bn(inception_4b_1x1_out)
        inception_4b_relu_1x1_out = self.inception_4b_relu_1x1(inception_4b_1x1_bn_out)
        inception_4b_3x3_reduce_out = self.inception_4b_3x3_reduce(inception_4a_output_out)
        inception_4b_3x3_reduce_bn_out = self.inception_4b_3x3_reduce_bn(inception_4b_3x3_reduce_out)
        inception_4b_relu_3x3_reduce_out = self.inception_4b_relu_3x3_reduce(inception_4b_3x3_reduce_bn_out)
        inception_4b_3x3_out = self.inception_4b_3x3(inception_4b_relu_3x3_reduce_out)
        inception_4b_3x3_bn_out = self.inception_4b_3x3_bn(inception_4b_3x3_out)
        inception_4b_relu_3x3_out = self.inception_4b_relu_3x3(inception_4b_3x3_bn_out)
        inception_4b_double_3x3_reduce_out = self.inception_4b_double_3x3_reduce(inception_4a_output_out)
        inception_4b_double_3x3_reduce_bn_out = self.inception_4b_double_3x3_reduce_bn(inception_4b_double_3x3_reduce_out)
        inception_4b_relu_double_3x3_reduce_out = self.inception_4b_relu_double_3x3_reduce(inception_4b_double_3x3_reduce_bn_out)
        inception_4b_double_3x3_1_out = self.inception_4b_double_3x3_1(inception_4b_relu_double_3x3_reduce_out)
        inception_4b_double_3x3_1_bn_out = self.inception_4b_double_3x3_1_bn(inception_4b_double_3x3_1_out)
        inception_4b_relu_double_3x3_1_out = self.inception_4b_relu_double_3x3_1(inception_4b_double_3x3_1_bn_out)
        inception_4b_double_3x3_2_out = self.inception_4b_double_3x3_2(inception_4b_relu_double_3x3_1_out)
        inception_4b_double_3x3_2_bn_out = self.inception_4b_double_3x3_2_bn(inception_4b_double_3x3_2_out)
        inception_4b_relu_double_3x3_2_out = self.inception_4b_relu_double_3x3_2(inception_4b_double_3x3_2_bn_out)
        inception_4b_pool_out = self.inception_4b_pool(inception_4a_output_out)
        inception_4b_pool_proj_out = self.inception_4b_pool_proj(inception_4b_pool_out)
        inception_4b_pool_proj_bn_out = self.inception_4b_pool_proj_bn(inception_4b_pool_proj_out)
        inception_4b_relu_pool_proj_out = self.inception_4b_relu_pool_proj(inception_4b_pool_proj_bn_out)
        inception_4b_output_out = torch.cat([inception_4b_relu_1x1_out,inception_4b_relu_3x3_out,inception_4b_relu_double_3x3_2_out,inception_4b_relu_pool_proj_out], 1)
        inception_4c_1x1_out = self.inception_4c_1x1(inception_4b_output_out)
        inception_4c_1x1_bn_out = self.inception_4c_1x1_bn(inception_4c_1x1_out)
        inception_4c_relu_1x1_out = self.inception_4c_relu_1x1(inception_4c_1x1_bn_out)
        inception_4c_3x3_reduce_out = self.inception_4c_3x3_reduce(inception_4b_output_out)
        inception_4c_3x3_reduce_bn_out = self.inception_4c_3x3_reduce_bn(inception_4c_3x3_reduce_out)
        inception_4c_relu_3x3_reduce_out = self.inception_4c_relu_3x3_reduce(inception_4c_3x3_reduce_bn_out)
        inception_4c_3x3_out = self.inception_4c_3x3(inception_4c_relu_3x3_reduce_out)
        inception_4c_3x3_bn_out = self.inception_4c_3x3_bn(inception_4c_3x3_out)
        inception_4c_relu_3x3_out = self.inception_4c_relu_3x3(inception_4c_3x3_bn_out)
        inception_4c_double_3x3_reduce_out = self.inception_4c_double_3x3_reduce(inception_4b_output_out)
        inception_4c_double_3x3_reduce_bn_out = self.inception_4c_double_3x3_reduce_bn(inception_4c_double_3x3_reduce_out)
        inception_4c_relu_double_3x3_reduce_out = self.inception_4c_relu_double_3x3_reduce(inception_4c_double_3x3_reduce_bn_out)
        inception_4c_double_3x3_1_out = self.inception_4c_double_3x3_1(inception_4c_relu_double_3x3_reduce_out)
        inception_4c_double_3x3_1_bn_out = self.inception_4c_double_3x3_1_bn(inception_4c_double_3x3_1_out)
        inception_4c_relu_double_3x3_1_out = self.inception_4c_relu_double_3x3_1(inception_4c_double_3x3_1_bn_out)
        inception_4c_double_3x3_2_out = self.inception_4c_double_3x3_2(inception_4c_relu_double_3x3_1_out)
        inception_4c_double_3x3_2_bn_out = self.inception_4c_double_3x3_2_bn(inception_4c_double_3x3_2_out)
        inception_4c_relu_double_3x3_2_out = self.inception_4c_relu_double_3x3_2(inception_4c_double_3x3_2_bn_out)
        inception_4c_pool_out = self.inception_4c_pool(inception_4b_output_out)
        inception_4c_pool_proj_out = self.inception_4c_pool_proj(inception_4c_pool_out)
        inception_4c_pool_proj_bn_out = self.inception_4c_pool_proj_bn(inception_4c_pool_proj_out)
        inception_4c_relu_pool_proj_out = self.inception_4c_relu_pool_proj(inception_4c_pool_proj_bn_out)
        inception_4c_output_out = torch.cat([inception_4c_relu_1x1_out,inception_4c_relu_3x3_out,inception_4c_relu_double_3x3_2_out,inception_4c_relu_pool_proj_out], 1)
        inception_4d_1x1_out = self.inception_4d_1x1(inception_4c_output_out)
        inception_4d_1x1_bn_out = self.inception_4d_1x1_bn(inception_4d_1x1_out)
        inception_4d_relu_1x1_out = self.inception_4d_relu_1x1(inception_4d_1x1_bn_out)
        inception_4d_3x3_reduce_out = self.inception_4d_3x3_reduce(inception_4c_output_out)
        inception_4d_3x3_reduce_bn_out = self.inception_4d_3x3_reduce_bn(inception_4d_3x3_reduce_out)
        inception_4d_relu_3x3_reduce_out = self.inception_4d_relu_3x3_reduce(inception_4d_3x3_reduce_bn_out)
        inception_4d_3x3_out = self.inception_4d_3x3(inception_4d_relu_3x3_reduce_out)
        inception_4d_3x3_bn_out = self.inception_4d_3x3_bn(inception_4d_3x3_out)
        inception_4d_relu_3x3_out = self.inception_4d_relu_3x3(inception_4d_3x3_bn_out)
        inception_4d_double_3x3_reduce_out = self.inception_4d_double_3x3_reduce(inception_4c_output_out)
        inception_4d_double_3x3_reduce_bn_out = self.inception_4d_double_3x3_reduce_bn(inception_4d_double_3x3_reduce_out)
        inception_4d_relu_double_3x3_reduce_out = self.inception_4d_relu_double_3x3_reduce(inception_4d_double_3x3_reduce_bn_out)
        inception_4d_double_3x3_1_out = self.inception_4d_double_3x3_1(inception_4d_relu_double_3x3_reduce_out)
        inception_4d_double_3x3_1_bn_out = self.inception_4d_double_3x3_1_bn(inception_4d_double_3x3_1_out)
        inception_4d_relu_double_3x3_1_out = self.inception_4d_relu_double_3x3_1(inception_4d_double_3x3_1_bn_out)
        inception_4d_double_3x3_2_out = self.inception_4d_double_3x3_2(inception_4d_relu_double_3x3_1_out)
        inception_4d_double_3x3_2_bn_out = self.inception_4d_double_3x3_2_bn(inception_4d_double_3x3_2_out)
        inception_4d_relu_double_3x3_2_out = self.inception_4d_relu_double_3x3_2(inception_4d_double_3x3_2_bn_out)
        inception_4d_pool_out = self.inception_4d_pool(inception_4c_output_out)
        inception_4d_pool_proj_out = self.inception_4d_pool_proj(inception_4d_pool_out)
        inception_4d_pool_proj_bn_out = self.inception_4d_pool_proj_bn(inception_4d_pool_proj_out)
        inception_4d_relu_pool_proj_out = self.inception_4d_relu_pool_proj(inception_4d_pool_proj_bn_out)
        inception_4d_output_out = torch.cat([inception_4d_relu_1x1_out,inception_4d_relu_3x3_out,inception_4d_relu_double_3x3_2_out,inception_4d_relu_pool_proj_out], 1)
        inception_4e_3x3_reduce_out = self.inception_4e_3x3_reduce(inception_4d_output_out)
        inception_4e_3x3_reduce_bn_out = self.inception_4e_3x3_reduce_bn(inception_4e_3x3_reduce_out)
        inception_4e_relu_3x3_reduce_out = self.inception_4e_relu_3x3_reduce(inception_4e_3x3_reduce_bn_out)
        inception_4e_3x3_out = self.inception_4e_3x3(inception_4e_relu_3x3_reduce_out)
        inception_4e_3x3_bn_out = self.inception_4e_3x3_bn(inception_4e_3x3_out)
        inception_4e_relu_3x3_out = self.inception_4e_relu_3x3(inception_4e_3x3_bn_out)
        inception_4e_double_3x3_reduce_out = self.inception_4e_double_3x3_reduce(inception_4d_output_out)
        inception_4e_double_3x3_reduce_bn_out = self.inception_4e_double_3x3_reduce_bn(inception_4e_double_3x3_reduce_out)
        inception_4e_relu_double_3x3_reduce_out = self.inception_4e_relu_double_3x3_reduce(inception_4e_double_3x3_reduce_bn_out)
        inception_4e_double_3x3_1_out = self.inception_4e_double_3x3_1(inception_4e_relu_double_3x3_reduce_out)
        inception_4e_double_3x3_1_bn_out = self.inception_4e_double_3x3_1_bn(inception_4e_double_3x3_1_out)
        inception_4e_relu_double_3x3_1_out = self.inception_4e_relu_double_3x3_1(inception_4e_double_3x3_1_bn_out)
        inception_4e_double_3x3_2_out = self.inception_4e_double_3x3_2(inception_4e_relu_double_3x3_1_out)
        inception_4e_double_3x3_2_bn_out = self.inception_4e_double_3x3_2_bn(inception_4e_double_3x3_2_out)
        inception_4e_relu_double_3x3_2_out = self.inception_4e_relu_double_3x3_2(inception_4e_double_3x3_2_bn_out)
        inception_4e_pool_out = self.inception_4e_pool(inception_4d_output_out)
        inception_4e_output_out = torch.cat([inception_4e_relu_3x3_out,inception_4e_relu_double_3x3_2_out,inception_4e_pool_out], 1)
        inception_5a_1x1_out = self.inception_5a_1x1(inception_4e_output_out)
        inception_5a_1x1_bn_out = self.inception_5a_1x1_bn(inception_5a_1x1_out)
        inception_5a_relu_1x1_out = self.inception_5a_relu_1x1(inception_5a_1x1_bn_out)
        inception_5a_3x3_reduce_out = self.inception_5a_3x3_reduce(inception_4e_output_out)
        inception_5a_3x3_reduce_bn_out = self.inception_5a_3x3_reduce_bn(inception_5a_3x3_reduce_out)
        inception_5a_relu_3x3_reduce_out = self.inception_5a_relu_3x3_reduce(inception_5a_3x3_reduce_bn_out)
        inception_5a_3x3_out = self.inception_5a_3x3(inception_5a_relu_3x3_reduce_out)
        inception_5a_3x3_bn_out = self.inception_5a_3x3_bn(inception_5a_3x3_out)
        inception_5a_relu_3x3_out = self.inception_5a_relu_3x3(inception_5a_3x3_bn_out)
        inception_5a_double_3x3_reduce_out = self.inception_5a_double_3x3_reduce(inception_4e_output_out)
        inception_5a_double_3x3_reduce_bn_out = self.inception_5a_double_3x3_reduce_bn(inception_5a_double_3x3_reduce_out)
        inception_5a_relu_double_3x3_reduce_out = self.inception_5a_relu_double_3x3_reduce(inception_5a_double_3x3_reduce_bn_out)
        inception_5a_double_3x3_1_out = self.inception_5a_double_3x3_1(inception_5a_relu_double_3x3_reduce_out)
        inception_5a_double_3x3_1_bn_out = self.inception_5a_double_3x3_1_bn(inception_5a_double_3x3_1_out)
        inception_5a_relu_double_3x3_1_out = self.inception_5a_relu_double_3x3_1(inception_5a_double_3x3_1_bn_out)
        inception_5a_double_3x3_2_out = self.inception_5a_double_3x3_2(inception_5a_relu_double_3x3_1_out)
        inception_5a_double_3x3_2_bn_out = self.inception_5a_double_3x3_2_bn(inception_5a_double_3x3_2_out)
        inception_5a_relu_double_3x3_2_out = self.inception_5a_relu_double_3x3_2(inception_5a_double_3x3_2_bn_out)
        inception_5a_pool_out = self.inception_5a_pool(inception_4e_output_out)
        inception_5a_pool_proj_out = self.inception_5a_pool_proj(inception_5a_pool_out)
        inception_5a_pool_proj_bn_out = self.inception_5a_pool_proj_bn(inception_5a_pool_proj_out)
        inception_5a_relu_pool_proj_out = self.inception_5a_relu_pool_proj(inception_5a_pool_proj_bn_out)
        inception_5a_output_out = torch.cat([inception_5a_relu_1x1_out,inception_5a_relu_3x3_out,inception_5a_relu_double_3x3_2_out,inception_5a_relu_pool_proj_out], 1)
        inception_5b_1x1_out = self.inception_5b_1x1(inception_5a_output_out)
        inception_5b_1x1_bn_out = self.inception_5b_1x1_bn(inception_5b_1x1_out)
        inception_5b_relu_1x1_out = self.inception_5b_relu_1x1(inception_5b_1x1_bn_out)
        inception_5b_3x3_reduce_out = self.inception_5b_3x3_reduce(inception_5a_output_out)
        inception_5b_3x3_reduce_bn_out = self.inception_5b_3x3_reduce_bn(inception_5b_3x3_reduce_out)
        inception_5b_relu_3x3_reduce_out = self.inception_5b_relu_3x3_reduce(inception_5b_3x3_reduce_bn_out)
        inception_5b_3x3_out = self.inception_5b_3x3(inception_5b_relu_3x3_reduce_out)
        inception_5b_3x3_bn_out = self.inception_5b_3x3_bn(inception_5b_3x3_out)
        inception_5b_relu_3x3_out = self.inception_5b_relu_3x3(inception_5b_3x3_bn_out)
        inception_5b_double_3x3_reduce_out = self.inception_5b_double_3x3_reduce(inception_5a_output_out)
        inception_5b_double_3x3_reduce_bn_out = self.inception_5b_double_3x3_reduce_bn(inception_5b_double_3x3_reduce_out)
        inception_5b_relu_double_3x3_reduce_out = self.inception_5b_relu_double_3x3_reduce(inception_5b_double_3x3_reduce_bn_out)
        inception_5b_double_3x3_1_out = self.inception_5b_double_3x3_1(inception_5b_relu_double_3x3_reduce_out)
        inception_5b_double_3x3_1_bn_out = self.inception_5b_double_3x3_1_bn(inception_5b_double_3x3_1_out)
        inception_5b_relu_double_3x3_1_out = self.inception_5b_relu_double_3x3_1(inception_5b_double_3x3_1_bn_out)
        inception_5b_double_3x3_2_out = self.inception_5b_double_3x3_2(inception_5b_relu_double_3x3_1_out)
        inception_5b_double_3x3_2_bn_out = self.inception_5b_double_3x3_2_bn(inception_5b_double_3x3_2_out)
        inception_5b_relu_double_3x3_2_out = self.inception_5b_relu_double_3x3_2(inception_5b_double_3x3_2_bn_out)
        inception_5b_pool_out = self.inception_5b_pool(inception_5a_output_out)
        inception_5b_pool_proj_out = self.inception_5b_pool_proj(inception_5b_pool_out)
        inception_5b_pool_proj_bn_out = self.inception_5b_pool_proj_bn(inception_5b_pool_proj_out)
        inception_5b_relu_pool_proj_out = self.inception_5b_relu_pool_proj(inception_5b_pool_proj_bn_out)
        inception_5b_output_out = torch.cat([inception_5b_relu_1x1_out,inception_5b_relu_3x3_out,inception_5b_relu_double_3x3_2_out,inception_5b_relu_pool_proj_out], 1)
        return inception_5b_output_out

    def logits(self, features):
        adaptiveAvgPoolWidth = features.shape[2]
        x = F.avg_pool2d(features, kernel_size=adaptiveAvgPoolWidth)
        x = x.view(x.size(0), -1)
        x = self.last_linear(x)
        return x

    def forward(self, input):
        x = self.features(input)
        x = self.logits(x)
        return x

def bninception(num_classes=1000, pretrained='imagenet'):
    r"""BNInception model architecture from <https://arxiv.org/pdf/1502.03167.pdf>`_ paper.
    """
    model = BNInception(num_classes=num_classes)
    if pretrained is not None:
        settings = pretrained_settings['bninception'][pretrained]
        assert num_classes == settings['num_classes'], \
            "num_classes should be {}, but is {}".format(settings['num_classes'], num_classes)
        model.load_state_dict(model_zoo.load_url(settings['url']))
        model.input_space = settings['input_space']
        model.input_size = settings['input_size']
        model.input_range = settings['input_range']
        model.mean = settings['mean']
        model.std = settings['std']
    return model


if __name__ == '__main__':

    model = bninception()


================================================
FILE: pretrainedmodels/models/cafferesnet.py
================================================
from __future__ import print_function, division, absolute_import
import math
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.model_zoo as model_zoo

pretrained_settings = {
    'cafferesnet101': {
        'imagenet': {
            'url': 'http://data.lip6.fr/cadene/pretrainedmodels/cafferesnet101-9d633cc0.pth',
            'input_space': 'BGR',
            'input_size': [3, 224, 224],
            'input_range': [0, 255],
            'mean': [102.9801, 115.9465, 122.7717],
            'std': [1, 1, 1],
            'num_classes': 1000
        }
    }
}


def conv3x3(in_planes, out_planes, stride=1):
  "3x3 convolution with padding"
  return nn.Conv2d(in_planes, out_planes, kernel_size=3, stride=stride,
           padding=1, bias=False)


class BasicBlock(nn.Module):
  expansion = 1

  def __init__(self, inplanes, planes, stride=1, downsample=None):
    super(BasicBlock, self).__init__()
    self.conv1 = conv3x3(inplanes, planes, stride)
    self.bn1 = nn.BatchNorm2d(planes)
    self.relu = nn.ReLU(inplace=True)
    self.conv2 = conv3x3(planes, planes)
    self.bn2 = nn.BatchNorm2d(planes)
    self.downsample = downsample
    self.stride = stride

  def forward(self, x):
    residual = x

    out = self.conv1(x)
    out = self.bn1(out)
    out = self.relu(out)

    out = self.conv2(out)
    out = self.bn2(ou
Download .txt
gitextract_mxx490a2/

├── .gitignore
├── .travis.yml
├── LICENSE.txt
├── README.md
├── data/
│   ├── imagenet_classes.txt
│   └── imagenet_synsets.txt
├── examples/
│   ├── imagenet_eval.py
│   ├── imagenet_logits.py
│   ├── visu_arch.py
│   └── voc2007_extract.py
├── pretrainedmodels/
│   ├── __init__.py
│   ├── datasets/
│   │   ├── __init__.py
│   │   ├── utils.py
│   │   └── voc.py
│   ├── models/
│   │   ├── __init__.py
│   │   ├── bninception.py
│   │   ├── cafferesnet.py
│   │   ├── dpn.py
│   │   ├── fbresnet/
│   │   │   ├── resnet152_dump.lua
│   │   │   └── resnet152_load.py
│   │   ├── fbresnet.py
│   │   ├── inceptionresnetv2.py
│   │   ├── inceptionv4.py
│   │   ├── nasnet.py
│   │   ├── nasnet_mobile.py
│   │   ├── pnasnet.py
│   │   ├── polynet.py
│   │   ├── resnext.py
│   │   ├── resnext_features/
│   │   │   ├── __init__.py
│   │   │   ├── resnext101_32x4d_features.py
│   │   │   └── resnext101_64x4d_features.py
│   │   ├── senet.py
│   │   ├── torchvision_models.py
│   │   ├── utils.py
│   │   ├── vggm.py
│   │   ├── wideresnet.py
│   │   └── xception.py
│   ├── utils.py
│   └── version.py
├── requirements.txt
├── setup.cfg
├── setup.py
└── tests/
    ├── test_pm_imagenet.py
    └── test_torch_save.py
Download .txt
SYMBOL INDEX (485 symbols across 28 files)

FILE: examples/imagenet_eval.py
  function main (line 64) | def main():
  function train (line 162) | def train(train_loader, model, criterion, optimizer, epoch):
  function validate (line 211) | def validate(val_loader, model, criterion):
  function save_checkpoint (line 255) | def save_checkpoint(state, is_best, filename='checkpoint.pth.tar'):
  class AverageMeter (line 261) | class AverageMeter(object):
    method __init__ (line 264) | def __init__(self):
    method reset (line 267) | def reset(self):
    method update (line 273) | def update(self, val, n=1):
  function adjust_learning_rate (line 280) | def adjust_learning_rate(optimizer, epoch):
  function accuracy (line 287) | def accuracy(output, target, topk=(1,)):

FILE: examples/imagenet_logits.py
  function main (line 27) | def main():

FILE: examples/visu_arch.py
  function print_info (line 75) | def print_info(self, input, output):
  function save_activation (line 177) | def save_activation(self, input, output):

FILE: examples/voc2007_extract.py
  function extract_features_targets (line 27) | def extract_features_targets(model, features_size, loader, path_data, cu...
  function train_multilabel (line 59) | def train_multilabel(features, targets, classes, train_split, test_split...
  function main (line 135) | def main ():

FILE: pretrainedmodels/datasets/utils.py
  function load_imagenet_classes (line 9) | def load_imagenet_classes(path_synsets='data/imagenet_synsets.txt',
  class Warp (line 32) | class Warp(object):
    method __init__ (line 33) | def __init__(self, size, interpolation=Image.BILINEAR):
    method __call__ (line 37) | def __call__(self, img):
    method __str__ (line 40) | def __str__(self):
  function download_url (line 45) | def download_url(url, destination=None, progress_bar=True):
  class AveragePrecisionMeter (line 86) | class AveragePrecisionMeter(object):
    method __init__ (line 100) | def __init__(self, difficult_examples=False):
    method reset (line 105) | def reset(self):
    method add (line 110) | def add(self, output, target):
    method value (line 158) | def value(self):
    method average_precision (line 180) | def average_precision(output, target, difficult_examples=True):

FILE: pretrainedmodels/datasets/voc.py
  function read_image_label (line 29) | def read_image_label(file):
  function read_object_labels (line 43) | def read_object_labels(root, dataset, set):
  function write_object_labels_csv (line 64) | def write_object_labels_csv(file, labeled_data):
  function read_object_labels_csv (line 82) | def read_object_labels_csv(file, header=True):
  function find_images_classification (line 104) | def find_images_classification(root, dataset, set):
  function download_voc2007 (line 114) | def download_voc2007(root):
  class Voc2007Classification (line 215) | class Voc2007Classification(data.Dataset):
    method __init__ (line 217) | def __init__(self, root, set, transform=None, target_transform=None):
    method __getitem__ (line 248) | def __getitem__(self, index):
    method __len__ (line 257) | def __len__(self):
    method get_number_classes (line 260) | def get_number_classes(self):

FILE: pretrainedmodels/models/bninception.py
  class BNInception (line 27) | class BNInception(nn.Module):
    method __init__ (line 29) | def __init__(self, num_classes=1000):
    method features (line 253) | def features(self, input):
    method logits (line 485) | def logits(self, features):
    method forward (line 492) | def forward(self, input):
  function bninception (line 497) | def bninception(num_classes=1000, pretrained='imagenet'):

FILE: pretrainedmodels/models/cafferesnet.py
  function conv3x3 (line 23) | def conv3x3(in_planes, out_planes, stride=1):
  class BasicBlock (line 29) | class BasicBlock(nn.Module):
    method __init__ (line 32) | def __init__(self, inplanes, planes, stride=1, downsample=None):
    method forward (line 42) | def forward(self, x):
  class Bottleneck (line 61) | class Bottleneck(nn.Module):
    method __init__ (line 64) | def __init__(self, inplanes, planes, stride=1, downsample=None):
    method forward (line 77) | def forward(self, x):
  class ResNet (line 100) | class ResNet(nn.Module):
    method __init__ (line 102) | def __init__(self, block, layers, num_classes=1000):
    method _make_layer (line 127) | def _make_layer(self, block, planes, blocks, stride=1):
    method features (line 144) | def features(self, x):
    method logits (line 156) | def logits(self, x):
    method forward (line 162) | def forward(self, x):
  function cafferesnet101 (line 168) | def cafferesnet101(num_classes=1000, pretrained='imagenet'):

FILE: pretrainedmodels/models/dpn.py
  function dpn68 (line 98) | def dpn68(num_classes=1000, pretrained='imagenet'):
  function dpn68b (line 116) | def dpn68b(num_classes=1000, pretrained='imagenet+5k'):
  function dpn92 (line 134) | def dpn92(num_classes=1000, pretrained='imagenet+5k'):
  function dpn98 (line 152) | def dpn98(num_classes=1000, pretrained='imagenet'):
  function dpn131 (line 170) | def dpn131(num_classes=1000, pretrained='imagenet'):
  function dpn107 (line 188) | def dpn107(num_classes=1000, pretrained='imagenet+5k'):
  class CatBnAct (line 207) | class CatBnAct(nn.Module):
    method __init__ (line 208) | def __init__(self, in_chs, activation_fn=nn.ReLU(inplace=True)):
    method forward (line 213) | def forward(self, x):
  class BnActConv2d (line 218) | class BnActConv2d(nn.Module):
    method __init__ (line 219) | def __init__(self, in_chs, out_chs, kernel_size, stride,
    method forward (line 226) | def forward(self, x):
  class InputBlock (line 230) | class InputBlock(nn.Module):
    method __init__ (line 231) | def __init__(self, num_init_features, kernel_size=7,
    method forward (line 240) | def forward(self, x):
  class DualPathBlock (line 248) | class DualPathBlock(nn.Module):
    method __init__ (line 249) | def __init__(
    method forward (line 285) | def forward(self, x):
  class DPN (line 312) | class DPN(nn.Module):
    method __init__ (line 313) | def __init__(self, small=False, num_init_features=64, k_r=96, groups=32,
    method logits (line 375) | def logits(self, features):
    method forward (line 386) | def forward(self, input):
  function pooling_factor (line 403) | def pooling_factor(pool_type='avg'):
  function adaptive_avgmax_pool2d (line 407) | def adaptive_avgmax_pool2d(x, pool_type='avg', padding=0, count_include_...
  class AdaptiveAvgMaxPool2d (line 431) | class AdaptiveAvgMaxPool2d(torch.nn.Module):
    method __init__ (line 434) | def __init__(self, output_size=1, pool_type='avg'):
    method forward (line 447) | def forward(self, x):
    method factor (line 456) | def factor(self):
    method __repr__ (line 459) | def __repr__(self):

FILE: pretrainedmodels/models/fbresnet.py
  function conv3x3 (line 27) | def conv3x3(in_planes, out_planes, stride=1):
  class BasicBlock (line 33) | class BasicBlock(nn.Module):
    method __init__ (line 36) | def __init__(self, inplanes, planes, stride=1, downsample=None):
    method forward (line 46) | def forward(self, x):
  class Bottleneck (line 65) | class Bottleneck(nn.Module):
    method __init__ (line 68) | def __init__(self, inplanes, planes, stride=1, downsample=None):
    method forward (line 81) | def forward(self, x):
  class FBResNet (line 103) | class FBResNet(nn.Module):
    method __init__ (line 105) | def __init__(self, block, layers, num_classes=1000):
    method _make_layer (line 133) | def _make_layer(self, block, planes, blocks, stride=1):
    method features (line 150) | def features(self, input):
    method logits (line 163) | def logits(self, features):
    method forward (line 170) | def forward(self, input):
  function fbresnet18 (line 176) | def fbresnet18(num_classes=1000):
  function fbresnet34 (line 186) | def fbresnet34(num_classes=1000):
  function fbresnet50 (line 196) | def fbresnet50(num_classes=1000):
  function fbresnet101 (line 206) | def fbresnet101(num_classes=1000):
  function fbresnet152 (line 216) | def fbresnet152(num_classes=1000, pretrained='imagenet'):

FILE: pretrainedmodels/models/fbresnet/resnet152_load.py
  function conv3x3 (line 20) | def conv3x3(in_planes, out_planes, stride=1):
  class BasicBlock (line 26) | class BasicBlock(nn.Module):
    method __init__ (line 29) | def __init__(self, inplanes, planes, stride=1, downsample=None):
    method forward (line 39) | def forward(self, x):
  class Bottleneck (line 58) | class Bottleneck(nn.Module):
    method __init__ (line 61) | def __init__(self, inplanes, planes, stride=1, downsample=None):
    method forward (line 74) | def forward(self, x):
  class ResNet (line 98) | class ResNet(nn.Module):
    method __init__ (line 100) | def __init__(self, block, layers, num_classes=1000):
    method _make_layer (line 124) | def _make_layer(self, block, planes, blocks, stride=1):
    method forward (line 141) | def forward(self, x):
  function resnet18 (line 160) | def resnet18(pretrained=False, **kwargs):
  function resnet34 (line 172) | def resnet34(pretrained=False, **kwargs):
  function resnet50 (line 184) | def resnet50(pretrained=False, **kwargs):
  function resnet101 (line 196) | def resnet101(pretrained=False, **kwargs):
  function resnet152 (line 208) | def resnet152(pretrained=False, **kwargs):

FILE: pretrainedmodels/models/inceptionresnetv2.py
  class BasicConv2d (line 34) | class BasicConv2d(nn.Module):
    method __init__ (line 36) | def __init__(self, in_planes, out_planes, kernel_size, stride, padding...
    method forward (line 47) | def forward(self, x):
  class Mixed_5b (line 54) | class Mixed_5b(nn.Module):
    method __init__ (line 56) | def __init__(self):
    method forward (line 77) | def forward(self, x):
  class Block35 (line 86) | class Block35(nn.Module):
    method __init__ (line 88) | def __init__(self, scale=1.0):
    method forward (line 109) | def forward(self, x):
  class Mixed_6a (line 120) | class Mixed_6a(nn.Module):
    method __init__ (line 122) | def __init__(self):
    method forward (line 135) | def forward(self, x):
  class Block17 (line 143) | class Block17(nn.Module):
    method __init__ (line 145) | def __init__(self, scale=1.0):
    method forward (line 161) | def forward(self, x):
  class Mixed_7a (line 171) | class Mixed_7a(nn.Module):
    method __init__ (line 173) | def __init__(self):
    method forward (line 194) | def forward(self, x):
  class Block8 (line 203) | class Block8(nn.Module):
    method __init__ (line 205) | def __init__(self, scale=1.0, noReLU=False):
    method forward (line 223) | def forward(self, x):
  class InceptionResNetV2 (line 234) | class InceptionResNetV2(nn.Module):
    method __init__ (line 236) | def __init__(self, num_classes=1001):
    method features (line 304) | def features(self, input):
    method logits (line 322) | def logits(self, features):
    method forward (line 328) | def forward(self, input):
  function inceptionresnetv2 (line 333) | def inceptionresnetv2(num_classes=1000, pretrained='imagenet'):

FILE: pretrainedmodels/models/inceptionv4.py
  class BasicConv2d (line 35) | class BasicConv2d(nn.Module):
    method __init__ (line 37) | def __init__(self, in_planes, out_planes, kernel_size, stride, padding...
    method forward (line 48) | def forward(self, x):
  class Mixed_3a (line 55) | class Mixed_3a(nn.Module):
    method __init__ (line 57) | def __init__(self):
    method forward (line 62) | def forward(self, x):
  class Mixed_4a (line 69) | class Mixed_4a(nn.Module):
    method __init__ (line 71) | def __init__(self):
    method forward (line 86) | def forward(self, x):
  class Mixed_5a (line 93) | class Mixed_5a(nn.Module):
    method __init__ (line 95) | def __init__(self):
    method forward (line 100) | def forward(self, x):
  class Inception_A (line 107) | class Inception_A(nn.Module):
    method __init__ (line 109) | def __init__(self):
    method forward (line 129) | def forward(self, x):
  class Reduction_A (line 138) | class Reduction_A(nn.Module):
    method __init__ (line 140) | def __init__(self):
    method forward (line 152) | def forward(self, x):
  class Inception_B (line 160) | class Inception_B(nn.Module):
    method __init__ (line 162) | def __init__(self):
    method forward (line 185) | def forward(self, x):
  class Reduction_B (line 194) | class Reduction_B(nn.Module):
    method __init__ (line 196) | def __init__(self):
    method forward (line 213) | def forward(self, x):
  class Inception_C (line 221) | class Inception_C(nn.Module):
    method __init__ (line 223) | def __init__(self):
    method forward (line 243) | def forward(self, x):
  class InceptionV4 (line 264) | class InceptionV4(nn.Module):
    method __init__ (line 266) | def __init__(self, num_classes=1001):
    method logits (line 300) | def logits(self, features):
    method forward (line 308) | def forward(self, input):
  function inceptionv4 (line 314) | def inceptionv4(num_classes=1000, pretrained='imagenet'):

FILE: pretrainedmodels/models/nasnet.py
  class MaxPoolPad (line 32) | class MaxPoolPad(nn.Module):
    method __init__ (line 34) | def __init__(self):
    method forward (line 39) | def forward(self, x):
  class AvgPoolPad (line 46) | class AvgPoolPad(nn.Module):
    method __init__ (line 48) | def __init__(self, stride=2, padding=1):
    method forward (line 53) | def forward(self, x):
  class SeparableConv2d (line 60) | class SeparableConv2d(nn.Module):
    method __init__ (line 62) | def __init__(self, in_channels, out_channels, dw_kernel, dw_stride, dw...
    method forward (line 71) | def forward(self, x):
  class BranchSeparables (line 77) | class BranchSeparables(nn.Module):
    method __init__ (line 79) | def __init__(self, in_channels, out_channels, kernel_size, stride, pad...
    method forward (line 88) | def forward(self, x):
  class BranchSeparablesStem (line 98) | class BranchSeparablesStem(nn.Module):
    method __init__ (line 100) | def __init__(self, in_channels, out_channels, kernel_size, stride, pad...
    method forward (line 109) | def forward(self, x):
  class BranchSeparablesReduction (line 119) | class BranchSeparablesReduction(BranchSeparables):
    method __init__ (line 121) | def __init__(self, in_channels, out_channels, kernel_size, stride, pad...
    method forward (line 125) | def forward(self, x):
  class CellStem0 (line 137) | class CellStem0(nn.Module):
    method __init__ (line 138) | def __init__(self, stem_filters, num_filters=42):
    method forward (line 161) | def forward(self, x):
  class CellStem1 (line 187) | class CellStem1(nn.Module):
    method __init__ (line 189) | def __init__(self, stem_filters, num_filters):
    method forward (line 223) | def forward(self, x_conv0, x_stem_0):
  class FirstCell (line 260) | class FirstCell(nn.Module):
    method __init__ (line 262) | def __init__(self, in_channels_left, out_channels_left, in_channels_ri...
    method forward (line 293) | def forward(self, x, x_prev):
  class NormalCell (line 329) | class NormalCell(nn.Module):
    method __init__ (line 331) | def __init__(self, in_channels_left, out_channels_left, in_channels_ri...
    method forward (line 356) | def forward(self, x, x_prev):
  class ReductionCell0 (line 382) | class ReductionCell0(nn.Module):
    method __init__ (line 384) | def __init__(self, in_channels_left, out_channels_left, in_channels_ri...
    method forward (line 410) | def forward(self, x, x_prev):
  class ReductionCell1 (line 437) | class ReductionCell1(nn.Module):
    method __init__ (line 439) | def __init__(self, in_channels_left, out_channels_left, in_channels_ri...
    method forward (line 465) | def forward(self, x, x_prev):
  class NASNetALarge (line 492) | class NASNetALarge(nn.Module):
    method __init__ (line 495) | def __init__(self, num_classes=1001, stem_filters=96, penultimate_filt...
    method features (line 563) | def features(self, input):
    method logits (line 594) | def logits(self, features):
    method forward (line 602) | def forward(self, input):
  function nasnetalarge (line 608) | def nasnetalarge(num_classes=1001, pretrained='imagenet'):

FILE: pretrainedmodels/models/nasnet_mobile.py
  class MaxPoolPad (line 48) | class MaxPoolPad(nn.Module):
    method __init__ (line 50) | def __init__(self):
    method forward (line 55) | def forward(self, x):
  class AvgPoolPad (line 62) | class AvgPoolPad(nn.Module):
    method __init__ (line 64) | def __init__(self, stride=2, padding=1):
    method forward (line 69) | def forward(self, x):
  class SeparableConv2d (line 76) | class SeparableConv2d(nn.Module):
    method __init__ (line 78) | def __init__(self, in_channels, out_channels, dw_kernel, dw_stride, dw...
    method forward (line 87) | def forward(self, x):
  class BranchSeparables (line 93) | class BranchSeparables(nn.Module):
    method __init__ (line 95) | def __init__(self, in_channels, out_channels, kernel_size, stride, pad...
    method forward (line 105) | def forward(self, x):
  class BranchSeparablesStem (line 120) | class BranchSeparablesStem(nn.Module):
    method __init__ (line 122) | def __init__(self, in_channels, out_channels, kernel_size, stride, pad...
    method forward (line 131) | def forward(self, x):
  class BranchSeparablesReduction (line 141) | class BranchSeparablesReduction(BranchSeparables):
    method __init__ (line 143) | def __init__(self, in_channels, out_channels, kernel_size, stride, pad...
    method forward (line 147) | def forward(self, x):
  class CellStem0 (line 159) | class CellStem0(nn.Module):
    method __init__ (line 160) | def __init__(self, stem_filters, num_filters=42):
    method forward (line 183) | def forward(self, x):
  class CellStem1 (line 209) | class CellStem1(nn.Module):
    method __init__ (line 211) | def __init__(self, stem_filters, num_filters):
    method forward (line 248) | def forward(self, x_conv0, x_stem_0):
  class FirstCell (line 285) | class FirstCell(nn.Module):
    method __init__ (line 287) | def __init__(self, in_channels_left, out_channels_left, in_channels_ri...
    method forward (line 318) | def forward(self, x, x_prev):
  class NormalCell (line 354) | class NormalCell(nn.Module):
    method __init__ (line 356) | def __init__(self, in_channels_left, out_channels_left, in_channels_ri...
    method forward (line 381) | def forward(self, x, x_prev):
  class ReductionCell0 (line 407) | class ReductionCell0(nn.Module):
    method __init__ (line 409) | def __init__(self, in_channels_left, out_channels_left, in_channels_ri...
    method forward (line 435) | def forward(self, x, x_prev):
  class ReductionCell1 (line 462) | class ReductionCell1(nn.Module):
    method __init__ (line 464) | def __init__(self, in_channels_left, out_channels_left, in_channels_ri...
    method forward (line 493) | def forward(self, x, x_prev):
  class NASNetAMobile (line 520) | class NASNetAMobile(nn.Module):
    method __init__ (line 523) | def __init__(self, num_classes=1000, stem_filters=32, penultimate_filt...
    method features (line 579) | def features(self, input):
    method logits (line 604) | def logits(self, features):
    method forward (line 612) | def forward(self, input):
  function nasnetamobile (line 618) | def nasnetamobile(num_classes=1000, pretrained='imagenet'):

FILE: pretrainedmodels/models/pnasnet.py
  class MaxPool (line 33) | class MaxPool(nn.Module):
    method __init__ (line 35) | def __init__(self, kernel_size, stride=1, padding=1, zero_pad=False):
    method forward (line 40) | def forward(self, x):
  class SeparableConv2d (line 49) | class SeparableConv2d(nn.Module):
    method __init__ (line 51) | def __init__(self, in_channels, out_channels, dw_kernel_size, dw_stride,
    method forward (line 61) | def forward(self, x):
  class BranchSeparables (line 67) | class BranchSeparables(nn.Module):
    method __init__ (line 69) | def __init__(self, in_channels, out_channels, kernel_size, stride=1,
    method forward (line 86) | def forward(self, x):
  class ReluConvBn (line 100) | class ReluConvBn(nn.Module):
    method __init__ (line 102) | def __init__(self, in_channels, out_channels, kernel_size, stride=1):
    method forward (line 110) | def forward(self, x):
  class FactorizedReduction (line 117) | class FactorizedReduction(nn.Module):
    method __init__ (line 119) | def __init__(self, in_channels, out_channels):
    method forward (line 135) | def forward(self, x):
  class CellBase (line 149) | class CellBase(nn.Module):
    method cell_forward (line 151) | def cell_forward(self, x_left, x_right):
  class CellStem0 (line 181) | class CellStem0(CellBase):
    method __init__ (line 183) | def __init__(self, in_channels_left, out_channels_left, in_channels_ri...
    method forward (line 220) | def forward(self, x_left):
  class Cell (line 226) | class Cell(CellBase):
    method __init__ (line 228) | def __init__(self, in_channels_left, out_channels_left, in_channels_ri...
    method forward (line 284) | def forward(self, x_left, x_right):
  class PNASNet5Large (line 291) | class PNASNet5Large(nn.Module):
    method __init__ (line 292) | def __init__(self, num_classes=1001):
    method features (line 340) | def features(self, x):
    method logits (line 358) | def logits(self, features):
    method forward (line 366) | def forward(self, input):
  function pnasnet5large (line 372) | def pnasnet5large(num_classes=1001, pretrained='imagenet'):

FILE: pretrainedmodels/models/polynet.py
  class BasicConv2d (line 23) | class BasicConv2d(nn.Module):
    method __init__ (line 25) | def __init__(self, in_planes, out_planes, kernel_size, stride=1, paddi...
    method forward (line 33) | def forward(self, x):
  class PolyConv2d (line 41) | class PolyConv2d(nn.Module):
    method __init__ (line 49) | def __init__(self, in_planes, out_planes, kernel_size, num_blocks,
    method forward (line 59) | def forward(self, x, block_index):
  class Stem (line 67) | class Stem(nn.Module):
    method __init__ (line 69) | def __init__(self):
    method forward (line 91) | def forward(self, x):
  class BlockA (line 108) | class BlockA(nn.Module):
    method __init__ (line 111) | def __init__(self):
    method forward (line 125) | def forward(self, x):
  class BlockB (line 134) | class BlockB(nn.Module):
    method __init__ (line 137) | def __init__(self):
    method forward (line 147) | def forward(self, x):
  class BlockC (line 155) | class BlockC(nn.Module):
    method __init__ (line 158) | def __init__(self):
    method forward (line 168) | def forward(self, x):
  class ReductionA (line 176) | class ReductionA(nn.Module):
    method __init__ (line 181) | def __init__(self):
    method forward (line 191) | def forward(self, x):
  class ReductionB (line 199) | class ReductionB(nn.Module):
    method __init__ (line 203) | def __init__(self):
    method forward (line 220) | def forward(self, x):
  class InceptionResNetBPoly (line 229) | class InceptionResNetBPoly(nn.Module):
    method __init__ (line 239) | def __init__(self, scale, num_blocks):
    method forward_block (line 259) | def forward_block(self, x, block_index):
    method forward (line 269) | def forward(self, x):
  class InceptionResNetCPoly (line 279) | class InceptionResNetCPoly(nn.Module):
    method __init__ (line 289) | def __init__(self, scale, num_blocks):
    method forward_block (line 309) | def forward_block(self, x, block_index):
    method forward (line 319) | def forward(self, x):
  class MultiWay (line 329) | class MultiWay(nn.Module):
    method __init__ (line 332) | def __init__(self, scale, block_cls, num_blocks):
    method forward (line 339) | def forward(self, x):
  class InceptionResNetA2Way (line 349) | class InceptionResNetA2Way(MultiWay):
    method __init__ (line 351) | def __init__(self, scale):
  class InceptionResNetB2Way (line 356) | class InceptionResNetB2Way(MultiWay):
    method __init__ (line 358) | def __init__(self, scale):
  class InceptionResNetC2Way (line 363) | class InceptionResNetC2Way(MultiWay):
    method __init__ (line 365) | def __init__(self, scale):
  class InceptionResNetBPoly3 (line 370) | class InceptionResNetBPoly3(InceptionResNetBPoly):
    method __init__ (line 372) | def __init__(self, scale):
  class InceptionResNetCPoly3 (line 376) | class InceptionResNetCPoly3(InceptionResNetCPoly):
    method __init__ (line 378) | def __init__(self, scale):
  class PolyNet (line 382) | class PolyNet(nn.Module):
    method __init__ (line 384) | def __init__(self, num_classes=1000):
    method features (line 439) | def features(self, x):
    method logits (line 448) | def logits(self, x):
    method forward (line 455) | def forward(self, x):
  function polynet (line 461) | def polynet(num_classes=1000, pretrained='imagenet'):

FILE: pretrainedmodels/models/resnext.py
  class ResNeXt101_32x4d (line 37) | class ResNeXt101_32x4d(nn.Module):
    method __init__ (line 39) | def __init__(self, num_classes=1000):
    method logits (line 46) | def logits(self, input):
    method forward (line 52) | def forward(self, input):
  class ResNeXt101_64x4d (line 58) | class ResNeXt101_64x4d(nn.Module):
    method __init__ (line 60) | def __init__(self, num_classes=1000):
    method logits (line 67) | def logits(self, input):
    method forward (line 73) | def forward(self, input):
  function resnext101_32x4d (line 79) | def resnext101_32x4d(num_classes=1000, pretrained='imagenet'):
  function resnext101_64x4d (line 93) | def resnext101_64x4d(num_classes=1000, pretrained='imagenet'):

FILE: pretrainedmodels/models/resnext_features/resnext101_32x4d_features.py
  class LambdaBase (line 7) | class LambdaBase(nn.Sequential):
    method __init__ (line 8) | def __init__(self, *args):
    method forward_prepare (line 11) | def forward_prepare(self, input):
  class Lambda (line 17) | class Lambda(LambdaBase):
    method __init__ (line 18) | def __init__(self, *args):
    method forward (line 22) | def forward(self, input):
  class LambdaMap (line 25) | class LambdaMap(LambdaBase):
    method __init__ (line 26) | def __init__(self, *args):
    method forward (line 30) | def forward(self, input):
  class LambdaReduce (line 33) | class LambdaReduce(LambdaBase):
    method __init__ (line 34) | def __init__(self, *args):
    method forward (line 38) | def forward(self, input):
  function identity (line 41) | def identity(x): return x
  function add (line 43) | def add(x, y): return x + y

FILE: pretrainedmodels/models/resnext_features/resnext101_64x4d_features.py
  class LambdaBase (line 7) | class LambdaBase(nn.Sequential):
    method __init__ (line 8) | def __init__(self, *args):
    method forward_prepare (line 11) | def forward_prepare(self, input):
  class Lambda (line 17) | class Lambda(LambdaBase):
    method __init__ (line 18) | def __init__(self, *args):
    method forward (line 22) | def forward(self, input):
  class LambdaMap (line 25) | class LambdaMap(LambdaBase):
    method __init__ (line 26) | def __init__(self, *args):
    method forward (line 30) | def forward(self, input):
  class LambdaReduce (line 33) | class LambdaReduce(LambdaBase):
    method __init__ (line 34) | def __init__(self, *args):
    method forward (line 38) | def forward(self, input):
  function identity (line 41) | def identity(x): return x
  function add (line 43) | def add(x, y): return x + y

FILE: pretrainedmodels/models/senet.py
  class SEModule (line 85) | class SEModule(nn.Module):
    method __init__ (line 87) | def __init__(self, channels, reduction):
    method forward (line 97) | def forward(self, x):
  class Bottleneck (line 107) | class Bottleneck(nn.Module):
    method forward (line 111) | def forward(self, x):
  class SEBottleneck (line 134) | class SEBottleneck(Bottleneck):
    method __init__ (line 140) | def __init__(self, inplanes, planes, groups, reduction, stride=1,
  class SEResNetBottleneck (line 158) | class SEResNetBottleneck(Bottleneck):
    method __init__ (line 166) | def __init__(self, inplanes, planes, groups, reduction, stride=1,
  class SEResNeXtBottleneck (line 183) | class SEResNeXtBottleneck(Bottleneck):
    method __init__ (line 189) | def __init__(self, inplanes, planes, groups, reduction, stride=1,
  class SENet (line 207) | class SENet(nn.Module):
    method __init__ (line 209) | def __init__(self, block, layers, groups, reduction, dropout_p=0.2,
    method _make_layer (line 327) | def _make_layer(self, block, planes, blocks, groups, reduction, stride=1,
    method features (line 347) | def features(self, x):
    method logits (line 355) | def logits(self, x):
    method forward (line 363) | def forward(self, x):
  function initialize_pretrained_model (line 369) | def initialize_pretrained_model(model, num_classes, settings):
  function senet154 (line 381) | def senet154(num_classes=1000, pretrained='imagenet'):
  function se_resnet50 (line 390) | def se_resnet50(num_classes=1000, pretrained='imagenet'):
  function se_resnet101 (line 401) | def se_resnet101(num_classes=1000, pretrained='imagenet'):
  function se_resnet152 (line 412) | def se_resnet152(num_classes=1000, pretrained='imagenet'):
  function se_resnext50_32x4d (line 423) | def se_resnext50_32x4d(num_classes=1000, pretrained='imagenet'):
  function se_resnext101_32x4d (line 434) | def se_resnext101_32x4d(num_classes=1000, pretrained='imagenet'):

FILE: pretrainedmodels/models/torchvision_models.py
  function update_state_dict (line 98) | def update_state_dict(state_dict):
  function load_pretrained (line 113) | def load_pretrained(model, num_classes, settings):
  function modify_alexnet (line 129) | def modify_alexnet(model):
  function alexnet (line 168) | def alexnet(num_classes=1000, pretrained='imagenet'):
  function modify_densenets (line 183) | def modify_densenets(model):
  function densenet121 (line 205) | def densenet121(num_classes=1000, pretrained='imagenet'):
  function densenet169 (line 216) | def densenet169(num_classes=1000, pretrained='imagenet'):
  function densenet201 (line 227) | def densenet201(num_classes=1000, pretrained='imagenet'):
  function densenet161 (line 238) | def densenet161(num_classes=1000, pretrained='imagenet'):
  function inceptionv3 (line 252) | def inceptionv3(num_classes=1000, pretrained='imagenet'):
  function modify_resnets (line 314) | def modify_resnets(model):
  function resnet18 (line 348) | def resnet18(num_classes=1000, pretrained='imagenet'):
  function resnet34 (line 358) | def resnet34(num_classes=1000, pretrained='imagenet'):
  function resnet50 (line 368) | def resnet50(num_classes=1000, pretrained='imagenet'):
  function resnet101 (line 378) | def resnet101(num_classes=1000, pretrained='imagenet'):
  function resnet152 (line 388) | def resnet152(num_classes=1000, pretrained='imagenet'):
  function modify_squeezenets (line 401) | def modify_squeezenets(model):
  function squeezenet1_0 (line 428) | def squeezenet1_0(num_classes=1000, pretrained='imagenet'):
  function squeezenet1_1 (line 440) | def squeezenet1_1(num_classes=1000, pretrained='imagenet'):
  function modify_vggs (line 456) | def modify_vggs(model):
  function vgg11 (line 495) | def vgg11(num_classes=1000, pretrained='imagenet'):
  function vgg11_bn (line 505) | def vgg11_bn(num_classes=1000, pretrained='imagenet'):
  function vgg13 (line 515) | def vgg13(num_classes=1000, pretrained='imagenet'):
  function vgg13_bn (line 525) | def vgg13_bn(num_classes=1000, pretrained='imagenet'):
  function vgg16 (line 535) | def vgg16(num_classes=1000, pretrained='imagenet'):
  function vgg16_bn (line 545) | def vgg16_bn(num_classes=1000, pretrained='imagenet'):
  function vgg19 (line 555) | def vgg19(num_classes=1000, pretrained='imagenet'):
  function vgg19_bn (line 565) | def vgg19_bn(num_classes=1000, pretrained='imagenet'):

FILE: pretrainedmodels/models/vggm.py
  class SpatialCrossMapLRN (line 24) | class SpatialCrossMapLRN(nn.Module):
    method __init__ (line 25) | def __init__(self, local_size=1, alpha=1.0, beta=0.75, k=1, ACROSS_CHA...
    method forward (line 40) | def forward(self, x):
  class LambdaBase (line 52) | class LambdaBase(nn.Sequential):
    method __init__ (line 53) | def __init__(self, fn, *args):
    method forward_prepare (line 57) | def forward_prepare(self, input):
  class Lambda (line 63) | class Lambda(LambdaBase):
    method forward (line 64) | def forward(self, input):
  class VGGM (line 67) | class VGGM(nn.Module):
    method __init__ (line 69) | def __init__(self, num_classes=1000):
    method forward (line 99) | def forward(self, x):
  function vggm (line 105) | def vggm(num_classes=1000, pretrained='imagenet'):

FILE: pretrainedmodels/models/wideresnet.py
  function define_model (line 15) | def define_model(params):
  class WideResNet (line 58) | class WideResNet(nn.Module):
    method __init__ (line 60) | def __init__(self, pooling):
    method forward (line 65) | def forward(self, x):
  function wideresnet50 (line 70) | def wideresnet50(pooling):

FILE: pretrainedmodels/models/xception.py
  class SeparableConv2d (line 50) | class SeparableConv2d(nn.Module):
    method __init__ (line 51) | def __init__(self,in_channels,out_channels,kernel_size=1,stride=1,padd...
    method forward (line 57) | def forward(self,x):
  class Block (line 63) | class Block(nn.Module):
    method __init__ (line 64) | def __init__(self,in_filters,out_filters,reps,strides=1,start_with_rel...
    method forward (line 101) | def forward(self,inp):
  class Xception (line 114) | class Xception(nn.Module):
    method __init__ (line 119) | def __init__(self, num_classes=1000):
    method features (line 172) | def features(self, input):
    method logits (line 202) | def logits(self, features):
    method forward (line 210) | def forward(self, input):
  function xception (line 216) | def xception(num_classes=1000, pretrained='imagenet'):

FILE: pretrainedmodels/utils.py
  class ToSpaceBGR (line 9) | class ToSpaceBGR(object):
    method __init__ (line 11) | def __init__(self, is_bgr):
    method __call__ (line 14) | def __call__(self, tensor):
  class ToRange255 (line 23) | class ToRange255(object):
    method __init__ (line 25) | def __init__(self, is_255):
    method __call__ (line 28) | def __call__(self, tensor):
  class TransformImage (line 34) | class TransformImage(object):
    method __init__ (line 36) | def __init__(self, opts, scale=0.875, random_crop=False,
    method __call__ (line 79) | def __call__(self, img):
  class LoadImage (line 84) | class LoadImage(object):
    method __init__ (line 86) | def __init__(self, space='RGB'):
    method __call__ (line 89) | def __call__(self, path_img):
  class LoadTransformImage (line 96) | class LoadTransformImage(object):
    method __init__ (line 98) | def __init__(self, model, scale=0.875):
    method __call__ (line 102) | def __call__(self, path_img):
  class Identity (line 108) | class Identity(nn.Module):
    method __init__ (line 110) | def __init__(self):
    method forward (line 113) | def forward(self, x):

FILE: tests/test_pm_imagenet.py
  function equal (line 20) | def equal(x,y):
  function test_pm_imagenet (line 24) | def test_pm_imagenet(model_name, pretrained):

FILE: tests/test_torch_save.py
  function test_torch_save (line 15) | def test_torch_save(model_name, pretrained, tmp_path):
Condensed preview — 44 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (500K chars).
[
  {
    "path": ".gitignore",
    "chars": 1194,
    "preview": "# Added by ~ cadene ~\n.DS_Store\n._.DS_Store\n\n# Byte-compiled / optimized / DLL files\n__pycache__/\n*.py[cod]\n*$py.class\n\n"
  },
  {
    "path": ".travis.yml",
    "chars": 3788,
    "preview": "language: python\npython:\n  - \"3.6\"\n # - \"2.7\"\n\n# cache:\n#   directories:\n#     - $HOME/.torch\n\nstages:\n#  - lint_check\n "
  },
  {
    "path": "LICENSE.txt",
    "chars": 1511,
    "preview": "BSD 3-Clause License\n\nCopyright (c) 2017, Remi Cadene\nAll rights reserved.\n\nRedistribution and use in source and binary "
  },
  {
    "path": "README.md",
    "chars": 29321,
    "preview": "# Pretrained models for Pytorch (Work in progress)\n\nThe goal of this repo is:\n\n- to help to reproduce research papers re"
  },
  {
    "path": "data/imagenet_classes.txt",
    "chars": 9999,
    "preview": "n01440764\nn01443537\nn01484850\nn01491361\nn01494475\nn01496331\nn01498041\nn01514668\nn01514859\nn01518878\nn01530575\nn01531178\n"
  },
  {
    "path": "data/imagenet_synsets.txt",
    "chars": 56691,
    "preview": "????????? dummy class for index 0\nn02119789 kit fox, Vulpes macrotis\nn02100735 English setter\nn02110185 Siberian husky\nn"
  },
  {
    "path": "examples/imagenet_eval.py",
    "chars": 10785,
    "preview": "from __future__ import print_function, division, absolute_import\nimport argparse\nimport os\nimport shutil\nimport time\n\nim"
  },
  {
    "path": "examples/imagenet_logits.py",
    "chars": 2419,
    "preview": "from __future__ import print_function, division, absolute_import\nimport argparse\n\nfrom PIL import Image\nimport torch\nimp"
  },
  {
    "path": "examples/visu_arch.py",
    "chars": 8750,
    "preview": "from __future__ import print_function, division, absolute_import\nimport os\n\nimport torch # http://pytorch.org/about/\nfro"
  },
  {
    "path": "examples/voc2007_extract.py",
    "chars": 8625,
    "preview": "from __future__ import print_function, division, absolute_import\nimport os\nimport argparse\nfrom tqdm import tqdm\n\nimport"
  },
  {
    "path": "pretrainedmodels/__init__.py",
    "chars": 2210,
    "preview": "from .version import __version__\n\nfrom . import models\nfrom . import datasets\n\nfrom .models.utils import pretrained_sett"
  },
  {
    "path": "pretrainedmodels/datasets/__init__.py",
    "chars": 103,
    "preview": "from __future__ import print_function, division, absolute_import\nfrom .voc import Voc2007Classification"
  },
  {
    "path": "pretrainedmodels/datasets/utils.py",
    "chars": 7320,
    "preview": "from __future__ import print_function, division, absolute_import\nimport math\nfrom six.moves.urllib.request import urlret"
  },
  {
    "path": "pretrainedmodels/datasets/voc.py",
    "chars": 8913,
    "preview": "from __future__ import print_function, division, absolute_import\nimport csv\nimport os\nimport os.path\nimport tarfile\nfrom"
  },
  {
    "path": "pretrainedmodels/models/__init__.py",
    "chars": 1735,
    "preview": "from __future__ import print_function, division, absolute_import\nfrom .fbresnet import fbresnet152\n\nfrom .cafferesnet im"
  },
  {
    "path": "pretrainedmodels/models/bninception.py",
    "chars": 43022,
    "preview": "from __future__ import print_function, division, absolute_import\nimport torch\nimport torch.nn as nn\nimport torch.nn.func"
  },
  {
    "path": "pretrainedmodels/models/cafferesnet.py",
    "chars": 5568,
    "preview": "from __future__ import print_function, division, absolute_import\nimport math\nimport torch\nimport torch.nn as nn\nimport t"
  },
  {
    "path": "pretrainedmodels/models/dpn.py",
    "chars": 18182,
    "preview": "\"\"\" PyTorch implementation of DualPathNetworks\nPorted to PyTorch by [Ross Wightman](https://github.com/rwightman/pytorch"
  },
  {
    "path": "pretrainedmodels/models/fbresnet/resnet152_dump.lua",
    "chars": 1136,
    "preview": "require 'cutorch'\nrequire 'cunn'\nrequire 'cudnn'\nrequire 'image'\nvision=require 'torchnet-vision'\n\nnet=vision.models.res"
  },
  {
    "path": "pretrainedmodels/models/fbresnet/resnet152_load.py",
    "chars": 9088,
    "preview": "from __future__ import print_function, division, absolute_import\nimport torch.nn as nn\nimport math\nimport torch.utils.mo"
  },
  {
    "path": "pretrainedmodels/models/fbresnet.py",
    "chars": 7271,
    "preview": "from __future__ import print_function, division, absolute_import\nimport torch.nn as nn\nimport torch.nn.functional as F\ni"
  },
  {
    "path": "pretrainedmodels/models/inceptionresnetv2.py",
    "chars": 12055,
    "preview": "from __future__ import print_function, division, absolute_import\nimport torch\nimport torch.nn as nn\nimport torch.utils.m"
  },
  {
    "path": "pretrainedmodels/models/inceptionv4.py",
    "chars": 11479,
    "preview": "from __future__ import print_function, division, absolute_import\nimport torch\nimport torch.nn as nn\nimport torch.nn.func"
  },
  {
    "path": "pretrainedmodels/models/nasnet.py",
    "chars": 30388,
    "preview": "from __future__ import print_function, division, absolute_import\nimport torch\nimport torch.nn as nn\nimport torch.nn.func"
  },
  {
    "path": "pretrainedmodels/models/nasnet_mobile.py",
    "chars": 31031,
    "preview": "\"\"\"\nNASNet Mobile\nThanks to Anastasiia (https://github.com/DagnyT) for the great help, support and motivation!\n\n\n-------"
  },
  {
    "path": "pretrainedmodels/models/pnasnet.py",
    "chars": 17983,
    "preview": "from __future__ import print_function, division, absolute_import\nfrom collections import OrderedDict\n\nimport torch\nimpor"
  },
  {
    "path": "pretrainedmodels/models/polynet.py",
    "chars": 17279,
    "preview": "from __future__ import print_function, division, absolute_import\nimport torch\nimport torch.nn as nn\nfrom torch.utils imp"
  },
  {
    "path": "pretrainedmodels/models/resnext.py",
    "chars": 3699,
    "preview": "from __future__ import print_function, division, absolute_import\nimport os\nimport torch\nimport torch.nn as nn\nimport tor"
  },
  {
    "path": "pretrainedmodels/models/resnext_features/__init__.py",
    "chars": 194,
    "preview": "from __future__ import print_function, division, absolute_import\nfrom .resnext101_32x4d_features import resnext101_32x4d"
  },
  {
    "path": "pretrainedmodels/models/resnext_features/resnext101_32x4d_features.py",
    "chars": 27908,
    "preview": "from __future__ import print_function, division, absolute_import\nimport torch\nimport torch.nn as nn\nfrom torch.autograd "
  },
  {
    "path": "pretrainedmodels/models/resnext_features/resnext101_64x4d_features.py",
    "chars": 28673,
    "preview": "from __future__ import print_function, division, absolute_import\nimport torch\nimport torch.nn as nn\nfrom torch.autograd "
  },
  {
    "path": "pretrainedmodels/models/senet.py",
    "chars": 16721,
    "preview": "\"\"\"\nResNet code gently borrowed from\nhttps://github.com/pytorch/vision/blob/master/torchvision/models/resnet.py\n\"\"\"\nfrom"
  },
  {
    "path": "pretrainedmodels/models/torchvision_models.py",
    "chars": 20596,
    "preview": "# -*- coding: utf-8 -*-\nfrom __future__ import print_function, division, absolute_import\nimport torchvision.models as mo"
  },
  {
    "path": "pretrainedmodels/models/utils.py",
    "chars": 1573,
    "preview": "from __future__ import print_function, division, absolute_import\nfrom .fbresnet import pretrained_settings as fbresnet_s"
  },
  {
    "path": "pretrainedmodels/models/vggm.py",
    "chars": 4048,
    "preview": "from __future__ import print_function, division, absolute_import\nimport torch\nimport torch.nn as nn\nfrom torch.autograd "
  },
  {
    "path": "pretrainedmodels/models/wideresnet.py",
    "chars": 2830,
    "preview": "from __future__ import print_function, division, absolute_import\nimport os\nfrom os.path import expanduser\nimport hickle "
  },
  {
    "path": "pretrainedmodels/models/xception.py",
    "chars": 7632,
    "preview": "\"\"\"\nPorted to pytorch thanks to [tstandley](https://github.com/tstandley/Xception-PyTorch)\n\n@author: tstandley\nAdapted b"
  },
  {
    "path": "pretrainedmodels/utils.py",
    "chars": 3154,
    "preview": "from __future__ import print_function, division, absolute_import\nimport math\nimport torch\nimport torch.nn as nn\nimport t"
  },
  {
    "path": "pretrainedmodels/version.py",
    "chars": 87,
    "preview": "from __future__ import print_function, division, absolute_import\n__version__ = '0.7.4'\n"
  },
  {
    "path": "requirements.txt",
    "chars": 35,
    "preview": "torch\ntorchvision\nmunch\ntqdm\nscipy\n"
  },
  {
    "path": "setup.cfg",
    "chars": 39,
    "preview": "[metadata]\ndescription-file = README.md"
  },
  {
    "path": "setup.py",
    "chars": 6643,
    "preview": "from __future__ import print_function, division, absolute_import\n\"\"\"A setuptools based setup module.\n\nSee:\nhttps://packa"
  },
  {
    "path": "tests/test_pm_imagenet.py",
    "chars": 1670,
    "preview": "import pytest\nimport torch\nimport torch.nn as nn\nfrom torch.autograd import Variable\nimport pretrainedmodels as pm\nimpor"
  },
  {
    "path": "tests/test_torch_save.py",
    "chars": 730,
    "preview": "import pytest\nimport torch\nimport pretrainedmodels as pm\n\n\n# TODO: put \"pm_args\" into fixture to share with all tests?\np"
  }
]

About this extraction

This page contains the full source code of the Cadene/pretrained-models.pytorch GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 44 files (472.7 KB), approximately 140.9k tokens, and a symbol index with 485 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!