def check_transform(img_path, out_path): imgset = imgs.make_imgs(img_path, norm=False, transform=imgs.to_3D) dirs.make_dir(out_path) for i, img_i in enumerate(imgset): raw_i = img_i[0] # imgs.unify_img(img_i) print(raw_i.shape) name_i = "img" + str(i) + ".jpg" new_img_i = imgs.Image(name_i, raw_i) new_img_i.save(out_path)
def reconstruction(ae_path, img_path, out_path): reader = deep.reader.NNReader() nn = reader.read(ae_path) # autoconv.read_conv_ae(ae_path) imgset = imgs.make_imgs(img_path, norm=True) recon = [nn.reconstructed(img_i) for img_i in imgset] recon = imgs.unorm(recon) dirs.make_dir(out_path) for i, img_i in enumerate(recon): img_i.save(out_path, i)
def agum_data(action_path, out_path): old_actions = actions.read_actions(action_path) new_actions = [flip_action(action_i) for action_i in old_actions] all_actions = old_actions + new_actions dirs.make_dir(out_path) for action_i in all_actions: path_i = utils.paths.Path(out_path) path_i.add(action_i.cat) dirs.make_dir(path_i) action_i.save(str(path_i))
def select_frames(action_path,out_path,action_dict): print(action_dict.name) action_path=action_path.create(action_dict.name) out_path=out_path.create(action_dict.name) for in_path_i,cat_i in action_dict.categorize(action_path): #dst_path=out_path.create(action_dict.name) dirs.make_dir(out_path) dst_path_i=out_path.replace(in_path_i) print(str(in_path_i)) print(str(dst_path_i)) copyfile(str(in_path_i), str(dst_path_i))
def save_actions(actions,outpath): dirs.make_dir(outpath) print(dir(utils.data)) extr_cats=utils.data.ExtractCat(parse_cat=lambda a:a.cat) for action_i in actions: extr_cats(action_i) for name_i in extr_cats.names(): cat_dir_i=outpath.append(name_i,copy=True) dirs.make_dir(cat_dir_i) for action_i in actions: cat_path_i=outpath.append(action_i.cat,copy=True) action_i.save(cat_path_i)
def seg_action(action_path,out_path,action_dict): action_path=action_path.create(action_dict.name) out_path=out_path.create(action_dict.name) print(str(action_path)) print(str(out_path)) cats=action_dict.categorize(action_path) cat_dict={} for cat_i in action_dict.data.keys(): cat_path=out_path.copy() cat_path.set_name(cat_i) dirs.make_dir(cat_path) cat_dict[cat_i]=cat_path for frame_path,cat_i in cats: dst_path=cat_dict[cat_i] dst_path=dst_path.create(action_dict.name) dirs.make_dir(dst_path) dst_path=dst_path.replace(frame_path) print(frame_path) print(dst_path) copyfile(str(frame_path), str(dst_path))
import os from utils.load_conf import parse_args, parse_conf from utils.dirs import make_dir, clear_dirs from run_main import run_timit if __name__ == '__main__': # Locate the root directory of the project root = os.environ['VOICE_VAE'] # parse command line arguments args = parse_args() if args is None: exit() # parse configuration file arguments config = parse_conf(root, args) # Setup the output directories of the program if config['clear']: clear_dirs() for n in ['results_path', 'results_dir', 'models_path', 'models_dir', 'tensorboard_dir', 'train_tb_dir', 'test_tb_dir']: d = config[n] make_dir(d) # main run_timit(config)
def extract_features(in_path,ext_path,seq_path='seq',short_names=True): out_path=in_path.copy().set_name(str(seq_path)) dirs.make_dir(str(out_path)) extractor=ext.read_external(str(ext_path),short_names) transform_seq(in_path,out_path,extractor)
def save(self,outpath): full_outpath=outpath.append(self.name,copy=True) dirs.make_dir(full_outpath) [img_i.save(full_outpath) for img_i in self.img_seq]
def extract(action_path,out_path,cat_path): dirs.make_dir(out_path) actions=parse_info(cat_path) print(str(actions[0])) [select_frames(action_path,out_path,act_i) for act_i in actions]