コード例 #1
0
def parse_info(cat_path):
    pattern = re.compile(r"s\d+_e\d+\n")
    txt=files.read_file(cat_path)
    txt=files.array_to_txt(txt)
    action_names=re.findall(pattern, txt)
    raw_actions=pattern.split(txt)
    del raw_actions[0]
    actions=[parse_action(name_i,action_i)
        for name_i,action_i in zip(action_names,raw_actions)
            if action_i!='']
    return actions
コード例 #2
0
ファイル: to_dataset.py プロジェクト: tjacek/cluster_images
def parse_seq(path_i,flat=True):
    if(flat):
        name=path_i.get_name()
        cat=path_i[-2]
        person=utils.text.get_person(name)
    else:
        name,cat,person=utils.actions.cp_dataset(path_i)
    lines=files.read_file(str(path_i))
    assert(len(lines)>0)
    parsed_data=parse_text(lines)
    return utils.actions.Action(name,parsed_data,cat,person)
コード例 #3
0
def get_audio_files(args: argparse.Namespace) -> List[str]:
    if args.text_file:
        audio_files = read_file(args.text_file)
    elif args.directory:
        # Only get the files in the top level directory (not recursive)
        _, _, audio_files = next(os.walk(args.directory))
        audio_files = [os.path.join(args.directory, f) for f in audio_files]
    else:
        audio_files = [
            f for f in os.listdir(AUDIO_DIR)
            if os.path.isfile(os.path.join(AUDIO_DIR, f))
        ]
    if args.random != 0:
        audio_files = random.sample(audio_files, args.random)
    return audio_files
コード例 #4
0
def structure_data(name_file):
    file = read_file(name_file)
    return [convert_to_number(x.split()) for x in file]
コード例 #5
0
def v4l_get_name(device='video0'):
    path_pattern = "/sys/class/video4linux/%s/name"
    from utils.files import read_file
    path = path_pattern % device
    return read_file(path).strip()
コード例 #6
0
ファイル: external.py プロジェクト: tjacek/cluster_images
def read_external(in_path,short_name=False):
    text='\n'.join(files.read_file(in_path))
    feat_dict=files.txt_to_dict(text)
    get_features=ExternalFeats(feat_dict,short_name)
    return get_features
コード例 #7
0
ファイル: external.py プロジェクト: tjacek/cluster_images
def transform_features(in_path,out_path,extractor):
    text=files.read_file(in_path,lines=False)
    feat_dict=files.txt_to_dict(text)
    data=[imgs.Image(name_i,np.expand_dims(vec_i,1))
            for name_i,vec_i in feat_dict.items()]
    external_features(out_path,data,extractor,array_extr=True)