Skip to content

Commit 3833d63

Browse files
committed
a bit fix of readme and small refinement
1 parent 78c4d61 commit 3833d63

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

ncnn/segment.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,17 @@ void inference() {
5151
mod.opt.use_vulkan_compute = 1;
5252
mod.set_vulkan_device(1);
5353
#endif
54-
mod.load_param(mod_param.c_str());
55-
mod.load_model(mod_model.c_str());
5654
// ncnn enable fp16 by default, so we do not need these options
5755
// int8 depends on the model itself, so we do not set here
5856
// bool use_fp16 = false;
5957
// mod.opt.use_fp16_packed = use_fp16;
6058
// mod.opt.use_fp16_storage = use_fp16;
6159
// mod.opt.use_fp16_arithmetic = use_fp16;
60+
mod.opt.use_winograd_convolution = true;
61+
62+
// we should set opt before load model
63+
mod.load_param(mod_param.c_str());
64+
mod.load_model(mod_model.c_str());
6265

6366
// load image, and copy to ncnn mat
6467
cv::Mat im = cv::imread(impth);

tensorrt/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Then we can use either c++ or python to compile the model and run inference.
2020
* ubuntu 18.04
2121
* nvidia Tesla T4 gpu, driver newer than 450.80
2222
* cuda 11.3, cudnn 8
23-
* cmake 3.17.1
23+
* cmake 3.22.0
2424
* opencv built from source
2525
* tensorrt 8.2.5.1
2626

@@ -49,7 +49,7 @@ $ ./segment compile /path/to/onnx.model /path/to/saved_model.trt --fp16
4949
```
5050
Building an int8 engine is also supported. Firstly, you should make sure your gpu support int8 inference, or you model will not be faster than fp16/fp32. Then you should prepare certain amount of images for int8 calibration. In this example, I use train set of cityscapes for calibration. The command is like this:
5151
```
52-
$ calibrate_int8 # delete this if exists
52+
$ rm calibrate_int8 # delete this if exists
5353
$ ./segment compile /path/to/onnx.model /path/to/saved_model.trt --int8 /path/to/BiSeNet/datasets/cityscapes /path/to/BiSeNet/datasets/cityscapes/train.txt
5454
```
5555
With the above commands, we will have an tensorrt engine named `saved_model.trt` generated.

tools/train_amp.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import random
99
import logging
1010
import time
11+
import json
1112
import argparse
1213
import numpy as np
1314
from tabulate import tabulate
@@ -55,7 +56,10 @@ def set_model(lb_ignore=255):
5556
net = model_factory[cfg.model_type](cfg.n_cats)
5657
if not args.finetune_from is None:
5758
logger.info(f'load pretrained weights from {args.finetune_from}')
58-
net.load_state_dict(torch.load(args.finetune_from, map_location='cpu'))
59+
msg = net.load_state_dict(torch.load(args.finetune_from,
60+
map_location='cpu'), strict=False)
61+
logger.info('\tmissing keys: ' + json.dumps(msg.missing_keys))
62+
logger.info('\tunexpected keys: ' + json.dumps(msg.unexpected_keys))
5963
if cfg.use_sync_bn: net = nn.SyncBatchNorm.convert_sync_batchnorm(net)
6064
net.cuda()
6165
net.train()

0 commit comments

Comments
 (0)