Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
70a0155
spatial pyramid for video adaptation by default, with a small range o…
yeshaokai Apr 6, 2023
8441909
Update test_crossvalutils.py
yeshaokai Apr 20, 2023
0e20e8d
Merge branch 'DeepLabCut:main' into master
yeshaokai Apr 25, 2023
d5febb1
Handled empty prediction
yeshaokai Apr 25, 2023
f32d317
Removed unused parameter. Updated config to use superanimal instead o…
n-poulsen May 23, 2023
7949045
Merge branch 'DeepLabCut:main' into master
yeshaokai May 31, 2023
d531e80
Merge branch 'DeepLabCut:main' into master
yeshaokai Jul 30, 2023
768296c
Merge branch 'DeepLabCut:main' into master
yeshaokai Jun 20, 2024
882f920
Added notebook for superanimal pytorch
yeshaokai Jun 20, 2024
4be4a70
Update COLAB_Pytorch_SuperAnimal.ipynb
MMathisLab Jun 20, 2024
ed8a979
Update COLAB_Pytorch_SuperAnimal.ipynb
MMathisLab Jun 20, 2024
624134b
Update COLAB_Pytorch_SuperAnimal.ipynb
MMathisLab Jun 20, 2024
7c123b3
Merge branch 'pytorch_dlc' into shaokai/educational_superanimal_notebook
n-poulsen Jun 26, 2024
d68a137
cleaned notebook and added bbox_threshold to analyze_superanimal_images
n-poulsen Jun 26, 2024
830f4ac
worked on superanimal notebook
n-poulsen Jul 2, 2024
66acb3d
fixed symlink creation for keypoint matching
n-poulsen Jul 4, 2024
ba39fd5
renamed COLAB to YOURDATA
n-poulsen Jul 4, 2024
24cc195
fixed some bugs and cleaned the notebook. added more print statements…
n-poulsen Jul 4, 2024
c99a199
installed latest version of DeepLabCut instead of from pypi
n-poulsen Jul 4, 2024
f59dc69
changed default training parameters
n-poulsen Jul 4, 2024
3877be3
added option to not have use symlinks for keypoint matching
n-poulsen Jul 4, 2024
97bb2a1
no symlinks for keypoint matching in COLAB
n-poulsen Jul 4, 2024
67903f0
set default eval interval to 10, add superanimal_analyze_images to init
n-poulsen Jul 4, 2024
faba3ac
do not copy images or create symlinks for memory replay
n-poulsen Jul 4, 2024
27a58af
fixed memory replay to only run once
n-poulsen Jul 9, 2024
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
Prev Previous commit
Next Next commit
worked on superanimal notebook
  • Loading branch information
n-poulsen committed Jul 2, 2024
commit 830f4ac9d16f01af2b75890a7e2c433691e368a7
47 changes: 29 additions & 18 deletions examples/COLAB/COLAB_Pytorch_SuperAnimal.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"\n",
"# 🦄 SuperAnimal in DeepLabCut PyTorch! 🔥\n",
"\n",
"This notebook demos how to use our SuperAnimal models within DLC3. Please read more in [Ye et al. Nature Communications 2024](https://www.nature.com/articles/s41467-024-48792-2) about the available SuperAnimal models, and follow along below!\n",
"This notebook demos how to use our SuperAnimal models within DeepLabCut 3.0! Please read more in [Ye et al. Nature Communications 2024](https://www.nature.com/articles/s41467-024-48792-2) about the available SuperAnimal models, and follow along below!\n",
"\n",
"### **Let's get going: install DeepLabCut into COLAB:**\n",
"\n",
Expand Down Expand Up @@ -54,7 +54,7 @@
"id": "5h0vq6E50Z4W"
},
"source": [
"### PLEASE, click \"restart runtime\" from the output above before proceeding!"
"**PLEASE, click \"restart runtime\" from the output above before proceeding!**"
]
},
{
Expand All @@ -73,6 +73,7 @@
"outputs": [],
"source": [
"import os\n",
"import zipfile\n",
"from pathlib import Path\n",
"\n",
"import matplotlib.pyplot as plt\n",
Expand Down Expand Up @@ -101,7 +102,7 @@
"source": [
"## Zero-shot Image Inference & Video Inference\n",
"SuperAnimal models are foundation animal pose models. They can be used for zero-shot predictions without further training on the data.\n",
"In this section, we show how to use SuperAnimal models to predict pose from images (given an image folder) and output the predicted images (with pose) into another dest folder."
"In this section, we show how to use SuperAnimal models to predict pose from images (given an image folder) and output the predicted images (with pose) into another destination folder."
]
},
{
Expand All @@ -110,9 +111,9 @@
"id": "FvFzntDMxPoL"
},
"source": [
"## Zero-shot image inference\n",
"### Zero-shot image inference\n",
"\n",
"- If you have a single Image you want to test, upload it here!"
"If you have a single Image you want to test, upload it here!"
]
},
{
Expand Down Expand Up @@ -159,7 +160,7 @@
"id": "Jashzdjb0Z4Y"
},
"source": [
"### Select a SuperAnimal name and corresponding model architecture\n",
"#### Select a SuperAnimal name and corresponding model architecture\n",
"\n",
"Check Our Docs on [SuperAnimals](https://github.com/DeepLabCut/DeepLabCut/blob/main/docs/ModelZoo.md) to learn more!"
]
Expand Down Expand Up @@ -197,7 +198,7 @@
"outputs": [],
"source": [
"# Note you need to enter max_individuals correctly to get the correct number of predictions in the image.\n",
"superanimal_analyze_images(\n",
"_ = superanimal_analyze_images(\n",
" superanimal_name,\n",
" model_name,\n",
" image_path,\n",
Expand All @@ -213,7 +214,8 @@
},
"source": [
"### Zero-shot Video Inference\n",
"- Without Video adaptation (faster, but not self-supervised fine-tuned on your data!)"
"\n",
"This can be done with or without video adaptation (faster, but not self-supervised fine-tuned on your data!)."
]
},
{
Expand Down Expand Up @@ -290,7 +292,9 @@
"id": "Zv3v0QgSJNOg"
},
"source": [
"### Zero-shot Video Inference without video adaptation"
"#### Zero-shot Video Inference without video adaptation\n",
"\n",
"The labeled video (and pose predictions for the video) are saved in `\"/content/\"`, with the labeled video name being `{your_video_name}_superanimal_{superanimal_name}_hrnetw32_labeled.mp4`."
]
},
{
Expand All @@ -308,12 +312,12 @@
},
"outputs": [],
"source": [
"video_inference_superanimal(\n",
"_ = video_inference_superanimal(\n",
" videos=video_path,\n",
" superanimal_name=f\"{superanimal_name}_{model_name}\",\n",
" video_adapt=False,\n",
" max_individuals=max_individuals,\n",
" dest_folder=\"/content/\"\n",
" dest_folder=\"/content/\",\n",
")"
]
},
Expand All @@ -323,7 +327,9 @@
"id": "Z8Z5GSti0Z4Z"
},
"source": [
"### Zero-shot Video Inference with video adaptation (unsupervised)"
"#### Zero-shot Video Inference with video adaptation (unsupervised)\n",
"\n",
"The labeled video (and pose predictions for the video) are saved in `\"/content/\"`, with the labeled video name being `{your_video_name}_superanimal_{superanimal_name}_hrnetw32_labeled_after_adapt.mp4`."
]
},
{
Expand Down Expand Up @@ -355,7 +361,7 @@
},
"outputs": [],
"source": [
"video_inference_superanimal(\n",
"_ = video_inference_superanimal(\n",
" videos=[video_path],\n",
" superanimal_name=f\"{superanimal_name}_{model_name}\",\n",
" video_adapt=True,\n",
Expand All @@ -375,14 +381,16 @@
},
"source": [
"## Training with SuperAnimal\n",
"In this section, we compare different ways to train the model, using and without using SuperAnimal.\n",
"You can compare the evaluation results and get a sense of each baseline.\n",
"We have following baselines:\n",
"\n",
"In this section, we compare different ways to train models in DeepLabCut 3.0, with or without using SuperAnimal-pretrained models.\n",
"You can compare the evaluation results and get a sense of each baseline. We have following baselines:\n",
"\n",
"- ImageNet transfer learning (training without superanimal)\n",
"- SuperAnimal transfer learning (baseline 1)\n",
"- SuperAnimal naive fine-tuning (baseline 2)\n",
"- SuperAnimal memory-replay fine-tuning (baseline3)"
"- SuperAnimal memory-replay fine-tuning (baseline3)\n",
"\n",
"This should be done on one of your DeepLabCut projects! If you don't have a DeepLabCut project that you can use SuperAnimal models with, you can always using the example openfield dataset [available in the DeepLabCut repository](https://github.com/DeepLabCut/DeepLabCut/tree/main/examples/openfield-Pranav-2018-10-30)! "
]
},
{
Expand All @@ -391,7 +399,9 @@
"id": "L2wxevEn0Z4a"
},
"source": [
"#### Uploading your DLC project into Drive. Note you have to zip your DLC project and select the zipped file"
"#### Uploading your DeepLabCut project into Google Colab\n",
"\n",
"Note you have to zip your DLC project and select the zipped file."
]
},
{
Expand All @@ -416,6 +426,7 @@
" with zipfile.ZipFile(zip_file_path, \"r\") as zip_ref:\n",
" zip_ref.extractall(\"/content/dlc_project_folder\")\n",
"\n",
"\n",
"print(\"Contents of the extracted folder:\")\n",
"extracted_files = os.listdir(\"/content/dlc_project_folder\")\n",
"for file in extracted_files:\n",
Expand Down