Skip to content

Commit

Permalink
Enable tracking-only inference pipeline from gui.
Browse files Browse the repository at this point in the history
If you use "run inference" and don't select any models but do
select a tracking method, it will just re-assign tracks for the
predicted instances you already have in the project.
  • Loading branch information
ntabris committed Jan 23, 2020
1 parent f1854b6 commit 2f53c32
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions sleap/gui/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,7 @@ def run_learning_pipeline(
trained_job_paths=trained_job_paths,
inference_params=inference_params,
frames_to_predict=frames_to_predict,
labels_filename=labels_filename,
)

return new_labeled_frame_count
Expand Down Expand Up @@ -969,6 +970,7 @@ def run_gui_inference(
trained_job_paths: List[str],
frames_to_predict: Dict[Video, List[int]],
inference_params: Dict[str, str],
labels_filename: str,
gui: bool = True,
) -> int:
"""Run inference on specified frames using models from training_jobs.
Expand Down Expand Up @@ -1015,6 +1017,7 @@ def waiting():
trained_job_paths=trained_job_paths,
kwargs=inference_params,
waiting_callback=waiting,
labels_filename=labels_filename,
)

if success:
Expand Down
9 changes: 8 additions & 1 deletion sleap/nn/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,9 +477,16 @@ def predict_subprocess(
kwargs: Dict[str, str],
frames: Optional[List[int]] = None,
waiting_callback: Optional[Callable] = None,
labels_filename: Optional[str] = None,
):

cli_args = ["python", "-m", "sleap.nn.inference", video.filename]
cli_args = ["python", "-m", "sleap.nn.inference"]

if not trained_job_paths and "tracking.tracker" in kwargs and labels_filename:
# No models so we must want to re-track previous predictions
cli_args.append(labels_filename)
else:
cli_args.append(video.filename)

# TODO: better support for video params
if hasattr(video.backend, "dataset"):
Expand Down

0 comments on commit 2f53c32

Please sign in to comment.