Fix wasm examples (#1824)

This commit is contained in:
Nathaniel Simard 2024-05-28 17:51:20 -04:00 committed by GitHub
parent e61b026918
commit 912ffb4a81
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 17 additions and 18 deletions

View File

@ -64,7 +64,6 @@ rusqlite = { version = "0.31.0" }
rust-format = { version = "0.3.4" }
sanitize-filename = "0.5.0"
serde_rusqlite = "0.35.0"
serde-wasm-bindgen = "0.6.5"
spin = { version = "0.9.8", features = ["mutex", "spin_mutex"] }
strum = "0.26.2"
strum_macros = "0.26.2"
@ -75,10 +74,6 @@ tokio = { version = "1.37.0", features = ["rt", "macros"] }
tracing-appender = "0.2.3"
tracing-core = "0.1.32"
tracing-subscriber = "0.3.18"
wasm-bindgen = "0.2.92"
wasm-bindgen-futures = "0.4.42"
wasm-logger = "0.2.0"
wasm-timer = "0.2.5"
md5 = "0.7.0"
serial_test = "3.1.1"
web-time = "1.1.0"

View File

@ -1,7 +1,7 @@
[package]
authors = ["Dilshod Tadjibaev (@antimora)"]
edition.workspace = true
license.workspace = true
license = "MIT OR Apache-2.0"
name = "image-classification-web"
publish = false
version.workspace = true
@ -20,17 +20,19 @@ burn = { path = "../../crates/burn", version = "0.15.0", default-features = fals
burn-wgpu = { path = "../../crates/burn-wgpu", version = "0.15.0", default-features = false }
burn-candle = { path = "../../crates/burn-candle", version = "0.15.0", default-features = false }
js-sys = { workspace = true }
log = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
serde-wasm-bindgen = { workspace = true }
wasm-bindgen = { workspace = true }
wasm-bindgen-futures = { workspace = true }
wasm-logger = { workspace = true }
wasm-timer = { workspace = true }
console_error_panic_hook = { workspace = true }
# Wasm dependencies
wasm-bindgen = "0.2"
wasm-bindgen-futures = "0.4"
serde-wasm-bindgen = "0.6"
wasm-logger = "0.2"
wasm-timer = "0.2"
js-sys = "0.3"
[build-dependencies]
# Used to generate code from ONNX model
burn-import = { path = "../../crates/burn-import" }

View File

@ -1,7 +1,7 @@
[package]
authors = ["Dilshod Tadjibaev (@antimora)"]
edition.workspace = true
license.workspace = true
license = "MIT OR Apache-2.0"
name = "mnist-inference-web"
publish = false
version.workspace = true
@ -18,10 +18,12 @@ wgpu = ["burn/wgpu"]
[dependencies]
burn = { path = "../../crates/burn", default-features = false }
serde = { workspace = true }
wasm-bindgen = { workspace = true }
wasm-bindgen-futures = { workspace = true }
js-sys = { workspace = true }
console_error_panic_hook = { workspace = true }
# Wasm dependencies
wasm-bindgen = "0.2"
wasm-bindgen-futures = "0.4"
js-sys = "0.3"
[dev-dependencies]
pollster = { workspace = true }

View File

@ -5,7 +5,7 @@ use burn::{
};
#[cfg(feature = "wgpu")]
use burn::backend::wgpu::{compute::init_async, AutoGraphicsApi, Wgpu, WgpuDevice};
use burn::backend::wgpu::{init_async, AutoGraphicsApi, Wgpu, WgpuDevice};
#[cfg(feature = "wgpu")]
pub type Backend = Wgpu<AutoGraphicsApi, f32, i32>;
@ -18,7 +18,7 @@ static STATE_ENCODED: &[u8] = include_bytes!("../model.bin");
/// Builds and loads trained parameters into the model.
pub async fn build_and_load_model() -> Model<Backend> {
#[cfg(feature = "wgpu")]
init_async::<AutoGraphicsApi>(&WgpuDevice::default()).await;
init_async::<AutoGraphicsApi>(&WgpuDevice::default(), Default::default()).await;
let model: Model<Backend> = Model::new(&Default::default());
let record = BinBytesRecorder::<FullPrecisionSettings>::default()