Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to predict on all videos #749

Merged
merged 4 commits into from
May 18, 2022
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions sleap/gui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1556,6 +1556,9 @@ def encode_range(a: int, b: int) -> Tuple[int, int]:

selection["clip"] = {current_video: encode_range(*clip_range)}
selection["video"] = {current_video: encode_range(0, current_video.num_frames)}
selection["all_videos"] = {
video: encode_range(0, video.num_frames) for video in self.labels.videos
}

selection["suggestions"] = {
video: remove_user_labeled(video, self.labels.get_video_suggestions(video))
Expand Down
14 changes: 12 additions & 2 deletions sleap/gui/learning/dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ def frame_selection(self, frame_selection: Dict[str, Dict[Video, List[int]]]):
random_video = 0
clip_length = 0
video_length = 0
all_videos_length = 0

# Determine which options are available given _frame_selection
if "random" in self._frame_selection:
Expand All @@ -219,6 +220,10 @@ def frame_selection(self, frame_selection: Dict[str, Dict[Video, List[int]]]):
video_length = self.count_total_frames_for_selection_option(
self._frame_selection["video"]
)
if "all_videos" in self._frame_selection:
all_videos_length = self.count_total_frames_for_selection_option(
self._frame_selection["all_videos"]
)

# Build list of options
# Priority for default (lowest to highest):
Expand Down Expand Up @@ -252,7 +257,10 @@ def frame_selection(self, frame_selection: Dict[str, Dict[Video, List[int]]]):
prediction_options.append(option)
default_option = option

prediction_options.append(f"entire video ({video_length} frames)")
prediction_options.append(f"entire current video ({video_length} frames)")

if len(self.labels.videos) > 1:
prediction_options.append(f"all videos ({all_videos_length} frames)")

self.pipeline_form_widget.fields["_predict_frames"].set_options(
prediction_options, default_option
Expand Down Expand Up @@ -454,8 +462,10 @@ def get_selected_frames_to_predict(
frames_to_predict = self._frame_selection["clip"]
elif predict_frames_choice.startswith("suggested"):
frames_to_predict = self._frame_selection["suggestions"]
elif predict_frames_choice.startswith("entire video"):
elif predict_frames_choice.startswith("entire current video"):
frames_to_predict = self._frame_selection["video"]
elif predict_frames_choice.startswith("all videos"):
frames_to_predict = self._frame_selection["all_videos"]
elif predict_frames_choice.startswith("user"):
frames_to_predict = self._frame_selection["user"]

Expand Down