thalianacv.api package

Submodules

thalianacv.api.main module

FastAPI application entry point for the thalianacv inference service.

Creates and configures the FastAPI application instance. All routes are registered via the router defined in thalianacv.api.routes.

Example

Run the development server with uvicorn:

uvicorn thalianacv.api.main:app –reload

thalianacv.api.routes module

API route definitions for the thalianacv inference service.

Defines the /health and /predict endpoints. All database operations are delegated to thalianacv.database.models. All inference operations are delegated to thalianacv.core.predict.

thalianacv.api.routes.health() HealthResponse[source]

Check that the API service is running.

Returns:

HealthResponse with status set to ‘ok’.

thalianacv.api.routes.predict_endpoint(file: UploadFile = File(PydanticUndefined)) PredictionResponse[source]

Accept a plant image and return segmentation results.

Validates the uploaded file is an image, runs the inference pipeline, saves submission and prediction metadata to the database, and returns structured results.

Parameters:

file – Uploaded image file. Must be JPEG, PNG, or TIFF.

Returns:

PredictionResponse containing confidence score, coordinates, mask shape, and database record IDs.

Raises:
  • HTTPException – 400 if the file is missing or not a supported image type.

  • HTTPException – 500 if inference or database operations fail.

thalianacv.api.schemas module

Pydantic schemas for the thalianacv API.

Defines request and response models for all API endpoints.

class thalianacv.api.schemas.HealthResponse(*, status: str)[source]

Bases: BaseModel

Response schema for the /health endpoint.

status: str
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class thalianacv.api.schemas.CoordinateRow(*, plant_order: int, length_px: float, x_px: float, y_px: float)[source]

Bases: BaseModel

A single row of root-tip coordinate data for one plant.

plant_order: int
length_px: float
x_px: float
y_px: float
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class thalianacv.api.schemas.PredictionResponse(*, submission_id: int, prediction_id: int, confidence_score: float, coordinates: list[CoordinateRow], mask_shape: list[int], message: str)[source]

Bases: BaseModel

Response schema for the POST /predict endpoint.

submission_id: int
prediction_id: int
confidence_score: float
coordinates: list[CoordinateRow]
mask_shape: list[int]
message: str
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

Module contents