rename lib to opengait
This commit is contained in:
@@ -98,7 +98,7 @@ See [prepare dataset](docs/0.prepare_dataset.md).
|
||||
### Train
|
||||
Train a model by
|
||||
```
|
||||
CUDA_VISIBLE_DEVICES=0,1 python -m torch.distributed.launch --nproc_per_node=2 lib/main.py --cfgs ./config/baseline.yaml --phase train
|
||||
CUDA_VISIBLE_DEVICES=0,1 python -m torch.distributed.launch --nproc_per_node=2 opengait/main.py --cfgs ./config/baseline.yaml --phase train
|
||||
```
|
||||
- `python -m torch.distributed.launch` [DDP](https://pytorch.org/tutorials/intermediate/ddp_tutorial.html) launch instruction.
|
||||
- `--nproc_per_node` The number of gpus to use, and it must equal the length of `CUDA_VISIBLE_DEVICES`.
|
||||
@@ -112,7 +112,7 @@ You can run commands in [train.sh](train.sh) for training different models.
|
||||
### Test
|
||||
Evaluate the trained model by
|
||||
```
|
||||
CUDA_VISIBLE_DEVICES=0,1 python -m torch.distributed.launch --nproc_per_node=2 lib/main.py --cfgs ./config/baseline.yaml --phase test
|
||||
CUDA_VISIBLE_DEVICES=0,1 python -m torch.distributed.launch --nproc_per_node=2 opengait/main.py --cfgs ./config/baseline.yaml --phase test
|
||||
```
|
||||
- `--phase` Specified as `test`.
|
||||
- `--iter` Specify a iteration checkpoint.
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
### model_cfg
|
||||
* Model to be trained
|
||||
> * Args
|
||||
> * model : Model type, please refer to [Model Library](../lib/modeling/models) for the supported values.
|
||||
> * model : Model type, please refer to [Model Library](../opengait/modeling/models) for the supported values.
|
||||
> * **others** : Please refer to the [Training Configuration File of Corresponding Model](../config).
|
||||
----
|
||||
### evaluator_cfg
|
||||
@@ -51,7 +51,7 @@
|
||||
> - type: The name of sampler. Choose `InferenceSampler`.
|
||||
> - sample_type: In general, we use `all_ordered` to input all frames by its natural order, which makes sure the tests are consistent.
|
||||
> - batch_size: `int` values.
|
||||
> - **others**: Please refer to [data.sampler](../lib/data/sampler.py) and [data.collate_fn](../lib/data/collate_fn.py)
|
||||
> - **others**: Please refer to [data.sampler](../opengait/data/sampler.py) and [data.collate_fn](../opengait/data/collate_fn.py)
|
||||
> * transform: Support `BaseSilCuttingTransform`, `BaseSilTransform`. The difference between them is `BaseSilCuttingTransform` cut out the black pixels on both sides horizontally.
|
||||
> * metric: `euc` or `cos`, generally, `euc` performs better.
|
||||
|
||||
@@ -73,7 +73,7 @@
|
||||
> - batch_size: *[P,K]* where `P` denotes the subjects in training batch while the `K` represents the sequences every subject owns. **Example**:
|
||||
> - 8
|
||||
> - 16
|
||||
> - **others**: Please refer to [data.sampler](../lib/data/sampler.py) and [data.collate_fn](../lib/data/collate_fn.py).
|
||||
> - **others**: Please refer to [data.sampler](../opengait/data/sampler.py) and [data.collate_fn](../opengait/data/collate_fn.py).
|
||||
> * **others**: Please refer to `evaluator_cfg`.
|
||||
---
|
||||
**Note**:
|
||||
|
||||
@@ -50,11 +50,11 @@ class NewModel(BaseModel):
|
||||
>
|
||||
> `embeddings`, `logits` and `labels` are the input arguments of the loss function.
|
||||
|
||||
More information should be seen in [base_model.py](../lib/modeling/base_model.py) and [loss_aggregator.py](../lib/modeling/loss_aggregator.py).
|
||||
More information should be seen in [base_model.py](../opengait/modeling/base_model.py) and [loss_aggregator.py](../opengait/modeling/loss_aggregator.py).
|
||||
|
||||
After finishing the model file, you have two steps left to do:
|
||||
|
||||
**Step 1**: Put your newmodel.py under `lib/modeling/models`.
|
||||
**Step 1**: Put your newmodel.py under `opengait/modeling/models`.
|
||||
|
||||
**Step 2**: Specify the model name in a yaml file:
|
||||
```yaml
|
||||
@@ -67,7 +67,7 @@ model_cfg:
|
||||
|
||||
|
||||
## A new loss
|
||||
If you want to write a new loss, you need to write a class inherited from `lib/modeling/losses`, like this
|
||||
If you want to write a new loss, you need to write a class inherited from `opengait/modeling/losses`, like this
|
||||
```python
|
||||
from .base import BaseLoss
|
||||
|
||||
@@ -81,6 +81,6 @@ class NewLoss(BaseLoss):
|
||||
```
|
||||
Remember to use `gather_and_scale_wrapper` to wrap your forward function if your loss is computed by pairs like `triplet`. By this, we gather all features to one GPU card and scale the loss by the number of GPUs.
|
||||
|
||||
Then, put your loss in `lib/modeling/losses` so that you can use it in config file.
|
||||
Then, put your loss in `opengait/modeling/losses` so that you can use it in config file.
|
||||
|
||||
Moreover, refer to [loss_aggregator.py](../lib/modeling/loss_aggregator.py) to explore how does your defined loss work in the model.
|
||||
Moreover, refer to [loss_aggregator.py](../opengait/modeling/loss_aggregator.py) to explore how does your defined loss work in the model.
|
||||
|
||||
@@ -32,10 +32,10 @@
|
||||
> * If your path structure is similar to [CASIA-B](http://www.cbsr.ia.ac.cn/english/Gait%20Databases.asp) (the 3-flod style: `id-type-view`), we recommand you to -->
|
||||
|
||||
### Data Augmentation
|
||||
> In OpenGait, there is a basic transform class almost called by all the models, this is [BaseSilCuttingTransform](../lib/data/transform.py#L20), which is used to cut the input silhouettes.
|
||||
> In OpenGait, there is a basic transform class almost called by all the models, this is [BaseSilCuttingTransform](../opengait/data/transform.py#L20), which is used to cut the input silhouettes.
|
||||
>
|
||||
> Accordingly, by referring to this implementation, you can easily customize the data agumentation in just two steps:
|
||||
> * *Step1*: Define the transform function or class in [transform.py](../lib/data/transform.py), and make sure it callable. The style of [torchvision.transforms](https://pytorch.org/vision/stable/_modules/torchvision/transforms/transforms.html) is recommanded, and following shows a demo;
|
||||
> * *Step1*: Define the transform function or class in [transform.py](../opengait/data/transform.py), and make sure it callable. The style of [torchvision.transforms](https://pytorch.org/vision/stable/_modules/torchvision/transforms/transforms.html) is recommanded, and following shows a demo;
|
||||
>> ```python
|
||||
>> import torchvision.transforms as T
|
||||
>> class demo1():
|
||||
@@ -77,9 +77,9 @@
|
||||
### Visualization
|
||||
> To learn how does the model work, sometimes, you need to visualize the intermediate result.
|
||||
>
|
||||
> For this purpose, we have defined a built-in instantiation of [`torch.utils.tensorboard.SummaryWriter`](https://pytorch.org/docs/stable/tensorboard.html), that is [`self.msg_mgr.writer`](../lib/utils/msg_manager.py#L24), to make sure you can log the middle information everywhere you want.
|
||||
> For this purpose, we have defined a built-in instantiation of [`torch.utils.tensorboard.SummaryWriter`](https://pytorch.org/docs/stable/tensorboard.html), that is [`self.msg_mgr.writer`](../opengait/utils/msg_manager.py#L24), to make sure you can log the middle information everywhere you want.
|
||||
>
|
||||
> Demo: if we want to visualize the output feature of [baseline's backbone](../lib/modeling/models/baseline.py#L27), we could just insert the following codes at [baseline.py#L28](../lib/modeling/models/baseline.py#L28):
|
||||
> Demo: if we want to visualize the output feature of [baseline's backbone](../opengait/modeling/models/baseline.py#L27), we could just insert the following codes at [baseline.py#L28](../opengait/modeling/models/baseline.py#L28):
|
||||
>> ```python
|
||||
>> summary_writer = self.msg_mgr.writer
|
||||
>> if torch.distributed.get_rank() == 0 and self.training and self.iteration % 100==0:
|
||||
|
||||
+2
-2
@@ -64,13 +64,13 @@ Then you will see the structure like:
|
||||
## Train the dataset
|
||||
Modify the `dataset_root` in `./config/baseline_GREW.yaml`, and then run this command:
|
||||
```shell
|
||||
CUDA_VISIBLE_DEVICES=0,1,2,3 python -m torch.distributed.launch --nproc_per_node=4 lib/main.py --cfgs ./config/baseline_GREW.yaml --phase train
|
||||
CUDA_VISIBLE_DEVICES=0,1,2,3 python -m torch.distributed.launch --nproc_per_node=4 opengait/main.py --cfgs ./config/baseline_GREW.yaml --phase train
|
||||
```
|
||||
<!-- You can also download the [trained model](https://github.com/ShiqiYu/OpenGait/releases/download/v1.1/pretrained_hid_model.zip) and place it in `output` after unzipping. -->
|
||||
|
||||
## Get the submission file
|
||||
```shell
|
||||
CUDA_VISIBLE_DEVICES=0,1,2,3 python -m torch.distributed.launch --nproc_per_node=4 lib/main.py --cfgs ./config/baseline_GREW.yaml --phase test
|
||||
CUDA_VISIBLE_DEVICES=0,1,2,3 python -m torch.distributed.launch --nproc_per_node=4 opengait/main.py --cfgs ./config/baseline_GREW.yaml --phase test
|
||||
```
|
||||
The result will be generated in your working directory, you must rename and compress it as the requirements before submitting.
|
||||
|
||||
|
||||
+2
-2
@@ -12,13 +12,13 @@ python misc/HID/pretreatment_HID.py --input_train_path="train" --input_gallery_p
|
||||
## Train the dataset
|
||||
Modify the `dataset_root` in `./misc/HID/baseline_hid.yaml`, and then run this command:
|
||||
```shell
|
||||
CUDA_VISIBLE_DEVICES=0,1,2,3 python -m torch.distributed.launch --nproc_per_node=4 lib/main.py --cfgs ./misc/HID/baseline_hid.yaml --phase train
|
||||
CUDA_VISIBLE_DEVICES=0,1,2,3 python -m torch.distributed.launch --nproc_per_node=4 opengait/main.py --cfgs ./misc/HID/baseline_hid.yaml --phase train
|
||||
```
|
||||
You can also download the [trained model](https://github.com/ShiqiYu/OpenGait/releases/download/v1.1/pretrained_hid_model.zip) and place it in `output` after unzipping.
|
||||
|
||||
## Get the submission file
|
||||
```shell
|
||||
CUDA_VISIBLE_DEVICES=0,1,2,3 python -m torch.distributed.launch --nproc_per_node=4 lib/main.py --cfgs ./misc/HID/baseline_hid.yaml --phase test
|
||||
CUDA_VISIBLE_DEVICES=0,1,2,3 python -m torch.distributed.launch --nproc_per_node=4 opengait/main.py --cfgs ./misc/HID/baseline_hid.yaml --phase test
|
||||
```
|
||||
The result will be generated in your working directory.
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
This module defines the abstract meta model class and base model class. In the base model,
|
||||
we define the basic model functions, like get_loader, build_network, and run_train, etc.
|
||||
The api of the base model is run_train and run_test, they are used in `lib/main.py`.
|
||||
The api of the base model is run_train and run_test, they are used in `opengait/main.py`.
|
||||
|
||||
Typical usage:
|
||||
|
||||
@@ -1,32 +1,32 @@
|
||||
# # **************** For CASIA-B ****************
|
||||
# # Baseline
|
||||
CUDA_VISIBLE_DEVICES=0,1 python -m torch.distributed.launch --nproc_per_node=2 lib/main.py --cfgs ./config/baseline.yaml --phase test
|
||||
CUDA_VISIBLE_DEVICES=0,1 python -m torch.distributed.launch --nproc_per_node=2 opengait/main.py --cfgs ./config/baseline.yaml --phase test
|
||||
|
||||
# # GaitSet
|
||||
# CUDA_VISIBLE_DEVICES=0,1 python -m torch.distributed.launch --nproc_per_node=2 lib/main.py --cfgs ./config/gaitset.yaml --phase test
|
||||
# CUDA_VISIBLE_DEVICES=0,1 python -m torch.distributed.launch --nproc_per_node=2 opengait/main.py --cfgs ./config/gaitset.yaml --phase test
|
||||
|
||||
# # GaitPart
|
||||
# CUDA_VISIBLE_DEVICES=0,1 python -m torch.distributed.launch --nproc_per_node=2 lib/main.py --cfgs ./config/gaitpart.yaml --phase test
|
||||
# CUDA_VISIBLE_DEVICES=0,1 python -m torch.distributed.launch --nproc_per_node=2 opengait/main.py --cfgs ./config/gaitpart.yaml --phase test
|
||||
|
||||
# GaitGL
|
||||
# CUDA_VISIBLE_DEVICES=0,1,2,3 python -m torch.distributed.launch --master_port 12345 --nproc_per_node=4 lib/main.py --cfgs ./config/gaitgl.yaml --phase test
|
||||
# CUDA_VISIBLE_DEVICES=0,1,2,3 python -m torch.distributed.launch --master_port 12345 --nproc_per_node=4 opengait/main.py --cfgs ./config/gaitgl.yaml --phase test
|
||||
|
||||
# # GLN
|
||||
# # Phase 1
|
||||
# CUDA_VISIBLE_DEVICES=3,4 python -m torch.distributed.launch --master_port 12345 --nproc_per_node=2 lib/main.py --cfgs ./config/gln/gln_phase1.yaml --phase test
|
||||
# CUDA_VISIBLE_DEVICES=3,4 python -m torch.distributed.launch --master_port 12345 --nproc_per_node=2 opengait/main.py --cfgs ./config/gln/gln_phase1.yaml --phase test
|
||||
# # Phase 2
|
||||
# CUDA_VISIBLE_DEVICES=2,5 python -m torch.distributed.launch --nproc_per_node=2 lib/main.py --cfgs ./config/gln/gln_phase2.yaml --phase test
|
||||
# CUDA_VISIBLE_DEVICES=2,5 python -m torch.distributed.launch --nproc_per_node=2 opengait/main.py --cfgs ./config/gln/gln_phase2.yaml --phase test
|
||||
|
||||
|
||||
# # **************** For OUMVLP ****************
|
||||
# # Baseline
|
||||
# CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python -m torch.distributed.launch --nproc_per_node=8 lib/main.py --cfgs ./config/baseline_OUMVLP.yaml --phase test
|
||||
# CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python -m torch.distributed.launch --nproc_per_node=8 opengait/main.py --cfgs ./config/baseline_OUMVLP.yaml --phase test
|
||||
|
||||
# # GaitSet
|
||||
# CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python -m torch.distributed.launch --nproc_per_node=8 lib/main.py --cfgs ./config/gaitset_OUMVLP.yaml --phase test
|
||||
# CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python -m torch.distributed.launch --nproc_per_node=8 opengait/main.py --cfgs ./config/gaitset_OUMVLP.yaml --phase test
|
||||
|
||||
# # GaitPart
|
||||
# CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python -m torch.distributed.launch --nproc_per_node=8 lib/main.py --cfgs ./config/gaitpart_OUMVLP.yaml --phase test
|
||||
# CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python -m torch.distributed.launch --nproc_per_node=8 opengait/main.py --cfgs ./config/gaitpart_OUMVLP.yaml --phase test
|
||||
|
||||
# GaitGL
|
||||
# CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python -m torch.distributed.launch --nproc_per_node=8 lib/main.py --cfgs ./config/gaitgl_OUMVLP.yaml --phase test
|
||||
# CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python -m torch.distributed.launch --nproc_per_node=8 opengait/main.py --cfgs ./config/gaitgl_OUMVLP.yaml --phase test
|
||||
|
||||
@@ -1,32 +1,32 @@
|
||||
# # **************** For CASIA-B ****************
|
||||
# # Baseline
|
||||
CUDA_VISIBLE_DEVICES=0,1 python -m torch.distributed.launch --nproc_per_node=2 lib/main.py --cfgs ./config/baseline.yaml --phase train
|
||||
CUDA_VISIBLE_DEVICES=0,1 python -m torch.distributed.launch --nproc_per_node=2 opengait/main.py --cfgs ./config/baseline.yaml --phase train
|
||||
|
||||
# # GaitSet
|
||||
# CUDA_VISIBLE_DEVICES=0,1 python -m torch.distributed.launch --nproc_per_node=2 lib/main.py --cfgs ./config/gaitset.yaml --phase train
|
||||
# CUDA_VISIBLE_DEVICES=0,1 python -m torch.distributed.launch --nproc_per_node=2 opengait/main.py --cfgs ./config/gaitset.yaml --phase train
|
||||
|
||||
# # GaitPart
|
||||
# CUDA_VISIBLE_DEVICES=0,1 python -m torch.distributed.launch --nproc_per_node=2 lib/main.py --cfgs ./config/gaitpart.yaml --phase train
|
||||
# CUDA_VISIBLE_DEVICES=0,1 python -m torch.distributed.launch --nproc_per_node=2 opengait/main.py --cfgs ./config/gaitpart.yaml --phase train
|
||||
|
||||
# GaitGL
|
||||
# CUDA_VISIBLE_DEVICES=0,1,2,3 python -m torch.distributed.launch --nproc_per_node=4 lib/main.py --cfgs ./config/gaitgl.yaml --phase train
|
||||
# CUDA_VISIBLE_DEVICES=0,1,2,3 python -m torch.distributed.launch --nproc_per_node=4 opengait/main.py --cfgs ./config/gaitgl.yaml --phase train
|
||||
|
||||
# # GLN
|
||||
# # Phase 1
|
||||
# CUDA_VISIBLE_DEVICES=2,5,6,7 python -m torch.distributed.launch --nproc_per_node=4 lib/main.py --cfgs ./config/gln/gln_phase1.yaml --phase train
|
||||
# CUDA_VISIBLE_DEVICES=2,5,6,7 python -m torch.distributed.launch --nproc_per_node=4 opengait/main.py --cfgs ./config/gln/gln_phase1.yaml --phase train
|
||||
# # Phase 2
|
||||
# CUDA_VISIBLE_DEVICES=2,5,6,7 python -m torch.distributed.launch --nproc_per_node=4 lib/main.py --cfgs ./config/gln/gln_phase2.yaml --phase train
|
||||
# CUDA_VISIBLE_DEVICES=2,5,6,7 python -m torch.distributed.launch --nproc_per_node=4 opengait/main.py --cfgs ./config/gln/gln_phase2.yaml --phase train
|
||||
|
||||
|
||||
# # **************** For OUMVLP ****************
|
||||
# # Baseline
|
||||
# CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python -m torch.distributed.launch --nproc_per_node=8 lib/main.py --cfgs ./config/baseline_OUMVLP.yaml --phase train
|
||||
# CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python -m torch.distributed.launch --nproc_per_node=8 opengait/main.py --cfgs ./config/baseline_OUMVLP.yaml --phase train
|
||||
|
||||
# # GaitSet
|
||||
# CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python -m torch.distributed.launch --nproc_per_node=8 lib/main.py --cfgs ./config/gaitset_OUMVLP.yaml --phase train
|
||||
# CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python -m torch.distributed.launch --nproc_per_node=8 opengait/main.py --cfgs ./config/gaitset_OUMVLP.yaml --phase train
|
||||
|
||||
# # GaitPart
|
||||
# CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python -m torch.distributed.launch --nproc_per_node=8 lib/main.py --cfgs ./config/gaitpart_OUMVLP.yaml --phase train
|
||||
# CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python -m torch.distributed.launch --nproc_per_node=8 opengait/main.py --cfgs ./config/gaitpart_OUMVLP.yaml --phase train
|
||||
|
||||
# GaitGL
|
||||
# CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python -m torch.distributed.launch --nproc_per_node=8 lib/main.py --cfgs ./config/gaitgl_OUMVLP.yaml --phase train
|
||||
# CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python -m torch.distributed.launch --nproc_per_node=8 opengait/main.py --cfgs ./config/gaitgl_OUMVLP.yaml --phase train
|
||||
Reference in New Issue
Block a user