cxr-report-generation / src /schemas /segmentation.py
adhisetiawan's picture
Sync latest application changes
21245a4
Raw
History Blame Contribute Delete
760 Bytes
from __future__ import annotations
from typing import Any, Literal
from pydantic import BaseModel, ConfigDict
class MaskResult(BaseModel):
"""Segmentation output for a single finding on a single image view."""
model_config = ConfigDict(arbitrary_types_allowed=True)
finding_label: str
image_path: str
image_index: int
# [y0, x0, y1, x1] normalized to [0, 1000] – matches Stage 1 BBox.box_2d
bbox_normalized: list[int]
# H × W binary uint8 numpy array; None when status is "failed"
mask: Any | None = None
# Polygon contour as [[x, y], ...] in original image pixel coords; largest contour from mask
polygon: list[list[int]] | None = None
status: Literal["success", "failed"]
error: str | None = None