Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ResNeSt plus #256

Merged
merged 46 commits into from
Apr 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
986ea5d
patch
zhanghang1989 Mar 16, 2020
e0e2878
merge some private work
zhanghang1989 Mar 16, 2020
98cbd80
rectify
zhanghang1989 Mar 17, 2020
07889d8
rectify conv and cifar training
zhanghang1989 Mar 18, 2020
305af8e
distributed training ready
zhanghang1989 Mar 20, 2020
962b1a7
distributed training
zhanghang1989 Mar 20, 2020
c7a402d
rectify conv
zhanghang1989 Mar 20, 2020
114c5e9
mixup and label smoothing
zhanghang1989 Mar 21, 2020
9e8e3a4
add transforms
zhanghang1989 Mar 21, 2020
bbf985b
warmup no bias decay
zhanghang1989 Mar 21, 2020
cc345c8
reorg script
zhanghang1989 Mar 21, 2020
4419018
wip resnest
zhanghang1989 Mar 22, 2020
01a6e22
resnest
zhanghang1989 Mar 22, 2020
19d8f6d
wip
zhanghang1989 Mar 24, 2020
4639e8e
dist syncbn and other models wip
zhanghang1989 Mar 31, 2020
eaa0301
add files
zhanghang1989 Mar 31, 2020
e9faeb4
fix resnext and wip
zhanghang1989 Apr 5, 2020
1278374
fix
zhanghang1989 Apr 5, 2020
45ed75b
wip
zhanghang1989 Apr 5, 2020
56391e3
Merge remote-tracking branch 'origin/master' into resnest
zhanghang1989 Apr 5, 2020
82ebbbc
fix merge issues
zhanghang1989 Apr 5, 2020
7935bd6
license badge and rm deprecated
zhanghang1989 Apr 6, 2020
3b00161
Merge remote-tracking branch 'origin/master' into resnest
zhanghang1989 Apr 6, 2020
9ddb5e2
seg distributed training okay
zhanghang1989 Apr 7, 2020
85d2580
training okay now
zhanghang1989 Apr 7, 2020
c1d9ec6
refactor and segmentation train test
zhanghang1989 Apr 10, 2020
f5777c9
add missing files
zhanghang1989 Apr 10, 2020
e7a58d5
Merge remote-tracking branch 'origin/master' into resnest
zhanghang1989 Apr 11, 2020
b836bd6
Revert "Update build_sphix_master.yml"
zhanghang1989 Apr 11, 2020
63aa533
wip
zhanghang1989 Apr 15, 2020
ee18d9a
inpace ABN
zhanghang1989 Apr 15, 2020
f27fcb9
name
zhanghang1989 Apr 15, 2020
1823cf3
add crop-size
zhanghang1989 Apr 15, 2020
80c1a9a
ci
zhanghang1989 Apr 15, 2020
f1b3022
change pr build doc
zhanghang1989 Apr 15, 2020
1da2599
rm secrets
zhanghang1989 Apr 15, 2020
7705985
no need setup python
zhanghang1989 Apr 15, 2020
ca71f2e
url
zhanghang1989 Apr 15, 2020
2d5523f
fix cmd
zhanghang1989 Apr 15, 2020
4ea5cb9
add citation
zhanghang1989 Apr 15, 2020
8a4ef34
doc indent
zhanghang1989 Apr 15, 2020
4877c73
Update README.md
zhanghang1989 Apr 16, 2020
82a3600
Update README.md
zhanghang1989 Apr 16, 2020
c50900c
docs
zhanghang1989 Apr 17, 2020
f657170
Merge branch 'resnest_plus' of github.com:zhanghang1989/PyTorch-Encod…
zhanghang1989 Apr 18, 2020
6d84141
add crop size
zhanghang1989 Apr 18, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
name: Upload Python Package

on:
push:
branches:
- master
schedule:
- cron: "0 12 * * *"

jobs:
deploy:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
build_dir: "docs/build/html/*"
build_dir: docs/build/html/
target_branch: gh-pages
45 changes: 13 additions & 32 deletions .github/workflows/sphix_build_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,21 @@ on:

jobs:
docs:
runs-on: ubuntu-latest
runs-on: self-hosted
steps:
- uses: actions/checkout@v2
- uses: seanmiddleditch/gha-setup-ninja@master
- name: Set up Python
uses: actions/setup-python@v1

- name: Set PR Number
uses: actions/[email protected]
with:
python-version: 3.7

github-token: ${{github.token}}
script: |
const core = require('@actions/core')
const prNumber = context.payload.number;
core.exportVariable('PULL_NUMBER', prNumber);
core.exportVariable("PATH", "/home/ubuntu/anaconda3/bin:/usr/local/bin:/usr/bin/:/bin:$PATH")

- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -39,35 +44,11 @@ jobs:
cd docs/
make html
touch build/html/.nojekyll

- name: Set PR Number
uses: actions/[email protected]
with:
github-token: ${{github.token}}
script: |
const core = require('@actions/core')
const prNumber = context.payload.number;
core.exportVariable('PULL_NUMBER', prNumber);


# https://github.com/marketplace/actions/github-pages
- name: Deploy
if: success()
uses: jakejarvis/s3-sync-action@master
with:
args: --acl public-read --follow-symlinks --delete
env:
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
DEST_DIR: "${{ secrets.DEST_DIR }}/${PULL_NUMBER}"
SOURCE_DIR: 'docs/build/html/'

aws s3 sync build/html/ s3://hangzh/encoding/docs/${{ env.PULL_NUMBER }}/ --acl public-read --follow-symlinks --delete

- name: Comment
if: success()
uses: thollander/actions-comment-pull-request@master
with:
message: "The docs are uploaded and can be previewed at http://${{ secrets.AWS_S3_BUCKET }}.s3.amazonaws.com/${{ secrets.DEST_DIR }}/${{ env.PULL_NUMBER }}/index.html"
message: "The docs are uploaded and can be previewed at http://hangzh.s3.amazonaws.com/encoding/docs/${{ env.PULL_NUMBER }}/index.html"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ docs/src/
docs/html/
encoding/_ext/
encoding.egg-info/
*.o
*.so
*.ninja*
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[![PyPI](https://img.shields.io/pypi/v/torch-encoding.svg)](https://pypi.python.org/pypi/torch-encoding)
[![PyPI Pre-release](https://img.shields.io/badge/pypi--prerelease-v1.1.0-ff69b4.svg)](https://pypi.org/project/torch-encoding/#history)
[![PyPI Pre-release](https://img.shields.io/badge/pypi--prerelease-v1.2.0-ff69b4.svg)](https://pypi.org/project/torch-encoding/#history)
[![Upload Python Package](https://github.com/zhanghang1989/PyTorch-Encoding/workflows/Upload%20Python%20Package/badge.svg)](https://github.com/zhanghang1989/PyTorch-Encoding/actions)
[![Downloads](http://pepy.tech/badge/torch-encoding)](http://pepy.tech/project/torch-encoding)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Build Docs](https://github.com/zhanghang1989/PyTorch-Encoding/workflows/Build%20Docs/badge.svg)](https://github.com/zhanghang1989/PyTorch-Encoding/actions)
# PyTorch-Encoding

Expand All @@ -11,10 +12,23 @@ created by [Hang Zhang](http://hangzh.com/)

- Please visit the [**Docs**](http://hangzh.com/PyTorch-Encoding/) for detail instructions of installation and usage.

- Please visit the [link](http://hangzh.com/PyTorch-Encoding/experiments/segmentation.html) to examples of semantic segmentation.
- Please visit the [link](http://hangzh.com/PyTorch-Encoding/model_zoo/imagenet.html) to image classification models.

- Please visit the [link](http://hangzh.com/PyTorch-Encoding/model_zoo/segmentation.html) to semantic segmentation models.

## Citations

**ResNeSt: Split-Attention Networks** [[arXiv]]()
[Hang Zhang](http://hangzh.com/), Chongruo Wu, Zhongyue Zhang, Yi Zhu, Zhi Zhang, Haibin Lin, Yue Sun, Tong He, Jonas Muller, R. Manmatha, Mu Li and Alex Smola
```
@article{zhang2020resnest,
title={ResNeSt: Split-Attention Networks},
author={Zhang, Hang and Wu, Chongruo and Zhang, Zhongyue and Zhu, Yi and Zhang, Zhi and Lin, Haibin and Sun, Yue and He, Tong and Muller, Jonas and Manmatha, R. and Li, Mu and Smola, Alexander},
journal={arXiv preprint},
year={2020}
}
```

**Context Encoding for Semantic Segmentation** [[arXiv]](https://arxiv.org/pdf/1803.08904.pdf)
[Hang Zhang](http://hangzh.com/), [Kristin Dana](http://eceweb1.rutgers.edu/vision/dana.html), [Jianping Shi](http://shijianping.me/), [Zhongyue Zhang](http://zhongyuezhang.com/), [Xiaogang Wang](http://www.ee.cuhk.edu.hk/~xgwang/), [Ambrish Tyagi](https://scholar.google.com/citations?user=GaSWCoUAAAAJ&hl=en), [Amit Agrawal](http://www.amitkagrawal.com/)
```
Expand Down
14 changes: 10 additions & 4 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,30 @@ An optimized PyTorch package with CUDA backend.
.. toctree::
:glob:
:maxdepth: 1
:caption: Notes
:caption: Installation

notes/*

.. toctree::
:glob:
:maxdepth: 1
:caption: Experiment Systems
:caption: Model Zoo

experiments/*
model_zoo/*

.. toctree::
:glob:
:maxdepth: 1
:caption: Other Tutorials

tutorials/*

.. toctree::
:maxdepth: 1
:caption: Package Reference

nn
parallel
models
utils

Indices and tables
Expand Down
83 changes: 83 additions & 0 deletions docs/source/model_zoo/imagenet.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
Image Classification
====================

Install Package
---------------

- Clone the GitHub repo::

git clone https://github.com/zhanghang1989/PyTorch-Encoding

- Install PyTorch Encoding (if not yet). Please follow the installation guide `Installing PyTorch Encoding <../notes/compile.html>`_.

Get Pre-trained Model
---------------------

.. hint::
How to get pretrained model, for example ``ResNeSt50``::

model = encoding.models.get_model('ResNeSt50', pretrained=True)

After clicking ``cmd`` in the table, the command for training the model can be found below the table.

.. role:: raw-html(raw)
:format: html


ResNeSt
~~~~~~~

.. note::
The provided models were trained using MXNet Gluon, this PyTorch implementation is slightly worse than the original implementation.

=============================== ============== ============== =========================================================================================================
Model crop-size Acc Command
=============================== ============== ============== =========================================================================================================
ResNeSt-50 224 81.03 :raw-html:`<a href="javascript:toggleblock('cmd_resnest50')" class="toggleblock">cmd</a>`
ResNeSt-101 256 82.83 :raw-html:`<a href="javascript:toggleblock('cmd_resnest101')" class="toggleblock">cmd</a>`
ResNeSt-200 320 83.84 :raw-html:`<a href="javascript:toggleblock('cmd_resnest200')" class="toggleblock">cmd</a>`
ResNeSt-269 416 84.54 :raw-html:`<a href="javascript:toggleblock('cmd_resnest269')" class="toggleblock">cmd</a>`
=============================== ============== ============== =========================================================================================================

.. raw:: html

<code xml:space="preserve" id="cmd_resnest50" style="display: none; text-align: left; white-space: pre-wrap">
# change the rank for worker node
python train_dist.py --dataset imagenet --model resnest50 --lr-scheduler cos --epochs 270 --checkname resnest50 --lr 0.025 --batch-size 64 --dist-url tcp://MASTER:NODE:IP:ADDRESS:23456 --world-size 4 --label-smoothing 0.1 --mixup 0.2 --no-bn-wd --last-gamma --warmup-epochs 5 --rand-aug --rank 0
</code>

<code xml:space="preserve" id="cmd_resnest101" style="display: none; text-align: left; white-space: pre-wrap">
# change the rank for worker node
python train_dist.py --dataset imagenet --model resnest101 --lr-scheduler cos --epochs 270 --checkname resnest101 --lr 0.025 --batch-size 64 --dist-url tcp://MASTER:NODE:IP:ADDRESS:23456 --world-size 4 --label-smoothing 0.1 --mixup 0.2 --no-bn-wd --last-gamma --warmup-epochs 5 --rand-aug --rank 0
</code>

<code xml:space="preserve" id="cmd_resnest200" style="display: none; text-align: left; white-space: pre-wrap">
# change the rank for worker node
python train_dist.py --dataset imagenet --model resnest200 --lr-scheduler cos --epochs 270 --checkname resnest200 --lr 0.0125 --batch-size 32 --dist-url tcp://MASTER:NODE:IP:ADDRESS:23456 --world-size 8 --label-smoothing 0.1 --mixup 0.2 --no-bn-wd --last-gamma --warmup-epochs 5 --rand-aug --crop-size 256 --rank 0
</code>

<code xml:space="preserve" id="cmd_resnest269" style="display: none; text-align: left; white-space: pre-wrap">
# change the rank for worker node
python train_dist.py --dataset imagenet --model resnest269 --lr-scheduler cos --epochs 270 --checkname resnest269 --lr 0.0125 --batch-size 32 --dist-url tcp://MASTER:NODE:IP:ADDRESS:23456 --world-size 8 --label-smoothing 0.1 --mixup 0.2 --no-bn-wd --last-gamma --warmup-epochs 5 --rand-aug --crop-size 320 --rank 0
</code>

Test Pretrained
~~~~~~~~~~~~~~~

- Prepare the datasets by downloading the data into current folder and then runing the scripts in the ``scripts/`` folder::

python scripts/prepare_imagenet.py --data-dir ./

- The test script is in the ``experiments/recognition/`` folder. For evaluating the model (using MS),
for example ``ResNeSt50``::

python test.py --dataset imagenet --model-zoo ResNeSt50 --crop-size 224 --eval

Train Your Own Model
--------------------

- Prepare the datasets by downloading the data into current folder and then runing the scripts in the ``scripts/`` folder::

python scripts/prepare_imagenet.py --data-dir ./

- The training script is in the ``experiments/recognition/`` folder. Commands for reproducing pre-trained models can be found in the table.
Loading