Skip to content

BUCTD GUI integration#3016

Merged
MMathisLab merged 11 commits intomainfrom
maxim/buctd_gui_integration
Jun 30, 2025
Merged

BUCTD GUI integration#3016
MMathisLab merged 11 commits intomainfrom
maxim/buctd_gui_integration

Conversation

@maximpavliv
Copy link
Copy Markdown
Contributor

@maximpavliv maximpavliv commented Jun 24, 2025

This Pull Request adds a widget to select conditions to the Create training dataset tab in the DeepLabCut GUI.

Screenshot from 2025-06-25 08-58-12

The widget is visible only when a CTD model is selected.
The conditions can be one of the following:

  • A pytorch model snapshot (a check is applied to verify if the selected model is Bottom-Up , an warning message is displayed if that is not the case)
  • Predictions stored in a .h5 file
  • Predictions stored in a .json file

The user can choose the type of conditions they want to use in the QtWidgets.QFileDialog.getOpenFileName dialog using the filter (in the bottom-right corner of the window).

Screenshot from 2025-06-25 09-03-42

If a CTD model is selected but conditions are missing - the shuffle creation fails (a warning message is displayed).

@maximpavliv maximpavliv added GUI issues relating to GUI DLC3.0🔥 CTD Contidional Top-Down labels Jun 24, 2025
@MMathisLab
Copy link
Copy Markdown
Member

hi @maximpavliv can you add a screen shot or short video of this?

@maximpavliv
Copy link
Copy Markdown
Contributor Author

hi @maximpavliv can you add a screen shot or short video of this?

Yes, done!

@AlexEMG
Copy link
Copy Markdown
Member

AlexEMG commented Jun 26, 2025

For training -- it should also link to the docs & recommendations. I'd also suggest to say that it's typically preferable to use generative sampling (so no predictions during training).

@MMathisLab MMathisLab requested a review from Copilot June 26, 2025 14:07
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds support for selecting conditional top-down (CTD) model conditions in the DeepLabCut GUI’s Create Training Dataset tab.

  • Introduces is_model_cond_top_down utility to identify CTD models.
  • Adds ConditionsSelectionWidget and integrates it into the layout and dataset‐creation flow.
  • Refactors combo-box updates via set_combo_items and centralizes message‐box creation.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
deeplabcut/pose_estimation_pytorch/config/utils.py Added is_model_cond_top_down to detect CTD models.
deeplabcut/pose_estimation_pytorch/config/init.py Exported new is_model_cond_top_down util.
deeplabcut/pose_estimation_pytorch/init.py Exported new is_model_cond_top_down util.
deeplabcut/gui/tabs/create_training_dataset.py Integrated CTD conditions widget, refactored combo updates, and added _build_ctd_conditions.
deeplabcut/gui/components.py Added ConditionsSelectionWidget, set_combo_items, and shared message-box helpers.
Comments suppressed due to low confidence (2)

deeplabcut/gui/components.py:361

  • [nitpick] Use consistent casing for acronyms: change "Json predictions" to "JSON predictions" for clarity.
        json_prediction_label = "Json predictions"

deeplabcut/gui/tabs/create_training_dataset.py:422

  • Add unit tests for _build_ctd_conditions to verify behavior for missing paths, unsupported file types, and correct parsing of .pt, .h5, and .json inputs.
    def _build_ctd_conditions(

if conditions_path.suffix.lower() in [".h5", ".json"]:
return conditions_path
elif conditions_path.suffix.lower() == ".pt":
match = re.search(r"shuffle(\d+)", str(conditions_path))
Copy link

Copilot AI Jun 26, 2025

Choose a reason for hiding this comment

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

The regex is case-sensitive and won’t match filenames with uppercase "Shuffle"; consider using re.IGNORECASE or normalizing the string to lowercase before searching.

Suggested change
match = re.search(r"shuffle(\d+)", str(conditions_path))
match = re.search(r"shuffle(\d+)", str(conditions_path), re.IGNORECASE)

Copilot uses AI. Check for mistakes.
Comment on lines +520 to +526
try:
index = detectors.index(default_detector)
except ValueError:
try:
index = detectors.index("ssdlite")
except ValueError:
index = -1
Copy link

Copilot AI Jun 26, 2025

Choose a reason for hiding this comment

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

Using -1 will clear the combo box selection; consider defaulting to 0 or checking for an empty list to avoid no-selection states.

Suggested change
try:
index = detectors.index(default_detector)
except ValueError:
try:
index = detectors.index("ssdlite")
except ValueError:
index = -1
if not detectors:
index = 0 # Default to the first item if the list is empty
else:
try:
index = detectors.index(default_detector)
except ValueError:
try:
index = detectors.index("ssdlite")
except ValueError:
index = 0 # Default to the first item if no match is found

Copilot uses AI. Check for mistakes.
@MMathisLab MMathisLab merged commit 820478c into main Jun 30, 2025
5 checks passed
@MMathisLab MMathisLab deleted the maxim/buctd_gui_integration branch June 30, 2025 03:25
This was referenced Jul 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CTD Contidional Top-Down DLC3.0🔥 GUI issues relating to GUI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants