thalianacv.core package

Submodules

thalianacv.core.predict module

Core inference pipeline for thalianacv.

This module exposes the primary public interface of the package. All consumers (API, CLI, database) should call predict() rather than invoking the data or model submodules directly.

predict() is currently a stub. It returns a PredictionResult populated with sentinel values and does not load any models or process any images. Sentinel values are deliberately invalid to make stub behaviour detectable. shoot_mask and root_mask are arrays filled with -1, coordinates is a DataFrame with correct columns and all values set to -999.0, and confidence_score is -1.0.

Example

>>> from pathlib import Path
>>> from thalianacv.core.predict import predict
>>> result = predict(
...     image_path=Path("image.png"),
...     shoot_model_path=Path("shoot.h5"),
...     root_model_path=Path("root.h5"),
... )
>>> print(result.confidence_score)  # -1.0 in stub
thalianacv.core.predict.predict(image_path: str | Path, shoot_model_path: str | Path, root_model_path: str | Path, global_stats_path: str | Path | None = None) PredictionResult[source]

Run the full inference pipeline on a single plant image.

Accepts a raw plant image and two trained segmentation models (shoot and root). Returns segmentation masks, per-plant coordinates, and a confidence score derived from raw model probabilities.

When global_stats_path is None, loads bundled default stats from thalianacv/data/default_stats.json. To use updated stats produced by the retraining pipeline, pass a path to a replacement JSON file with the same schema.

Parameters:
  • image_path – Path to the input plant image file.

  • shoot_model_path – Path to the trained shoot segmentation model (.h5).

  • root_model_path – Path to the trained root segmentation model (.h5).

  • global_stats_path – Path to a JSON file containing global Y-pixel statistics for shoot mask quality validation. If None, uses the bundled default at thalianacv/data/default_stats.json.

Returns:

  • shoot_mask: Binary shoot segmentation mask (H, W) numpy array.

  • root_mask: Binary root segmentation mask (H, W) numpy array.

  • coordinates: DataFrame with 5 rows, one per plant, containing root lengths and pixel/robot coordinates.

  • confidence_score: Mean foreground prediction probability in range [0.0, 1.0]. Returns -1.0 in stub.

Return type:

PredictionResult containing

Raises:

Example

>>> result = predict(
...     image_path="plate_01.png",
...     shoot_model_path="shoot.h5",
...     root_model_path="root.h5",
... )
>>> print(result.confidence_score)
>>> print(result.coordinates[["plant_order", "Length (px)"]])

Module contents

Core inference pipeline for thalianacv.

This submodule orchestrates the full inference pipeline. The primary entry point is predict() in thalianacv.core.predict.