Skip to content

Commit

Permalink
debug util
Browse files Browse the repository at this point in the history
  • Loading branch information
Wuziyi616 committed Jul 13, 2022
1 parent 4335017 commit 928147c
Show file tree
Hide file tree
Showing 16 changed files with 42 additions and 24 deletions.
4 changes: 1 addition & 3 deletions configs/_base_/default_exp.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
_C = CN()
_C.ckp_dir = 'checkpoint/'
_C.weight_file = ''
_C.gpus = [
0,
]
_C.gpus = [0]
_C.num_workers = 8
_C.batch_size = 32
_C.num_epochs = 200
Expand Down
3 changes: 0 additions & 3 deletions configs/_base_/models/pn_transformer/vn_pn_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,9 @@
_C.pc_feat_dim = 48 # use a smaller one because VN feature is 3xC

_C.encoder = 'vn-pointnet'
_C.encoder_pool1 = 'mean' # pooling for the input edge-conv
_C.encoder_pool2 = 'max' # pooling for the global feature

_C.transformer_heads = 4
_C.transformer_layers = 4
_C.transformer_relu = True


def get_cfg_defaults():
Expand Down
4 changes: 2 additions & 2 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ We follow the below style to name each training config:
{model}_{batch_per_gpu x gpu}_{schedule}_{dataset}.py
```

To inspect one specific config file, simply call our privided script:
To inspect one specific config file, simply call our provided script:

```
python script/print_cfg.py --cfg_file $CFG
python scripts/print_cfg.py --cfg_file $CFG
```
16 changes: 8 additions & 8 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
To train a model, simply run:

```
python script/train.py --cfg_file $CFG --other_args ...
python scripts/train.py --cfg_file $CFG --other_args ...
```

For example, to train the Global baseline model on PartNet chair, replace `$CFG` with `configs/global/global-32x1-cosine_200e-partnet_chair.py`.
Other optional arguments include:

- `--category`: train the model only on a subset of data, e.g. `Chair`, `Table`, `Lamp` on PartNet
- `--gpus`: setting training GPUs, note that by default we are using DP training. Please modify `script/train.py` to enable DDP training
- `--gpus`: setting training GPUs, note that by default we are using DP training. Please modify `scripts/train.py` to enable DDP training
- `--weight`: loading pre-trained weights
- `--fp16`: FP16 mixed precision training
- `--cudnn`: setting `cudnn.benchmark = True`
Expand All @@ -28,24 +28,24 @@ Please set up your account on the machine before running training commands.
Script for configuring and submitting jobs to cluster SLURM system:

```
GPUS=1 CPUS_PER_TASK=8 MEM_PER_CPU=5 QOS=normal ./script/sbatch_run.sh $PARTITION $JOB_NAME ./script/train.py --cfg_file $CFG --other_args...
GPUS=1 CPUS_PER_TASK=8 MEM_PER_CPU=5 QOS=normal ./scripts/sbatch_run.sh $PARTITION $JOB_NAME ./scripts/train.py --cfg_file $CFG --other_args...
```

Script for running a job multiple times over different random seeds:

```
GPUS=1 CPUS_PER_TASK=8 MEM_PER_CPU=5 QOS=normal REPEAT=$NUM_REPEAT ./script/dup_run_sbatch.sh $PARTITION $JOB_NAME ./script/train.py $CFG --other_args...
GPUS=1 CPUS_PER_TASK=8 MEM_PER_CPU=5 QOS=normal REPEAT=$NUM_REPEAT ./scripts/dup_run_sbatch.sh $PARTITION $JOB_NAME ./scripts/train.py $CFG --other_args...
```

We also provide scripts for training on single/all categories of the Breaking-Bad dataset's `everyday` subset.
See [train_everyday_categories.sh](../script/train_everyday_categories.sh) and [train_one_category.sh](../script/train_one_category.sh).
See [train_everyday_categories.sh](../scripts/train_everyday_categories.sh) and [train_one_category.sh](../scripts/train_one_category.sh).

## Testing

Similar to training, to test a pre-trained weight, simply run:

```
python script/test.py --cfg_file $CFG --weight path/to/weight
python scripts/test.py --cfg_file $CFG --weight path/to/weight
```

Optional auguments:
Expand All @@ -57,15 +57,15 @@ Optional auguments:
If you want to get per-category result of this model (currently only support `everyday` subset of the Breaking-Bad dataset), and report performance averaged over all the categories (used in the paper), run:

```
python script/test.py --cfg_file $CFG --weight path/to/weight --category all
python scripts/test.py --cfg_file $CFG --weight path/to/weight --category all
```

We will print the metrics on each category and the averaged results.

We also provide script to test your per-category trained models (currently only support `everyday` subset of the Breaking-Bad dataset). Suppose you train the models by running `./scrips/train_everyday_categories.sh $COMMAND $CFG.py`. Then the model checkpoint will be saved in `checkpoint/$CFG-$CATEGORY-dup$X`. To collect the performance on each category, run:

```
python script/collect_test.py --cfg_file $CFG.py --num_dup $X --ckp_suffix checkpoint/$CFG-
python scripts/collect_test.py --cfg_file $CFG.py --num_dup $X --ckp_suffix checkpoint/$CFG-
```

You can again control the number of pieces and GPUs to use.
Expand Down
4 changes: 2 additions & 2 deletions multi_part_assembly/models/pn_transformer/vn_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ def _init_encoder(self):
self.cfg.model.encoder,
feat_dim=self.pc_feat_dim,
global_feat=True,
pool1=self.cfg.model.get('encoder_pool1', 'mean'),
pool2=self.cfg.model.get('encoder_pool2', 'max'),
pool1='mean',
pool2='max',
)
return encoder

Expand Down
File renamed without changes.
23 changes: 23 additions & 0 deletions scripts/debug.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import os
import sys
import importlib

from multi_part_assembly.datasets import build_dataloader
from multi_part_assembly.models import build_model


def build(cfg_file):
sys.path.append(os.path.dirname(cfg_file))
cfg = importlib.import_module(os.path.basename(cfg_file)[:-3])
cfg = cfg.get_cfg_defaults()

cfg.freeze()
print(cfg)

# Initialize model
model = build_model(cfg)

# Initialize dataloaders
train_loader, val_loader = build_dataloader(cfg)

return model, train_loader, val_loader, cfg
4 changes: 2 additions & 2 deletions script/dup_run_sbatch.sh → scripts/dup_run_sbatch.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#######################################################################
# An example usage:
# GPUS=1 CPUS_PER_TASK=8 MEM_PER_CPU=5 QOS=normal REPEAT=3 ./script/dup_run_sbatch.sh \
# GPUS=1 CPUS_PER_TASK=8 MEM_PER_CPU=5 QOS=normal REPEAT=3 ./scripts/dup_run_sbatch.sh \
# rtx6000 test-sbatch test.py config.py --fp16 --cudnn
#######################################################################

Expand All @@ -27,7 +27,7 @@ do
cfg="${CFG:0:(-3)}-dup${repeat_idx}.py"
cp $CFG $cfg
job_name="${JOB_NAME}-dup${repeat_idx}"
cmd="./script/sbatch_run.sh $PARTITION $job_name $PY_FILE --cfg_file $cfg $PY_ARGS"
cmd="./scripts/sbatch_run.sh $PARTITION $job_name $PY_FILE --cfg_file $cfg $PY_ARGS"
echo $cmd
eval $cmd
done
File renamed without changes.
4 changes: 2 additions & 2 deletions script/sbatch_run.sh → scripts/sbatch_run.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

#######################################################################
# An example usage:
# GPUS=1 CPUS_PER_TASK=8 MEM_PER_CPU=5 QOS=normal ./script/sbatch_run.sh rtx6000 train-sbatch \
# ./script/train.py --cfg_file config.py
# GPUS=1 CPUS_PER_TASK=8 MEM_PER_CPU=5 QOS=normal ./scripts/sbatch_run.sh rtx6000 train-sbatch \
# ./scripts/train.py --cfg_file config.py
#######################################################################

# read args from command line
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion script/train_everyday_categories.sh → scripts/train_everyday_categories.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#######################################################################
# An example usage:
# ./script/train_everyday_categories.sh "GPUS=1 CPUS_PER_TASK=8 MEM_PER_CPU=5 QOS=normal REPEAT=3 ./script/dup_run_sbatch.sh rtx6000 everyday_cat ./script/train.py config.py --fp16 --cudnn" config.py
# ./scripts/train_everyday_categories.sh "GPUS=1 CPUS_PER_TASK=8 MEM_PER_CPU=5 QOS=normal REPEAT=3 ./scripts/dup_run_sbatch.sh rtx6000 everyday_cat ./scripts/train.py config.py --fp16 --cudnn" config.py
#######################################################################

CMD=$1
Expand Down
2 changes: 1 addition & 1 deletion script/train_one_category.sh → scripts/train_one_category.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#######################################################################
# An example usage:
# ./script/train_one_category.sh "GPUS=1 CPUS_PER_TASK=8 MEM_PER_CPU=5 QOS=normal REPEAT=3 ./script/dup_run_sbatch.sh rtx6000 everyday_cat ./script/train.py config.py --fp16 --cudnn" config.py Bottle
# ./scripts/train_one_category.sh "GPUS=1 CPUS_PER_TASK=8 MEM_PER_CPU=5 QOS=normal REPEAT=3 ./scripts/dup_run_sbatch.sh rtx6000 everyday_cat ./scripts/train.py config.py --fp16 --cudnn" config.py Bottle
#######################################################################

CMD=$1
Expand Down
File renamed without changes.

0 comments on commit 928147c

Please sign in to comment.