Spaces:
Sleeping
Sleeping
Commit
·
b48318f
1
Parent(s):
dd85fb6
Fix: unignore backend models package
Browse files- .gitignore +3 -1
- backend/py/app/models/__init__.py +2 -0
- backend/py/app/models/schemas.py +37 -0
.gitignore
CHANGED
|
@@ -1,2 +1,4 @@
|
|
| 1 |
__pycache__
|
| 2 |
-
models
|
|
|
|
|
|
|
|
|
| 1 |
__pycache__
|
| 2 |
+
# Only ignore top-level models directory (for DL assets),
|
| 3 |
+
# not Python packages named "models" deeper in the tree.
|
| 4 |
+
/models
|
backend/py/app/models/__init__.py
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
__all__ = []
|
| 2 |
+
|
backend/py/app/models/schemas.py
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Any, Dict, Literal, Optional
|
| 2 |
+
|
| 3 |
+
from pydantic import BaseModel, Field
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
class DetectionParams(BaseModel):
|
| 7 |
+
canny_low: Optional[int] = Field(None, ge=0, le=255)
|
| 8 |
+
canny_high: Optional[int] = Field(None, ge=0, le=255)
|
| 9 |
+
harris_k: Optional[float] = Field(None, ge=0.0, le=1.0)
|
| 10 |
+
harris_block: Optional[int] = Field(None, ge=1, le=16)
|
| 11 |
+
harris_ksize: Optional[int] = Field(None, ge=1, le=15)
|
| 12 |
+
hough_thresh: Optional[int] = Field(None, ge=1, le=500)
|
| 13 |
+
hough_min_len: Optional[int] = Field(None, ge=1, le=1000)
|
| 14 |
+
hough_max_gap: Optional[int] = Field(None, ge=0, le=200)
|
| 15 |
+
ellipse_min_area: Optional[int] = Field(None, ge=10, le=100000)
|
| 16 |
+
max_ellipses: Optional[int] = Field(None, ge=1, le=100)
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
class DetectionRequest(BaseModel):
|
| 20 |
+
image: str = Field(..., description="Base64-encoded image (PNG/JPEG).")
|
| 21 |
+
params: Optional[DetectionParams] = None
|
| 22 |
+
mode: Literal["classical", "dl", "both"] = "classical"
|
| 23 |
+
compare: bool = False
|
| 24 |
+
dl_model: Optional[str] = Field(
|
| 25 |
+
None, description="Optional ONNX filename override from ./models."
|
| 26 |
+
)
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
class DetectionResponse(BaseModel):
|
| 30 |
+
overlay: Optional[str] = None
|
| 31 |
+
overlays: Dict[str, Optional[str]]
|
| 32 |
+
features: Dict[str, Any]
|
| 33 |
+
timings: Dict[str, float]
|
| 34 |
+
fps_estimate: Optional[float] = None
|
| 35 |
+
model: Dict[str, Any]
|
| 36 |
+
models: Dict[str, Dict[str, Any]]
|
| 37 |
+
|