コード例 #1
0
def generate_all_video(type, only_pose=False):
    assert type in video_types
    image_folder_base = "/media/jion/D/chenhaoming/DataSet/DouYin/images/{}".format(
        type)
    openpose_dir_base = "/media/jion/D/chenhaoming/DataSet/DouYin/machine_openpose/{}".format(
        type)
    output_dir_base = "/media/jion/D/chenhaoming/DataSet/DouYin/images/{}".format(
        type)

    images_folder_paths = utils_io_folder.get_immediate_subfolder_paths(
        image_folder_base)
    for image_folder_path in images_folder_paths:
        images_paths = utils_io_folder.get_immediate_childfile_paths(
            image_folder_path, exclude=".json")
        video_name = utils_io_folder.get_file_name_without_ext_from_path(
            image_folder_path)

        if not video_name.isdigit():
            continue

        input_jsons = utils_io_folder.get_immediate_childfile_paths(
            os.path.join(openpose_dir_base, video_name), ext=".json")
        output_dir = os.path.join(output_dir_base, video_name)
        assert len(images_paths) == len(input_jsons)
        print("images_path:{}".format(image_folder_path))
        for index in range(len(images_paths)):
            if only_pose:
                output_dir_final = os.path.join(output_dir, "only_pose")
            else:
                output_dir_final = os.path.join(output_dir, "pose_and_hand")
            openpose_convert_labelme_format(input_jsons[index],
                                            images_paths[index],
                                            output_dir_final,
                                            only_pose=only_pose)
コード例 #2
0
ファイル: checkfile.py プロジェクト: chenhaomingbob/ToolBox
def work():
    root_path = "/media/jion/D/chenhaoming/DataSet/PoseTrack2017/cropped_image"
    first_paths = utils_io_folder.get_immediate_subfolder_paths(root_path)
    for first_path in first_paths:
        second_paths = utils_io_folder.get_immediate_subfolder_paths(
            first_path)
        for second_path in second_paths:
            image_paths = utils_io_folder.get_immediate_childfile_paths(
                second_path)
            if image_paths is None or len(image_paths) == 0:
                os.rmdir(second_path)
            else:
                pa = "/media/jion/D/chenhaoming/experiment/hmr"
                print(pa + second_path[61:])
                # new_path=""
                utils_io_folder.create_folder(pa + second_path[61:])
コード例 #3
0
ファイル: move.py プロジェクト: chenhaomingbob/ToolBox
def work():
    cmd = "mv {} {}"
    root_path = "/media/jion/D/chenhaoming/DataSet/PoseTrack2017/posetrack_data/images"
    change_path = "/media/jion/D/chenhaoming/DataSet/PoseTrack2017/cropped_image/{}/{}"
    folder_paths = utils_io_folder.get_immediate_subfolder_paths(root_path)
    for folder_path in tqdm(folder_paths):
        first_folder_name = utils_io_folder.get_file_name_without_ext_from_path(folder_path)
        # print(first_folder_name)
        paths = utils_io_folder.get_immediate_subfolder_paths(folder_path)
        for path in paths:
            second_folder_name = utils_io_folder.get_file_name_without_ext_from_path(path)
            # print(second_folder_name)
            images_path = utils_io_folder.get_immediate_childfile_paths(path)
            new_path = change_path.format(first_folder_name, second_folder_name)
            utils_io_folder.create_folder(new_path)
            for image_path in images_path:
                image_name = utils_io_folder.get_file_name_without_ext_from_path(image_path)
                if image_name.find("transform") >= 0:
                    cmd_i = cmd.format(image_path, os.path.join(new_path, image_name))
                    os.system(cmd_i)
コード例 #4
0
def start_convert():
    labelme_base_path = "F:/DataSet/DouYin/annotation_labelme_image/{}"
    output_base_path = "F:/DataSet/DouYin/annotation_openpose/{}"
    for video_type in tqdm(video_types):
        openpose_json_folder_type = output_base_path.format(video_type)
        labelme_folder = labelme_base_path.format(video_type)

        video_folder_sequence = utils_io_folder.get_immediate_subfolder_paths(labelme_folder)
        for video_folder in tqdm(video_folder_sequence):
            folder_name = utils_io_folder.get_file_name_without_ext_from_path(video_folder)
            if folder_name.isdigit():
                openpose_json_folder = os.path.join(openpose_json_folder_type, folder_name)
                utils_io_folder.create_folder(openpose_json_folder)
                labelme_json_paths = utils_io_folder.get_immediate_childfile_paths(video_folder, ext="json")
                for labelme_json_path in tqdm(labelme_json_paths):
                    # convert json one by one
                    labelme_to_openpose(labelme_json_path, openpose_json_folder)
コード例 #5
0
#!/usr/bin/python
# -*- coding:utf8 -*-
"""
    Author: Haoming Chen
    E-mail: [email protected]
    Time: 2020/05/29
    Description:
"""
from common import utils_io_folder
import shutil
from tqdm import tqdm

train_base_path = "/media/jion/D/chenhaoming/experiment/tubes/384x288/train"

train_subfolder_paths = utils_io_folder.get_immediate_subfolder_paths(train_base_path)

for train_subfolder_path in tqdm(train_subfolder_paths):
    video_paths = utils_io_folder.get_immediate_subfolder_paths(train_subfolder_path)
    for video_path in tqdm(video_paths):
        video_npy_path = utils_io_folder.get_immediate_childfile_paths(video_path)
        shutil.copy(video_npy_path[0], "/media/jion/D/chenhaoming/experiment/tubes/384x288/npy/train/")

val_base_path = "/media/jion/D/chenhaoming/experiment/tubes/384x288/val"

val_subfolder_paths = utils_io_folder.get_immediate_subfolder_paths(val_base_path)

for val_subfolder_path in tqdm(val_subfolder_paths):
    video_paths = utils_io_folder.get_immediate_subfolder_paths(val_subfolder_path)
    for video_path in tqdm(video_paths):
        video_npy_path = utils_io_folder.get_immediate_childfile_paths(video_path)
        shutil.copy(video_npy_path[0], "/media/jion/D/chenhaoming/experiment/tubes/384x288/npy/val/")