Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Process SpawnPoolWorker Problem - Solved #152

Open
Yarroudh opened this issue May 6, 2023 · 0 comments
Open

Process SpawnPoolWorker Problem - Solved #152

Yarroudh opened this issue May 6, 2023 · 0 comments

Comments

@Yarroudh
Copy link

Yarroudh commented May 6, 2023

Hello everyone,

I'm trying to use MVSNet on COLMAP results. I faced some issues when I tried to run python colmap2mvsnet.py --dense_folder <PATH>. I wanted to share with you how I solved this problem in case someone is still struggling with it.

This error typically occurs when the calc_score function is defined in the same module as the code that is being executed by a multiprocessing pool. This is how I solved it:

  • I deleted the calc_score() function from colmap2mvsnet.py file and I created a new file calc_score.py:
import numpy

def calc_score(inputs):
    i, j, images, extrinsic, points3d, args = inputs
    id_i = images[i+1].point3D_ids
    id_j = images[j+1].point3D_ids
    id_intersect = [it for it in id_i if it in id_j]
    cam_center_i = -np.matmul(extrinsic[i+1][:3, :3].transpose(), extrinsic[i+1][:3, 3:4])[:, 0]
    cam_center_j = -np.matmul(extrinsic[j+1][:3, :3].transpose(), extrinsic[j+1][:3, 3:4])[:, 0]
    score = 0
    for pid in id_intersect:
        if pid == -1:
            continue
        p = points3d[pid].xyz
        theta = (180 / np.pi) * np.arccos(np.dot(cam_center_i - p, cam_center_j - p) / np.linalg.norm(cam_center_i - p) / np.linalg.norm(cam_center_j - p))
        score += np.exp(-(theta - args.theta0) * (theta - args.theta0) / (2 * (args.sigma1 if theta <= args.theta0 else args.sigma2) ** 2))
    return i, j, score
  • Then, I imported the function from that module: from calc_score import calc_score

  • As I added new arguments, I changed result = p.map(calc_score, queue) to:

result = p.map(calc_score, [(i, j, images, extrinsic, points3d, args) for i, j in queue])

This should solve the problem and launch the multiprocessing without errors.

@Yarroudh Yarroudh closed this as completed May 6, 2023
@Yarroudh Yarroudh reopened this May 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant