提交 6339af81 编写于 作者: L linjintao 提交者: lizz

Fix order number display bug in readme

上级 7639c477
......@@ -69,27 +69,27 @@ Assume that you have already downloaded the checkpoints to the directory `checkp
1. Test I3D on Kinetics-400 (without saving the test results) and evaluate the top-k accuracy and mean class accuracy.
```shell
python tools/test.py config/i3d_rgb_32x2x1_r50_3d_kinetics400_100e.py \
checkpoints/SOME_CHECKPOINT.pth \
--eval top_k_accuracy mean_class_accuracy
```
```shell
python tools/test.py config/i3d_rgb_32x2x1_r50_3d_kinetics400_100e.py \
checkpoints/SOME_CHECKPOINT.pth \
--eval top_k_accuracy mean_class_accuracy
```
2. Test TSN on Something-Something V1 with 8 GPUS, and evaluate the top-k accuracy.
```shell
python tools/test.py config/tsn_rgb_1x1x8_r50_2d_sthv1_50e.py \
checkpoints/SOME_CHECKPOINT.pth \
8 --out results.pkl --eval top_k_accuracy
```
```shell
python tools/test.py config/tsn_rgb_1x1x8_r50_2d_sthv1_50e.py \
checkpoints/SOME_CHECKPOINT.pth \
8 --out results.pkl --eval top_k_accuracy
```
3. Test I3D on Kinetics-400 in slurm environment and evaluate the top-k accuracy
```shell
python tools/test.py config/i3d_rgb_32x2x1_r50_3d_kinetics400_100e.py \
checkpoints/SOME_CHECKPOINT.pth \
--launcher slurm --eval top_k_accuracy
```
```shell
python tools/test.py config/i3d_rgb_32x2x1_r50_3d_kinetics400_100e.py \
checkpoints/SOME_CHECKPOINT.pth \
--launcher slurm --eval top_k_accuracy
```
### Video demo
......@@ -151,12 +151,12 @@ in [TSM: Temporal Shift Module for Efficient Video Understanding](https://arxiv.
1. create a new file in `mmaction/models/backbones/resnet_tsm.py`.
```python
from ..registry import BACKBONES
from .resnet import ResNet
```python
from ..registry import BACKBONES
from .resnet import ResNet
@BACKBONES.register_module()
class ResNetTSM(ResNet):
@BACKBONES.register_module()
class ResNetTSM(ResNet):
def __init__(self,
depth,
......@@ -171,33 +171,31 @@ in [TSM: Temporal Shift Module for Efficient Video Understanding](https://arxiv.
def forward(self, x):
# implementation is ignored
pass
```
```
2. Import the module in `mmaction/models/backbones/__init__.py`
```python
from .resnet_tsm import ResNetTSM
```
```python
from .resnet_tsm import ResNetTSM
```
3. modify the config file from
```python
backbone=dict(
```python
backbone=dict(
type='ResNet',
pretrained='torchvision://resnet50',
depth=50,
norm_eval=False)
```
to
```python
backbone=dict(
```
to
```python
backbone=dict(
type='ResNetTSM',
pretrained='torchvision://resnet50',
depth=50,
norm_eval=False,
shift_div=8)
```
```
### Write a new model
......@@ -403,13 +401,13 @@ Params: 28.04 M
You may well use the result for simple comparisons, but double check it before you adopt it in technical reports or papers.
(1) FLOPs are related to the input shape while parameters are not. The default input shape is (1, 3, 340, 256) for 2D recognizer, (1, 3, 32, 340, 256) for 3D recognizer.
(2) Some custom operators are not counted into FLOPs.
You can add support for new operators by modifying [`mmaction/utils/flops_counter.py`](../mmaction/utils/file_client.py).
(2) Some custom operators are not counted into FLOPs. You can add support for new operators by modifying [`mmaction/utils/flops_counter.py`](../mmaction/utils/file_client.py).
### Publish a model
Before you upload a model to AWS, you may want to
(1) convert model weights to CPU tensors, (2) delete the optimizer states and
Before you upload a model to AWS, you may want to:
(1) convert model weights to CPU tensors.
(2) delete the optimizer states.
(3) compute the hash of the checkpoint file and append the hash id to the filename.
```shell
......@@ -613,75 +611,75 @@ Here we show how to develop new components with an example of TSN.
1. Create a new file `mmaction/models/backbones/resnet.py`.
```python
import torch.nn as nn
```python
import torch.nn as nn
from ..registry import BACKBONES
from ..registry import BACKBONES
@BACKBONES.register_module()
class ResNet(nn.Module):
@BACKBONES.register_module()
class ResNet(nn.Module):
def __init__(self, arg1, arg2):
pass
def __init__(self, arg1, arg2):
pass
def forward(self, x): # should return a tuple
pass
def forward(self, x): # should return a tuple
pass
def init_weights(self, pretrained=None):
pass
```
def init_weights(self, pretrained=None):
pass
```
2. Import the module in `mmaction/models/backbones/__init__.py`.
```python
from .resnet import ResNet
```
```python
from .resnet import ResNet
```
3. Create a new file `mmaction/models/heads/tsn_head.py`.
You can write a new classification head inherit from [BaseHead](../mmaction/models/heads/base.py),
and overwrite `init_weights(self)` and `forward(self, x)` method.
You can write a new classification head inherit from [BaseHead](../mmaction/models/heads/base.py),
and overwrite `init_weights(self)` and `forward(self, x)` method.
```python
from ..registry import HEADS
from .base import BaseHead
```python
from ..registry import HEADS
from .base import BaseHead
@HEADS.register_module()
class TSNHead(BaseHead):
@HEADS.register_module()
class TSNHead(BaseHead):
def __init__(self, arg1, arg2):
pass
def __init__(self, arg1, arg2):
pass
def forward(self, x):
pass
def forward(self, x):
pass
def init_weights(self):
pass
```
def init_weights(self):
pass
```
4. Import the module in `mmaction/models/heads/__init__.py`
```python
from .tsn_head import TSNHead
```
```python
from .tsn_head import TSNHead
```
5. Use it in your config file.
Since TSN is a 2D action recognition model, we set its type `Recognizer2D`.
```python
model = dict(
type='Recognizer2D',
backbone=dict(
type='ResNet',
arg1=xxx,
arg2=xxx),
cls_head=dict(
type='TSNHead',
arg1=xxx,
arg2=xxx))
```
Since TSN is a 2D action recognition model, we set its type `Recognizer2D`.
```python
model = dict(
type='Recognizer2D',
backbone=dict(
type='ResNet',
arg1=xxx,
arg2=xxx),
cls_head=dict(
type='TSNHead',
arg1=xxx,
arg2=xxx))
```
## Tutorials
......
......@@ -69,50 +69,50 @@ Use environment variable `MMACTION_MODEL_CONVERT=1` to control execution trainin
1) code prepare
```
git clone git@gitlab.sz.sensetime.com:open-mmlab/mmaction-lite.git
git clone git@gitlab.bj.sensetime.com:platform/ParrotsDL/parrots.convert.git
```
contact `luopeichao@sensetime.com` for `parrots.convert` permission.
```
git clone git@gitlab.sz.sensetime.com:open-mmlab/mmaction-lite.git
git clone git@gitlab.bj.sensetime.com:platform/ParrotsDL/parrots.convert.git
```
contact `luopeichao@sensetime.com` for `parrots.convert` permission.
2) install mmaction and parrots.convert
```
cd mmaction-lite
pip install -e .
```
and
```
cd parrots.convert
pip install -e .
```
```
cd mmaction-lite
pip install -e .
```
and
```
cd parrots.convert
pip install -e .
```
3) enter work directory
```
cd parrots.convert/tools/mmaction
```
```
cd parrots.convert/tools/mmaction
```
4) execute ./run.sh
```
./run.sh Platform --model=SlowFast3D --config=./tests/slowfast/slowfast_32x2x1_r50_3d_kinetics400_256e.py --checkpoint=./tests/slowfast/epoch.pth --mergebn --savedir=caffe_model_slowfast --inputsize="6,3,32,224,224"
```
```
./run.sh Platform --model=SlowFast3D --config=./tests/slowfast/slowfast_32x2x1_r50_3d_kinetics400_256e.py --checkpoint=./tests/slowfast/epoch.pth --mergebn --savedir=caffe_model_slowfast --inputsize="6,3,32,224,224"
```
the args of **./run.sh**, first is cluster partition, all the following are python args.
the args of **./run.sh**, first is cluster partition, all the following are python args.
The python args are illustrated below.
The python args are illustrated below.
|args|description|other|
|---|---|---|
|--model|The name of the model that needs to be converted|required|
|--config|path of the config|required|
|--checkpoint|path of the checkpoint|required|
|--batchsize|batchsize of the input data|optional, default:8|
|--mergebn|merger bn layer|optional, default:false|
|--savedir|the directory where the transformed model is saved|optional, default:caffe_model|
|--inputsize|size of the input data, for example, "8,8,3,224,224"|required|
--saveinput|whether to save the generated input data|optional, default:false|
|args|description|other|
|---|---|---|
|--model|The name of the model that needs to be converted|required|
|--config|path of the config|required|
|--checkpoint|path of the checkpoint|required|
|--batchsize|batchsize of the input data|optional, default:8|
|--mergebn|merger bn layer|optional, default:false|
|--savedir|the directory where the transformed model is saved|optional, default:caffe_model|
|--inputsize|size of the input data, for example, "8,8,3,224,224"|required|
--saveinput|whether to save the generated input data|optional, default:false|
### Model Convert (Parrots to Pytorch)
......
......@@ -102,41 +102,41 @@ Here we show how to develop new components with an example of TSN.
1. Create a new file `mmaction/models/backbones/resnet.py`.
```python
import torch.nn as nn
```python
import torch.nn as nn
from ..registry import BACKBONES
from ..registry import BACKBONES
@BACKBONES.register_module()
class ResNet(nn.Module):
@BACKBONES.register_module()
class ResNet(nn.Module):
def __init__(self, arg1, arg2):
pass
def __init__(self, arg1, arg2):
pass
def forward(self, x): # should return a tuple
pass
def forward(self, x): # should return a tuple
pass
def init_weights(self, pretrained=None):
pass
```
def init_weights(self, pretrained=None):
pass
```
2. Import the module in `mmaction/models/backbones/__init__.py`.
```python
from .resnet import ResNet
```
```python
from .resnet import ResNet
```
3. Use it in your config file.
```python
model = dict(
...
backbone=dict(
type='ResNet',
arg1=xxx,
arg2=xxx),
)
```
```python
model = dict(
...
backbone=dict(
type='ResNet',
arg1=xxx,
arg2=xxx),
)
```
### Add new heads
......@@ -144,45 +144,45 @@ Here we show how to develop a new head with the example of TSNHead as the follow
1. Create a new file `mmaction/models/heads/tsn_head.py`.
You can write a new classification head inheriting from [BaseHead](../mmaction/models/heads/base.py),
and overwrite `init_weights(self)` and `forward(self, x)` method.
You can write a new classification head inheriting from [BaseHead](../mmaction/models/heads/base.py),
and overwrite `init_weights(self)` and `forward(self, x)` method.
```python
from ..registry import HEADS
from .base import BaseHead
```python
from ..registry import HEADS
from .base import BaseHead
@HEADS.register_module()
class TSNHead(BaseHead):
@HEADS.register_module()
class TSNHead(BaseHead):
def __init__(self, arg1, arg2):
pass
def __init__(self, arg1, arg2):
pass
def forward(self, x):
pass
def forward(self, x):
pass
def init_weights(self):
pass
```
def init_weights(self):
pass
```
2. Import the module in `mmaction/models/heads/__init__.py`
```python
from .tsn_head import TSNHead
```
```python
from .tsn_head import TSNHead
```
3. Use it in your config file
```python
model = dict(
...
cls_head=dict(
type='TSNHead',
num_classes=400,
in_channels=2048,
arg1=xxx,
arg2=xxx),
```
```python
model = dict(
...
cls_head=dict(
type='TSNHead',
num_classes=400,
in_channels=2048,
arg1=xxx,
arg2=xxx),
```
### Add new loss
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册