Open zhujingsong opened 3 years ago
I have the same issue:)
I think you can use this for a simple infernece:
from mmdet.apis import init_detector, inference_detector
import mmcv
# Specify the path to model config and checkpoint file
config_file = 'configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py'
checkpoint_file = 'checkpoints/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth'
# build the model from a config file and a checkpoint file
model = init_detector(config_file, checkpoint_file, device='cuda:0')
# test a single image and show the results
img = 'test.jpg' # or img = mmcv.imread(img), which will only load it once
result = inference_detector(model, img)
# visualize the results in a new window
model.show_result(img, result)
# or save the visualization results to image files
model.show_result(img, result, out_file='result.jpg')
# test a video and show the results
video = mmcv.VideoReader('video.mp4')
for frame in video:
result = inference_detector(model, frame)
model.show_result(frame, result, wait_time=1)
Noted that you may set a parameter score_thr
for show_result
This is my vis result as follow, I do not know if it is ok(The best choice may comment out the laebl
for visualization?)..
can you solve this problem? I have the same question?
no, I have trouble in mmcv and pytorch enviroment and I run in cpu enviroment
This is my vis result as follow, I do not know if it is ok(The best choice may comment out the
laebl
for visualization?)..
I found the solution. You can comment out the class_name
in line 133,134 in file mmdet/core/visualization/image.py
:
for i, (bbox, label) in enumerate(zip(bboxes, labels)):
bbox_int = bbox.astype(np.int32)
poly = [[bbox_int[0], bbox_int[1]], [bbox_int[0], bbox_int[3]],
[bbox_int[2], bbox_int[3]], [bbox_int[2], bbox_int[1]]]
np_poly = np.array(poly).reshape((4, 2))
polygons.append(Polygon(np_poly))
color.append(bbox_color)
label_text = '' #class_names[
#label] if class_names is not None else f'class {label}'
if len(bbox) > 4:
label_text += f'|{bbox[-1]:.02f}'
Here is example result:
(1) How can I generate the result image as Fig 3/ Fig 5/ Fig6 in your paper?
(2) I've noticed that in the test_cfg, rcnn=dict(score_thr=0.0, ......), why set score_thr=0.0?