Skip to content

Commit

Permalink
ResNeSt plus (zhanghang1989#256)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanghang1989 committed Apr 18, 2020
1 parent 5a1e3fb commit b872eb8
Show file tree
Hide file tree
Showing 103 changed files with 5,360 additions and 2,674 deletions.
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/github-script@0.3.0
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/github-script@0.3.0
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

0 comments on commit b872eb8

Please sign in to comment.