alessandro trinca tornidor
[feat] prepare entire docker build with nvidia GPU on hf space cloning https://huggingface.co/spaces/aletrn/samgis
0914710
"""custom type hints""" | |
from enum import IntEnum, Enum | |
from typing import TypedDict | |
from affine import Affine | |
from numpy import ndarray | |
from pydantic import BaseModel | |
tuple_ndarray_transform = tuple[ndarray, Affine] | |
class XYZDefaultProvidersNames(str, Enum): | |
"""Default xyz provider names""" | |
DEFAULT_TILES_NAME_SHORT = "openstreetmap" | |
DEFAULT_TILES_NAME = "openstreetmap.mapnik" | |
class XYZTerrainProvidersNames(str, Enum): | |
"""Custom xyz provider names for digital elevation models""" | |
MAPBOX_TERRAIN_TILES_NAME = "mapbox.terrain-rgb" | |
NEXTZEN_TERRAIN_TILES_NAME = "nextzen.terrarium" | |
class LatLngDict(BaseModel): | |
"""Generic geographic latitude-longitude type""" | |
lat: float | |
lng: float | |
class ContentTypes(str, Enum): | |
"""Segment Anything: validation point prompt type""" | |
APPLICATION_JSON = "application/json" | |
TEXT_PLAIN = "text/plain" | |
TEXT_HTML = "text/html" | |
class PromptPointType(str, Enum): | |
"""Segment Anything: validation point prompt type""" | |
point = "point" | |
class PromptRectangleType(str, Enum): | |
"""Segment Anything: validation rectangle prompt type""" | |
rectangle = "rectangle" | |
class PromptLabel(IntEnum): | |
"""Valid prompt label type""" | |
EXCLUDE = 0 | |
INCLUDE = 1 | |
class ImagePixelCoordinates(TypedDict): | |
"""Image pixel coordinates type""" | |
x: int | |
y: int | |
class RawBBox(BaseModel): | |
"""Input lambda bbox request type (not yet parsed)""" | |
ne: LatLngDict | |
sw: LatLngDict | |
class RawPromptPoint(BaseModel): | |
"""Input lambda prompt request of type 'PromptPointType' - point (not yet parsed)""" | |
type: PromptPointType | |
data: LatLngDict | |
label: PromptLabel | |
class RawPromptRectangle(BaseModel): | |
"""Input lambda prompt request of type 'PromptRectangleType' - rectangle (not yet parsed)""" | |
type: PromptRectangleType | |
data: RawBBox | |
def get_type_str(self): | |
return self.type | |
class ApiRequestBody(BaseModel): | |
"""Input lambda request validator type (not yet parsed)""" | |
id: str = "" | |
bbox: RawBBox | |
prompt: list[RawPromptPoint | RawPromptRectangle] | |
zoom: int | float | |
source_type: str = "OpenStreetMap.Mapnik" | |
debug: bool = False | |
class StringPromptApiRequestBody(BaseModel): | |
"""Input lambda request validator type (not yet parsed)""" | |
id: str = "" | |
bbox: RawBBox | |
string_prompt: str | |
zoom: int | float | |
source_type: str = "OpenStreetMap.Mapnik" | |
debug: bool = False | |
class ApiResponseBodyFailure(BaseModel): | |
duration_run: float | |
message: str | |
request_id: str | |
class ApiResponseBodySuccess(ApiResponseBodyFailure): | |
n_predictions: int | |
geojson: str | |
n_shapes_geojson: int | |