mirror of
https://github.com/huggingface/candle.git
synced 2025-06-19 03:54:56 +00:00
Also fix the aspect ratio in the wasm example. (#556)
* Also fix the aspect ratio in the wasm example. * Add the yolo lib. * Update the build script.
This commit is contained in:
25
candle-wasm-examples/yolo/src/bin/m.rs
Normal file
25
candle-wasm-examples/yolo/src/bin/m.rs
Normal file
@ -0,0 +1,25 @@
|
||||
use candle_wasm_example_yolo::worker::Model as M;
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub struct Model {
|
||||
inner: M,
|
||||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
impl Model {
|
||||
#[wasm_bindgen(constructor)]
|
||||
pub fn new(data: Vec<u8>) -> Result<Model, JsError> {
|
||||
let inner = M::load_(&data)?;
|
||||
Ok(Self { inner })
|
||||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn run(&self, image: Vec<u8>) -> Result<String, JsError> {
|
||||
let boxes = self.inner.run(image)?;
|
||||
let json = serde_json::to_string(&boxes)?;
|
||||
Ok(json)
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
Reference in New Issue
Block a user