def main()

in scripts/render/render.py [0:0]


def main():
    """Runs the main render pipeline with the parameters passed in through command line args."""
    base_params = {
        flag: value
        for flag, value in FLAGS.flag_values_dict().items()
        if flag in setup.flag_names
    }

    if not FLAGS.skip_setup and FLAGS.cloud == "":
        setup.setup_workers(base_params)

    # If the address is a Samba or local endpoint, we have the addresses mapped in Docker
    # Access to the externally visible endpoint is only necessary in remote cases
    input_protocol = Address(FLAGS.input_root).protocol

    base_params["num_levels"] = len(config.WIDTHS)
    if input_protocol is None or input_protocol == "smb":
        base_params["input_root"] = config.DOCKER_INPUT_ROOT
        base_params["output_root"] = config.DOCKER_OUTPUT_ROOT
        base_params["rig"] = FLAGS.rig.replace(
            FLAGS.input_root, base_params["input_root"]
        )
        input_image_types = {
            "background_color",
            "background_disp",
            "color",
            "foreground_masks",
        }
        for image_type in input_image_types:
            set_input_param(base_params, image_type)

    # frame_chunks use the Python range standard where first is included but last excluded
    frame_chunks = [
        {
            "first": get_frame_name(frame),
            "last": get_frame_name(min(int(FLAGS.last), frame + FLAGS.chunk_size - 1)),
        }
        for frame in range(int(FLAGS.first), int(FLAGS.last) + 1, FLAGS.chunk_size)
    ]
    if FLAGS.background_frame == "":
        background_frame = None
    else:
        background_frame = [
            {
                "first": get_frame_name(int(FLAGS.background_frame)),
                "last": get_frame_name(int(FLAGS.background_frame)),
            }
        ]

    pipeline = Pipeline(
        FLAGS.master, base_params, frame_chunks, background_frame, FLAGS.force_recompute
    )

    # We need resized colors to compute foreground masks
    pipeline_stages = [
        (pipeline.precompute_resizes, FLAGS.run_precompute_resizes),
        (pipeline.generate_foreground_masks, FLAGS.run_generate_foreground_masks),
    ]

    if FLAGS.use_foreground_masks:
        # Resize foreground masks
        pipeline_stages.append(
            (
                pipeline.precompute_resizes_foreground,
                FLAGS.run_precompute_resizes_foreground,
            )
        )

    pipeline_stages.append((pipeline.depth_estimation, FLAGS.run_depth_estimation))

    if FLAGS.format == "6dof":
        pipeline_stages += [
            (pipeline.convert_to_binary, FLAGS.run_convert_to_binary),
            (pipeline.fusion, FLAGS.run_fusion),
        ]
    else:
        pipeline_stages.append(
            (pipeline.simple_mesh_renderer, FLAGS.run_simple_mesh_renderer)
        )

    pipeline.run(pipeline_stages)
    setup.cleanup_workers()