mirror of
https://github.com/huggingface/candle.git
synced 2025-06-15 18:28:24 +00:00
[WIP] Improve Yolo WASM UI example (#591)
* return detections with classes names * ignore .DS_Store * example how to load wasm module * add param to set model size * add param for model size * accept iou and confidence threshold on run * conf and iou thresholds * clamp only * remove images from branch * a couple of renamings, add readme with instructions * final design * minor font + border update
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
use crate::console_log;
|
||||
use crate::worker::{ModelData, Worker, WorkerInput, WorkerOutput};
|
||||
use crate::worker::{ModelData, RunData, Worker, WorkerInput, WorkerOutput};
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen_futures::JsFuture;
|
||||
use yew::{html, Component, Context, Html};
|
||||
@ -50,9 +50,13 @@ pub struct App {
|
||||
}
|
||||
|
||||
async fn model_data_load() -> Result<ModelData, JsValue> {
|
||||
let weights = fetch_url("yolo.safetensors").await?;
|
||||
let weights = fetch_url("yolov8s.safetensors").await?;
|
||||
let model_size = "s".to_string();
|
||||
console_log!("loaded weights {}", weights.len());
|
||||
Ok(ModelData { weights })
|
||||
Ok(ModelData {
|
||||
weights,
|
||||
model_size,
|
||||
})
|
||||
}
|
||||
|
||||
fn performance_now() -> Option<f64> {
|
||||
@ -162,7 +166,11 @@ impl Component for App {
|
||||
let status = format!("{err:?}");
|
||||
Msg::UpdateStatus(status)
|
||||
}
|
||||
Ok(image_data) => Msg::WorkerInMsg(WorkerInput::Run(image_data)),
|
||||
Ok(image_data) => Msg::WorkerInMsg(WorkerInput::RunData(RunData {
|
||||
image_data,
|
||||
conf_threshold: 0.5,
|
||||
iou_threshold: 0.5,
|
||||
})),
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user