Skip to content

Commit 1daf52a

Browse files
author
chenjun2hao
committed
update the accuracy
1 parent 383cb53 commit 1daf52a

File tree

4 files changed

+17
-13
lines changed

4 files changed

+17
-13
lines changed

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ download the pretrained model on imagenet or the segmentation model from the [of
3939

4040
## VAL
4141

42-
use the [official pretrained model](https://github.com/ydhongHIT/DDRNet) and our `eval.py` code. so the result may different from official.
42+
use the [official pretrained model](https://github.com/ydhongHIT/DDRNet) and our `eval.py` code. with [ydhongHIT's](https://github.com/ydhongHIT) advice now can reach the same accuracy in the paper. Thanks.
4343

4444
```python
4545
cd ${PROJECT}
@@ -48,14 +48,14 @@ python tools/eval.py --cfg experiments/cityscapes/ddrnet23_slim.yaml
4848

4949
| model | Train Set | Test Set | OHEM | Multi-scale| Flip | mIoU | Link |
5050
| :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: |
51-
| DDRNet23_slim | unknown | eval | Yes | No | No | 76.83 | [official](https://github.com/ydhongHIT/DDRNet) |
52-
| DDRNet23_slim | unknown | eval | Yes | No | Yes| 77.40 | [official](https://github.com/ydhongHIT/DDRNet) |
53-
| DDRNet23 | unknown | eval | Yes | No | No | 78.41 | [official](https://github.com/ydhongHIT/DDRNet) |
54-
| DDRNet23 | unknown | eval | Yes | No | Yes| 78.85 | [official](https://github.com/ydhongHIT/DDRNet) |
51+
| DDRNet23_slim | unknown | eval | Yes | No | No | 77.83 | [official](https://github.com/ydhongHIT/DDRNet) |
52+
| DDRNet23_slim | unknown | eval | Yes | No | Yes| 78.42 | [official](https://github.com/ydhongHIT/DDRNet) |
53+
| DDRNet23 | unknown | eval | Yes | No | No | 79.51 | [official](https://github.com/ydhongHIT/DDRNet) |
54+
| DDRNet23 | unknown | eval | Yes | No | Yes| 79.98 | [official](https://github.com/ydhongHIT/DDRNet) |
5555

5656

5757
**Note**
58-
- [the official repository](https://github.com/ydhongHIT/DDRNet) on DDRNet23_slim without Flip can reach 77.40 on cityscapes dataset
58+
- with the `ALIGN_CORNERS: false` in `***.yaml` will reach higher accuracy.
5959

6060

6161
## TRAIN
@@ -78,6 +78,7 @@ python -m torch.distributed.launch --nproc_per_node=2 tools/train.py --cfg exper
7878
| DDRNet39 | train | eval | Yes | No | Yes | ~ | None |
7979

8080
**Note**
81+
- set the `ALIGN_CORNERS: true` in `***.yaml`, because i use the default setting in [HRNet-Semantic-Segmentation OCR](https://github.com/HRNet/HRNet-Semantic-Segmentation/tree/HRNet-OCR).
8182
- Multi-scale with scales: 0.5,0.75,1.0,1.25,1.5,1.75. it runs too slow.
8283
- from [ydhongHIT](https://github.com/ydhongHIT), can change the `align_corners=True` with better performance, the default option is `False`
8384

experiments/cityscapes/ddrnet23.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ MODEL:
1818
NAME: ddrnet_23
1919
NUM_OUTPUTS: 2
2020
PRETRAINED: "pretrained_models/DDRNet23_imagenet.pth"
21+
ALIGN_CORNERS: false
2122
LOSS:
2223
USE_OHEM: true
2324
OHEMTHRES: 0.9
@@ -49,7 +50,7 @@ TEST:
4950
- 1024
5051
BASE_SIZE: 2048
5152
BATCH_SIZE_PER_GPU: 4
52-
FLIP_TEST: false
53+
FLIP_TEST: true
5354
MULTI_SCALE: false
5455
MODEL_FILE: "pretrained_models/best_val.pth"
5556
OUTPUT_INDEX: 0

experiments/cityscapes/ddrnet23_slim.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ MODEL:
1818
NAME: ddrnet_23_slim
1919
NUM_OUTPUTS: 2
2020
PRETRAINED: "pretrained_models/DDRNet23s_imagenet.pth"
21+
ALIGN_CORNERS: false
2122
LOSS:
2223
USE_OHEM: true
2324
OHEMTHRES: 0.9
@@ -49,9 +50,9 @@ TEST:
4950
- 1024
5051
BASE_SIZE: 2048
5152
BATCH_SIZE_PER_GPU: 4
52-
FLIP_TEST: true
53+
FLIP_TEST: false
5354
MULTI_SCALE: false
5455
SCALE_LIST: [1]
5556
#0.5,0.75,1.0,1.25,1.5,1.75
56-
MODEL_FILE: "pretrained_models/best_val_smaller.pth"
57+
# MODEL_FILE: "pretrained_models/best_val_smaller.pth"
5758
OUTPUT_INDEX: 0

tools/to_onnx.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def parse_args():
2727

2828
parser.add_argument('--cfg',
2929
help='experiment configure file name',
30-
default="experiments/map/map_hrnet_ocr_w18_small_v2_512x1024_sgd_lr1e-2_wd5e-4_bs_12_epoch484.yaml",
30+
default="experiments/cityscapes/ddrnet23_slim.yaml",
3131
type=str)
3232
parser.add_argument('opts',
3333
help="Modify config options using the command-line",
@@ -46,7 +46,7 @@ def __init__(self, model):
4646

4747
def forward(self, x):
4848
x1, x2 = self.backone(x)
49-
y = F.interpolate(x2, size=(480,640), mode='bilinear')
49+
y = F.interpolate(x1, size=(480,640), mode='bilinear')
5050
# y = F.softmax(y, dim=1)
5151
y = torch.argmax(y, dim=1)
5252

@@ -94,18 +94,19 @@ def main():
9494
model.load_state_dict(model_dict)
9595

9696
net = onnx_net(model)
97+
net = net.eval()
9798

9899
# x = torch.randn((1, 3, 512, 384))
99100
x = torch.randn((1,3,480,640))
100101
torch_out = net(x)
101102

102103
# output_path = "output/tensorrt/resnet50/resnet50_bilinear.onnx"
103-
output_path = "output/hrnetv2_w18_480_640.onnx"
104+
output_path = "output/ddrnet23_slim.onnx"
104105
torch.onnx.export(net, # model being run
105106
x, # model input (or a tuple for multiple inputs)
106107
output_path, # where to save the model (can be a file or file-like object)
107108
export_params=True, # store the trained parameter weights inside the model file
108-
opset_version=9, # the ONNX version to export the model to
109+
opset_version=11, # the ONNX version to export the model to
109110
do_constant_folding=True, # whether to execute constant folding for optimization
110111
input_names = ['inputx'], # the model's input names
111112
output_names = ['outputy'], # the model's output names

0 commit comments

Comments
 (0)