Skip to content

Commit

Permalink
[Fix] set default topk for dump info (#702)
Browse files Browse the repository at this point in the history
* set default topk for dump info

* remove redundant docstrings

* add ci densenet

* fix classification warnings

* fix mmcls version

* fix logger.warnings
  • Loading branch information
hanrui1sensetime authored Jul 14, 2022
1 parent 71d085b commit d216af8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
14 changes: 9 additions & 5 deletions mmdeploy/codebase/mmcls/deploy/classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,6 @@ def evaluate_outputs(model_cfg: mmcv.Config,
log_file (str | None): The file to write the evaluation results.
Defaults to `None` and the results will only print on stdout.
"""
import warnings

from mmcv.utils import get_logger
logger = get_logger('test', log_file=log_file, log_level=logging.INFO)

Expand All @@ -243,7 +241,7 @@ def evaluate_outputs(model_cfg: mmcv.Config,
for k, v in results.items():
logger.info(f'{k} : {v:.2f}')
else:
warnings.warn('Evaluation metrics are not specified.')
logger.warning('Evaluation metrics are not specified.')
scores = np.vstack(outputs)
pred_score = np.max(scores, axis=1)
pred_label = np.argmax(scores, axis=1)
Expand Down Expand Up @@ -281,8 +279,14 @@ def get_postprocess(self) -> Dict:
dict: Composed of the postprocess information.
"""
postprocess = self.model_cfg.model.head
assert 'topk' in postprocess, 'model config lack topk'
postprocess.topk = max(postprocess.topk)
if 'topk' not in postprocess:
topk = (1, )
logger = get_root_logger()
logger.warning('no topk in postprocess config, using default \
topk value.')
else:
topk = postprocess.topk
postprocess.topk = max(topk)
return postprocess

def get_model_name(self) -> str:
Expand Down
2 changes: 1 addition & 1 deletion requirements/optional.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
mmcls>=0.21.0,<=0.22.1
mmcls>=0.21.0,<=0.23.0
mmdet>=2.19.0,<=2.20.0
mmedit
mmocr>=0.3.0,<=0.4.1
Expand Down
12 changes: 12 additions & 0 deletions tests/regression/mmcls.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,18 @@ models:
- *pipeline_pplnn_dynamic_fp32
- *pipeline_openvino_dynamic_fp32

- name: DenseNet
metafile: configs/densenet/metafile.yml
model_configs:
- configs/densenet/densenet121_4xb256_in1k.py
pipelines:
- *pipeline_ts_fp32
- *pipeline_ort_dynamic_fp32
- *pipeline_trt_dynamic_fp16
- *pipeline_ncnn_static_fp32
- *pipeline_pplnn_dynamic_fp32
- *pipeline_openvino_dynamic_fp32

- name: SE-ResNet
metafile: configs/seresnet/metafile.yml
model_configs:
Expand Down

0 comments on commit d216af8

Please sign in to comment.