LittlePey / SFD

Sparse Fuse Dense: Towards High Quality 3D Detection with Depth Completion (CVPR 2022, Oral)
Apache License 2.0
264 stars 35 forks source link

Visualize the results - please help #13

Closed NNtamp closed 1 year ago

NNtamp commented 1 year ago

Hi again, even with batch_size of 1 the results seem very promising.

Do you know any convenient way of visualizing the results output? Eg for 000004 image from testing data I got the below result:

{'name': array(['Car', 'Car'], dtype='<U3'), 'truncated': array([0., 0.]), 'occluded': array([0., 0.]), 'alpha': array([-4.2922497, -4.3647017], dtype=float32), 'bbox': array([[280.2791 , 185.48521, 344.42862, 215.91551], [366.02884, 182.1751 , 407.58246, 204.38509]], dtype=float32), 'dimensions': array([[3.9297729, 1.4563081, 1.673077 ], [3.8724215, 1.4690247, 1.5991172]], dtype=float32), 'location': array([[-15.700158 , 2.1591296, 38.17403 ], [-15.8616 , 2.1576223, 51.3538 ]], dtype=float32), 'rotation_y': array([-4.6803393, -4.6631627], dtype=float32), 'score': array([0.8405248 , 0.82384217], dtype=float32), 'boxes_lidar': array([[38.463722 , 15.724873 , -1.6663605, 3.9297729, 1.673077 , 1.4563081, 3.1095428], [51.642723 , 15.887928 , -1.5254021, 3.8724215, 1.5991172, 1.4690247, 3.0923662]], dtype=float32), 'frame_id': '000004'}

Do you know how to depict the boundary boxes (in 2D and 3D)? I tried the below code and the results are not correct for the first out of the 2 bboxes of the image.

import pandas as pd from object_detection.utils import label_map_util from object_detection.utils import visualization_utils as vis_util from PIL import Image obj = pd.read_pickle(r'...\result.pkl')

img = Image.open(r'...\SFD\training files\image_2\000004.png')

xmin, ymin, xmax, ymax = obj[0]['bbox'][0] cat = obj[0]['name'][0] caption = cat score = str(obj[0]['score'][0]) vis_util.draw_bounding_box_on_image(img, ymin, xmin, ymax, xmax, display_str_list = [caption, score], use_normalized_coordinates=False)

img.save('viz_test1.png')

Thank you in advance.

Raiden-cn commented 1 year ago

I think that you should inference the model on your datasets. And the results will be generated by OpenPCDet in .txt format.

NNtamp commented 1 year ago

Thank you @Raiden-cn for your answer. Actually I inferenced the model in the testing dataset of KITTI 3d, same dataset that the model proposed. The results are coming in a pkl format. Above you can find an example of a result for the 000004 image. For your convenience, you can find the picture attached also. The main issue is that I cant combine visually the results with the image in order to depict the boundary boxes both in 2D and 3d. Do you have any idea? 000004

LittlePey commented 1 year ago

Hi, @NNtamp , maybe the following codes are helpful for you to visualize results: https://github.com/chaomath/open3d-kitti-visualization https://github.com/kuixu/kitti_object_vis To generate prediction file in .txt format, you need to open this switch save_to_file.

NNtamp commented 1 year ago

Thank you for this! Worked!