Skip to content

Add option to group cameras from sessions #2125

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

Draft
wants to merge 81 commits into
base: liezl/add-gui-elements-for-sessions
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
ffe5582
Imports
Jvshen Feb 27, 2025
3023b10
Add a button to add camera to group
Jvshen Feb 27, 2025
23c9dd6
Add camera to group function
Jvshen Feb 27, 2025
16c7d88
Create Camera Groups table model
Jvshen Feb 27, 2025
0b963be
Create camera groups table
Jvshen Feb 27, 2025
7182b07
Create camera groups table
Jvshen Feb 27, 2025
e646a92
Add camera groups table model to class attributes
Jvshen Feb 27, 2025
fca9e8f
Add camera groups table function and adding and deleteing a camera gr…
Jvshen Feb 27, 2025
baa283b
Add table model for camera groups
Jvshen Feb 27, 2025
5ce4bc4
Merge branch 'liezl/add-gui-elements-for-sessions' of https://github.…
Jvshen Mar 4, 2025
3844141
Update sessions dock to be able to add and delete camera groups and a…
Jvshen Mar 4, 2025
d61ea3c
Initialize camera_groups state variables in App class
Jvshen Mar 4, 2025
4233131
Update on_data_update to sync camera_groups between labels metadata a…
Jvshen Mar 4, 2025
8bb6b99
Add setCameraGroupName method to enable renaming camera groups in table
Jvshen Mar 4, 2025
b508503
Add CameraGroup class, AddCameraGroup, DeleteCameraGroup,
Jvshen Mar 4, 2025
1292cdc
Add camera group methods to CommandContext for executing camera group…
Jvshen Mar 4, 2025
c0c28a4
Change naming and remove unnecessary code
Jvshen Mar 11, 2025
ca06614
Add import
Jvshen Mar 11, 2025
d6bf553
Refactor: Rename function CameraGroup to CameraCategory in CommandCon…
Jvshen Mar 11, 2025
695500d
Refactor: Rename function CameraGroup to CameraCategory in command cl…
Jvshen Mar 11, 2025
0cc94e6
Refactor: Rename function CameraGroupsTableModel to CameraCategoriesT…
Jvshen Mar 11, 2025
83e2dff
Refactor: Rename function CameraGroup to CameraCategory in docks
Jvshen Mar 11, 2025
b16c1af
Add CameraCategory class to cameras.py
Jvshen Mar 11, 2025
1032c83
Add camera_categories attribute
Jvshen Mar 11, 2025
6836608
Add YAML config for Export Labels Package dialog
Jvshen Mar 13, 2025
07de332
Add menu item for Export Labels Package dialog
Jvshen Mar 13, 2025
271ddf1
Add ExportLabelsPackage command for handling dialog-based exports
Jvshen Mar 13, 2025
74c7160
Add execute function for ExportLabelsPackage in CommandContext
Jvshen Mar 13, 2025
b9ce559
Add dialog function for collecting export options
Jvshen Mar 13, 2025
8de15b0
Move export labels dialog into command class and remove export_labels.py
Jvshen Mar 13, 2025
9e6a698
Format change
Jvshen Mar 13, 2025
fd1a93f
Add Camera_category option to exporting
Jvshen Apr 3, 2025
6cf5f0e
formatting
Jvshen Apr 3, 2025
63aae15
Make ExportLabelsPackage be a subclass of ExportDatasetWithImages
Jvshen Apr 3, 2025
8c1839b
Spacing and formatting
Jvshen Apr 3, 2025
f980680
Dialog for exporting labels
Jvshen Apr 3, 2025
918bc9d
make_cattr for cameraCategory
Jvshen Apr 3, 2025
4bdec1b
Filter labels to include frames from cameras in camera categories
Jvshen Apr 3, 2025
4a8afa3
Testing to see if labels store and retrieve camera categories correctly
Jvshen Apr 3, 2025
64c0ec1
add camera category filter to export labels dialog
Jvshen Apr 15, 2025
54b943b
remove old export labels package button
Jvshen Apr 15, 2025
8caa652
remove unused import
Jvshen Apr 15, 2025
0544830
remove extra do_action method
Jvshen Apr 15, 2025
956d3c3
Add back navigation commands comment
Jvshen Apr 15, 2025
c67e634
remove since Labels.camera_categories now always exists
Jvshen Apr 15, 2025
240da9b
Set, add, and populate combobox with available camera categories
Jvshen Apr 15, 2025
986d6a4
Formatting
Jvshen Apr 15, 2025
a2f83f8
Remove unused method
Jvshen Apr 15, 2025
8f550f7
Remove "camera_categories"
Jvshen Apr 17, 2025
5be482b
Change to category
Jvshen Apr 17, 2025
e634f51
Formatting
Jvshen Apr 17, 2025
957cbdf
WIP: Change add_camera_to_category workflow
Jvshen Apr 17, 2025
e7e8936
Formatting
Jvshen Apr 17, 2025
6fd57c8
Make changes to add camera to categories
roomrys Apr 17, 2025
6bb48f9
Make changes to add camera to categories
roomrys Apr 17, 2025
48fcf7f
Reset selection after command
roomrys Apr 21, 2025
5ed8c4e
Fix selected_camera_category not being selected
roomrys Apr 21, 2025
64805b1
Link Delete Category button straight to command
roomrys Apr 21, 2025
34eec48
Remove unused update model method
roomrys Apr 21, 2025
2939eb0
Move create category code to commands
roomrys Apr 21, 2025
1eda317
Rename methods to more appropriate names
roomrys Apr 21, 2025
acdf642
Disable delete category button when there is no selected category
roomrys Apr 21, 2025
e947165
Delegate code to commands instead of dock
roomrys Apr 24, 2025
3b42451
Reorganize method in SessionsDock
roomrys Apr 24, 2025
637ca42
Add remove from category button
Jvshen Apr 24, 2025
721eb32
Add defaults for removeCameraFromCateogory
Jvshen Apr 24, 2025
9ccf2e0
Raise error if camera category or camera is not selected
Jvshen Apr 24, 2025
f4a9045
Add remove from categoyr to update_gui_state
Jvshen Apr 24, 2025
47e0168
Delegate table update to command topic when rename
roomrys Apr 28, 2025
3d56c4b
Rename variable
roomrys Apr 28, 2025
7ae86ea
Add failing camera category load (or save) test
roomrys Apr 28, 2025
f98714e
Redo to_dict and from_dict methods (standalone)
roomrys Apr 28, 2025
115dadf
Test standalone to_dict and from_dict methods
roomrys Apr 28, 2025
dc90117
Redo to and from dict for Labels integration
roomrys Apr 28, 2025
fad7446
Typehint and docstring CameraCategory.make_cattr
roomrys Apr 29, 2025
c208d50
Fix CameraCategory (de)serialization with Labels
roomrys Apr 29, 2025
5a04419
Test CameraCategory (de)serialization with Labels
roomrys Apr 29, 2025
c8e6daa
Lint
roomrys Apr 29, 2025
612ae83
[wip] Filter exported labels by camera category
roomrys Apr 29, 2025
2fa7ebe
[wip] Add test for export labels with category
roomrys Apr 29, 2025
f795e62
Add tests for executing exportlabelspackage and verifying cameras and…
Jvshen May 1, 2025
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
18 changes: 18 additions & 0 deletions sleap/config/export_labels_form.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
main:

- name: export_type
label: Export Type
type: list
options: Labeled frames,Labeled + suggested frames (recommended),Labeled + predicted + suggested frames
default: training
help: >
User Labels: Only user-labeled frames
Training: User-labeled and suggested frames
Full: All frames including unlabeled ones

- name: camera_category
label: Camera Category
type: list
options: all
default: all
help: Select which camera category to export, or 'All Cameras' to export everything
56 changes: 27 additions & 29 deletions sleap/gui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ def __init__(
self.state["share usage data"] = False
self.state["clipboard_track"] = None
self.state["clipboard_instance"] = None
self.state["selected_camera_category"] = None

self.state.connect("marker size", self.plotFrame)
self.state.connect("node label size", self.plotFrame)
Expand Down Expand Up @@ -962,37 +963,14 @@ def new_instance_menu_action():

predictionMenu.addSeparator()

labels_package_menu = predictionMenu.addMenu("Export Labels Package...")
add_menu_item(
labels_package_menu,
"export user labels package",
"Labeled frames",
self.commands.exportUserLabelsPackage,
).setToolTip(
"Export user-labeled frames with image data into a single SLP file.\n\n"
"Use this for archiving a dataset with labeled frames only."
)
add_menu_item(
labels_package_menu,
"export labels package",
"Labeled + suggested frames (recommended)",
self.commands.exportTrainingPackage,
).setToolTip(
"Export user-labeled frames and suggested frames with image data into a "
"single SLP file.\n\n"
"Use this for human-in-the-loop training to enable remote inference on "
"unlabeled frames."
)
add_menu_item(
labels_package_menu,
"export full package",
"Labeled + predicted + suggested frames",
self.commands.exportFullPackage,
predictionMenu,
"export_labels",
"Export Labels Package...",
self.commands.exportLabelsPackage,
).setToolTip(
"Export all frames (including predictions) and suggested frames with image "
"data into a single SLP file.\n\n"
"Use this when you need to store images for predicted frames, such as for "
"proofreading or reproducibility."
"Export labeled frames with various options into a single file.\n\n"
"Use this for archiving, training, or sharing your dataset."
)

predictionMenu.addSeparator()
Expand Down Expand Up @@ -1127,6 +1105,9 @@ def _update_gui_state(self):
has_selected_session = self.state["selected_session"] is not None
has_video = self.state["video"] is not None
has_selected_camcorder = self.state["selected_camera"] is not None
has_selected_camera_category = (
self.state["selected_camera_category"] is not None
)
has_selected_unlinked_video = self.state["selected_unlinked_video"] is not None

has_frame_range = bool(self.state["has_frame_range"])
Expand Down Expand Up @@ -1184,6 +1165,9 @@ def _update_gui_state(self):
self._buttons["remove video"].setEnabled(has_video)
self._buttons["delete instance"].setEnabled(has_selected_instance)
self._buttons["unlink video"].setEnabled(has_selected_camcorder)
self._buttons["remove from category"].setEnabled(
has_selected_camera_category and has_selected_camcorder
)
self.suggestions_dock.suggestions_form_widget.buttons[
"generate_button"
].setEnabled(has_videos)
Expand All @@ -1193,6 +1177,8 @@ def _update_gui_state(self):
and has_selected_camcorder
and has_selected_session
)
self._buttons["add to category"].setEnabled(has_selected_camcorder)
self._buttons["delete category"].setEnabled(has_selected_camera_category)

# Update overlays
self.overlays["track_labels"].visible = (
Expand Down Expand Up @@ -1293,6 +1279,7 @@ def _has_topic(topic_list):
self.update_unlinked_videos_model()
self._update_sessions_menu()
self._update_instance_group_model()
self._update_camera_categories_model()

def update_unlinked_videos_model(self):
"""Update the unlinked videos model with the selected session."""
Expand All @@ -1315,6 +1302,12 @@ def _update_instance_group_model(self):

self.instance_groups_dock.table.model().items = []

def _update_camera_categories_model(self):
"""Update the camera categories model with the selected session."""
self.sessions_dock.camera_categories_table.model().items = self.state[
"labels"
].camera_categories

def update_cameras_model(self):
"""Update the cameras model with the selected session."""
self.sessions_dock.camera_table.model().items = self.state["selected_session"]
Expand Down Expand Up @@ -1875,3 +1868,8 @@ def main(args: Optional[list] = None, labels: Optional[Labels] = None):
app.exec_()

pass


if __name__ == "__main__":
ds = "tests/data/cameras/minimal_session/min_session_frame_groups.slp"
main([ds])
Comment on lines +1871 to +1875
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove before merging

Loading
Loading