Skip to content

feat: Adding exported value to extract_frames - #3390

Draft
sam-delap wants to merge 4 commits into
DeepLabCut:mainfrom
sam-delap:main
Draft

feat: Adding exported value to extract_frames#3390
sam-delap wants to merge 4 commits into
DeepLabCut:mainfrom
sam-delap:main

Conversation

@sam-delap

@sam-delap sam-delap commented Jul 11, 2026

Copy link
Copy Markdown

Clearly document what changed and why

Added a consistent output type (and additional type hinting) to extract_frames function

Link any related issue(s)

Closes #3188

Update docstrings and documentation when behavior changes

Docstrings updated, from what I remember the API auto-generates the upstream docs here so no additional docs changes need to be made

Add or update tests when appropriate

extract_frames was not directly under test in any test suite components at present

Include a small usage example when it helps reviewers understand and/or test the change

import deeplabcut

# extract_frames now RETURNS a mapping of video path -> picked frame indices
frames_by_video = deeplabcut.extract_frames(
    "/analysis/project/reaching-task/config.yaml",
    mode="automatic",
    algo="kmeans",
    userfeedback=False,
)
for video, indices in frames_by_video.items():
    print(video, "->", len(indices), "frames:", indices)

@C-Achard C-Achard self-assigned this Jul 13, 2026
@C-Achard C-Achard added enhancement New feature or request backwards compatibility issues concerning prior to current versions documentation documentation updates/comments labels Jul 13, 2026

@C-Achard C-Achard left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Hello @sam-delap,

Thanks a lot for the contribution, we might adapt it a bit to retain full backwards compatibility, no need to implement the changes yourself, we are happy to handle it.
We will discuss this internally and take care of the PR once we agree on the best implementation.

Best,
Cyril

extracted_cam=0,
videos_list=None,
):
config: str,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for adding!

@@ -173,7 +174,11 @@ def extract_frames(

Returns

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We may want to make returning the dict optional, so as to retain previous behavior where the success was reported (though the docstring return type was incorrect)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Will make sure I update the docstring, apologies

if all(has_failed):
print("Frame extraction failed. Video files must be corrupted.")
return has_failed
return frames_by_video

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This will likely have to change slightly to retain backwards compatibility.

I would suggest we make the base return type bool/None to get granularity (failed/success with result/success with no result), and add a flag to request the frames dict as output in the signature, so it preserves the old behavior as default.

Or we can make an extra function and rely on a private underlying implementation to provide both without making the return type conditional.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I'm OK gating this behind a flag... will update on my side accordingly

@deruyter92
deruyter92 self-requested a review July 15, 2026 16:29
@deruyter92 deruyter92 self-assigned this Jul 15, 2026
@deruyter92

deruyter92 commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Merged with main to resolve some conflicts regarding the str / Path type hints

@deruyter92

Copy link
Copy Markdown
Collaborator

Hi @sam-delap thanks again for contributing. I am putting this PR in draft-status for now, as you are working on it. Let us know when you are finished adding your changes, then we will help out as well to get this in a production-ready state! 💪

@deruyter92
deruyter92 marked this pull request as draft July 27, 2026 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backwards compatibility issues concerning prior to current versions documentation documentation updates/comments enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Return frames2pick from extract_videos

3 participants