dance icon indicating copy to clipboard operation
dance copied to clipboard

How to visualize the prediction

Open JunbongJang opened this issue 3 years ago • 4 comments

Hi

When I run the following command,

python train_net.py --config-file configs/Dance_R_101_3x.yaml --eval-only MODEL.WEIGHTS ./output/r101_3x_model_final.pth 

DANCE model predicts box coordinates and classes but does not produce a segmentation mask, as shown below. output_image_2

How do I get the segmentation? Also, which code did you use to visualize the predictions, like the figures in your DANCE paper?

Thank you for your help in advance.

JunbongJang avatar Dec 11 '21 08:12 JunbongJang

Dear all,

  1. To get the segmentation, look for the "pred_polys" key among the output of the model in the following function in the detectron2/detectron2/evaluation/evaluator.py
inference_on_dataset(model, data_loader, evaluator)

  1. There is a visualization function in the dance/core/modeling/edge_snake/snake_head.py
vis(image, poly_sample_locations, poly_sample_targets)

If you write some code with two information above, you can get the following image:

vis_single_2

p.s. I had to put the following code in the line 98 of /detectron2/detectron2/data/dataset_mapper.py in order to correctly visualize the predicted boxes and segmentation on the image.

dataset_dict['height'] = image_shape[0]
dataset_dict['width'] = image_shape[1]

Without it, you will get the following image instead. vis_single_2

JunbongJang avatar Dec 12 '21 10:12 JunbongJang

Hi @JunbongJang , sorry for the delayed reply, just saw you have already found a way to obtain the vertices point, nice!

Yes all the predictions need proper scaling since the training / testing operate on some fixed scales.

If you have further questions welcome to leave an issue or email me :)

lkevinzc avatar Dec 12 '21 11:12 lkevinzc

No Problem! @lkevinzc

Thank you for your work.

Your framework will be very useful for my future project.

JunbongJang avatar Dec 12 '21 12:12 JunbongJang

Dear all,

  1. To get the segmentation, look for the "pred_polys" key among the output of the model in the following function in the detectron2/detectron2/evaluation/evaluator.py
inference_on_dataset(model, data_loader, evaluator)
  1. There is a visualization function in the dance/core/modeling/edge_snake/snake_head.py
vis(image, poly_sample_locations, poly_sample_targets)

If you write some code with two information above, you can get the following image:

vis_single_2

p.s. I had to put the following code in the line 98 of /detectron2/detectron2/data/dataset_mapper.py in order to correctly visualize the predicted boxes and segmentation on the image.

dataset_dict['height'] = image_shape[0]
dataset_dict['width'] = image_shape[1]

Without it, you will get the following image instead. vis_single_2

Thanks for your sharing. It works well.

bamboopu avatar Aug 09 '22 13:08 bamboopu