weitong8591 / differentiable_ransac

PyTorch Implementation of the ICCV 2023 paper: Generalized Differentiable RANSAC ($\nabla$-RANSAC).
GNU General Public License v3.0
173 stars 9 forks source link

test_magsac #13

Open hidfgidh opened 2 months ago

hidfgidh commented 2 months ago

Hello teacher, my pymagsac version is installed with version 0.2.1, and pygcransac is installed with version 0.1.1, I used to want to use the link you provided to install pymagsac, but I needed administrator privileges on the school server, so I used the pip command of Python 3.8 to install Pymagsac,

but I am running the code

python test_magsac. py - nf 2000-m pretrained_madels/savd_model_5PC_1_iepi/model.net - bs 32- fmat 0- sam 1- bm 1- t 2- th+local path,

An error occurred, and I made changes based on the source code https://github.com/weitong8591/differentiable_ransac/blob/d128128c1038f1eb8fbde94c2779bfc41092e994/test_magsac.py#L108

rank the points according to their probabilities

                sorted_pts1 = pts1[sorted_indices]
                sorted_pts2 = pts2[sorted_indices]
               # weights = weights[sorted_indices]
                sorted_pts1 = sorted_pts1.astype(np.float64)
                sorted_pts2 = sorted_pts2.astype(np.float64)
                K1[b] = K1[b].astype(np.float64)
                K2[b] = K2[b].astype(np.float64)
                weights = weights.astype(np.float64)

               #      After # is the output
                print("sorted_pts1 shape and type:", sorted_pts1.shape, sorted_pts1.dtype)#shape and type: (2000, 2) float64
                print("sorted_pts2 shape and type:", sorted_pts2.shape, sorted_pts2.dtype)#sorted_pts2 shape and type: (2000, 2) float64
                print("K1 shape and type:", K1.shape, K1.dtype)#K1 shape and type: (32, 3, 3) float32
                print("K2 shape and type:", K2.shape, K2.dtype)#K2 shape and type: (32, 3, 3) float32
                print("weights shape and type:", weights.shape, weights.dtype)#weights shape and type: (2000,) float64
                K1[b] = K1[b].astype(np.float64)
                K2[b] = K2[b].astype(np.float64)
                print("K1 shape and type:", K1.shape, K1.dtype)##K1 shape and type: (32, 3, 3) float32
                print("K2 shape and type:", K2.shape, K2.dtype)##K2 shape and type: (32, 3, 3) float32
                correspondences = np.concatenate((sorted_pts1, sorted_pts2), axis=1)
                print(correspondences.shape, correspondences.dtype)#(2000, 4) float64

I have also made changes to the first parameter input below

                start_time = time.time()
                E, mask, save_samples = pymagsac.findEssentialMatrix(
                    correspondences, # pts[sorted_indices]
                    K1[b], K2[b],
                    float(im_size1[b][0]), float(im_size1[b][1]), float(im_size2[b][0]), float(im_size2[b][1]),
                    # probabilities=get_probabilities(sorted_pts1.shape[0])
                    probabilities=weights,
                    use_magsac_plus_plus=True,
                    sigma_th=opt.threshold,
                    sampler_id=opt.sampler,
                    save_samples=True
                )

捕获sfsf I made changes for a long time, but it didn't work May I ask how to make further modifications to this? Could you please guide me? Thank you very much。