DLClibrary
DLClibrary is a lightweight library supporting universal functions for the DeepLabCut ecosystem.
Supported functions (at this point):
- API for downloading model weights from the model zoo
Quick start
Install
The package can be installed using pip:
pip install dlclibrary
⚠️ warning, the closely named package dlclib is not an official DeepLabCut product. ⚠️
Example Usage
Downloading a pretrained model from the model zoo:
from pathlib import Path
from dlclibrary import download_huggingface_model
# Creates a folder and downloads the model to it
model_dir = Path("./superanimal_quadruped_model")
model_dir.mkdir()
download_huggingface_model("superanimal_quadruped", model_dir)
PyTorch models available for a given dataset (compatible with DeepLabCut>=3.0) can be
listed using the dlclibrary.get_available_detectors and
dlclibrary.get_available_models methods. The datasets for which models are available
can be listed using dlclibrary.get_available_datasets. Example use:
>>> import dlclibrary
>>> dlclibrary.get_available_datasets()
['superanimal_bird', 'superanimal_topviewmouse', 'superanimal_quadruped']
>>> dlclibrary.get_available_detectors("superanimal_bird")
['fasterrcnn_mobilenet_v3_large_fpn', 'ssdlite']
>>> dlclibrary.get_available_models("superanimal_bird")
['resnet_50']
How to add a new model?
TensorFlow models
Pick a good model_name. Follow the (novel) naming convention (modeltype_species), e.g. superanimal_topviewmouse.
-
Add the model_name with path and commit ID to: https://github.com/DeepLabCut/DLClibrary/blob/main/dlclibrary/dlcmodelzoo/modelzoo_urls.yaml
-
Add the model name to the constant: MODELOPTIONS https://github.com/DeepLabCut/DLClibrary/blob/main/dlclibrary/dlcmodelzoo/modelzoo_download.py#L15
-
For superanimal models also fill in the configs!
PyTorch models (for deeplabcut >= 3.0.0)
PyTorch models are listed in dlclibrary/dlcmodelzoo/modelzoo_urls_pytorch.yaml. The file is organized as:
my_cool_dataset: # name of the dataset used to train the model
detectors:
detector_name: path/to/huggingface-detector.pt # add detectors under `detector`
pose_models:
pose_model_name: path/to/huggingface-pose-model.pt # add pose models under `pose_models`
other_pose_model_name: path/to/huggingface-other-pose-model.pt
This will allow users to download the models using the format datatsetName_modelName,
i.e. for this example 3 models would be available: my_cool_dataset_detector_name,
my_cool_dataset_pose_model_name and my_cool_dataset_other_pose_model_name.
To add a new model for deeplabcut >= 3.0.0, simply:
- add a new line under detectors or pose models if the dataset is already defined
- add the structure if the model was trained on a new dataset
The models will then be listed when calling dlclibrary.get_available_detectors or
dlclibrary.get_available_models! You can list the datasets for which models are
available using dlclibrary.get_available_datasets.
Metadata
Release files for dlclibrary 0.0.12
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dlclibrary-0.0.12.tar.gz | 13.2 kB | Without provenance | Details for dlclibrary-0.0.12.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dlclibrary-0.0.12-py3-none-any.whl | Python 3 | none | any | Details for dlclibrary-0.0.12-py3-none-any.whl |
Total release size: 30.7 kB
Release files / dlclibrary-0.0.12.tar.gz
| Download URL | dlclibrary-0.0.12.tar.gz |
|---|---|
| Size | 13.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9c1dcb98edcba03f33c31e0c0f9d18ce1c349bef65f8d3cd5bde49d5e76171db
|
|
BLAKE2b-256 checksum How to use checksums |
0dbf14c4a73bfb090642a2f8353ff38a623024ee39f7efb4966962ed2a194c3a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / dlclibrary-0.0.12-py3-none-any.whl
| Download URL | dlclibrary-0.0.12-py3-none-any.whl |
|---|---|
| Size | 17.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
be8e22d334fd37cfde6e68936b73ee45a2f0f55baedc83832d773e4f2aedb38b
|
|
BLAKE2b-256 checksum How to use checksums |
4957c0ebe1191a2a445e0a671ce9255b149747ff6285aa6610e355b2e4e72cfe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for dlclibrary 0.0.12
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.