Spaces:
Sleeping
Sleeping
Commit ·
59f313f
1
Parent(s): acf75f8
Model names
Browse files- planparser/app.py +24 -8
planparser/app.py
CHANGED
|
@@ -59,13 +59,25 @@ def join_pt(folder: str | None, name: str | None) -> str | None:
|
|
| 59 |
RESOLVED_MODEL_DIR = _resolve_models_dir()
|
| 60 |
|
| 61 |
MODEL_MAP = {
|
| 62 |
-
"
|
| 63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
}
|
|
|
|
| 65 |
MODEL_MAP = {k: v for k, v in MODEL_MAP.items() if v}
|
| 66 |
|
| 67 |
def _model_type(model_label: str) -> str:
|
| 68 |
-
|
|
|
|
|
|
|
|
|
|
| 69 |
|
| 70 |
MODEL_CHOICES = list(MODEL_MAP.keys())
|
| 71 |
if not MODEL_CHOICES:
|
|
@@ -195,14 +207,18 @@ def _request_predict(model_label: str, img: Image.Image) -> tuple[list[dict], fl
|
|
| 195 |
buf.seek(0)
|
| 196 |
|
| 197 |
t0 = time.perf_counter()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 198 |
r = requests.post(
|
| 199 |
f"{API_URL}/predict",
|
| 200 |
files={"file": ("image.jpg", buf, "image/jpeg")},
|
| 201 |
-
data=
|
| 202 |
-
"weights_path": MODEL_MAP[model_label],
|
| 203 |
-
"model_type": _model_type(model_label),
|
| 204 |
-
},
|
| 205 |
-
timeout=60,
|
| 206 |
)
|
| 207 |
dt = time.perf_counter() - t0
|
| 208 |
|
|
|
|
| 59 |
RESOLVED_MODEL_DIR = _resolve_models_dir()
|
| 60 |
|
| 61 |
MODEL_MAP = {
|
| 62 |
+
"YOLO11 Large": {
|
| 63 |
+
"model_type": "yolo",
|
| 64 |
+
"weights_path": join_pt(RESOLVED_MODEL_DIR, MODEL_1),
|
| 65 |
+
"conf": 0.25,
|
| 66 |
+
},
|
| 67 |
+
"Faster R-CNN": {
|
| 68 |
+
"model_type": "fasterrcnn",
|
| 69 |
+
"weights_path": join_pt(RESOLVED_MODEL_DIR, MODEL_2),
|
| 70 |
+
"conf": 0.25,
|
| 71 |
+
},
|
| 72 |
}
|
| 73 |
+
|
| 74 |
MODEL_MAP = {k: v for k, v in MODEL_MAP.items() if v}
|
| 75 |
|
| 76 |
def _model_type(model_label: str) -> str:
|
| 77 |
+
info = MODEL_MAP.get(model_label)
|
| 78 |
+
mt = info.get("model_type")
|
| 79 |
+
return mt
|
| 80 |
+
|
| 81 |
|
| 82 |
MODEL_CHOICES = list(MODEL_MAP.keys())
|
| 83 |
if not MODEL_CHOICES:
|
|
|
|
| 207 |
buf.seek(0)
|
| 208 |
|
| 209 |
t0 = time.perf_counter()
|
| 210 |
+
|
| 211 |
+
info = MODEL_MAP[model_label]
|
| 212 |
+
data={
|
| 213 |
+
"weights_path": info["weights_path"],
|
| 214 |
+
"model_type": info["model_type"],
|
| 215 |
+
"conf": info["conf"],
|
| 216 |
+
}
|
| 217 |
+
|
| 218 |
r = requests.post(
|
| 219 |
f"{API_URL}/predict",
|
| 220 |
files={"file": ("image.jpg", buf, "image/jpeg")},
|
| 221 |
+
data=data,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 222 |
)
|
| 223 |
dt = time.perf_counter() - t0
|
| 224 |
|