-
Notifications
You must be signed in to change notification settings - Fork 109
Add bonsai guide for sleap docs #2050
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
roomrys
merged 15 commits into
talmolab:develop
from
croblesMed:carlos/review-bonsai-guide-for-sleap-docs
Dec 16, 2024
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
b2930ae
[WIP] Add bonsai guide page
shrivaths16 d5d2b09
Add more information to the guide with images
shrivaths16 9c13e12
Merge branch 'develop' into shrivaths/bonsai-guide
shrivaths16 d2ec2db
merge with develop for updated website workflow
shrivaths16 2a1c587
add branch for website build
shrivaths16 4f8e111
Typos
shrivaths16 182bb4c
Merge branch 'develop' into shrivaths/bonsai-guide
shrivaths16 4b798ce
fix links
shrivaths16 5d8de25
Include suggestions
shrivaths16 f332499
Add more screenshots and refine the doc
shrivaths16 c54bac3
Remove branch from website workflow
shrivaths16 331144a
Merge branch 'develop' into shrivaths/bonsai-guide
roomrys fd6ddea
Merge branch 'develop' into shrivaths/bonsai-guide
shrivaths16 b15f90f
Completed documentation edits from PR made by reviewer + review bot.
croblesMed b2990dc
Merge branch 'develop' into carlos/review-bonsai-guide-for-sleap-docs
roomrys File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
(bonsai)= | ||
|
||
# Using Bonsai with SLEAP | ||
|
||
Bonsai is a visual language for reactive programming and currently supports SLEAP models. | ||
|
||
:::{note} | ||
Currently Bonsai supports only single instance, top-down and top-down-id SLEAP models. | ||
::: | ||
|
||
### Exporting a SLEAP trained model | ||
|
||
Before we can import a trained model into Bonsai, we need to use the {code}`sleap-export` command to convert the model to a format supported by Bonsai. For example, to export a top-down-id model, the command is as follows: | ||
|
||
```bash | ||
sleap-export -m centroid/model/folder/path -m top_down_id/model/folder/path -e exported/model/path | ||
``` | ||
|
||
Please refer to the {ref}`sleap-export` docs for more details on using the command. | ||
|
||
This will generate the necessary `.pb` file and other information files required by Bonsai. In this example, these files were saved to the specified `exported/model/path` folder. | ||
|
||
The `exported/model/path` folder will have a structure like the following: | ||
|
||
```plaintext | ||
exported/model/path | ||
├── centroid_config.json | ||
├── confmap_config.json | ||
├── frozen_graph.pb | ||
└── info.json | ||
``` | ||
|
||
### Installing Bonsai and necessary packages | ||
|
||
1. Install Bonsai. See the [Bonsai installation instructions](https://bonsai-rx.org/docs/articles/installation.html). | ||
|
||
2. Download and add the necessary packages for Bonsai to run with SLEAP. See the official [Bonsai SLEAP documentation](https://github.com/bonsai-rx/sleap?tab=readme-ov-file#bonsai---sleap) for more information. | ||
|
||
### Using Bonsai SLEAP modules | ||
|
||
Once you have Bonsai installed with the required packages, you should be able to open the Bonsai application. The workflow must have a source module `FileCapture` which can be found in the toolbox search in the workflow editor. Provide the path to the video that was used to train the SLEAP model in the `FileName` field of the module. | ||
|
||
 | ||
|
||
#### Top-down model | ||
The top-down model requires both the `PredictCentroids` and the `PredictPoses` modules. | ||
|
||
The `PredictCentroids` module will predict the centroids of detections. There are two fields inside the `PredictCentroids` module: the `ModelFileName` field and the `TrainingConfig` field. The `TrainingConfig` field expects the path to the training config JSON file for the centroid model. The `ModelFileName` field expects the path to the `frozen_graph.pb` file in the `exported/model/path` folder. | ||
|
||
 | ||
|
||
The `PredictPoses` module will predict the instances of detections. Similar to the `PredictCentroid` module, there are two fields inside the `PredictPoses` module: the `ModelFileName` field and the `TrainingConfig` field. The `TrainingConfig` field expects the path to the training config JSON file for the centered instance model. The `ModelFileName` field expects the path to the `frozen_graph.pb` file in the `exported/model/path` folder. | ||
|
||
 | ||
|
||
#### Top-Down-ID model | ||
The `PredictPoseIdentities` module will predict the instances with identities. This module has two fields: the `ModelFileName` field and the `TrainingConfig` field. The `TrainingConfig` field expects the path to the training config JSON file for the top-down-id model. The `ModelFileName` field expects the path to the `frozen_graph.pb` file in the `exported/model/path` folder. | ||
|
||
 | ||
|
||
#### Single instance model | ||
The `PredictSinglePose` module will predict the poses for single instance models. This module also has two fields: the `ModelFileName` field and the `TrainingConfig` field. The `TrainingConfig` field expects the path to the training config JSON file for the single instance model. The `ModelFileName` field expects the path to the `frozen_graph.pb` file in the `exported/model/path` folder. | ||
|
||
### Connecting the modules | ||
Right-click on the `FileCapture` module and select **Create Connection**. Now click on the required SLEAP module to complete the connection. | ||
|
||
 | ||
|
||
Once it is done, the workflow in Bonsai will look something like the following: | ||
|
||
 | ||
|
||
Now you can click the green start button to run the workflow and you can add more modules to analyze and visualize the results in Bonsai. | ||
|
||
For more documentation on various modules and workflows, please refer to the [official Bonsai docs](https://bonsai-rx.org/docs/articles/editor.html). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
💡 Codebase verification
Alt text needs improvement for better accessibility
The verification confirms that all referenced images exist in the
_static
directory, but the alt text could be more descriptive:bonsai-filecapture.jpg
: Current "Bonsai FileCapture module" → Should describe the UI elements visible in the screenshotbonsai-predictcentroids.jpg
: Current "Bonsai PredictCentroids module" → Should describe the configuration fields shownbonsai-predictposes.jpg
: Current "Bonsai PredictPoses module" → Should describe the module's settings interfacebonsai-predictposeidentities.jpg
: Current "Bonsai PredictPoseIdentities module" → Should describe the configuration viewbonsai-connection.jpg
: Current "Bonsai module connection" → Should describe the connection process being shownbonsai-workflow.jpg
: Current "Bonsai.SLEAP workflow" → Should describe the complete workflow diagram🔗 Analysis chain
Verify image references and add alt text
The documentation includes multiple image references. Please verify:
_static
directoryAlso applies to: 50-50, 54-54, 59-59, 67-67, 71-71
Let me check the alt text for these images by examining the markdown file.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 1108
Script:
Length of output: 4569