Skip to content

Commit e1e6e66

Browse files
Add face detection feature on video input (#6)
1 parent 17afedb commit e1e6e66

4 files changed

Lines changed: 1119 additions & 0 deletions

File tree

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,18 @@ mise run ws-e2e-chrome
1919

2020
## Run ws agent in browser
2121

22+
### HAR model setup
23+
2224
Download the onnx from https://modelnova.ai/models/details/human-activity-recognition ,
2325
and save it as `services/ws-server/static/models/human_activity_recognition.onnx`
2426

27+
### Face detection setup
28+
29+
Download the onnx from https://huggingface.co/amd/retinaface and save it in
30+
`services/ws-server/static/models/` and rename the file to `video_cv.onnx`.
31+
32+
### Build and run the agent
33+
2534
```bash
2635
mise run build-ws-wasm-agent
2736
mise run ws-server
@@ -35,6 +44,7 @@ which will normally be something like 192.168.1.x.
3544
Then on your phone, open Chrome and type in https://192.168.1.x:8433/
3645

3746
Click "Load HAR model" and then "Start sensors".
47+
For webcam inference, click "Load video CV model" and then "Start video".
3848

3949
## Grant
4050

services/ws-server/src/main.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,27 @@ impl StreamHandler<Result<ws::Message, ws::ProtocolError>> for WebSocketActor {
177177
action,
178178
details,
179179
} => {
180+
if capability == "video_cv" && action == "inference" {
181+
let detected_class = details
182+
.get("detected_class")
183+
.and_then(|value| value.as_str())
184+
.unwrap_or("unknown");
185+
let confidence = details
186+
.get("confidence")
187+
.and_then(|value| value.as_f64())
188+
.unwrap_or_default();
189+
let processed_at = details
190+
.get("processed_at")
191+
.and_then(|value| value.as_str())
192+
.unwrap_or("unknown");
193+
info!(
194+
"Video inference received from {}: class={} confidence={:.4} processed_at={}",
195+
self.current_agent_id(),
196+
detected_class,
197+
confidence,
198+
processed_at
199+
);
200+
}
180201
info!(
181202
"Client event from {}: capability={} action={} details={}",
182203
self.current_agent_id(),

0 commit comments

Comments
 (0)