示例#1
0
        for post_images in tqdm(os.listdir(output_data_dir)):
            root, ext = os.path.splitext(post_images)
            img_link = os.path.join(output_data_dir, post_images)
            # Only handle DAIN-inference imgs
            if root[-1] != "0" and ext == "png":
                img = cv2.imread(img_link)
                dimension = (img.shape[1] + 2, img.shape[0] + 2)
                resized = cv2.resize(img,
                                     dimension,
                                     interpolation=cv2.INTER_LANCZOS4)
                crop = resized[1:(dimension[1] - 1), 1:(dimension[0] - 1)]
                cv2.imwrite(img_link, crop)
    except IOError:
        print("IOError: Resizing frames rewrite failure!")
    else:
        print("Succeed to resize DAIN-inference-frames!")

    # STAGE 4: video post-processing
    os.chdir(DAIN_PREFIX)
    clean_folder(input_data_dir)
    file_order(src=output_data_dir, dst=input_data_dir)
    output_video_file = f"{args.input_video.split('.')[0]}-{target_fps}.{args.input_video.split('.')[1]}"

    video_fusion(
        src=input_data_dir + "/%10d.png",
        dst=os.path.join(output_data_dir, output_video_file),
        fps=target_fps,
        thread=4,
    )
    clean_folder(input_data_dir)
示例#2
0
    os.system(
        f"sed -i 's/num_frames: 240/num_frames: {args.frames}/g' curr_argument.yml"
    )
    os.system(
        f"sed -i 's/longer_side_len: 960/longer_side_len: {args.longer_side_len}/g' curr_argument.yml"
    )

    # start processing
    file_list = os.listdir(input_data_dir)
    actual_input_dir = os.path.join(Photo_3D, "image")
    actual_output_dir = os.path.join(Photo_3D, "video")

    for i in range(len(file_list)):
        # transfer inputs
        shutil.copy(src=os.path.join(input_data_dir, file_list[i]),
                    dst=actual_input_dir)
        # file_transfer(
        #     src=os.path.join(input_data_dir, file_list[i]), dst=actual_input_dir
        # )
        # inference
        os.system("python3 main.py --config curr_argument.yml")
        # transfer outputs
        file_transfer(src=actual_output_dir, dst=output_data_dir)
        # clean cache
        clean_folder(actual_input_dir)
        clean_folder(actual_output_dir)

    # clean input
    clean_folder(input_data_dir)
    os.remove(curr_cfg_file)