Spaces:
Sleeping
Sleeping
Download demo_api/models.py from HarryDeepWise/web_demo: direct link, hf CLI and curl.
- Browser
- Download file 1.41 kB
-
https://huggingface.co/spaces/HarryDeepWise/web_demo/resolve/main/demo_api/models.py
- Command line
-
hf download hf://spaces/HarryDeepWise/web_demo/demo_api/models.py
-
curl -L -o models.py https://huggingface.co/spaces/HarryDeepWise/web_demo/resolve/main/demo_api/models.py
1.41 kB
| from __future__ import annotations | |
| from typing import Literal | |
| from pydantic import BaseModel, Field | |
| from sami_client.models import PointPrompt | |
| class SessionRequest(BaseModel): | |
| """Select one of the public MSD demo volumes.""" | |
| case_id: Literal["liver_ct", "prostate_mr"] | |
| model_config = {"json_schema_extra": {"examples": [{"case_id": "liver_ct"}]}} | |
| class PromptRequest(BaseModel): | |
| """A single 3D point in voxel coordinates.""" | |
| type: Literal["point"] | |
| mode: Literal["add", "remove"] | |
| point: list[int] = Field(min_length=3, max_length=3) | |
| model_config = { | |
| "json_schema_extra": { | |
| "examples": [{"type": "point", "mode": "add", "point": [80, 96, 42]}] | |
| } | |
| } | |
| def to_sami_prompt(self) -> PointPrompt: | |
| return PointPrompt(mode=self.mode, point=tuple(self.point)) | |
| class BackendStatusResponse(BaseModel): | |
| status: Literal["ready", "waking", "unavailable"] | |
| class SessionResponse(BaseModel): | |
| case_id: Literal["liver_ct", "prostate_mr"] | |
| dims: list[int] = Field(min_length=3, max_length=3) | |
| demo_client_id: str | |
| class MaskResponse(BaseModel): | |
| encoding: Literal["bbox_packed_gzip_b64"] | |
| mask: str | |
| bbox: list[int] = Field(min_length=6, max_length=6) | |
| crop_shape: list[int] = Field(min_length=3, max_length=3) | |
| timings: dict[str, float] | |
| session_restarted: bool | |
| class OkResponse(BaseModel): | |
| ok: bool | |