def shorten_video(self, event): def sweet_time_format(val): return str(datetime.timedelta(seconds=val)) deeplabcut.ShortenVideo(self.filelist[0], start=sweet_time_format( self.vstart.GetValue()), stop=sweet_time_format(self.vstop.GetValue()))
def shorten_video(self, event): def sweet_time_format(val): return str(datetime.timedelta(seconds=val)) Videos = self.filelist if len(Videos) > 0: for video in Videos: deeplabcut.ShortenVideo( video, start=sweet_time_format(self.vstart.GetValue()), stop=sweet_time_format(self.vstop.GetValue()), ) else: print("Please select a video first!")
print("TRAIN") deeplabcut.train_network(path_config_file) print("EVALUATE") deeplabcut.evaluate_network(path_config_file, plotting=True) #deeplabcut.evaluate_network(path_config_file,plotting=True,trainingsetindex=33) print("CUT SHORT VIDEO AND ANALYZE (with dynamic cropping!)") # Make super short video (so the analysis is quick!) try: #you need ffmpeg command line interface #subprocess.call(['ffmpeg','-i',video[0],'-ss','00:00:00','-to','00:00:00.4','-c','copy',newvideo]) newvideo = deeplabcut.ShortenVideo(video[0], start='00:00:00', stop='00:00:00.4', outsuffix='short', outpath=os.path.join( cfg['project_path'], 'videos')) vname = Path(newvideo).stem except: # if ffmpeg is broken vname = 'brief' newvideo = os.path.join(cfg['project_path'], 'videos', vname + '.mp4') from moviepy.editor import VideoFileClip, VideoClip clip = VideoFileClip(video[0]) clip.reader.initialize() def make_frame(t): return clip.get_frame(1) newclip = VideoClip(make_frame, duration=1) newclip.write_videofile(newvideo, fps=30)
print("Training network...") deeplabcut.train_network(config_path, maxiters=N_ITER) print("Network trained.") print("Evaluating network...") deeplabcut.evaluate_network(config_path, plotting=True) print("Network evaluated....") print("Extracting maps...") deeplabcut.extract_save_all_maps(config_path, Indices=[0, 1, 2]) new_video_path = deeplabcut.ShortenVideo( video_path, start="00:00:00", stop="00:00:01", outsuffix="short", outpath=os.path.join(cfg["project_path"], "videos"), ) print("Analyzing video...") deeplabcut.analyze_videos( config_path, [new_video_path], "mp4", robust_nframes=True, allow_growth=True, use_shelve=USE_SHELVE, ) print("Video analyzed.")
print("TRAIN") deeplabcut.train_network(path_config_file) print("EVALUATE") deeplabcut.evaluate_network(path_config_file, plotting=True) # deeplabcut.evaluate_network(path_config_file,plotting=True,trainingsetindex=33) print("CUT SHORT VIDEO AND ANALYZE (with dynamic cropping!)") # Make super short video (so the analysis is quick!) try: # you need ffmpeg command line interface # subprocess.call(['ffmpeg','-i',video[0],'-ss','00:00:00','-to','00:00:00.4','-c','copy',newvideo]) newvideo = deeplabcut.ShortenVideo( video[0], start="00:00:00", stop="00:00:00.4", outsuffix="short", outpath=os.path.join(cfg["project_path"], "videos"), ) vname = Path(newvideo).stem except: # if ffmpeg is broken vname = "brief" newvideo = os.path.join(cfg["project_path"], "videos", vname + ".mp4") from moviepy.editor import VideoFileClip, VideoClip clip = VideoFileClip(video[0]) clip.reader.initialize() def make_frame(t): return clip.get_frame(1)