diff --git a/Examples/changeSessionMetadata.py b/Examples/changeSessionMetadata.py index eb5425ca..e03f46f0 100644 --- a/Examples/changeSessionMetadata.py +++ b/Examples/changeSessionMetadata.py @@ -46,15 +46,16 @@ from utils import changeSessionMetadata -session_ids = ["0d46adef-62cb-455f-9ff3-8116717cc2fe"] +session_ids = ["6dc0721a-7457-4ce1-8523-577900b5399f"] # Dictionary of metadata fields to change (see sessionMetadata.yaml). newMetadata = { - 'openSimModel':'LaiUhlrich2022_shoulder', - 'posemodel':'hrnet', - 'augmentermodel':'v0.3', - 'filterfrequency':15, - 'datasharing':'Share processed data and identified videos', - 'scalingsetup': 'upright_standing_pose' + 'camerastouse': ['all_available'] + # 'openSimModel':'LaiUhlrich2022_shoulder', + # 'posemodel':'hrnet', + # 'augmentermodel':'v0.3', + # 'filterfrequency':15, + # 'datasharing':'Share processed data and identified videos', + # 'scalingsetup': 'upright_standing_pose' } changeSessionMetadata(session_ids,newMetadata) \ No newline at end of file diff --git a/Examples/reprocessSessions.py b/Examples/reprocessSessions.py index 37330ebd..fe536940 100644 --- a/Examples/reprocessSessions.py +++ b/Examples/reprocessSessions.py @@ -55,7 +55,7 @@ # Enter the identifier(s) of the session(s) you want to reprocess. This is a list of one # or more session identifiers. The identifier is found as the 36-character string at the # end of the session url: app.opencap.ai/session/ -session_ids = ['23d52d41-69fe-47cf-8b60-838e4268dd50'] +session_ids = ['6dc0721a-7457-4ce1-8523-577900b5399f'] # Select which trials to reprocess. You can reprocess all trials in the session # by entering None in all fields below. The correct calibration and static @@ -68,7 +68,7 @@ calib_id = [] # None (auto-selected trial), [] (skip), or string of specific trial_id static_id = [] # None (auto-selected trial), [] (skip), or string of specific trial_id -dynamic_trialNames = None # None (all dynamic trials), [] (skip), or list of trial names +dynamic_trialNames = ['test_2'] # None (all dynamic trials), [] (skip), or list of trial names # Select which pose estimation model to use; options are 'OpenPose' and 'hrnet'. # If the same pose estimation model was used when collecting data with the web @@ -79,7 +79,7 @@ # selected 'hrnet' when collecting data with the web app. You can however re- # process data originally collected with 'hrnet' with 'OpenPose' if you have # installed OpenPose locally (see README.md for instructions). -poseDetector = 'OpenPose' +poseDetector = 'hrnet' # OpenPose only: # Select the resolution at which the videos are processed. There are no @@ -110,4 +110,5 @@ batchReprocess(session_ids,calib_id,static_id,dynamic_trialNames, poseDetector=poseDetector, resolutionPoseDetection=resolutionPoseDetection, - deleteLocalFolder=deleteLocalFolder) + deleteLocalFolder=deleteLocalFolder, + cameras_to_use = ['all_available']) diff --git a/app.py b/app.py index fab31fc6..bef1b48d 100644 --- a/app.py +++ b/app.py @@ -121,24 +121,11 @@ headers = {"Authorization": "Token {}".format(API_TOKEN)}) continue - # This is a hack to have the trials with status "reprocess" to be reprocessed - # with camerasToUse = ['all_available'] instead of ['all']. In practice, this - # allows reprocessing on server trials that failed because video(s) were not available. - # This is a temporary solution until we have a better way to handle this. By default, - # trials with missing videos are error-ed out directly so that we do not spend time - # on processing them. Problem is that these trials then don't have pose pickles, which - # makes is hard for local reprocessing (hrnet still a hassle to install locally on Windows). - # status = trial["status"] - # status = 'reprocess' - # logging.info(f"Trial status: {status}") - # if status == "reprocess": - # camerasToUse_c = ['all_available'] - # else: - # camerasToUse_c = ['all'] - # if any([v["video"] is None for v in trial["videos"]]): - # r = requests.patch(trial_url, data={"status": "error"}, - # headers = {"Authorization": "Token {}".format(API_TOKEN)}) - # continue + # The following is now done in main, to allow reprocessing trials with missing videos + # if any([v["video"] is None for v in trial["videos"]]): + # r = requests.patch(trial_url, data={"status": "error"}, + # headers = {"Authorization": "Token {}".format(API_TOKEN)}) + # continue trial_type = "dynamic" if trial["name"] == "calibration": diff --git a/main.py b/main.py index 00d5b5cc..0c9f6707 100644 --- a/main.py +++ b/main.py @@ -31,7 +31,7 @@ from utilsAugmenter import augmentTRC from utilsOpenSim import runScaleTool, getScaleTimeRange, runIKTool, generateVisualizerJson -def main(sessionName, trialName, trial_id, camerasToUse=['all'], +def main(sessionName, trialName, trial_id, cameras_to_use=['all'], intrinsicsFinalFolder='Deployed', isDocker=False, extrinsicsTrial=False, alternateExtrinsics=None, calibrationOptions=None, @@ -41,7 +41,8 @@ def main(sessionName, trialName, trial_id, camerasToUse=['all'], genericFolderNames=False, offset=True, benchmark=False, dataDir=None, overwriteAugmenterModel=False, filter_frequency='default', overwriteFilterFrequency=False, - scaling_setup='upright_standing_pose', overwriteScalingSetup=False): + scaling_setup='upright_standing_pose', overwriteScalingSetup=False, + overwriteCamerasToUse=False): # %% High-level settings. # Camera calibration. @@ -121,11 +122,14 @@ def main(sessionName, trialName, trial_id, camerasToUse=['all'], else: scalingSetup = scaling_setup - # If reprocess is in sessionMetadata, reprocess with all cameras available - # instead of all cameras. This allows reprocessing of trials with missing - # videos. - if 'reprocess' in sessionMetadata: - camerasToUse = ['all_available'] + # If camerastouse is in sessionMetadata, reprocess with specified cameras. + # This allows reprocessing trials with missing videos. If + # overwriteCamerasToUse is True, the camera selection is the one + # passed as an argument to main(). This is useful for local testing. + if 'camerastouse' in sessionMetadata and not overwriteCamerasToUse: + camerasToUse = sessionMetadata['camerastouse'] + else: + camerasToUse = cameras_to_use # %% Paths to pose detector folder for local testing. if poseDetector == 'OpenPose': diff --git a/utils.py b/utils.py index 0e79a1bf..e45a1bba 100644 --- a/utils.py +++ b/utils.py @@ -671,7 +671,7 @@ def changeSessionMetadata(session_ids,newMetaDict): for newMeta in newMetaDict: if not newMeta in addedKey: print("Could not find {} in existing metadata, trying to add it.".format(newMeta)) - settings_fields = ['framerate', 'posemodel', 'openSimModel', 'augmentermodel', 'filterfrequency', 'scalingsetup'] + settings_fields = ['framerate', 'posemodel', 'openSimModel', 'augmentermodel', 'filterfrequency', 'scalingsetup', 'camerastouse'] if newMeta in settings_fields: if 'settings' not in existingMeta: existingMeta['settings'] = {} diff --git a/utilsServer.py b/utilsServer.py index 624fc54c..352a8419 100644 --- a/utilsServer.py +++ b/utilsServer.py @@ -41,7 +41,7 @@ def processTrial(session_id, trial_id, trial_type = 'dynamic', hasWritePermissions = True, use_existing_pose_pickle = False, batchProcess = False, - camerasToUse=['all']): + cameras_to_use=['all']): # Get session directory session_name = session_id @@ -63,7 +63,7 @@ def processTrial(session_id, trial_id, trial_type = 'dynamic', try: main(session_name, trial_name, trial_id, isDocker=isDocker, extrinsicsTrial=True, imageUpsampleFactor=imageUpsampleFactor,genericFolderNames = True, - camerasToUse=camerasToUse) + cameras_to_use=cameras_to_use) except Exception as e: error_msg = {} error_msg['error_msg'] = e.args[0] @@ -125,7 +125,7 @@ def processTrial(session_id, trial_id, trial_type = 'dynamic', genericFolderNames = True, bbox_thr = bbox_thr, calibrationOptions = calibrationOptions, - camerasToUse=camerasToUse) + cameras_to_use=cameras_to_use) except Exception as e: # Try to post pose pickles so can be used offline. This function will # error at kinematics most likely, but if pose estimation completed, @@ -215,7 +215,7 @@ def processTrial(session_id, trial_id, trial_type = 'dynamic', resolutionPoseDetection = resolutionPoseDetection, genericFolderNames = True, bbox_thr = bbox_thr, - camerasToUse=camerasToUse) + cameras_to_use=cameras_to_use) except Exception as e: # Try to post pose pickles so can be used offline. This function will # error at kinematics most likely, but if pose estimation completed, @@ -336,7 +336,7 @@ def newSessionSameSetup(session_id_old,session_id_new,extrinsicTrialName='calibr def batchReprocess(session_ids,calib_id,static_id,dynamic_trialNames,poseDetector='OpenPose', resolutionPoseDetection='1x736',deleteLocalFolder=True, isServer=False, use_existing_pose_pickle=True, - camerasToUse=['all']): + cameras_to_use=['all']): # extract trial ids from trial names if dynamic_trialNames is not None and len(dynamic_trialNames)>0: @@ -372,7 +372,7 @@ def batchReprocess(session_ids,calib_id,static_id,dynamic_trialNames,poseDetecto deleteLocalFolder = deleteLocalFolder, isDocker=isServer, hasWritePermissions = hasWritePermissions, - camerasToUse=camerasToUse) + cameras_to_use=cameras_to_use) statusData = {'status':'done'} _ = requests.patch(API_URL + "trials/{}/".format(calib_id_toProcess), data=statusData, headers = {"Authorization": "Token {}".format(API_TOKEN)}) @@ -399,7 +399,7 @@ def batchReprocess(session_ids,calib_id,static_id,dynamic_trialNames,poseDetecto hasWritePermissions = hasWritePermissions, use_existing_pose_pickle = use_existing_pose_pickle, batchProcess = True, - camerasToUse=camerasToUse) + cameras_to_use=cameras_to_use) statusData = {'status':'done'} _ = requests.patch(API_URL + "trials/{}/".format(static_id_toProcess), data=statusData, headers = {"Authorization": "Token {}".format(API_TOKEN)}) @@ -431,7 +431,7 @@ def batchReprocess(session_ids,calib_id,static_id,dynamic_trialNames,poseDetecto hasWritePermissions = hasWritePermissions, use_existing_pose_pickle = use_existing_pose_pickle, batchProcess = True, - camerasToUse=camerasToUse) + cameras_to_use=cameras_to_use) statusData = {'status':'done'} _ = requests.patch(API_URL + "trials/{}/".format(dID), data=statusData,