Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there any demo for visualization? #8

Closed
zzzzzz0407 opened this issue Oct 24, 2019 · 9 comments
Closed

Is there any demo for visualization? #8

zzzzzz0407 opened this issue Oct 24, 2019 · 9 comments

Comments

@zzzzzz0407
Copy link

Hi, thanks for your wonderful work, but I do not find a demo to test the image and then visualize it, can you share one?

@xieenze
Copy link
Owner

xieenze commented Oct 24, 2019

Sorry, I do not have enough time to do these things before 2019.11.20.
I will consider adding these tools and demo.

@zzzzzz0407
Copy link
Author

Okay, thanks anyway, I will try it myself.

@pandamax
Copy link

Okay, thanks anyway, I will try it myself.

hi,do you have any idea to visualize the tested image?

@zzzzzz0407
Copy link
Author

@pandamax PolarMask is just based on mmdetection, just follow the demo https://github.com/open-mmlab/mmdetection/blob/master/demo/inference_demo.ipynb
it is quite easy.

@xieenze
Copy link
Owner

xieenze commented Oct 26, 2019

@pandamax PolarMask is just based on mmdetection, just follow the demo https://github.com/open-mmlab/mmdetection/blob/master/demo/inference_demo.ipynb
it is quite easy.

Thanks. I ignore this tool. Have you successfully use this tool to visualize the images during inference?

@pandamax
Copy link

@zzzzzz0407 @xieenze thanks a lot,I am not familiar with this tool. I use PolarMask to train my own coco-style datasets. emmmm,I just look at the demo,it seems to only show the detection box,and I want to show the segmentation result as well. Maybe this tool contains this feature, but I didn't find it.

thanks a lot again.

@zzzzzz0407
Copy link
Author

zzzzzz0407 commented Oct 26, 2019

@xieenze
yeal, it is easy, but PolarMask is not perfectly compatible with mmdetection, so you may modify some detail firstly.
I find that PolarMask has no cfg.data.test.size_divisor in its config_file, yet the default inference needs this, so I just set it=None, like this:
`
In mmdet/api/inference/inference_detector, about line 63

img_transform = ImageTransform(
size_divisor=None, **cfg.img_norm_cfg)
`

Please check it, I cannot ensure its influence to other function.

Then just follow the demo, put the demo at tools/
`
from mmdet.apis import init_detector, inference_detector, show_result_pyplot
import mmcv

config_file = '../configs/polarmask/4gpu/polar_768_1x_r50.py'
checkpoint_file = '../checkpoints/r50_1x.pth
model = init_detector(config_file, checkpoint_file, device='cuda:0')

img = './000000465179.jpg'
result = inference_detector(model, img)
show_result_pyplot(img, result, model.CLASSES)
`

@xieenze
Copy link
Owner

xieenze commented Oct 26, 2019

@zzzzzz0407 @pandamax
Thanks for your advice. I try to visualize polarmask. You need to set 'size_divisor=32' in the config file and do not need to change the code in inference.py.
Details are shown below.
image

And I also upload a file in ./demo folder.
Thanks for your advice!

@PinxueGuo
Copy link

PinxueGuo commented Sep 5, 2020

I'm willing to share a simple code which is simple for visualization.

from mmdet.apis import init_detector, inference_detector, show_result_pyplot, show_result
import mmcv
import os
import cv2

config_file = '/home/gpx/PolarMask/configs/polarmask/4gpu/polar_768_1x_x101.py'
checkpoint_file = '/home/gpx/PolarMask/x101_1x.pth'
model = init_detector(config_file, checkpoint_file, device='cuda:0')

img_path = '/home/gpx/PolarMask/test_img'
output_path = '/home/gpx/PolarMask/test_img_result/X-101_128'
img_names = os.listdir(img_path)
for name in img_names:
    img = os.path.join(img_path, name)
    result = inference_detector(model, img)
    img_result = show_result(img, result, model.CLASSES, score_thr=0.3, show=False)
    save_path = os.path.join(output_path, f'{name}_result.jpg')
    cv2.imwrite(save_path, img_result)
    print(name+' DONE!')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants