Skip to content

Conversation

@YankoFelipe
Copy link
Contributor

Hello DeepLabCut!

I'm integrating DLC-Pytorch into my project (2D/single animal) and I needed to add cropping functionality to deeplabcut.analyze_videos. Unfortunately I wasn't able to run the test scripts due different errors so I'd appreciate if someone from the team can run them, the log files of my runs are below. I tested the output of deeplabcut.analyze_videos with my data and it looked good so far.

testscript.py: https://datashare.mpcdf.mpg.de/s/UXTZAoKIejb0iKx
testscript_pytorch_multi_animal.py: https://datashare.mpcdf.mpg.de/s/AZsJ18QsA74CeRG
testscript_pytorch_single_animal.py: https://datashare.mpcdf.mpg.de/s/OrIwKmmMmkCwRho

The change is mostly moving VideoWriter.set_bbox to the parent class and pass cropping to VideoIterator. Everything was performed in 24ba111 aka. 3.0.0rc4 on SUSE Linux 15.5.

Best,
Yanko

@YankoFelipe
Copy link
Contributor Author

I can't add the reviewers @AlexEMG

Copy link
Contributor

@n-poulsen n-poulsen left a comment

Choose a reason for hiding this comment

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

@YankoFelipe this is awesome, thank you for implementing the cropping feature!

There are a few changes that I think should be made to match the tensorflow implementation of cropping.

As is done in the tensorflow implementation, I would read the cropping parameters from the project configuration file if no cropping parameters were passed (e.g., in analyze_videos, after the if batch_size is None: batch_size = cfg.get("batch_size", 1) lines ):

if cropping is None and cfg.get("cropping", False):
    cropping = cfg["x1"], cfg["x2"], cfg["y1"], cfg["y2"]

When calling metadata = _generate_metadata(, I would also pass the cropping parameters that were used (this can be done through a VideoIterator object instead of passing a VideoReader) so they can be stored in the video analysis metadata file.

@Jiachen24
Copy link

Hi DeepLabCut! I am using Deeplabcut 3.0.0rc4 on windows11. Deeplabcut failed to crop the video when analyze new videos using the parameters in config file. I tried via GUI and command, but both of them didn't work. Will there be a new release to fix this issue? Thank you!!

@n-poulsen
Copy link
Contributor

hey @Jiachen24 - yes, a new release will be made with the fixes from this branch :)

Copy link
Contributor

@n-poulsen n-poulsen left a comment

Choose a reason for hiding this comment

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

Looks good to me! Thanks @YankoFelipe!

@n-poulsen n-poulsen merged commit 5f41812 into DeepLabCut:pytorch_dlc Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants