Dala.ML.Example (dala v0.1.1)

Copy Markdown View Source

Examples of using ML in a Dala app.

Demonstrates basic ML operations using the auto-configured backend (EMLX on iOS, BinaryBackend elsewhere).

Summary

Functions

Simple tensor operations with auto-configured backend.

Runs a full ML pipeline: preprocess → inspect → report. Useful for debugging model input/output shapes.

Image classification preprocessing pipeline.

Verifies the ML stack is working and returns status info.

YOLO-like object detection preprocessing.

Functions

basic_operations()

@spec basic_operations() :: map()

Simple tensor operations with auto-configured backend.

debug_pipeline(tensor, task \\ :image_classification)

@spec debug_pipeline(Nx.Tensor.t(), atom()) :: map()

Runs a full ML pipeline: preprocess → inspect → report. Useful for debugging model input/output shapes.

image_classify(image_tensor)

@spec image_classify(Nx.Tensor.t()) :: {:ok, Nx.Tensor.t()} | {:error, term()}

Image classification preprocessing pipeline.

Takes an image tensor and applies standard ImageNet preprocessing. Returns a normalized batch tensor ready for model input.

verify_setup()

@spec verify_setup() :: {:ok, map()} | {:error, term()}

Verifies the ML stack is working and returns status info.

yolo_detect(image_tensor)

@spec yolo_detect(Nx.Tensor.t()) :: {:ok, Nx.Tensor.t()} | {:error, term()}

YOLO-like object detection preprocessing.

Takes an image tensor and applies YOLO preprocessing.