summaryrefslogtreecommitdiff
path: root/candle-wasm-examples/segment-anything/src/lib.rs
blob: 0f4f96fdfd31d4f7aef73290cca38d21367050b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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()))
}