Skip to content

Commit 1af2ad6

Browse files
authored
Fixed voc aug convert (open-mmlab#19)
* Fixed voc aug convert * update getting_started.md * add class balanced doc
1 parent 1c3f547 commit 1af2ad6

File tree

5 files changed

+41
-4
lines changed

5 files changed

+41
-4
lines changed

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
11
blank_issues_enabled: false
2+
3+
contact_links:
4+
- name: MMSegmentation Documentation
5+
url: https://mmsegmentation.readthedocs.io
6+
about: Check the docs and FAQ to see if you question is already anwsered.

docs/config.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,3 +363,13 @@ data = dict(
363363
test=dict(pipeline=test_pipeline))
364364
```
365365
We first define the new `train_pipeline`/`test_pipeline` and pass them into `data`.
366+
367+
Similarly, if we would like to switch from `SyncBN` to `BN` or `MMSyncBN`, we need to substitute every `norm_cfg` in the config.
368+
```python
369+
_base_ = '../pspnet/psp_r50_512x1024_40ki_cityscpaes.py'
370+
norm_cfg = dict(type='BN', requires_grad=True)
371+
model = dict(
372+
backbone=dict(norm_cfg=norm_cfg),
373+
decode_head=dict(norm_cfg=norm_cfg),
374+
auxiliary_head=dict(norm_cfg=norm_cfg))
375+
```

docs/getting_started.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ Assume that you have already downloaded the checkpoints to the directory `checkp
132132
checkpoints/pspnet_r50-d8_512x1024_40k_cityscapes_20200605_003338-2966598c.pth \
133133
4 --out results.pkl --eval mIoU cityscapes
134134
```
135+
Note: There is some inconsistency between cityscapes mIoU and our mIoU. The reason is that cityscapes average each class with class size by default.
136+
We use the simple version without average for all datasets.
135137

136138
5. Test PSPNet on cityscapes test split with 4 GPUs, and generate the png files to be submit to the official evaluation server.
137139

@@ -151,8 +153,8 @@ Assume that you have already downloaded the checkpoints to the directory `checkp
151153
4 --format-only --options "imgfile_prefix=./pspnet_test_results"
152154
```
153155

154-
You will get png files under `./pspnet_test_results` directory.
155-
You may run `zip -r results.zip pspnet_test_results/` and submit the zip file to [evaluation server](https://www.cityscapes-dataset.com/submit/).
156+
You will get png files under `./pspnet_test_results` directory.
157+
You may run `zip -r results.zip pspnet_test_results/` and submit the zip file to [evaluation server](https://www.cityscapes-dataset.com/submit/).
156158

157159

158160
### Image demo

docs/tutorials/training_tricks.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,19 @@ model=dict(
2626
sampler=dict(type='OHEMPixelSampler', thresh=0.7, min_kept=100000)) )
2727
```
2828
In this way, only pixels with confidence score under 0.7 are used to train. And we keep at least 100000 pixels during training.
29+
30+
## Class Balanced Loss
31+
For dataset that is not balanced in classes distribution, you may change the loss weight of each class.
32+
Here is an example for cityscapes dataset.
33+
```python
34+
_base_ = './pspnet_r50-d8_512x1024_40k_cityscapes.py'
35+
model=dict(
36+
decode_head=dict(
37+
loss_decode=dict(
38+
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0,
39+
# DeepLab used this class weight for cityscapes
40+
class_weight=[0.8373, 0.9180, 0.8660, 1.0345, 1.0166, 0.9969, 0.9754,
41+
1.0489, 0.8786, 1.0023, 0.9539, 0.9843, 1.1116, 0.9037,
42+
1.0865, 1.0955, 1.0865, 1.1529, 1.0507])))
43+
```
44+
`class_weight` will be passed into `CrossEntropyLoss` as `weight` argument. Please refer to [PyTorch Doc ](https://pytorch.org/docs/stable/nn.html?highlight=crossentropy#torch.nn.CrossEntropyLoss) for details.

tools/convert_datasets/voc_aug.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,12 @@ def main():
5050
list(mmcv.scandir(in_dir, suffix='.mat')),
5151
nproc=nproc)
5252

53-
with open(osp.join(aug_path, 'dataset', 'trainval.txt')) as f:
54-
full_aug_list = [line.strip() for line in f]
53+
full_aug_list = []
54+
with open(osp.join(aug_path, 'dataset', 'train.txt')) as f:
55+
full_aug_list += [line.strip() for line in f]
56+
with open(osp.join(aug_path, 'dataset', 'val.txt')) as f:
57+
full_aug_list += [line.strip() for line in f]
58+
5559
with open(
5660
osp.join(devkit_path, 'VOC2012/ImageSets/Segmentation',
5761
'train.txt')) as f:

0 commit comments

Comments
 (0)