Skip to main content

Deploy and access image and data processing models across processes.

Project description

Nahual: Deploy and access image and data processing models across environments/processes.

Note that this is early work in progress.

This tool aims to provide a one-stop-shop source for multiple models to process imaging data or their derivatives. You can think of it as a much simpler ollama but for biological analyses, deep learning-based or otherwise.

Implemented tools

By default, the models and tools are deployable using Nix.

  • trackastra: Transformer-based models trained on a multitude of datasets.
  • DINOv2: Generalistic self-supervised model to obtain visual features.

WIP tools

  • Baby: Segmentation, tracking and lineage assignment for budding yeast.
  • Other models and methods (to be defined)

Example of server+client

Any model requires a thin layer that communicates using [[https://github.com/nanomsg/nng][nng]]. You can see an example of trackastra's [[https://github.com/afermg/trackastra/blob/main/server.py][server]] and [[https://github.com/afermg/nahual/blob/master/src/nahual.client/trackastra.py][client]].

Usage

Step 1: Deploy server

cd to the model you want to deploy. In this case we will test the image embedding model DINOv2.

git clone https://github.com/afermg/dinov2.git
cd dinov2
nix develop --command bash -c "python server.py ipc:///tmp/example_name.ipc"

Step 2: Run client

Once the server is running, you can call it from a different python script.

import numpy

from nahual.client.dinov2 import load_model, process_data

address = "ipc:///tmp/example_name.ipc"

# Load models server-side
parameters = {"repo_or_dir": "facebookresearch/dinov2", "model": "dinov2_vits14_lc"}
load_model(parameters, address=address)

# Define custom data
data = numpy.random.random_sample((1, 3, 420, 420))
result = process_data(data, address=address)

You can press C-c C-c from the terminal where the server lives to kill it. We will also add a way to kill the server from within the client.

Future goals

  • Support multiple instances of a model loaded on memory server-side.
  • Formalize supported packet formats: (e.g., numpy arrays, dictionary).
  • Increase number of supported models/methods.
  • Document server-side API.
  • Integrate into the [[github.com/afermg/aliby][aliby]] pipelining framework.
  • Support containers that wrap the Nix derivations.

Why nahual?

logo

In Mesoamerican folklore, a Nahual is a shaman able to transform into different animals.

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

nahual-0.0.3.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

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

nahual-0.0.3-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file nahual-0.0.3.tar.gz.

File metadata

  • Download URL: nahual-0.0.3.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.19

File hashes

Hashes for nahual-0.0.3.tar.gz
Algorithm Hash digest
SHA256 bc0b3385214554ac92d8a4004f5b77f402b9f55ddc1a1987a2a87f9ddbe6715c
MD5 65dcec32c77273a8c9ad1ce67ad3813c
BLAKE2b-256 6ad912b1faa4d19c81417727d8f3ffafbc715f5333c3cb7c7dcd36dd7aafdf0c

See more details on using hashes here.

File details

Details for the file nahual-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: nahual-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 10.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.19

File hashes

Hashes for nahual-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e736f58528e22341f36619448ea4225d35b9f20d5a0a55f89210ad0fc3496656
MD5 a67bd0ee5d5d4f22169a1b951bb607f6
BLAKE2b-256 7d1433a12e31a6c2c7a433765d816d8fcc68815dbe9a122c3104061e9c844e62

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