diff --git a/.github/workflows/provision-darwin.sh b/.github/workflows/provision-darwin.sh index 9b37a68a7..79ae463b1 100755 --- a/.github/workflows/provision-darwin.sh +++ b/.github/workflows/provision-darwin.sh @@ -66,5 +66,15 @@ tar -xf "wasmtime-v${wasmtime_version}-x86_64-macos.tar.xz" --directory "${HOME} mv "${HOME}/bin/wasmtime-v${wasmtime_version}-x86_64-macos/wasmtime" "${HOME}/bin/wasmtime" rm "wasmtime-v${wasmtime_version}-x86_64-macos.tar.xz" +# Install wasi2ic +git clone https://github.com/wasm-forge/wasi2ic +cargo install --path wasi2ic --root "${HOME}" + +# Install wasm-opt +version=117 +curl -fsSLO "https://github.com/WebAssembly/binaryen/releases/download/version_117/binaryen-version_${version}-x86_64-macos.tar.gz" +tar -xzf "binaryen-version_${version}-x86_64-macos.tar.gz" --directory "${HOME}/" --strip-components 1 +rm "binaryen-version_${version}-x86_64-macos.tar.gz" + # Exit temporary directory. popd diff --git a/.github/workflows/provision-linux.sh b/.github/workflows/provision-linux.sh index 1ec2ece00..1fe0de182 100755 --- a/.github/workflows/provision-linux.sh +++ b/.github/workflows/provision-linux.sh @@ -60,6 +60,16 @@ tar -xf "wasmtime-v${wasmtime_version}-x86_64-linux.tar.xz" --directory "${HOME} mv "${HOME}/bin/wasmtime-v${wasmtime_version}-x86_64-linux/wasmtime" "${HOME}/bin/wasmtime" rm "wasmtime-v${wasmtime_version}-x86_64-linux.tar.xz" +# Install wasi2ic +git clone https://github.com/wasm-forge/wasi2ic +cargo install --path wasi2ic --root "${HOME}" + +# Install wasm-opt +version=117 +curl -fsSLO "https://github.com/WebAssembly/binaryen/releases/download/version_117/binaryen-version_${version}-x86_64-linux.tar.gz" +tar -xzf "binaryen-version_${version}-x86_64-linux.tar.gz" --directory "${HOME}/" --strip-components 1 +rm "binaryen-version_${version}-x86_64-linux.tar.gz" + # Set environment variables. echo "$HOME/bin" >> $GITHUB_PATH echo "$HOME/.cargo/bin" >> $GITHUB_PATH diff --git a/.github/workflows/rust-image-classification-example.yaml b/.github/workflows/rust-image-classification-example.yaml new file mode 100644 index 000000000..f33a25f81 --- /dev/null +++ b/.github/workflows/rust-image-classification-example.yaml @@ -0,0 +1,44 @@ +name: rust-image-classification +on: + push: + branches: + - master + pull_request: + paths: + - rust/image-classification/** + - .github/workflows/provision-darwin.sh + - .github/workflows/provision-linux.sh + - .github/workflows/rust-image-classification-example.yaml + - .ic-commit +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +jobs: + rust-image-classification-example-darwin: + runs-on: macos-12 + steps: + - uses: actions/checkout@v1 + - name: Provision Darwin + run: DFX_VERSION="0.20.2-beta.0" bash .github/workflows/provision-darwin.sh + - name: Remove networks.json + run: rm -f ~/.config/dfx/networks.json + - name: Rust Image Classification Darwin + run: | + dfx start --background + pushd rust/image-classification + make test + popd + rust-image-classification-example-linux: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v1 + - name: Provision Linux + run: DFX_VERSION="0.20.2-beta.0" bash .github/workflows/provision-linux.sh + - name: Remove networks.json + run: rm -f ~/.config/dfx/networks.json + - name: Rust Image Classification Linux + run: | + dfx start --background + pushd rust/image-classification + make test + popd diff --git a/rust/image-classification/.cargo/config.toml b/rust/image-classification/.cargo/config.toml new file mode 100644 index 000000000..067cfd27d --- /dev/null +++ b/rust/image-classification/.cargo/config.toml @@ -0,0 +1,5 @@ +[build] +target = ["wasm32-wasi"] + +[target.wasm32-wasi] +rustflags = ["-Ctarget-feature=+simd128"] diff --git a/rust/image-classification/.gitignore b/rust/image-classification/.gitignore index 39b6eb4d0..6273b8366 100644 --- a/rust/image-classification/.gitignore +++ b/rust/image-classification/.gitignore @@ -8,3 +8,5 @@ _MACOSX target/ *.old.did .idea +src/backend/assets/mobilenetv2-7.onnx +.env diff --git a/rust/image-classification/Cargo.lock b/rust/image-classification/Cargo.lock index 9eb2ebdef..87b2265e5 100644 --- a/rust/image-classification/Cargo.lock +++ b/rust/image-classification/Cargo.lock @@ -22,18 +22,18 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" dependencies = [ "memchr", ] [[package]] name = "anyhow" -version = "1.0.81" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247" +checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" [[package]] name = "anymap2" @@ -49,9 +49,9 @@ checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" [[package]] name = "autocfg" -version = "1.1.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "backend" @@ -61,7 +61,7 @@ dependencies = [ "bytes", "candid", "colorgrad", - "ic-cdk", + "ic-cdk 0.14.0", "ic-stable-structures", "ic-wasi-polyfill", "image", @@ -117,9 +117,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.2" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" [[package]] name = "block-buffer" @@ -132,9 +132,9 @@ dependencies = [ [[package]] name = "bytemuck" -version = "1.15.0" +version = "1.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d6d68c57235a3a081186990eca2867354726650f42f7516ca50c28d6281fd15" +checksum = "b236fc92302c97ed75b38da1f4917b5cdda4984745740f153a5d3059e48d725e" [[package]] name = "byteorder" @@ -144,15 +144,15 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.5.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" +checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" [[package]] name = "candid" -version = "0.10.5" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "088c2e3d22a0fb1ada78b968946b0f7b96027ac8669973fe7c0815a98e8d13ef" +checksum = "dd5902d37352dffd8bd9177a2daa6444ce3cd0279c91763fb0171c053aa04335" dependencies = [ "anyhow", "binread", @@ -180,14 +180,14 @@ dependencies = [ "lazy_static", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.66", ] [[package]] name = "cc" -version = "1.0.90" +version = "1.0.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" +checksum = "96c51067fd44124faa7f870b4b1c969379ad32b2ba805aa959430ceaa384f695" [[package]] name = "cfg-if" @@ -222,12 +222,6 @@ dependencies = [ "half", ] -[[package]] -name = "color_quant" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" - [[package]] name = "colorgrad" version = "0.6.2" @@ -248,9 +242,9 @@ dependencies = [ [[package]] name = "crc32fast" -version = "1.4.0" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3855a8a784b474f333699ef2bbca9db2c4a1f6d9088a90a2d25b1eb53111eaa" +checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" dependencies = [ "cfg-if", ] @@ -307,9 +301,9 @@ dependencies = [ [[package]] name = "data-encoding" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5" +checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2" [[package]] name = "deranged" @@ -349,9 +343,9 @@ checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" [[package]] name = "downcast-rs" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" +checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2" [[package]] name = "dyn-clone" @@ -367,15 +361,15 @@ checksum = "a650a461c6a8ff1ef205ed9a2ad56579309853fecefc2423f73dced342f92258" [[package]] name = "either" -version = "1.10.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" +checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" [[package]] name = "errno" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" dependencies = [ "libc", "windows-sys", @@ -404,9 +398,9 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.28" +version = "1.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" +checksum = "5f54427cfd1c7829e2a139fcefea601bf088ebca651d2bf53ebc600eac295dae" dependencies = [ "crc32fast", "miniz_oxide", @@ -439,9 +433,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.12" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "libc", @@ -450,9 +444,9 @@ dependencies = [ [[package]] name = "half" -version = "2.4.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5eceaaeec696539ddaf7b333340f1af35a5aa87ae3e4f3ead0532f72affab2e" +checksum = "6dd08c532ae367adf81c312a4580bc67f1d0fe8bc9c460520283f4c0ff277888" dependencies = [ "cfg-if", "crunchy", @@ -461,9 +455,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.3" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" dependencies = [ "ahash", ] @@ -476,47 +470,75 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "ic-cdk" -version = "0.12.1" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f3d204af0b11c45715169c997858edb58fa8407d08f4fae78a6b415dd39a362" +checksum = "f8859bc2b863a77750acf199e1fb7e3fc403e1b475855ba13f59cb4e4036d238" dependencies = [ "candid", - "ic-cdk-macros", - "ic0", + "ic-cdk-macros 0.13.2", + "ic0 0.21.1", + "serde", + "serde_bytes", +] + +[[package]] +name = "ic-cdk" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff384f182459bec490a7f50a58bbdf8f7a6934de4dcc259e30c70641bcbcb917" +dependencies = [ + "candid", + "ic-cdk-macros 0.14.0", + "ic0 0.23.0", "serde", "serde_bytes", ] [[package]] name = "ic-cdk-macros" -version = "0.8.4" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5a618e4020cea88e933d8d2f8c7f86d570ec06213506a80d4f2c520a9bba512" +checksum = "a45800053d80a6df839a71aaea5797e723188c0b992618208ca3b941350c7355" dependencies = [ "candid", "proc-macro2", "quote", "serde", - "serde_tokenstream", + "serde_tokenstream 0.1.7", "syn 1.0.109", ] +[[package]] +name = "ic-cdk-macros" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01dc6bc425ec048d6ac4137c7c0f2cfbd6f8b0be8efc568feae2b265f566117c" +dependencies = [ + "candid", + "proc-macro2", + "quote", + "serde", + "serde_tokenstream 0.2.1", + "syn 2.0.66", +] + [[package]] name = "ic-stable-structures" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07e2282054c8ddf0cb2a7abf5c174c373917b4345c9a096ae4aa7f7185cdcdc7" +checksum = "03f3044466a69802de74e710dc0300b706a05696a0531c942ca856751a13b0db" dependencies = [ "ic_principal", ] [[package]] name = "ic-wasi-polyfill" -version = "0.3.17" -source = "git+https://github.com/wasm-forge/ic-wasi-polyfill#870e2cd0b533c03a45dbd3a516176a1fe261cea6" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1617b3be6bc1a4c854fbd86dc97dea3ff4461f70b5c4e95cf895dbc089dac51b" dependencies = [ "function_name", - "ic-cdk", + "ic-cdk 0.13.2", "ic-stable-structures", "rand", "stable-fs", @@ -528,6 +550,12 @@ version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a54b5297861c651551676e8c43df805dad175cc33bc97dbd992edbbb85dcbcdf" +[[package]] +name = "ic0" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8de254dd67bbd58073e23dc1c8553ba12fa1dc610a19de94ad2bbcd0460c067f" + [[package]] name = "ic_principal" version = "0.1.1" @@ -543,13 +571,12 @@ dependencies = [ [[package]] name = "image" -version = "0.24.9" +version = "0.25.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5690139d2f55868e080017335e4b94cb7414274c74f1669c84fb5feba2c9f69d" +checksum = "fd54d660e773627692c524beaad361aca785a4f9f5730ce91f42aabe5bce3d11" dependencies = [ "bytemuck", "byteorder", - "color_quant", "num-traits", "png", ] @@ -574,9 +601,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "kstring" @@ -602,9 +629,9 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.153" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "libm" @@ -614,15 +641,15 @@ checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" [[package]] name = "linux-raw-sys" -version = "0.4.13" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" [[package]] name = "liquid" -version = "0.26.4" +version = "0.26.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69f68ae1011499ae2ef879f631891f21c78e309755f4a5e483c4a8f12e10b609" +checksum = "10929f201279ba14da3297b957dcda1e0bf7a6f3bb5115688be684aa8864e9cc" dependencies = [ "doc-comment", "liquid-core", @@ -633,12 +660,12 @@ dependencies = [ [[package]] name = "liquid-core" -version = "0.26.4" +version = "0.26.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79e0724dfcaad5cfb7965ea0f178ca0870b8d7315178f4a7179f5696f7f04d5f" +checksum = "3aef4b2160791f456eb880c990a97746f693746f92302ef5f1d06111cf14b768" dependencies = [ "anymap2", - "itertools 0.10.5", + "itertools 0.12.1", "kstring", "liquid-derive", "num-traits", @@ -651,22 +678,22 @@ dependencies = [ [[package]] name = "liquid-derive" -version = "0.26.4" +version = "0.26.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc2fb41a9bb4257a3803154bdf7e2df7d45197d1941c9b1a90ad815231630721" +checksum = "915f6d0a2963a27cd5205c1902f32ddfe3bc035816afd268cf88c0fc0f8d287e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.66", ] [[package]] name = "liquid-lib" -version = "0.26.4" +version = "0.26.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2a17e273a6fb1fb6268f7a5867ddfd0bd4683c7e19b51084f3d567fad4348c0" +checksum = "73f48fc446873f74d869582f5c4b8cbf3248c93395e410a67af5809b3731e44a" dependencies = [ - "itertools 0.10.5", + "itertools 0.12.1", "liquid-core", "once_cell", "percent-encoding", @@ -699,9 +726,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.7.1" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "memmap2" @@ -720,9 +747,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.7.2" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" +checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" dependencies = [ "adler", "simd-adler32", @@ -753,11 +780,10 @@ dependencies = [ [[package]] name = "num-bigint" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" +checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" dependencies = [ - "autocfg", "num-integer", "num-traits", "serde", @@ -765,9 +791,9 @@ dependencies = [ [[package]] name = "num-complex" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23c6602fda94a57c990fe0df199a035d83576b496aa29f4e634a8ac6004e68a6" +checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" dependencies = [ "num-traits", ] @@ -789,9 +815,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.18" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", "libm", @@ -805,9 +831,9 @@ checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "paste" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] name = "percent-encoding" @@ -817,9 +843,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" -version = "2.7.8" +version = "2.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56f8023d0fb78c8e03784ea1c7f3fa36e68a723138990b8d5a47d916b651e7a8" +checksum = "560131c633294438da9f7c4b08189194b20946c8274c6b9e38881a7874dc8ee8" dependencies = [ "memchr", "thiserror", @@ -828,9 +854,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.7.8" +version = "2.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0d24f72393fd16ab6ac5738bc33cdb6a9aa73f8b902e8fe29cf4e67d7dd1026" +checksum = "26293c9193fbca7b1a3bf9b79dc1e388e927e6cacaa78b4a3ab705a1d3d41459" dependencies = [ "pest", "pest_generator", @@ -838,22 +864,22 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.8" +version = "2.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdc17e2a6c7d0a492f0158d7a4bd66cc17280308bbaff78d5bef566dca35ab80" +checksum = "3ec22af7d3fb470a85dd2ca96b7c577a1eb4ef6f1683a9fe9a8c16e136c04687" dependencies = [ "pest", "pest_meta", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.66", ] [[package]] name = "pest_meta" -version = "2.7.8" +version = "2.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "934cd7631c050f4674352a6e835d5f6711ffbfb9345c2fc0107155ac495ae293" +checksum = "d7a240022f37c361ec1878d646fc5b7d7c4d28d5946e1a80ad5a7a4f4ca0bdcd" dependencies = [ "once_cell", "pest", @@ -890,7 +916,7 @@ dependencies = [ "phf_shared", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.66", ] [[package]] @@ -940,18 +966,18 @@ dependencies = [ [[package]] name = "primal-check" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9df7f93fd637f083201473dab4fee2db4c429d32e55e3299980ab3957ab916a0" +checksum = "dc0d895b311e3af9902528fbb8f928688abbd95872819320517cc24ca6b2bd08" dependencies = [ "num-integer", ] [[package]] name = "proc-macro2" -version = "1.0.79" +version = "1.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" +checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" dependencies = [ "unicode-ident", ] @@ -999,9 +1025,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.35" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] @@ -1083,9 +1109,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.3" +version = "1.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" +checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" dependencies = [ "aho-corasick", "memchr", @@ -1095,9 +1121,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" dependencies = [ "aho-corasick", "memchr", @@ -1106,9 +1132,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.2" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" [[package]] name = "rustfft" @@ -1127,11 +1153,11 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.31" +version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "errno", "libc", "linux-raw-sys", @@ -1140,9 +1166,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.14" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" +checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" [[package]] name = "same-file" @@ -1164,9 +1190,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.197" +version = "1.0.203" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" +checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" dependencies = [ "serde_derive", ] @@ -1182,13 +1208,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.197" +version = "1.0.203" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" +checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.66", ] [[package]] @@ -1202,6 +1228,18 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "serde_tokenstream" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8790a7c3fe883e443eaa2af6f705952bc5d6e8671a220b9335c8cae92c037e74" +dependencies = [ + "proc-macro2", + "quote", + "serde", + "syn 2.0.66", +] + [[package]] name = "sha2" version = "0.10.8" @@ -1227,19 +1265,19 @@ checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" [[package]] name = "smallvec" -version = "1.13.1" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "stable-fs" -version = "0.2.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3bdb2e5bc9999a09abebe8e104c50db06184d4cb87249ea5d796ab7c9af669e" +checksum = "fefe75766646a3c7de5ec64e646d775cb2f59e736bb703e44a5fd0cfc6e87bc7" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "ciborium", - "ic-cdk", + "ic-cdk 0.13.2", "ic-stable-structures", "serde", "serde_bytes", @@ -1294,9 +1332,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.52" +version = "2.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" +checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" dependencies = [ "proc-macro2", "quote", @@ -1305,9 +1343,9 @@ dependencies = [ [[package]] name = "tar" -version = "0.4.40" +version = "0.4.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b16afcea1f22891c49a00c751c7b63b2233284064f11a200fc624137c51e2ddb" +checksum = "cb797dad5fb5b76fcf519e702f4a589483b5ef06567f160c392832c1f5e44909" dependencies = [ "filetime", "libc", @@ -1316,29 +1354,29 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.58" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" +checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.58" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" +checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.66", ] [[package]] name = "time" -version = "0.3.34" +version = "0.3.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8248b6521bb14bc45b4067159b9b6ad792e2d6d754d6c41fb50e29fefe38749" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ "deranged", "itoa", @@ -1357,9 +1395,9 @@ checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.17" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ba3a3ef41e6672a2f0f001392bb5dcd3ff0a9992d618ca761a11c3121547774" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" dependencies = [ "num-conv", "time-core", @@ -1556,9 +1594,9 @@ checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" [[package]] name = "unicode-width" -version = "0.1.11" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" +checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" [[package]] name = "version_check" @@ -1600,11 +1638,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.6" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" +checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" dependencies = [ - "winapi", + "windows-sys", ] [[package]] @@ -1624,13 +1662,14 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", "windows_i686_gnu", + "windows_i686_gnullvm", "windows_i686_msvc", "windows_x86_64_gnu", "windows_x86_64_gnullvm", @@ -1639,45 +1678,51 @@ dependencies = [ [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" [[package]] name = "windows_aarch64_msvc" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" [[package]] name = "windows_i686_gnu" -version = "0.52.4" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" [[package]] name = "windows_i686_msvc" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" [[package]] name = "windows_x86_64_gnu" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" [[package]] name = "windows_x86_64_msvc" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" [[package]] name = "xattr" @@ -1692,20 +1737,20 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.7.32" +version = "0.7.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" +checksum = "ae87e3fcd617500e5d106f0380cf7b77f3c6092aae37191433159dda23cfb087" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.32" +version = "0.7.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" +checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.66", ] diff --git a/rust/image-classification/Makefile b/rust/image-classification/Makefile new file mode 100644 index 000000000..d95355123 --- /dev/null +++ b/rust/image-classification/Makefile @@ -0,0 +1,38 @@ +.PHONY: all +all: build + +.PHONY: download_model +.SILENT: download_model +download_model: + bash ./download_model.sh + +.PHONY: node_modules +.SILENT: node_modules +node_modules: + npm install + +.PHONY: build +.SILENT: build +build: node_modules download_model + dfx canister create --all + dfx build + +.PHONY: install +.SILENT: install +install: build + dfx deploy --yes + +.PHONY: upgrade +.SILENT: upgrade +upgrade: build + dfx canister install --all --mode=upgrade + +.PHONY: test +.SILENT: test +test: install + dfx canister call backend run | grep -w 'tractor' && echo 'PASS' + +.PHONY: clean +.SILENT: clean +clean: + rm -fr .dfx diff --git a/rust/image-classification/build.sh b/rust/image-classification/build.sh old mode 100644 new mode 100755 index e685f813a..adb25ebfa --- a/rust/image-classification/build.sh +++ b/rust/image-classification/build.sh @@ -1,5 +1,8 @@ #!/bin/bash +set -ex + export RUSTFLAGS=$RUSTFLAGS' -C target-feature=+simd128' cargo build --release --target=wasm32-wasi wasi2ic ./target/wasm32-wasi/release/backend.wasm ./target/wasm32-wasi/release/backend-ic.wasm -wasm-opt -Os -o ./target/wasm32-wasi/release/backend-ic.wasm ./target/wasm32-wasi/release/backend-ic.wasm +wasm-opt -Os -o ./target/wasm32-wasi/release/backend-ic.wasm \ + ./target/wasm32-wasi/release/backend-ic.wasm diff --git a/rust/image-classification/dfx.json b/rust/image-classification/dfx.json index 4dcae4122..e5ee40ef0 100644 --- a/rust/image-classification/dfx.json +++ b/rust/image-classification/dfx.json @@ -1,6 +1,11 @@ { "canisters": { "backend": { + "metadata": [ + { + "name": "candid:service" + } + ], "candid": "src/backend/backend.did", "package": "backend", "type": "custom", @@ -29,4 +34,4 @@ }, "output_env_file": ".env", "version": 1 -} +} \ No newline at end of file diff --git a/rust/image-classification/download_model.sh b/rust/image-classification/download_model.sh index d72cb0f12..2c9d32ccb 100755 --- a/rust/image-classification/download_model.sh +++ b/rust/image-classification/download_model.sh @@ -1,11 +1,20 @@ #!/bin/bash +set -ex + URL="https://github.com/onnx/models/raw/main/validated/vision/classification/mobilenet/model/mobilenetv2-7.onnx?download=:" TGT="src/backend/assets/mobilenetv2-7.onnx" -if which wget >/dev/null ; then - wget $URL -O $TGT -elif which curl >/dev/null ; then - curl -vL $URL -o $TGT + +echo "Downloading ${TGT}..." +if [ -s "${TGT}" ]; then + echo " (cached)" + exit 0 +fi + +if which wget >/dev/null; then + wget $URL -O $TGT +elif which curl >/dev/null; then + curl -vL $URL -o $TGT else - echo "Couldn't find wget or curl." - echo "Please download manually from \"$URL\" and save the file in $TGT." + echo "Couldn't find wget or curl." + echo "Please download manually from \"$URL\" and save the file in $TGT." fi diff --git a/rust/image-classification/rust-toolchain.toml b/rust/image-classification/rust-toolchain.toml index 3fbeaec6f..0ecadb670 100644 --- a/rust/image-classification/rust-toolchain.toml +++ b/rust/image-classification/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] -channel = "1.75" -targets = ["wasm32-unknown-unknown"] +channel = "1.79" +targets = ["wasm32-unknown-unknown", "wasm32-wasi"] components = ["rustfmt", "clippy"] diff --git a/rust/image-classification/src/backend/Cargo.toml b/rust/image-classification/src/backend/Cargo.toml index 03a44b316..e9aae8482 100644 --- a/rust/image-classification/src/backend/Cargo.toml +++ b/rust/image-classification/src/backend/Cargo.toml @@ -8,14 +8,14 @@ crate-type = ["cdylib"] [dependencies] anyhow = "1.0" +bytes = "1.5.0" candid = "0.10" colorgrad = "0.6" -ic-cdk = "0.12" -bytes = "1.5.0" +ic-cdk = "0.14.0" +ic-stable-structures = "0.6" +ic-wasi-polyfill = "0.4.1" +image = { version = "0.25.1", features = ["png"], default-features = false } prost = "0.11.0" prost-types = "0.11.0" -image = { version = "0.24", features = ["png"], default-features = false } serde = { version = "1.0", features = ["derive"] } tract-onnx = { git = "https://github.com/sonos/tract", rev = "2a2914ac29390cc08963301c9f3d437b52dd321a" } -ic-stable-structures = "0.6" -ic-wasi-polyfill = { git = "https://github.com/wasm-forge/ic-wasi-polyfill", version = "0.3.17" } diff --git a/rust/image-classification/src/backend/assets/man_on_ferrari_1975.png b/rust/image-classification/src/backend/assets/man_on_ferrari_1975.png new file mode 100644 index 000000000..a533bffc8 Binary files /dev/null and b/rust/image-classification/src/backend/assets/man_on_ferrari_1975.png differ diff --git a/rust/image-classification/src/backend/backend.did b/rust/image-classification/src/backend/backend.did index 6fa4eda83..c9c4b2949 100644 --- a/rust/image-classification/src/backend/backend.did +++ b/rust/image-classification/src/backend/backend.did @@ -15,4 +15,5 @@ type ClassificationResult = variant { service : { "classify": (image: blob) -> (ClassificationResult); "classify_query": (image: blob) -> (ClassificationResult) query; + "run": () -> (ClassificationResult) query; } diff --git a/rust/image-classification/src/backend/src/lib.rs b/rust/image-classification/src/backend/src/lib.rs index 9f5d8e8ea..73f52fed3 100644 --- a/rust/image-classification/src/backend/src/lib.rs +++ b/rust/image-classification/src/backend/src/lib.rs @@ -69,3 +69,25 @@ fn post_upgrade() { ic_wasi_polyfill::init_with_memory(&[0u8; 32], &[], wasi_memory); onnx::setup().unwrap(); } + +const IMAGE: &'static [u8] = include_bytes!("../assets/man_on_ferrari_1975.png"); + +/// Formats thousands for the specified `u64` integer (helper function). +fn fmt(n: u64) -> String { + n.to_string() + .as_bytes() + .rchunks(3) + .rev() + .map(std::str::from_utf8) + .collect::, _>>() + .unwrap() + .join("_") +} + +#[ic_cdk::query] +fn run() -> ClassificationResult { + let result = classify(IMAGE.into()); + let instructions = ic_cdk::api::performance_counter(0); + ic_cdk::println!("Executed instructions: {}", fmt(instructions)); + result +} diff --git a/rust/image-classification/src/backend/src/onnx.rs b/rust/image-classification/src/backend/src/onnx.rs index 8fb5c275c..ee182cda6 100644 --- a/rust/image-classification/src/backend/src/onnx.rs +++ b/rust/image-classification/src/backend/src/onnx.rs @@ -1,10 +1,8 @@ -use std::cell::RefCell; - +use crate::Classification; use prost::Message; +use std::cell::RefCell; use tract_onnx::prelude::*; -use crate::Classification; - type Model = SimplePlan, Graph>>; thread_local! { diff --git a/rust/image-classification/src/declarations/backend/backend.did b/rust/image-classification/src/declarations/backend/backend.did index 6fa4eda83..c9c4b2949 100644 --- a/rust/image-classification/src/declarations/backend/backend.did +++ b/rust/image-classification/src/declarations/backend/backend.did @@ -15,4 +15,5 @@ type ClassificationResult = variant { service : { "classify": (image: blob) -> (ClassificationResult); "classify_query": (image: blob) -> (ClassificationResult) query; + "run": () -> (ClassificationResult) query; } diff --git a/rust/image-classification/src/declarations/backend/backend.did.d.ts b/rust/image-classification/src/declarations/backend/backend.did.d.ts index 418d8e98b..586f72b78 100644 --- a/rust/image-classification/src/declarations/backend/backend.did.d.ts +++ b/rust/image-classification/src/declarations/backend/backend.did.d.ts @@ -9,6 +9,7 @@ export type ClassificationResult = { 'Ok' : Array } | export interface _SERVICE { 'classify' : ActorMethod<[Uint8Array | number[]], ClassificationResult>, 'classify_query' : ActorMethod<[Uint8Array | number[]], ClassificationResult>, + 'run' : ActorMethod<[], ClassificationResult>, } export declare const idlFactory: IDL.InterfaceFactory; export declare const init: (args: { IDL: typeof IDL }) => IDL.Type[]; diff --git a/rust/image-classification/src/declarations/backend/backend.did.js b/rust/image-classification/src/declarations/backend/backend.did.js index d6ab35a3a..5d8252d85 100644 --- a/rust/image-classification/src/declarations/backend/backend.did.js +++ b/rust/image-classification/src/declarations/backend/backend.did.js @@ -15,6 +15,7 @@ export const idlFactory = ({ IDL }) => { [ClassificationResult], ['query'], ), + 'run' : IDL.Func([], [ClassificationResult], ['query']), }); }; export const init = ({ IDL }) => { return []; };