Skip to content

Commit 4658103

Browse files
authored
[Refactor]: Clean deprecated warning and fix 'meta' error (#4695)
* Deprecated warning and fix 'meta' error * Fix comment * Deprecated font_scale
1 parent 3cb1a70 commit 4658103

File tree

4 files changed

+2
-18
lines changed

4 files changed

+2
-18
lines changed

mmdet/apis/inference.py

+1-8
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def init_detector(config, checkpoint=None, device='cuda:0', cfg_options=None):
4040
if checkpoint is not None:
4141
map_loc = 'cpu' if device == 'cpu' else None
4242
checkpoint = load_checkpoint(model, checkpoint, map_location=map_loc)
43-
if 'CLASSES' in checkpoint['meta']:
43+
if 'CLASSES' in checkpoint.get('meta', {}):
4444
model.CLASSES = checkpoint['meta']['CLASSES']
4545
else:
4646
warnings.simplefilter('once')
@@ -184,9 +184,7 @@ def show_result_pyplot(model,
184184
img,
185185
result,
186186
score_thr=0.3,
187-
fig_size=(15, 10),
188187
title='result',
189-
block=True,
190188
wait_time=0):
191189
"""Visualize the detection results on the image.
192190
@@ -196,15 +194,10 @@ def show_result_pyplot(model,
196194
result (tuple[list] or list): The detection result, can be either
197195
(bbox, segm) or just bbox.
198196
score_thr (float): The threshold to visualize the bboxes and masks.
199-
fig_size (tuple): Figure size of the pyplot figure.
200197
title (str): Title of the pyplot figure.
201-
block (bool): Whether to block GUI. Default: True
202198
wait_time (float): Value of waitKey param.
203199
Default: 0.
204200
"""
205-
warnings.warn('"block" will be deprecated in v2.9.0,'
206-
'Please use "wait_time"')
207-
warnings.warn('"fig_size" are deprecated and takes no effect.')
208201
if hasattr(model, 'module'):
209202
model = model.module
210203
model.show_result(

mmdet/core/visualization/image.py

-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import warnings
2-
31
import matplotlib.pyplot as plt
42
import mmcv
53
import numpy as np
@@ -37,7 +35,6 @@ def imshow_det_bboxes(img,
3735
text_color='green',
3836
mask_color=None,
3937
thickness=2,
40-
font_scale=0.5,
4138
font_size=13,
4239
win_name='',
4340
show=True,
@@ -61,7 +58,6 @@ def imshow_det_bboxes(img,
6158
Color of masks. The tuple of color should be in BGR order.
6259
Default: None
6360
thickness (int): Thickness of lines. Default: 2
64-
font_scale (float): Font scales of texts. Default: 0.5
6561
font_size (int): Font size of texts. Default: 13
6662
show (bool): Whether to show the image. Default: True
6763
win_name (str): The window name. Default: ''
@@ -72,8 +68,6 @@ def imshow_det_bboxes(img,
7268
Returns:
7369
ndarray: The image with bboxes drawn on it.
7470
"""
75-
warnings.warn('"font_scale" will be deprecated in v2.9.0,'
76-
'Please use "font_size"')
7771
assert bboxes.ndim == 2, \
7872
f' bboxes ndim should be 2, but its ndim is {bboxes.ndim}.'
7973
assert labels.ndim == 1, \

mmdet/models/detectors/base.py

-3
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,6 @@ def show_result(self,
275275
text_color=(72, 101, 241),
276276
mask_color=None,
277277
thickness=2,
278-
font_scale=0.5,
279278
font_size=13,
280279
win_name='',
281280
show=False,
@@ -297,7 +296,6 @@ def show_result(self,
297296
Color of masks. The tuple of color should be in BGR order.
298297
Default: None
299298
thickness (int): Thickness of lines. Default: 2
300-
font_scale (float): Font scales of texts. Default: 0.5
301299
font_size (int): Font size of texts. Default: 13
302300
win_name (str): The window name. Default: ''
303301
wait_time (float): Value of waitKey param.
@@ -347,7 +345,6 @@ def show_result(self,
347345
text_color=text_color,
348346
mask_color=mask_color,
349347
thickness=thickness,
350-
font_scale=font_scale,
351348
font_size=font_size,
352349
win_name=win_name,
353350
show=show,

tools/test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def main():
179179
model = fuse_conv_bn(model)
180180
# old versions did not save class info in checkpoints, this walkaround is
181181
# for backward compatibility
182-
if 'CLASSES' in checkpoint['meta']:
182+
if 'CLASSES' in checkpoint.get('meta', {}):
183183
model.CLASSES = checkpoint['meta']['CLASSES']
184184
else:
185185
model.CLASSES = dataset.CLASSES

0 commit comments

Comments
 (0)