Backend API: auth, projects/images/annotations, R2 presign, tracing, thumbnails, pagination, tests, docs
This commit is contained in:
parent
5c5deed2f5
commit
f8ed08b854
49 changed files with 2626 additions and 0 deletions
75
shared/schemas.py
Normal file
75
shared/schemas.py
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
"""Pydantic schemas mirroring anotation-frontend/src/types/*."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Literal
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
TaskType = Literal["classification", "object_detection", "segmentation"]
|
||||
ProjectStatus = Literal["annotating", "pending_review", "completed", "draft"]
|
||||
ImageStatus = Literal["unassigned", "in_progress", "pending_review", "completed"]
|
||||
ShapeType = Literal["bbox", "polygon", "point"]
|
||||
ExportFormat = Literal["coco_json", "yolo_txt", "labelme_json", "mask_png"]
|
||||
|
||||
|
||||
class BBox(BaseModel):
|
||||
x: float
|
||||
y: float
|
||||
width: float
|
||||
height: float
|
||||
|
||||
|
||||
class Point2D(BaseModel):
|
||||
x: float
|
||||
y: float
|
||||
|
||||
|
||||
class AnnotationShape(BaseModel):
|
||||
id: str
|
||||
index: int = 0
|
||||
type: ShapeType
|
||||
labelId: str
|
||||
labelName: str = ""
|
||||
color: str = "#888888"
|
||||
visible: bool = True
|
||||
groupId: int | None = None
|
||||
bbox: BBox | None = None
|
||||
points: list[Point2D] | None = None
|
||||
point: Point2D | None = None
|
||||
|
||||
|
||||
class Flags(BaseModel):
|
||||
blurryOrUncertain: bool = False
|
||||
needsRecheck: bool = False
|
||||
|
||||
|
||||
class AnnotationUpsert(BaseModel):
|
||||
classificationLabelId: str | None = None
|
||||
flags: Flags = Field(default_factory=Flags)
|
||||
shapes: list[AnnotationShape] = Field(default_factory=list)
|
||||
|
||||
|
||||
class LabelClassIn(BaseModel):
|
||||
name: str
|
||||
color: str = "#888888"
|
||||
shortcutKey: str | None = None
|
||||
|
||||
|
||||
class ProjectCreate(BaseModel):
|
||||
name: str
|
||||
slug: str
|
||||
description: str = ""
|
||||
taskType: TaskType
|
||||
|
||||
|
||||
class ImageConfirm(BaseModel):
|
||||
"""After direct PUT to R2, client confirms so API creates metadata."""
|
||||
fileName: str
|
||||
r2Key: str
|
||||
width: int = 0
|
||||
height: int = 0
|
||||
|
||||
|
||||
class PresignRequest(BaseModel):
|
||||
fileName: str
|
||||
contentType: str = "image/jpeg"
|
||||
Loading…
Add table
Add a link
Reference in a new issue