Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions deeplabcut/pose_estimation_tensorflow/predict_videos.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
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'.")
Expand Down Expand Up @@ -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 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
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)
Expand Down