Skip to content
Snippets Groups Projects
Unverified Commit 4658103b authored by Haian Huang(深度眸)'s avatar Haian Huang(深度眸) Committed by GitHub
Browse files

[Refactor]: Clean deprecated warning and fix 'meta' error (#4695)

* Deprecated warning and fix 'meta' error

* Fix comment

* Deprecated font_scale
parent 3cb1a70d
No related branches found
No related tags found
No related merge requests found
......@@ -40,7 +40,7 @@ def init_detector(config, checkpoint=None, device='cuda:0', cfg_options=None):
if checkpoint is not None:
map_loc = 'cpu' if device == 'cpu' else None
checkpoint = load_checkpoint(model, checkpoint, map_location=map_loc)
if 'CLASSES' in checkpoint['meta']:
if 'CLASSES' in checkpoint.get('meta', {}):
model.CLASSES = checkpoint['meta']['CLASSES']
else:
warnings.simplefilter('once')
......@@ -184,9 +184,7 @@ def show_result_pyplot(model,
img,
result,
score_thr=0.3,
fig_size=(15, 10),
title='result',
block=True,
wait_time=0):
"""Visualize the detection results on the image.
......@@ -196,15 +194,10 @@ def show_result_pyplot(model,
result (tuple[list] or list): The detection result, can be either
(bbox, segm) or just bbox.
score_thr (float): The threshold to visualize the bboxes and masks.
fig_size (tuple): Figure size of the pyplot figure.
title (str): Title of the pyplot figure.
block (bool): Whether to block GUI. Default: True
wait_time (float): Value of waitKey param.
Default: 0.
"""
warnings.warn('"block" will be deprecated in v2.9.0,'
'Please use "wait_time"')
warnings.warn('"fig_size" are deprecated and takes no effect.')
if hasattr(model, 'module'):
model = model.module
model.show_result(
......
import warnings
import matplotlib.pyplot as plt
import mmcv
import numpy as np
......@@ -37,7 +35,6 @@ def imshow_det_bboxes(img,
text_color='green',
mask_color=None,
thickness=2,
font_scale=0.5,
font_size=13,
win_name='',
show=True,
......@@ -61,7 +58,6 @@ def imshow_det_bboxes(img,
Color of masks. The tuple of color should be in BGR order.
Default: None
thickness (int): Thickness of lines. Default: 2
font_scale (float): Font scales of texts. Default: 0.5
font_size (int): Font size of texts. Default: 13
show (bool): Whether to show the image. Default: True
win_name (str): The window name. Default: ''
......@@ -72,8 +68,6 @@ def imshow_det_bboxes(img,
Returns:
ndarray: The image with bboxes drawn on it.
"""
warnings.warn('"font_scale" will be deprecated in v2.9.0,'
'Please use "font_size"')
assert bboxes.ndim == 2, \
f' bboxes ndim should be 2, but its ndim is {bboxes.ndim}.'
assert labels.ndim == 1, \
......
......@@ -275,7 +275,6 @@ class BaseDetector(nn.Module, metaclass=ABCMeta):
text_color=(72, 101, 241),
mask_color=None,
thickness=2,
font_scale=0.5,
font_size=13,
win_name='',
show=False,
......@@ -297,7 +296,6 @@ class BaseDetector(nn.Module, metaclass=ABCMeta):
Color of masks. The tuple of color should be in BGR order.
Default: None
thickness (int): Thickness of lines. Default: 2
font_scale (float): Font scales of texts. Default: 0.5
font_size (int): Font size of texts. Default: 13
win_name (str): The window name. Default: ''
wait_time (float): Value of waitKey param.
......@@ -347,7 +345,6 @@ class BaseDetector(nn.Module, metaclass=ABCMeta):
text_color=text_color,
mask_color=mask_color,
thickness=thickness,
font_scale=font_scale,
font_size=font_size,
win_name=win_name,
show=show,
......
......@@ -179,7 +179,7 @@ def main():
model = fuse_conv_bn(model)
# old versions did not save class info in checkpoints, this walkaround is
# for backward compatibility
if 'CLASSES' in checkpoint['meta']:
if 'CLASSES' in checkpoint.get('meta', {}):
model.CLASSES = checkpoint['meta']['CLASSES']
else:
model.CLASSES = dataset.CLASSES
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment