-
Notifications
You must be signed in to change notification settings - Fork 51
[WIP] Integration with DeepLabCut 3.0 - PyTorch Engine #121
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
base: master
Are you sure you want to change the base?
Conversation
- Feb 2021: DeepLabCut-Live! was featured in **Nature Methods**: [ | ||
"Real-time behavioral analysis"](https://www.nature.com/articles/s41592-021-01072-z) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Feb 2021: DeepLabCut-Live! was featured in **Nature Methods**: [ | |
"Real-time behavioral analysis"](https://www.nature.com/articles/s41592-021-01072-z) | |
- Feb 2021: DeepLabCut-Live! was featured in **Nature Methods**: | |
["Real-time behavioral analysis"](https://www.nature.com/articles/s41592-021-01072-z) |
resize=resize, | ||
cropping=cropping, | ||
dynamic=dynamic, | ||
display=display, | ||
max_detections=max_detections, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DLCLive
's constructor doesn't have a max_detections
argument
iterator = range(n_frames) if (print_rate) or (display) else tqdm(range(n_frames)) | ||
for i in iterator: | ||
iterator = range(n_frames) | ||
if print_rate or display: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we check if has_tqdm
here?
frame_width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)) | ||
frame_height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT)) | ||
|
||
vwriter = cv2.VideoWriter( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's name it vid_writer
as in benchmark()
? I find vid_writer
indeed better
am only a peripheral maintainer here at this point, but i see that we have copied and pasted this whole directory? https://github.com/DeepLabCut/DeepLabCut/tree/main/deeplabcut/pose_estimation_pytorch that sounds pretty fragile to me! if we're already copy/pasting it once, we might as well just make that a cut/paste into a separate |
Hey @sneakers-the-rat afaik its not strictly the same though; this the same reason we don't keep dlc-live in DeepLabCut main. We also used to have core, but it becomes yet another package to maintain and ultimately was more work for dev team. But I would leave it to @n-poulsen to give a better technical answer (as this addition here I haven't been deeply involved in yet) ❤️- thanks for your engagement!!! |
oh ya i don't see a reason to have dlc-live in main dlc, i would think that the dep graph would look something like this flowchart TB
deeplabcut --> dlc-pytorch
deeplabcut --> dlc-tensorflow
dlc-pytorch --> dlclibrary
dlc-tensorflow --> dlclibrary
dlc-live --> dlc-pytorch
dlc-live --> dlc-tensorflow
dlc-live --> dlclibrary
deeplabcut --> dlclibrary
where
I believe y'all have your own processes and flow and etc. and don't mean to step on that. the thing that works is the thing that works. i would suspect that having multiple copies of what was initially the same code drift apart (or require active duplication as changes are made) would be more maintenance labor in all but the short term, but i also don't deal with tf or torch directly and am aware they introduce their own packaging nightmares wherever they go, so up to y'all ofc. The thing that we did for the tensorflow stuff is just operate on serialized versions of the models, so the model code for tf isn't in the package at all - does torch not have a similar system for serializing and deserializing models? that worked out really well, and i partly credit that design decision with why this package has needed relatively little maintenance over its lifespan. that is a third way that would avoid new package but also not require a copy/paste :) |
Hi @sneakers-the-rat! Thanks for the input! When it comes to duplicating code, only the models from the deeplabcut/pose_estimation_pytorch folder were copied over. This is absolutely a sub-optimal solution, and requires maintenance when new models are added to DeepLabCut or bug fixes are made. This was done to have a prototype ready, but I'm still exploring better solutions. The issue is that:
If we can't find a good way to serialize models, it's true that the best solution may be to have a separate package containing the models and predictors - but that's something I still want to explore. If you have any opinions on the best way to this I'm glad to get any other input! |
aha, that is extremely annoying there is no good way to serialize pytorch models, or at least serialization is in a transitional period right now. I'm not gonna be maintaining it, and have said my piece re: splitting off into a separate package, so by all means! good to see this update getting ported over to dlc live, glhf with the rest of the impl, lmk if a review would be helpful <3 |
This pull requests updates DeepLabCut-Live for models exported with DeepLabCut 3.0. TensorFlow models can still be used, and the code is siloed so that only the engine used to run the code is required as a package (i.e. no need to install TensorFlow if you want to run live pose estimation with PyTorch models).
If you want to give this PR a try, you can install the code in your local
conda
environment by running:pip install "git+https://github.com/DeepLabCut/DeepLabCut-live.git@dlclive3"