Skip to main content

Lightweight library supporting universal functions for the DeepLabCut ecosystem

Project description

Generic badge Code style: blackLicense: LGPL v3

DLClibrary

DLClibrary is a lightweight library supporting universal functions for the DeepLabCut ecosystem.

Supported functions (at this point):

Quick start

Install

The package can be installed using pip:

pip install dlclibrary

:warning: warning, the closely named package dlclib is not an official DeepLabCut product. :warning:

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.

  1. Add the model_name with path and commit ID to: https://github.com/DeepLabCut/DLClibrary/blob/main/dlclibrary/dlcmodelzoo/modelzoo_urls.yaml

  2. Add the model name to the constant: MODELOPTIONS https://github.com/DeepLabCut/DLClibrary/blob/main/dlclibrary/dlcmodelzoo/modelzoo_download.py#L15

  3. 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dlclibrary-0.0.10.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

dlclibrary-0.0.10-py3-none-any.whl (17.2 kB view details)

Uploaded Python 3

File details

Details for the file dlclibrary-0.0.10.tar.gz.

File metadata

  • Download URL: dlclibrary-0.0.10.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for dlclibrary-0.0.10.tar.gz
Algorithm Hash digest
SHA256 96a589f8bb79f499ecfd1156f751c693dd184e09c06afa69af31bb9c07900cf8
MD5 f1909ddab475887fc8e3b5865c884248
BLAKE2b-256 a9bb9afd4433005e4c6f0ca81f36bb641c8d246e8871ffec10c3a9bd7b9b288d

See more details on using hashes here.

File details

Details for the file dlclibrary-0.0.10-py3-none-any.whl.

File metadata

  • Download URL: dlclibrary-0.0.10-py3-none-any.whl
  • Upload date:
  • Size: 17.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for dlclibrary-0.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 d9433312094e0b8b5c97d866501fb48c9ee6f5ee8e4a88250ee6b397865ebd3b
MD5 60b75b9df42a48c197f5048483d12b49
BLAKE2b-256 e0a71df0962a70371f2cc64fa7e60d07b06803e72531552397bf633f0e500d91

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page