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:
Laurent Mazare
2023-08-22 22:20:08 +01:00
committed by GitHub
parent f9ecc84477
commit 7687a0f453
6 changed files with 68 additions and 26 deletions

View 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() {}