Closed emdavis02 closed 3 months ago
Great job @emdavis02!
Path.isdir()
and Path.isfile()
documented here.inference.py
to make sure changes are covered.
- We could try it with and without the additional argument to determine if the input is a directory. It might be sufficient to use
os.path.isdir()
and os.path.isfile()` documented here.
Just jumping in to say: please use pathlib instead of os.path
APIs!
Thanks! Here is the correspondence between os.path
and Path
: correspondence to tools in the os module
Discussed in https://github.com/talmolab/sleap/discussions/1439
Problem Description
Feature Proposal
Implementation Details
Currently,
sleap_track
takes in an argumentdata_path
from the command line that is the file path to a.slp
file, this means that the user must run this function once for every video they wish to run an inference on either manually or through a script. We would like to allow the argumentdata_path
to also take in a path to a folder of.slp
files and run an inference on each of these files. This will all be acomplished insleap/nn/inference.py
1. Create an optional flag to the cli to specify if
data_path
is a folder_make_cli_parser()
function2. Make
data_path
a list to enable iterationdata_path
data_path = [args.data_path]
Note: The
"labels"
cli argument has been deprecated and will not need to be edited to accomodate this new function. https://github.com/talmolab/sleap/blob/43a4f13ab28d2726af4a9c1858e8e2cde06d53cc/sleap/nn/inference.py#L5292-L52963. Add a loop to file loading lines
data_path
. The loop will encompass the entire code section shown below.provider
to a list to store a value for each item indata_path
https://github.com/talmolab/sleap/blob/43a4f13ab28d2726af4a9c1858e8e2cde06d53cc/sleap/nn/inference.py#L5304-L53284. Add a loop to
main()
for running inference and tracking[ ] Iterate through
data_path
in the section of main shown below. The loop will start at line 5476, before we run the inference but after the predictor.tracker is set. https://github.com/talmolab/sleap/blob/43a4f13ab28d2726af4a9c1858e8e2cde06d53cc/sleap/nn/inference.py#L5473-L5485[ ] transplate the following lines of code into the above loop. This will need to be run for each item in
data_path
https://github.com/talmolab/sleap/blob/43a4f13ab28d2726af4a9c1858e8e2cde06d53cc/sleap/nn/inference.py#L5510-L55415. Add an aditional loop to
main()
for just running tracking[ ] Iterate through
data_path
for the following code. The loop will start after theelif
and contain the rest of the attatched lines. https://github.com/talmolab/sleap/blob/43a4f13ab28d2726af4a9c1858e8e2cde06d53cc/sleap/nn/inference.py#L5487-L5500[ ] Again, we will have to transplant the following lines of code into the loop. https://github.com/talmolab/sleap/blob/43a4f13ab28d2726af4a9c1858e8e2cde06d53cc/sleap/nn/inference.py#L5510-L5541
Documentation Changes
Changes will be made to the sleap-track section of the documentation
positional arguments: data_path Path to data to predict on. This can be one of the following:
.slp
file containing labeled data.optional arguments: ... -o OUTPUT, --output OUTPUT The output filename or directory path to use for the predicted data. If not provided, defaults to '[data_path].predictions.slp'.