satellit_sam.prompts

Auto-generated from satellit_sam/src/satellit_sam/prompts.py by satellit_sam/scripts/generate_api_docs.py.

Prompt parsing and tile-coordinate projection utilities.

Back to API index

Functions

parse_bbox_prompt

def parse_bbox_prompt(raw_bbox: str) -> tuple[float, float, float, float]:
Parse one bbox prompt in ``x1,y1,x2,y2`` format.

Arguments

  • raw_bbox: Raw prompt string from CLI input.

Returns

  • Parsed box tuple ``(x1, y1, x2, y2)``.

Exceptions

  • ValueError: If formatting or coordinate ordering is invalid.

parse_bbox_prompts

def parse_bbox_prompts(
    raw_bboxes: list[str] | None,
) -> list[tuple[float, float, float, float]]:
Parse repeatable bbox prompt options.

Arguments

  • raw_bboxes: Raw ``--bbox`` values from CLI options.

Returns

  • Parsed bounding boxes.

parse_point_prompt

def parse_point_prompt(raw_point: str) -> tuple[float, float]:
Parse one point prompt in ``x,y`` format.

Arguments

  • raw_point: Raw prompt string from CLI input.

Returns

  • Parsed point tuple ``(x, y)``.

Exceptions

  • ValueError: If formatting or coordinate values are invalid.

parse_point_prompts

def parse_point_prompts(raw_points: list[str] | None) -> list[tuple[float, float]]:
Parse repeatable point prompt options.

Arguments

  • raw_points: Raw ``--point`` values from CLI options.

Returns

  • Parsed point prompts.

parse_tile_origin

def parse_tile_origin(tile_path: str) -> tuple[int, int]:
Extract tile origin ``(x, y)`` from a tile filename.

Arguments

  • tile_path: Path to a tile image.

Returns

  • Tile origin in image coordinates.

Exceptions

  • ValueError: If the filename does not match the expected tile pattern.

tile_id_from_origin

def tile_id_from_origin(tile_origin: tuple[int, int]) -> str:
Build weak-label tile id from a tile origin tuple.

Arguments

  • tile_origin: Tile origin ``(x, y)``.

Returns

  • Tile identifier in ``tile_x{X}_y{Y}`` form.

load_weak_label_bboxes

def load_weak_label_bboxes(
    weak_labels_csv: Path,
) -> dict[str, list[tuple[float, float, float, float]]]:
Load tile-local bbox prompts from labels generated by ``label weak``.

Arguments

  • weak_labels_csv: Path to ``labels_tiles.csv``.

Returns

  • Mapping from tile id to local bounding boxes.

Exceptions

  • ValueError: If required fields are missing or rows are malformed.

project_bboxes_to_tile

def project_bboxes_to_tile(
    image_bboxes: list[tuple[float, float, float, float]],
    tile_origin: tuple[int, int],
    tile_size: tuple[int, int],
) -> list[tuple[float, float, float, float]]:
Project image-space boxes into one tile as clipped tile-space boxes.

Arguments

  • image_bboxes: Boxes in full-image coordinates. tile_origin: Tile origin ``(x, y)`` in full-image coordinates. tile_size: Tile size ``(width, height)`` in pixels.

Returns

  • Tile-local boxes that intersect with the tile.

project_points_to_tile

def project_points_to_tile(
    image_points: list[tuple[float, float]],
    tile_origin: tuple[int, int],
    tile_size: tuple[int, int],
) -> list[tuple[float, float]]:
Project image-space points into one tile as tile-space points.

Arguments

  • image_points: Points in full-image coordinates. tile_origin: Tile origin ``(x, y)`` in full-image coordinates. tile_size: Tile size ``(width, height)`` in pixels.

Returns

  • Tile-local points that fall inside the tile.

Classes

No public classes.