From 8ae677849286a7b3f7a050f986dad895f362422f Mon Sep 17 00:00:00 2001 From: Pierre Karashchuk Date: Tue, 22 Jan 2019 18:12:00 -0800 Subject: [PATCH 1/2] add destination folder argument --- .../pose_estimation_tensorflow/predict_videos.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/deeplabcut/pose_estimation_tensorflow/predict_videos.py b/deeplabcut/pose_estimation_tensorflow/predict_videos.py index 23b3208ad8..76f0107d97 100644 --- a/deeplabcut/pose_estimation_tensorflow/predict_videos.py +++ b/deeplabcut/pose_estimation_tensorflow/predict_videos.py @@ -33,7 +33,7 @@ # Loading data, and defining model folder #################################################### -def analyze_videos(config,videos,shuffle=1,trainingsetindex=0,videotype='avi',gputouse=None,save_as_csv=False): +def analyze_videos(config,videos,shuffle=1,trainingsetindex=0,videotype='avi',gputouse=None,save_as_csv=False, destfolder=None): """ Makes prediction based on a trained network. The index of the trained network is specified by parameters in the config file (in particular the variable 'snapshotindex') @@ -67,6 +67,9 @@ def analyze_videos(config,videos,shuffle=1,trainingsetindex=0,videotype='avi',gp save_as_csv: bool, optional Saves the predictions in a .csv file. The default is ``False``; if provided it must be either ``True`` or ``False`` + destfolder: string, optional + Specifies the destination folder for analysis data (default is the path of the video) + Examples -------- If you want to analyze only 1 video @@ -165,7 +168,7 @@ def analyze_videos(config,videos,shuffle=1,trainingsetindex=0,videotype='avi',gp if len(Videos)>0: #looping over videos for video in Videos: - AnalzyeVideo(video,DLCscorer,cfg,dlc_cfg,sess,inputs, outputs,pdindex,save_as_csv) + AnalzyeVideo(video,DLCscorer,cfg,dlc_cfg,sess,inputs, outputs,pdindex,save_as_csv, destfolder) os.chdir(str(start_path)) print("The videos are analyzed. Now your research can truly start! \n You can create labeled videos with 'create_labeled_video'.") @@ -265,11 +268,13 @@ def GetPoseS(cfg,dlc_cfg, sess, inputs, outputs,cap,nframes): return PredicteData,nframes -def AnalzyeVideo(video,DLCscorer,cfg,dlc_cfg,sess,inputs, outputs,pdindex,save_as_csv): +def AnalzyeVideo(video,DLCscorer,cfg,dlc_cfg,sess,inputs, outputs,pdindex,save_as_csv, destfolder=None): ''' Helper function for analyzing a video ''' print("Starting to analyze % ", video) vname = Path(video).stem - dataname = os.path.join(str(Path(video).parents[0]),vname + DLCscorer + '.h5') + if destfolder is None: + destfolder = str(Path(video).parents[0]) + dataname = os.path.join(destfolder,vname + DLCscorer + '.h5') try: # Attempt to load data... pd.read_hdf(dataname) From dae66b312265c8c6b0d29fdd0d9c1a1af35dda1b Mon Sep 17 00:00:00 2001 From: Pierre Karashchuk Date: Tue, 22 Jan 2019 18:12:24 -0800 Subject: [PATCH 2/2] fix type in AnalyzeVideo --- deeplabcut/pose_estimation_tensorflow/predict_videos.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deeplabcut/pose_estimation_tensorflow/predict_videos.py b/deeplabcut/pose_estimation_tensorflow/predict_videos.py index 76f0107d97..e418406dbb 100644 --- a/deeplabcut/pose_estimation_tensorflow/predict_videos.py +++ b/deeplabcut/pose_estimation_tensorflow/predict_videos.py @@ -168,7 +168,7 @@ def analyze_videos(config,videos,shuffle=1,trainingsetindex=0,videotype='avi',gp if len(Videos)>0: #looping over videos for video in Videos: - AnalzyeVideo(video,DLCscorer,cfg,dlc_cfg,sess,inputs, outputs,pdindex,save_as_csv, destfolder) + AnalyzeVideo(video,DLCscorer,cfg,dlc_cfg,sess,inputs, outputs,pdindex,save_as_csv, destfolder) os.chdir(str(start_path)) print("The videos are analyzed. Now your research can truly start! \n You can create labeled videos with 'create_labeled_video'.") @@ -268,7 +268,7 @@ def GetPoseS(cfg,dlc_cfg, sess, inputs, outputs,cap,nframes): return PredicteData,nframes -def AnalzyeVideo(video,DLCscorer,cfg,dlc_cfg,sess,inputs, outputs,pdindex,save_as_csv, destfolder=None): +def AnalyzeVideo(video,DLCscorer,cfg,dlc_cfg,sess,inputs, outputs,pdindex,save_as_csv, destfolder=None): ''' Helper function for analyzing a video ''' print("Starting to analyze % ", video) vname = Path(video).stem