Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
Upload sensAI-Generic-Object-Detection with upload_repo.py
Browse files- README.md +4 -5
- app.py +26 -17
- mod_models.py +10 -9
- shared/eve_messages.py +1 -1
- shared/eve_wrapper.py +1 -1
README.md
CHANGED
|
@@ -31,13 +31,12 @@ an uploaded video, or a live webcam feed. Pick exactly one of three models:
|
|
| 31 |
|
| 32 |
| Model | Description |
|
| 33 |
| --- | --- |
|
| 34 |
-
| **GMOD
|
| 35 |
-
| **
|
| 36 |
-
| **
|
| 37 |
|
| 38 |
Each model is a self-contained `.tflite` loaded through the EVE SDK's custom
|
| 39 |
-
object-detection model path. GMOD
|
| 40 |
-
OMOD-8 load from `models/`. Selecting a model in either tab loads it on the worker.
|
| 41 |
|
| 42 |
To preview the demo, use the tabs:
|
| 43 |
|
|
|
|
| 31 |
|
| 32 |
| Model | Description |
|
| 33 |
| --- | --- |
|
| 34 |
+
| **GMOD Base Model** | Generic 80-class object detector |
|
| 35 |
+
| **Automotive Object Detector** | 8-class automotive object detector — person, bicycle, car, motorcycle, truck, bus, traffic light, stop sign |
|
| 36 |
+
| **Office Object Detector** | 8-class office-objects detector — bottle, cup, potted plant, laptop, mouse, keyboard, cell phone, book |
|
| 37 |
|
| 38 |
Each model is a self-contained `.tflite` loaded through the EVE SDK's custom
|
| 39 |
+
object-detection model path. GMOD Base Model uses the SDK's bundled weights. Selecting a model in either tab loads it on the worker.
|
|
|
|
| 40 |
|
| 41 |
To preview the demo, use the tabs:
|
| 42 |
|
app.py
CHANGED
|
@@ -40,8 +40,8 @@ def _build_feature_radio(hint: str = "") -> gr.Radio:
|
|
| 40 |
choices=MOD_MODELS,
|
| 41 |
value=DEFAULT_MOD_MODEL,
|
| 42 |
label=label,
|
| 43 |
-
info="Pick one object detector: GMOD
|
| 44 |
-
", or Office
|
| 45 |
interactive=True,
|
| 46 |
)
|
| 47 |
|
|
@@ -155,26 +155,28 @@ if __name__ == "__main__":
|
|
| 155 |
gr.Markdown(
|
| 156 |
"Run object detection on videos or a live camera feed using "
|
| 157 |
"one of three EVE SDK models:\n\n"
|
| 158 |
-
"- **GMOD
|
| 159 |
-
" - Classes
|
| 160 |
-
"
|
| 161 |
-
"
|
| 162 |
-
"
|
| 163 |
-
"
|
| 164 |
-
"
|
| 165 |
-
"
|
| 166 |
-
"
|
| 167 |
-
"
|
| 168 |
-
"- **
|
|
|
|
|
|
|
|
|
|
| 169 |
" - Classes: person, bicycle, car, motorcycle, bus, truck, traffic light and stop sign.\n"
|
| 170 |
-
"- **Office
|
| 171 |
" - Classes: bottle, cup, potted plant, laptop, mouse, keyboard, cell phone and book.\n\n"
|
| 172 |
"Only one model is active at a time. Pick the model with the radio button below."
|
| 173 |
)
|
| 174 |
gr.Markdown(
|
| 175 |
-
"A guide on how to finetune the GMOD
|
| 176 |
-
"For any questions or support, please reach out to us at evehelp@latticesemi.com.
|
| 177 |
-
"> Note: For demo purposes, execution of the AI pipeline and image draw operations are all performed on a Hugging Face CPU server. Performance may vary based on the number of concurrent users."
|
| 178 |
)
|
| 179 |
|
| 180 |
# Required by EveAppHandlers signatures (Face ID gallery state). Empty
|
|
@@ -203,6 +205,13 @@ if __name__ == "__main__":
|
|
| 203 |
|
| 204 |
build_eula_tab()
|
| 205 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 206 |
# --- Examples wire-up: clicking a sample loads it into the matching input ---
|
| 207 |
video_example_dataset.click(
|
| 208 |
fn=lambda sample: sample[0],
|
|
|
|
| 40 |
choices=MOD_MODELS,
|
| 41 |
value=DEFAULT_MOD_MODEL,
|
| 42 |
label=label,
|
| 43 |
+
info="Pick one object detector: GMOD Base Model (generic 80-class), Automotive Object Detector (8-class)"
|
| 44 |
+
", or Office Object Detector (8-class).",
|
| 45 |
interactive=True,
|
| 46 |
)
|
| 47 |
|
|
|
|
| 155 |
gr.Markdown(
|
| 156 |
"Run object detection on videos or a live camera feed using "
|
| 157 |
"one of three EVE SDK models:\n\n"
|
| 158 |
+
"- **GMOD Base Model** — 80-class generic multi-object detector.\n\n"
|
| 159 |
+
" - Classes, grouped by category:\n\n"
|
| 160 |
+
" - **People and animals:** person, bird, cat, dog, horse, sheep, cow, elephant, bear, zebra and giraffe.\n"
|
| 161 |
+
" - **Vehicles:** bicycle, car, motorcycle, airplane, bus, train, truck and boat.\n"
|
| 162 |
+
" - **Outdoor:** traffic light, fire hydrant, stop sign, parking meter and bench.\n"
|
| 163 |
+
" - **Accessories:** backpack, umbrella, handbag, tie and suitcase.\n"
|
| 164 |
+
" - **Sports:** frisbee, skis, snowboard, sports ball, kite, baseball bat, baseball glove, skateboard, surfboard and tennis racket.\n"
|
| 165 |
+
" - **Kitchen:** bottle, wine glass, cup, fork, knife, spoon and bowl.\n"
|
| 166 |
+
" - **Food:** banana, apple, sandwich, orange, broccoli, carrot, hot dog, pizza, donut and cake.\n"
|
| 167 |
+
" - **Furniture:** chair, couch, potted plant, bed, dining table and toilet.\n"
|
| 168 |
+
" - **Electronics:** tv, laptop, mouse, remote, keyboard and cell phone.\n"
|
| 169 |
+
" - **Appliances:** microwave, oven, toaster, sink and refrigerator.\n"
|
| 170 |
+
" - **Indoor:** book, clock, vase, scissors, teddy bear, hair drier and toothbrush.\n\n"
|
| 171 |
+
"- **Automotive Object Detector** — 8-class automotive object detector finetuned from GMOD Base Model.\n\n"
|
| 172 |
" - Classes: person, bicycle, car, motorcycle, bus, truck, traffic light and stop sign.\n"
|
| 173 |
+
"- **Office Object Detector** — 8-class office object detector finetuned from GMOD Base Model.\n\n"
|
| 174 |
" - Classes: bottle, cup, potted plant, laptop, mouse, keyboard, cell phone and book.\n\n"
|
| 175 |
"Only one model is active at a time. Pick the model with the radio button below."
|
| 176 |
)
|
| 177 |
gr.Markdown(
|
| 178 |
+
"A guide on how to finetune the GMOD Base Model with your own data will be available soon, along with the release 7.3 of the EVE SDK.\n\n"
|
| 179 |
+
"For any questions or support, please reach out to us at evehelp@latticesemi.com."
|
|
|
|
| 180 |
)
|
| 181 |
|
| 182 |
# Required by EveAppHandlers signatures (Face ID gallery state). Empty
|
|
|
|
| 205 |
|
| 206 |
build_eula_tab()
|
| 207 |
|
| 208 |
+
gr.Markdown(
|
| 209 |
+
"<p style='font-size:1.0em;text-align:center'>"
|
| 210 |
+
"<strong>Note:</strong> For demo purposes, execution of the AI pipeline and image draw "
|
| 211 |
+
"operations are all performed on a Hugging Face CPU server. Performance may vary based on "
|
| 212 |
+
"the number of concurrent users.</p>"
|
| 213 |
+
)
|
| 214 |
+
|
| 215 |
# --- Examples wire-up: clicking a sample loads it into the matching input ---
|
| 216 |
video_example_dataset.click(
|
| 217 |
fn=lambda sample: sample[0],
|
mod_models.py
CHANGED
|
@@ -4,9 +4,10 @@ This is the single place that maps each selectable model name to the
|
|
| 4 |
``ModelConfig`` the EVE worker loads. Adding a model, or pointing an existing
|
| 5 |
one at new weights, is a one-line change here — nothing else needs to move.
|
| 6 |
|
| 7 |
-
- **GMOD
|
| 8 |
-
and no class table.
|
| 9 |
-
- **Automotive** and **Office** load their
|
|
|
|
| 10 |
(the gated weights fetched at build time, see ``install_eve.py``; falls back to
|
| 11 |
the demo-relative ``models/`` locally) and ship their own class labels (in
|
| 12 |
output-index order).
|
|
@@ -46,16 +47,16 @@ OFFICE_CLASS_NAMES: tuple[str, ...] = (
|
|
| 46 |
)
|
| 47 |
|
| 48 |
MOD_MODEL_REGISTRY: dict[str, ModelConfig] = {
|
| 49 |
-
"GMOD
|
| 50 |
-
"Automotive": ModelConfig(
|
| 51 |
-
name="Automotive",
|
| 52 |
model_path=str(_MODELS_DIR / "automotive-640x640.tflite"),
|
| 53 |
class_names=AUTOMOTIVE_CLASS_NAMES,
|
| 54 |
nms_threshold=0.4,
|
| 55 |
iou_threshold=0.4
|
| 56 |
),
|
| 57 |
-
"Office": ModelConfig(
|
| 58 |
-
name="Office",
|
| 59 |
model_path=str(_MODELS_DIR / "office-640x640.tflite"),
|
| 60 |
class_names=OFFICE_CLASS_NAMES,
|
| 61 |
nms_threshold=0.4,
|
|
@@ -65,4 +66,4 @@ MOD_MODEL_REGISTRY: dict[str, ModelConfig] = {
|
|
| 65 |
|
| 66 |
# UI order of the selection radio; first entry is the default.
|
| 67 |
MOD_MODELS: list[str] = list(MOD_MODEL_REGISTRY)
|
| 68 |
-
DEFAULT_MOD_MODEL: str = "GMOD
|
|
|
|
| 4 |
``ModelConfig`` the EVE worker loads. Adding a model, or pointing an existing
|
| 5 |
one at new weights, is a one-line change here — nothing else needs to move.
|
| 6 |
|
| 7 |
+
- **GMOD Base Model** uses the EVE SDK's bundled default model, so it carries
|
| 8 |
+
no path and no class table.
|
| 9 |
+
- **Automotive Object Detector** and **Office Object Detector** load their
|
| 10 |
+
``.tflite`` from ``MOD_MODELS_DIR``
|
| 11 |
(the gated weights fetched at build time, see ``install_eve.py``; falls back to
|
| 12 |
the demo-relative ``models/`` locally) and ship their own class labels (in
|
| 13 |
output-index order).
|
|
|
|
| 47 |
)
|
| 48 |
|
| 49 |
MOD_MODEL_REGISTRY: dict[str, ModelConfig] = {
|
| 50 |
+
"GMOD Base Model": ModelConfig(name="GMOD Base Model", nms_threshold=0.2),
|
| 51 |
+
"Automotive Object Detector": ModelConfig(
|
| 52 |
+
name="Automotive Object Detector",
|
| 53 |
model_path=str(_MODELS_DIR / "automotive-640x640.tflite"),
|
| 54 |
class_names=AUTOMOTIVE_CLASS_NAMES,
|
| 55 |
nms_threshold=0.4,
|
| 56 |
iou_threshold=0.4
|
| 57 |
),
|
| 58 |
+
"Office Object Detector": ModelConfig(
|
| 59 |
+
name="Office Object Detector",
|
| 60 |
model_path=str(_MODELS_DIR / "office-640x640.tflite"),
|
| 61 |
class_names=OFFICE_CLASS_NAMES,
|
| 62 |
nms_threshold=0.4,
|
|
|
|
| 66 |
|
| 67 |
# UI order of the selection radio; first entry is the default.
|
| 68 |
MOD_MODELS: list[str] = list(MOD_MODEL_REGISTRY)
|
| 69 |
+
DEFAULT_MOD_MODEL: str = "GMOD Base Model"
|
shared/eve_messages.py
CHANGED
|
@@ -26,7 +26,7 @@ class ModelConfig:
|
|
| 26 |
|
| 27 |
Carries everything ``eve_wrapper.enable_object_detection`` needs to
|
| 28 |
configure one MOD model. ``model_path`` of ``None`` / ``""`` selects the
|
| 29 |
-
EVE SDK's bundled default model (GMOD
|
| 30 |
and applies ``class_names``. ``None`` thresholds fall back to the SDK
|
| 31 |
defaults. Picklable so it can ride inside ``FeatureFlags`` to a worker.
|
| 32 |
|
|
|
|
| 26 |
|
| 27 |
Carries everything ``eve_wrapper.enable_object_detection`` needs to
|
| 28 |
configure one MOD model. ``model_path`` of ``None`` / ``""`` selects the
|
| 29 |
+
EVE SDK's bundled default model (GMOD Base Model); a path loads that ``.tflite``
|
| 30 |
and applies ``class_names``. ``None`` thresholds fall back to the SDK
|
| 31 |
defaults. Picklable so it can ride inside ``FeatureFlags`` to a worker.
|
| 32 |
|
shared/eve_wrapper.py
CHANGED
|
@@ -257,7 +257,7 @@ class EveWrapper:
|
|
| 257 |
it, matching the SDK's disabled-by-default state). Otherwise:
|
| 258 |
|
| 259 |
- ``config.model_path`` empty / ``None`` selects the SDK's bundled
|
| 260 |
-
default model (GMOD
|
| 261 |
- a populated ``config.model_path`` loads that ``.tflite`` and, if
|
| 262 |
given, replaces the class table with ``config.class_names``.
|
| 263 |
|
|
|
|
| 257 |
it, matching the SDK's disabled-by-default state). Otherwise:
|
| 258 |
|
| 259 |
- ``config.model_path`` empty / ``None`` selects the SDK's bundled
|
| 260 |
+
default model (GMOD Base Model) with its default class names.
|
| 261 |
- a populated ``config.model_path`` loads that ``.tflite`` and, if
|
| 262 |
given, replaces the class table with ``config.class_names``.
|
| 263 |
|