Add a wasm module for the segment anything example. (#797)

This commit is contained in:
Laurent Mazare
2023-09-10 12:29:37 +01:00
committed by GitHub
parent 6c58fc59fd
commit 584171cae1
6 changed files with 189 additions and 3 deletions

View File

@ -0,0 +1,19 @@
use candle_transformers::models::segment_anything::sam;
use wasm_bindgen::prelude::*;
pub use sam::{Sam, IMAGE_SIZE};
#[wasm_bindgen]
extern "C" {
// Use `js_namespace` here to bind `console.log(..)` instead of just
// `log(..)`
#[wasm_bindgen(js_namespace = console)]
pub fn log(s: &str);
}
#[macro_export]
macro_rules! console_log {
// Note that this is using the `log` function imported above during
// `bare_bones`
($($t:tt)*) => ($crate::log(&format_args!($($t)*).to_string()))
}