• Stars
    star
    227
  • Rank 175,900 (Top 4 %)
  • Language
    Python
  • Created almost 8 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Convert resnet trained in caffe to pytorch model. (group norm resnet is provided too)

pytorch-resnet

This repository contains codes for converting resnet50,101,152 trained in caffe to pytorch model.

First, you need to have pycaffe and pytorch. Secondly, you should download the caffe models from https://github.com/KaimingHe/deep-residual-networks. Put them in data folder.

Then,

python convert.py --mode caffe

or

python convert.py --mode pth

The models generated by convert.py --mode caffe expect different preprocessing than the other models in the PyTorch model zoo. Images should be in BGR format in the range [0, 255], and the following BGR values should then be subtracted from each pixel: [103.939, 116.779, 123.68].

The models generated by convert.py --mode pth expect RGB image ranging [0, 1]. You can use standard trn.Normalize([0.485, 0.456, 0.406],[0.229, 0.224, 0.225]).

Converted models (converted from convert.py --mode caffe, used in my pytorch-faster-rcnn repo)

resnet50-caffe: https://drive.google.com/open?id=0B7fNdx_jAqhtbllXbWxMVEdZclE

resnet101-caffe: https://drive.google.com/open?id=0B7fNdx_jAqhtaXZ4aWppWV96czg

resnet152-caffe: https://drive.google.com/open?id=0B7fNdx_jAqhtMXU1N0VTZkN1dHc

Converted models (converted from convert.py --mode pth, used in my neuraltalk2-pytorch repo)

resnet50: https://drive.google.com/uc?export=download&id=0B7fNdx_jAqhtam1MSTNSYXVYZ2s

resnet101: https://drive.google.com/uc?export=download&id=0B7fNdx_jAqhtSmdCNDVOVVdINWs

resnet152: https://drive.google.com/uc?export=download&id=0B7fNdx_jAqhtckNGQ2FLd25fa3c

Note

This model is different from what's in pytorch model zoo. Although you can actually load the parameters into the pytorch resnet, the strucuture of caffe resnet and torch resnet are slightly different. The structure is defined in the resnet.py. (The file is almost identical to what's in torchvision, with only some slight changes.)

Acknowledgement

A large part of the code is borrowed from https://github.com/ry/tensorflow-resnet


pytorch-resnet-gn

Convert group norm pretrained model to pytorch.

Requirement: torchvision 0.3

python convert_gn --layers 50 --mode pth

layers can be 50 and 101, mode can be pth or caffe. mode defines what you expect as input.

The converted checkpoint gets:

  • Resnet50+GN: Prec@1 75.716 Prec@5 92.596
  • Resnet101+GN: Prec@1 77.046 Prec@5 93.438

More Repositories

1

pytorch-faster-rcnn

pytorch1.0 updated. Support cpu test and demo. (Use detectron2, it's a masterpiece)
Jupyter Notebook
1,818
star
2

ImageCaptioning.pytorch

I decide to sync up this repo and self-critical.pytorch. (The old master is in old master branch for archive)
Python
1,349
star
3

self-critical.pytorch

Unofficial pytorch implementation for Self-critical Sequence Training for Image Captioning. and others.
Python
942
star
4

Image_Captioning_AI_Challenger

Code for AI Challenger contest. (Generating chinese image captions)
Python
210
star
5

Transformer_Captioning

Use transformer for captioning
Python
156
star
6

DiscCaptioning

Code for Discriminability objective for training descriptive captions(CVPR 2018)
Python
110
star
7

NeuralDialog-CVAE-pytorch

OpenEdge ABL
95
star
8

Faster-RCNN-Densecap-torch

Faster-RCNN based on Densecap(deprecated)
Jupyter Notebook
86
star
9

zsl-gcn-pth

zero-shot-gcn in pytorch
Python
72
star
10

neuraltalk2-tensorflow

Neuraltalk2 in tensorflow
Python
58
star
11

Context-aware-ZSR

Official code for paper Context-aware Zero-shot Recognition (https://arxiv.org/abs/1904.09320 to appear at AAAI2020)
Python
57
star
12

baipiao_jianying

η™½ε«–ε‰ͺζ˜ ηš„θ―­ιŸ³θ―†εˆ«οΌˆε­¦δΉ εˆ†δΊ«οΌ‰
Python
55
star
13

GoogleConceptualCaptioning

Python
53
star
14

pytorch-mobilenet-from-tf

Mobilenet model converted from tensorflow
Jupyter Notebook
49
star
15

bottom-up-attention-ai-challenger

Jupyter Notebook
38
star
16

lmdbdict

A simple wrapper for lmdb. Support dict-like operations.
Python
21
star
17

rtutils

Python
17
star
18

lazy_related_work

Python
14
star
19

refexp-comprehension

Referring expression comprehension on ReferIt(RefClef)
Lua
10
star
20

canada_us_visa_spotter

Python
7
star
21

ruotianluo.github.io

SCSS
4
star
22

play_with_jax

My attempt to learn jax.
2
star