Skip to main content

Distinguish behavioral clusters Toolbox

Project description

CASTLE 標誌 arXiv PyPI version CI

License: Apache 2.0 PyPI Downloads PyPI Downloads

CASTLE Flowchart

CASTLE (Combined Approach for Segmentation and Tracking with Latent Extraction) is a training-free framework that combines segmentation models, tracking algorithms, and visual foundation models to automatically discover animal behaviors from video. Through focused latent extraction and hierarchical clustering, it achieves expert-level accuracy across multiple species without manual labeling, while uncovering previously hidden behavioral patterns that keypoint methods miss.

Reaching Demo

Latest updates

  • 2024-09: Public release of this tool.

Quick start

Option 1 (Open In Colab (free accounts are vary slow))

Open In Colab (free accounts are vary slow) CASTLE Quick start @Colab

Option 2 (Docker)

Option 3 (Directly Install Dependency)

Installation

git clone https://github.com/CASTLE-ai/castle-ai.git
cd castle-ai
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

Sometime the ckpt download may be blocked by Google. So you can download the models from the web by copying the links to the Chrome browser and downloading them.

https://dl.fbaipublicfiles.com/segment_anything/sam_vit_b_01ec64.pth
https://dl.fbaipublicfiles.com/dinov2/dinov2_vitb14/dinov2_vitb14_reg4_pretrain.pth
https://drive.google.com/file/d/1g4E-F0RPOx9Nd6J7tU9AE1TjsouL4oZq/edit
https://drive.google.com/file/d/1QoChMkTVxdYZ_eBlZhK2acq9KMQZccPJ/edit

Afterward, place them into the ckpt folder.

castle-ai
├── castle
└── ckpt
    ├── dinov2_vitb14_reg4_pretrain.pth
    ├── R50_DeAOTL_PRE_YTB_DAV.pth
    ├── sam_vit_b_01ec64.pth
    └── SwinB_DeAOTL_PRE_YTB_DAV.pth

My Python version is 3.10.12. For details version, see INSTALLATION.md.

Run

python app.py

About us

CASTLE is a project by the Wu Lab, a research group at the Academia Sinica.

Credits & Licenses

This project incorporates code and methodologies from the following sources:

This work is distributed under the terms of the Apache License 2.0.

Citation

If you find this work useful, please consider citing:

@article{CASTLE,
  title={CASTLE: a training‑free foundation‑model pipeline for unsupervised, cross‑species behavioral classification},
  author={Liu, Yu-Shun and Yeh, Han-Yuan and Hu, Yu-Ting and Wu, Bing-Shiuan and Chen, Yi-Fang and Yang, Jia-Bin and Jasmin, Sureka and Hsu, Ching-Lung and Lin, Suewei and Chen, Chun-Hao and Wu, Yu-Wei},
  journal={bioRxiv},
  year={2025}
}

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

castle_ai-0.0.16.tar.gz (154.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

castle_ai-0.0.16-py3-none-any.whl (190.8 kB view details)

Uploaded Python 3

File details

Details for the file castle_ai-0.0.16.tar.gz.

File metadata

  • Download URL: castle_ai-0.0.16.tar.gz
  • Upload date:
  • Size: 154.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for castle_ai-0.0.16.tar.gz
Algorithm Hash digest
SHA256 22e5c1472844710344c9fdf637888dbb24c63afec1b085fb07cd4c8d1246fe76
MD5 f816a35d79746f585d9bede243c79a4e
BLAKE2b-256 f8d65feed5acd42c18e8eb7c9fc868a8c714618ca045235bdd1b6cdd943e3455

See more details on using hashes here.

File details

Details for the file castle_ai-0.0.16-py3-none-any.whl.

File metadata

  • Download URL: castle_ai-0.0.16-py3-none-any.whl
  • Upload date:
  • Size: 190.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for castle_ai-0.0.16-py3-none-any.whl
Algorithm Hash digest
SHA256 7d6e87070e0bf8a27221e2b5d6cce37973896f4fb31899b65db52069e5a4723e
MD5 2daa1e9b096d4b3d43e7ef46d5abc140
BLAKE2b-256 42420ee4df730dd86352f7e3b5e711a7536a723fc8dc3c0cf35f88018d0463d9

See more details on using hashes here.

Supported by

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