mcahny / object_localization_network

Learning Open-World Object Proposals without Learning to Classify
Apache License 2.0
192 stars 24 forks source link

can you release a demo.py to show the detection results of a 'test.jpg' #1

Open zhujingsong opened 3 years ago

zhujingsong commented 3 years ago

(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?

Wei-i commented 3 years ago

I have the same issue:)

Wei-i commented 3 years ago

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

Wei-i commented 3 years ago

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?).. image

zkyunqi commented 2 years ago

图片

xiehou-design commented 2 years ago

can you solve this problem? I have the same question?

zkyunqi commented 2 years ago

no, I have trouble in mmcv and pytorch enviroment and I run in cpu enviroment

bachzz commented 8 months ago

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?).. image

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: image