FAQ & Troubleshooting¶
Installation¶
CUDA not found / PyTorch not detecting GPU¶
Symptom: torch.cuda.is_available() returns False
Solutions:
- Check that NVIDIA drivers are installed:
nvidia-smi - Verify CUDA version compatibility: CASTLE requires CUDA 12.x
- Reinstall PyTorch with the correct CUDA version from pytorch.org
- If using Docker, ensure NVIDIA Container Toolkit is installed and the
deploysection indocker-compose.ymlis not commented out
Google Drive download quota exceeded¶
Symptom: gdown fails with "Too many users have viewed or downloaded this file recently"
Solutions:
- Download manually via browser — open the Google Drive link, sign in, and download
- Wait a few hours — quotas reset periodically
- Try with the fuzzy flag:
gdown --fuzzy '<URL>' - Use a different Google account
cuml installation fails¶
Symptom: pip install cuml-cu12 fails or cuml import errors
Solutions:
- Verify CUDA 12.x is installed:
nvcc --version - cuml requires an NVIDIA GPU — it will not work on CPU-only systems
- Try installing from NVIDIA's package index explicitly:
- On systems without GPU, CASTLE will still work but GPU-accelerated UMAP will be unavailable
Import errors on startup¶
Symptom: ModuleNotFoundError when running python app.py
Solutions:
- Ensure you're in the correct virtual environment
- Reinstall dependencies:
pip install -r requirements.txt - Check you're running from the repository root (not a subdirectory)
Tracking¶
Tracking loses the animal / mask drifts¶
Solutions:
- Add more labels — label frames where tracking fails, especially frames with different postures or lighting
- Label diverse frames — not just the first frame, but frames across the video with varied appearances
- Try SwinB model — more accurate than R50, especially for challenging cases
- Use iterative refinement — cancel bad tracking early, add labels at failure points, re-track from there
- Reduce frame range — track shorter segments and verify quality before proceeding
- Aim for 5–30 prompt frames — more diverse prompts improve robustness
Tracking is very slow¶
Solutions:
- Use the R50 model instead of SwinB (faster, often sufficient)
- Check GPU utilization (
nvidia-smi) — if GPU is not being used, there may be a CUDA issue - Reduce video resolution if possible
Feature Extraction¶
Extraction is very slow¶
Solutions:
- Increase batch size (e.g., 64, 128) if you have spare VRAM
- Use
dinov2_vitb14_reg4_pretrain(fastest) instead ofdinov3_vitl16(slowest) - Enable Skip existing files to avoid re-processing
- Check GPU utilization — ensure the GPU is actually being used
"Please click Apply on Preprocess settings first"¶
You must click the Apply button after configuring preprocessing settings (Center ROI, Rotate, Remove Background) before running extraction.
Behavior Analysis¶
UMAP looks random / no structure visible¶
Solutions:
- Check your features — if latent extraction had issues (many NaN frames), the embedding will be poor
- Try different n_neighbors — start with Low Magnification 100, then experiment
- Verify preprocessing — Center ROI and Remove Background often improve results significantly
- Increase data — more frames and videos produce better embeddings
- Check tracking quality — poor tracking → poor features → poor embedding
Too many / too few clusters¶
Adjust the eps parameter in DBSCAN:
- Too many clusters: increase eps (e.g., 2.0, 3.0)
- Too few clusters: decrease eps (e.g., 0.5, 0.3)
- All noise (-1): eps is too small, increase it
Hierarchical analysis: how to zoom in¶
- Run UMAP + DBSCAN at low magnification
- Label and submit the broad clusters
- Select one cluster from the Select Cluster dropdown
- Re-run UMAP at intermediate or high magnification on just that cluster
- Cluster and label the sub-behaviors
- Submit again — results accumulate
General¶
What species does CASTLE support?¶
Any animal (or object) that SAM can segment. CASTLE is species-agnostic — it has been tested on mice, rats, flies, C. elegans, and gait analysis. If you can click on it and SAM can segment it, CASTLE can track and analyze it.
Can I use CASTLE without a GPU?¶
Yes, but with significant limitations:
- Tracking: much slower (minutes → hours for a single video)
- Feature extraction: very slow on CPU
- UMAP: cuml-based GPU UMAP will not be available; a CPU fallback may be needed
- Overall: feasible for short demo videos, not practical for real datasets
Can I process multiple videos at once?¶
Yes. Use Batch Videos Tracking (Step 2) to track multiple videos with shared ROI prompts. Feature extraction (Step 3) supports an "All" option to process all project videos. The Behavior Microscope (Step 4) automatically aggregates features across all videos.
Where are my results stored?¶
All results are in projects/{project_name}/:
- Tracking masks:
track/{video}/mask_list.h5 - Latent features:
latent/{model}/{video}_ROI_{id}_{model}.npz - Cluster results:
cluster/id.csv,cluster/time_series.csv
See Data Formats for complete details.
How do I cite CASTLE?¶
See the Citation page for BibTeX entries.
Still Need Help?¶
- Open an issue on GitHub
- Check existing issues for similar problems