Skip to content

Commit

Permalink
copy over repository
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinefalisse committed Oct 5, 2022
1 parent cc67f1a commit b65a4bb
Show file tree
Hide file tree
Showing 205 changed files with 32,963 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.git
Data
.env
docker
19 changes: 19 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
*.mp4
#*.mov
*~
#*.json
.ipynb_checkpoints
__pycache__
*.log
*WithKeypoints.avi
*_rotated.avi
.env
*.pth

# Data
*/Data/*
Data/
Examples/Data/*

*.ini
*.stats
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
58 changes: 58 additions & 0 deletions Examples/batchDownloadData.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
"""
---------------------------------------------------------------------------
OpenCap: batchDownloadData.py
---------------------------------------------------------------------------
Copyright 2022 Stanford University and the Authors
Author(s): Scott Uhlrich, Antoine Falisse
Licensed under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy
of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
This script dowloads data from multiple sessions from the database.
You will need login credentials from app.opencap.ai to run this script. You
can quickly create credentials from the home page: https://app.opencap.ai.
We recommend first running the Examples/createAuthenticationEnvFile.py script
prior to running this script. Otherwise, you will need to to login every time
you run the script.
"""

# %% Imports

import sys
import os
sys.path.append(os.path.abspath('./..'))
import utils

# %% User inputs

# Sessions to download. List of strings of identifiers (36-character) string
# at the end of the session url app.opencap.ai/session/<session_id>
session_ids = [
'23d52d41-69fe-47cf-8b60-838e4268dd50'
] # list of session identifiers as strings

# Local path to download sessions to
downloadFolder = os.path.abspath(os.path.join(os.path.dirname(__file__),'..','Data'))

# Name downloaded folder with subject name from web app (True), or the session_id (False)
useSubjectIdentifierAsFolderName = True


#%% Processing

# Batch download.
for session_id in session_ids:
utils.downloadAndZipSession(session_id,justDownload=True,data_dir=downloadFolder,
useSubjectNameFolder=useSubjectIdentifierAsFolderName)
37 changes: 37 additions & 0 deletions Examples/changeSessionMetadata.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
"""
---------------------------------------------------------------------------
OpenCap: changeSessionMetadata.py
---------------------------------------------------------------------------
Copyright 2022 Stanford University and the Authors
Author(s): Scott Uhlrich, Antoine Falisse
Licensed under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy
of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
This script allows you to change the metadata of the session. E.g., to change
the pose estimator used when reprocessing data in the cloud. This is mostly for
developer use.
"""
import os
import sys
sys.path.append(os.path.abspath('./..'))

from utils import changeSessionMetadata

session_ids = ['0d46adef-62cb-455f-9ff3-8116717cc2fe']

# Dictionary of metadata fields to change.
newMetadata = {'posemodel':'openpose'} # dict of meta fields to change
# newMetadata= {'mass':83}

changeSessionMetadata(session_ids,newMetadata)
36 changes: 36 additions & 0 deletions Examples/createAuthenticationEnvFile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
'''
---------------------------------------------------------------------------
OpenCap: createAuthenticationEnvFile.py
---------------------------------------------------------------------------
Copyright 2022 Stanford University and the Authors
Author(s): Antoine Falisse, Scott Uhlrich
Licensed under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy
of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Run this script to save your authentication token (for logging into webapp)
as an environment variable in a .env file.
DO NOT CHANGE THE FILE NAME OF THE .env FILE, or your credentials will get pushed
to github with a commit, and anyone could get access to your data.
We recommend only saving this .env file on your own encrypted machine
and not while running on google collab.
'''



# Restart your terminal or IDE (eg Spyder) after running the script for the
# new environment variable to be loaded.
from utilsAuth import getToken
import os

getToken(saveEnvPath=os.path.abspath(os.path.join(os.path.dirname(__file__),'../')))
110 changes: 110 additions & 0 deletions Examples/reprocessSessions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
"""
---------------------------------------------------------------------------
OpenCap: reprocessSessions.py
---------------------------------------------------------------------------
Copyright 2022 Stanford University and the Authors
Author(s): Scott Uhlrich, Antoine Falisse
Licensed under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy
of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
This script reprocesses OpenCap trials collected with the web application at
app.opencap.ai. You can specify multiple sessions to reprocess, or specific
trials within a session to reprocess. Data will (optionally) be saved locally
in your <repositoryDirectory>/Data/<session_id> folder.
This script is useful for processing a session with more accurate and higher
resolution pose estimation settings It is also useful for debugging failed trials.
The example session is publicly available, but you will need login credentials
from app.opencap.ai to run this script. You can quickly create credentials
from the home page: https://app.opencap.ai. We recommend first running the
Examples/createAuthenticationEnvFile.py script prior to running this script. Otherwise,
you will need to to login every time you run the script.
You can view the example session at:
https://app.opencap.ai/session/23d52d41-69fe-47cf-8b60-838e4268dd50
"""

import os
import sys
sys.path.append(os.path.abspath('./..'))

from utilsServer import batchReprocess
from utils import getTrialNameIdMapping
from utilsAPI import getAPIURL
from utilsAuth import getToken

API_URL = getAPIURL()
API_TOKEN = getToken()

# %% User inputs.
# 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_id>
session_ids = ['23d52d41-69fe-47cf-8b60-838e4268dd50']


# 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
# trials will be automatically selected if None, and all dynamic trials will be
# processed if None. If you do not want to process one of the trial types,
# enter []. If you specify multiple sessions above, all of the fields
# below must be None or []. If you selected only one session_id above, you may
# select specific reprocessed. Only one trial (str) is allowed for calib_id and
# static_id. A list of strings is allowed for dynamic_ids.

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_ids = None # None (all dynamic trials), [] (skip), or list of trial_id strings


# # Optional: Uncomment this section to create a list of dynamic_ids to
# # reprocess from the trial names. This overwrites previous selection.

# trialNames = getTrialNameIdMapping(session_ids[0])
# dynamic_trialNames = ['squat'] # Enter a list of dynamic trial names to be reprocessed
# dynamic_ids = [trialNames[name]['id'] for name in dynamic_trialNames]
# print ('You are reprocessing specific dynamic trials by name')


# The resolution at which the videos are processed by OpenPose can be adjusted.
# The finer the resolution the more accurate the results (typically) but also
# the more GPU memory is required and the more time it takes to process the video.
# OpenCap supports the following four resolutionPoseDetection options (ordered
# from lower to higher resolution/required memory):
# - 'default': 1x368 resolution, default in OpenPose (we were able to run with a GPU with 4GB memory).
# - '1x736': 1x736 resolution, default in OpenCap (we were able to run with a GPU with 4GB memory).
# - '1x736_2scales': 1x736 resolution with 2 scales (gap = 0.75). (may help with people larger in the frame. (we were able to run with a GPU with 8GB memory)
# - Please visit https://github.com/CMU-Perceptual-Computing-Lab/openpose/blob/master/include/openpose/flags.hpp#L112
# to learn more about scales. The conversation in this issue is also
# relevant: https://github.com/CMU-Perceptual-Computing-Lab/openpose/issues/622
# - '1x1008_4scales': 1x1008 resolution with 4 scales (gap = 0.25). (we were only able to run with a GPU with 24GB memory)
# - This is the highest resolution/settings we could use with a 24GB
# GPU without running into memory issues.
resolutionPoseDetection = 'default'


# Set deleteLocalFolder to False to keep a local copy of the data. If you are
# reprocessing a session that you collected, data will get written to the database
# regardless of your selection. If True, the local copy will be deleted.
deleteLocalFolder = False


# %% Process data.
batchReprocess(session_ids,calib_id,static_id,dynamic_ids,
resolutionPoseDetection=resolutionPoseDetection,
deleteLocalFolder=deleteLocalFolder)
Binary file added MarkerAugmenter/LSTM/v0.0/mean.npy
Binary file not shown.
1 change: 1 addition & 0 deletions MarkerAugmenter/LSTM/v0.0/model.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"class_name": "Sequential", "config": {"name": "sequential_1", "layers": [{"class_name": "InputLayer", "config": {"batch_input_shape": [null, null, 59], "dtype": "float32", "sparse": false, "ragged": false, "name": "lstm_3_input"}}, {"class_name": "LSTM", "config": {"name": "lstm_3", "trainable": true, "batch_input_shape": [null, null, 59], "dtype": "float32", "return_sequences": true, "return_state": false, "go_backwards": false, "stateful": false, "unroll": false, "time_major": false, "units": 144, "activation": "tanh", "recurrent_activation": "sigmoid", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}}, "recurrent_initializer": {"class_name": "Orthogonal", "config": {"gain": 1.0, "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "unit_forget_bias": true, "kernel_regularizer": null, "recurrent_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "recurrent_constraint": null, "bias_constraint": null, "dropout": 0.0, "recurrent_dropout": 0.0, "implementation": 2}}, {"class_name": "LSTM", "config": {"name": "lstm_4", "trainable": true, "dtype": "float32", "return_sequences": true, "return_state": false, "go_backwards": false, "stateful": false, "unroll": false, "time_major": false, "units": 144, "activation": "tanh", "recurrent_activation": "sigmoid", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}}, "recurrent_initializer": {"class_name": "Orthogonal", "config": {"gain": 1.0, "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "unit_forget_bias": true, "kernel_regularizer": null, "recurrent_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "recurrent_constraint": null, "bias_constraint": null, "dropout": 0.0, "recurrent_dropout": 0.0, "implementation": 2}}, {"class_name": "TimeDistributed", "config": {"name": "time_distributed_1", "trainable": true, "dtype": "float32", "layer": {"class_name": "Dense", "config": {"name": "dense_1", "trainable": true, "dtype": "float32", "units": 129, "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}}}}]}, "keras_version": "2.6.0", "backend": "tensorflow"}
Binary file added MarkerAugmenter/LSTM/v0.0/std.npy
Binary file not shown.
Binary file added MarkerAugmenter/LSTM/v0.0/weights.h5
Binary file not shown.
Binary file added MarkerAugmenter/LSTM/v0.1_lower/mean.npy
Binary file not shown.
1 change: 1 addition & 0 deletions MarkerAugmenter/LSTM/v0.1_lower/model.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"class_name": "Sequential", "config": {"name": "sequential_1", "layers": [{"class_name": "InputLayer", "config": {"batch_input_shape": [null, null, 47], "dtype": "float32", "sparse": false, "ragged": false, "name": "lstm_3_input"}}, {"class_name": "LSTM", "config": {"name": "lstm_3", "trainable": true, "batch_input_shape": [null, null, 47], "dtype": "float32", "return_sequences": true, "return_state": false, "go_backwards": false, "stateful": false, "unroll": false, "time_major": false, "units": 128, "activation": "tanh", "recurrent_activation": "sigmoid", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}}, "recurrent_initializer": {"class_name": "Orthogonal", "config": {"gain": 1.0, "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "unit_forget_bias": true, "kernel_regularizer": null, "recurrent_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "recurrent_constraint": null, "bias_constraint": null, "dropout": 0.0, "recurrent_dropout": 0.0, "implementation": 2}}, {"class_name": "LSTM", "config": {"name": "lstm_4", "trainable": true, "dtype": "float32", "return_sequences": true, "return_state": false, "go_backwards": false, "stateful": false, "unroll": false, "time_major": false, "units": 128, "activation": "tanh", "recurrent_activation": "sigmoid", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}}, "recurrent_initializer": {"class_name": "Orthogonal", "config": {"gain": 1.0, "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "unit_forget_bias": true, "kernel_regularizer": null, "recurrent_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "recurrent_constraint": null, "bias_constraint": null, "dropout": 0.0, "recurrent_dropout": 0.0, "implementation": 2}}, {"class_name": "TimeDistributed", "config": {"name": "time_distributed_1", "trainable": true, "dtype": "float32", "layer": {"class_name": "Dense", "config": {"name": "dense_1", "trainable": true, "dtype": "float32", "units": 105, "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}}}}]}, "keras_version": "2.6.0", "backend": "tensorflow"}
Binary file added MarkerAugmenter/LSTM/v0.1_lower/std.npy
Binary file not shown.
Binary file added MarkerAugmenter/LSTM/v0.1_lower/weights.h5
Binary file not shown.
Binary file added MarkerAugmenter/LSTM/v0.1_upper/mean.npy
Binary file not shown.
1 change: 1 addition & 0 deletions MarkerAugmenter/LSTM/v0.1_upper/model.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"class_name": "Sequential", "config": {"name": "sequential_1", "layers": [{"class_name": "InputLayer", "config": {"batch_input_shape": [null, null, 23], "dtype": "float32", "sparse": false, "ragged": false, "name": "lstm_4_input"}}, {"class_name": "LSTM", "config": {"name": "lstm_4", "trainable": true, "batch_input_shape": [null, null, 23], "dtype": "float32", "return_sequences": true, "return_state": false, "go_backwards": false, "stateful": false, "unroll": false, "time_major": false, "units": 80, "activation": "tanh", "recurrent_activation": "sigmoid", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}}, "recurrent_initializer": {"class_name": "Orthogonal", "config": {"gain": 1.0, "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "unit_forget_bias": true, "kernel_regularizer": null, "recurrent_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "recurrent_constraint": null, "bias_constraint": null, "dropout": 0.0, "recurrent_dropout": 0.0, "implementation": 2}}, {"class_name": "LSTM", "config": {"name": "lstm_5", "trainable": true, "dtype": "float32", "return_sequences": true, "return_state": false, "go_backwards": false, "stateful": false, "unroll": false, "time_major": false, "units": 80, "activation": "tanh", "recurrent_activation": "sigmoid", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}}, "recurrent_initializer": {"class_name": "Orthogonal", "config": {"gain": 1.0, "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "unit_forget_bias": true, "kernel_regularizer": null, "recurrent_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "recurrent_constraint": null, "bias_constraint": null, "dropout": 0.0, "recurrent_dropout": 0.0, "implementation": 2}}, {"class_name": "LSTM", "config": {"name": "lstm_6", "trainable": true, "dtype": "float32", "return_sequences": true, "return_state": false, "go_backwards": false, "stateful": false, "unroll": false, "time_major": false, "units": 80, "activation": "tanh", "recurrent_activation": "sigmoid", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}}, "recurrent_initializer": {"class_name": "Orthogonal", "config": {"gain": 1.0, "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "unit_forget_bias": true, "kernel_regularizer": null, "recurrent_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "recurrent_constraint": null, "bias_constraint": null, "dropout": 0.0, "recurrent_dropout": 0.0, "implementation": 2}}, {"class_name": "TimeDistributed", "config": {"name": "time_distributed_1", "trainable": true, "dtype": "float32", "layer": {"class_name": "Dense", "config": {"name": "dense_1", "trainable": true, "dtype": "float32", "units": 24, "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}}}}]}, "keras_version": "2.6.0", "backend": "tensorflow"}
Binary file added MarkerAugmenter/LSTM/v0.1_upper/std.npy
Binary file not shown.
Binary file added MarkerAugmenter/LSTM/v0.1_upper/weights.h5
Binary file not shown.
Binary file added MarkerAugmenter/LSTM/v0.2_lower/mean.npy
Binary file not shown.
Loading

0 comments on commit b65a4bb

Please sign in to comment.