lity20 / DCCDIF

MIT License
54 stars 3 forks source link

I have some questions about training #7

Open krancev opened 1 year ago

krancev commented 1 year ago

I'm very sorry to bother you.If the provided training code is suitable for training the reconstruction of a class of objects rather than a single shape fitting?Because when I train with single object data,dataset.py doesn't work(Perhaps 500w sampling points per model is too much?).In addition,There are also some small questions I hope can be answered.Thank you! 1.When I use dataset.py to train a single shape object, I find that batch_size 512 mentioned in the supplementray does not work very well.Is this the optimal training batch_size? 2.In addition,Can I ask the reconstructed CD distance for a single object?Because the average CD distance of the model I trained is about 0.0x.That's orders of magnitude less than the 3.55 in the paper. I look forward to hearing from you.Thank you!

lity20 commented 1 year ago

Yes, the code in this repo is only suitable for the reconstruction of a class of objects. For single shape fitting, some codes must be modified. For example, there is no 'resample' code in this repo, but it is necessary in single shape fitting task.

  1. Following NGLOD, we set "batch size = 512". We didn't try to modify it. Maybe other values are better.
  2. The specific calculations of CD are different in single shape fitting and class reconstruction experiments. For fair comparison, we adopt the same calculation method with MDIF / NGLOD in the class reconstruction / single shape fitting experiment.

The code for the CD metric in single shape fitting:

def chamfer_distance(pred_mesh, gt_mesh, num_surface_sample_points):
    """
    Args:
        pred_mesh: tensor(float), shape (num_faces, 3, 3)
        gt_mesh: tensor(float), shape (num_faces, 3, 3)
        num_surface_sample_points: int
    Returns:
        chamfer_l1: float
    """
    print(datetime.now().strftime('%Y-%m-%d %H:%M:%S'), 'computing cd-l1(num_points=%d).'%num_surface_sample_points)

    pred_surface_points = sample_on_surface(pred_mesh, num_surface_sample_points)[0].cpu().numpy()
    gt_surface_points = sample_on_surface(gt_mesh, num_surface_sample_points)[0].cpu().numpy()
    kdtree1 = KDTree(pred_surface_points)
    dist2, idx2 = kdtree1.query(gt_surface_points)
    kdtree2 = KDTree(gt_surface_points)
    dist1, idx1 = kdtree2.query(pred_surface_points)
    chamfer_l1 = 0.5 * (dist1.mean() + dist2.mean())

    print(datetime.now().strftime('%Y-%m-%d %H:%M:%S'), 'cd-l1 done.')
    return chamfer_l1
krancev commented 1 year ago

Thank you very much for your answer!But,I'm sorry to bother you again.Can I ask about the code for training a single object?If so,I would really appreciate it!

lity20 commented 1 year ago

We only sorted and archived the code and results on shapenet. #5 Currently, you need to modify codes based on this repo for singgle shape fitting. Referring to the description in the paper, I expect it will not be very complicated.

I plan to release the code and results on Thingi32 when it is convenient in the future. But unfortunately, I am busy with other projects now...

krancev commented 1 year ago

Ok, Thank you for your reply!