facebook / facebook360_dep

Facebook360 Depth Estimation Pipeline - https://facebook.github.io/facebook360_dep
Other
244 stars 53 forks source link

Multiproccessing in resize.py hangs run.py #21

Open elaidlaw opened 4 years ago

elaidlaw commented 4 years ago

When I try to start the UI with run.py, the script hangs when it tries to generate the color_levels. Through some investigation, I found that it was hanging in resize_frames(). I'm not sure exactly why the multiprocessing doesn't work, but changing the function to directly resize the images fixed the issue for me. Here's how I altered resize frames:

def resize_frames(src_dir, dst_dir, rig, first, last, threshold=None):
    """Resizes a frame to the appropriate pyramid level sizes. Files are saved in
    level_0/[camera], ..., level_9/[camera] in the destination directory.

    Args:
        src_dir (str): Path to the source directory.
        dst_dir (str): Path to the destination directory.
        rig (dict[str, _]): Rig descriptor object.
        first (str): Name of the first frame to render.
        last (str): Name of the last frame to render.
        threshold (int): Threshold to be used for binary thresholding. No thresholding
            is performed if None is passed in.
    """

    for frame in range(int(first), int(last) + 1):
        for camera in rig["cameras"]:
            verify_frame(src_dir, camera["id"], get_frame_name(frame))
            resize_camera(
                src_dir,
                dst_dir,
                camera["id"],
                camera["resolution"],
                get_frame_name(frame),
                threshold,
            )

I'm on Windows 10, using Docker with the WSL 2 configuration. I'm sure this function works on other setups, but in case anyone else sees this issue, this might help.

yashpatel5400 commented 4 years ago

Interesting find! Given that it works when you directly call it, I would assume this has to do with the mp.set_start_method("spawn", force=True) call we do beforehand to work around https://github.com/opencv/opencv/issues/5150. The best way to verify this is by replacing pool.apply_async( with pool.apply( and seeing what errors are produced (since the former silences errors).