yzqin / s4g-release

S4G: Amodal Single-view Single-Shot SE(3) Grasp Detection in Cluttered Scene
35 stars 5 forks source link

Importance sampling vs Non-maximum Suppression #8

Closed kimanton closed 10 months ago

kimanton commented 1 year ago

Hi @yzqin again Sorry to constantly bothering you, but I have another question In your paper you mention Non-maximum Suppression and Grasp Sampling algorithm. I am wondering if this part of your code is an equivalent implementation?

Also, would you be able to explain what function $g(s_h)$ does in Algorithm 1 of your paper? And what is the meaning of variable $p_k$, is it a score for a grasp?

Also I assume that in this line there is a typo and there should be another "and" between H and dist, is it? image

I added picture of the entire algorithm for convenience image

Btw, I did transform point cloud as you suggested and it worked like a charm, thank you again

kimanton commented 1 year ago

I also can't get good results when using GraspDetector class, actually no results most of the time. I get much better results with grasp_proposal_test.py, although they are loading the same model and I feed both with 2638_view_0.p that you provided

Is there something specific I should do to use GraspDetector? Like some tweaking before using?

Some additional info if it helps in any way Here is sample code I use to test GraspDetector

import os
import torch

import numpy as np
import open3d

from grasp_proposal.grasp_detector import GraspDetector
from grasp_proposal.cloud_processor.cloud_processor import CloudPreProcessor
from grasp_proposal.utils.grasp_visualizer import GraspVisualizer

single_training_data = np.load("../2638_view_0.p", allow_pickle=True)
data = single_training_data["point_cloud"]
pcd_m = open3d.geometry.PointCloud(open3d.utility.Vector3dVector(data.T))

detector = GraspDetector()
poses, scores = detector.detect(data, num_selected=5, collision_check=True, score_threshold=0.7, verticalness_threshold=0.2)

print("Scores: \n", scores,)
print("Pose 0: \n", poses[0])

visualizer = GraspVisualizer(pcd_m)
visualizer.add_multiple_poses(poses)
visualizer.visualize()

I am able to get results like this image

And this is a result from grasp_proposal_test.py image

yzqin commented 1 year ago

@kimanton

This is the reply to your first question (Non-maximum Suppression). The code you linked [here[(https://github.com/yzqin/s4g-release/blob/b684ade8fa32ddb55d03a6a36fcfe7f1dc81ca1c/inference/grasp_proposal/grasp_detector.py#L236) is not related to NMS. It is simply sort and sample the initial set of grasp poses based on predicted scores. The NMS step is performed after the output of the whole function.

The NMS part is heavily coupled with real-robot execution part (since we will only sample a new pose when the motion planning or controller execution fails) and is not included in this github repo. The NMS part is very straight forward and standard in detection to implement and you can find many existing NMS implementation from detection code on Github, e.g. this one. You can simply replace the 2D distance function using the 3D distance function.

kimanton commented 1 year ago

Thank you for explanation, I understand now