def crop_scale_save(self,files,o_size,o_path): utils.assert_dir(o_path) #chk = os.path.isdir(o_path) #if chk == False: # cmd = "mkdir -p "+o_path # os.system("cmd") splitter=utils.split_seq(files,4) split_indices=splitter.get_indices() print split_indices p1=Process(target=self.css_parallel,args=(files[0:split_indices[1]] ,o_size,o_path,0)) p2=Process(target=self.css_parallel,args=(files[split_indices[1]:split_indices[3]],o_size,o_path,split_indices[1])) p3=Process(target=self.css_parallel,args=(files[split_indices[2]:split_indices[3]],o_size,o_path,split_indices[2])) p4=Process(target=self.css_parallel,args=(files[split_indices[3]:-1] ,o_size,o_path,split_indices[3])) p1.start() p2.start() p3.start() p4.start() p1.join() p2.join() p3.join() p4.join()
def __init__(self,path,id=-1): self.img_orig_=wx.Image(path,wx.BITMAP_TYPE_ANY) self.img_work_=self.img_orig_.Copy() self.pts_=list() self.id_=id self.size_=self.img_orig_.GetSize() # make sure temporary directory exists (change to database) self.tmpdir="/tmp/frames/" utils.assert_dir(self.tmpdir) self.check_log()
def get_out_dir(self): out_path = self.b_browse.GetData() utils.assert_dir(out_path) slash = out_path.rfind("/") if (len(out_path)-slash) >1: out_path+="/" # chk = os.path.isdir(out_path) # if chk == False: # self.make_dir(out_path) return out_path
def Run(self): dot = self.i_path.find(".") mov_name = self.i_path[0:dot] o_path = self.o_path+"thb"+self.format utils.assert_dir(self.o_path) if len(self.frame_size)>0: command = ["avconv","-i",self.i_path,"-vframes","1","-s",str(self.frame_size),"-y",o_path] else: command = ["avconv","-i",self.i_path,"-vframes","1","-y",o_path] subprocess.call(command)
def Run(self): # get movie name dot = self.i_path[0].find(".") slash = self.i_path[0].rfind("/") mov_name = self.i_path[0][slash+1:dot] self.o_path = self.o_dir+mov_name+"%"+str(self.leading_zeros)+"d"+self.format utils.assert_dir(self.o_dir) if len(self.frame_size)>0: command = ["avconv","-i",self.i_path[0],"-r",str(self.fps),"-s",self.frame_size,"-v","-10","-y",self.o_path] else: command = ["avconv","-i",self.i_path[0],"-r",str(self.fps),"-y",self.o_path] print command subprocess.call(command)
def OnProcess(self,e): do_convert = False if self.WD.done == False: self.project.CreateNewProject(self.WD) self.WD.done = True if len(self.list_paths) == 0: print "Choose input files first" if self.chkbx.IsChecked() == True: Converter = avtools.converter() do_convert = True av_config={"format":".mov","zeros":3,"i_path":"","o_path":"","frame_size":"vga","fps":24,"bv":"10000K"} av_config["format"]=self.choices["codec_lookup"][self.choice_codec.GetCurrentSelection()] av_config["bv"]=self.choices["bitrate_lookup"][self.choice_codec.GetCurrentSelection()] av_config["frame_size"]=self.choices["scale_lookup"][self.choice_codec.GetCurrentSelection()] av_config["fps"]=self.choices["fps_lookup"][self.choice_codec.GetCurrentSelection()] for i in range(len(self.list_paths)): input_name= self.list_names[i] input_file = self.list_paths[i] cp_string=self.CpString(input_name,input_file,self.WD.basepath) utils.assert_dir(self.WD.basepath) os.system(cp_string) if do_convert == True: for i in range(len(self.list_paths)): input_name= self.list_names[i] input_file = self.list_paths[i] self.AvconvString(input_name,self.WD.basepath,av_config) print "config" print av_config Converter.UpdateConfig(av_config) print "converting file %i of %i"%(i,len(self.list_paths)) Thread(target=Converter.Run()).start()
def OnAccept(self,e): tl_mode = self.check_tl_mode() if tl_mode ==3: # for mode with full frame self.positions[:]=[] self.positions.append((0,0)) self.positions.append(self.img.size()) self.positions.append((0,0)) self.positions.append(self.img.size()) out_path = self.get_out_dir() utils.assert_dir(out_path) # init tlm T = tlm() T.SetIO(self.in_path,out_path) box0=list() box1=list() box1.append((self.positions[2][0],(self.positions[2][1]))) box1.append((self.positions[3][0],(self.positions[3][1]))) box0.append((self.positions[0][0],(self.positions[0][1]))) box0.append((self.positions[1][0],(self.positions[1][1]))) output_res = self.choices_res.GetChoice() output_fps = self.check_fps() seq_out = True seq_out = self.check_out_mode() config ={"res":output_res,"fps":output_fps,"box_start":box0,"box_end":box1} if self.vid_mode ==True: if seq_out ==True: print"VID2SEQ" T.Vid2Seq(config) else: print"VID2VID" T.Vid2Vid(config) if self.vid_mode ==False: if seq_out ==True: print"SEQ2SEQ" T.Seq2Seq(config) else: print"SEQ2VID" T.Seq2Vid(config) print "DONE"
def process_sequence(in_path, o_path, T): tmp_path = "/tmp/frames" o_type = ".jpg" warp_frames = 100 utils.assert_dir(tmp_path) ctr = 0 w = warper() config = {"i_path": "", "o_path": o_path, "warp_frames": warp_frames, "o_type": o_type} w.UpdateConfig(config) for f in range(len(in_path) - 1): T_curr = T[ctr] if ctr == 0: # TODO: not right T_prev = (1, 0, 0, 0, 0, 1, 0, 0) else: T_prev = T[ctr - 1] # TODO: make this work # T_use=imgutils.trafo_combine(T_curr,T_prev) if ctr == 0: f0 = iwx.iFrame(in_path[ctr], ctr) f1 = iwx.iFrame(in_path[ctr + 1], ctr) img0 = f0.pil_img() img1 = f1.pil_img() else: img0 = mor f1 = iwx.iFrame(in_path[ctr + 1], ctr) img1 = f1.pil_img() m = morpher() m.SetInputFrames(f0, f1) if ctr > 0: m.Run(T_prev) mor = iwx.iFrame(m.GetImgM()) m.SetInputFrames(f0, mor) m.Run(T_curr) else: m.Run(T_curr) mor = m.GetImgM() w.process_images(img0, mor, ctr=ctr * warp_frames) ctr += 1
import data import utils import char_rnn import sys if __name__ == '__main__': # get cmd line args from user <- config file if len(sys.argv) > 1: # get configuration g = utils.get_config(sys.argv[1]) # check if we need to process text file if g['data_file'] and utils.isEmpty(g['ckpt_path']): # check if folder exists, if not create folder utils.assert_dir(g['data_path']) data.process_data(filename= g['data_file'], path= g['data_path']) # check if checkpoint path exists utils.assert_dir(g['ckpt_path']) try: # fetch dataset X, Y, idx2ch, ch2idx = data.load_data(path=g['data_path']) except: print('\n>> Is the folder {} empty?'.format(g['ckpt_path'])) print('Shouldn\'t it be?') sys.exit() # training set batch generator trainset = utils.rand_batch_gen(X, Y, batch_size= g['batch_size'])