-
Notifications
You must be signed in to change notification settings - Fork 7
Added EfficientSAM Wasm demo #49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
b86b666
to
f19b81b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thank you!
efficient_sam/wasm/CMakeLists.txt
Outdated
add_executable(executorch_wasm_demo_lib) | ||
target_link_libraries(executorch_wasm_demo_lib PRIVATE executorch_wasm executorch_backends) | ||
target_link_options(executorch_wasm_demo_lib PRIVATE -sALLOW_MEMORY_GROWTH | ||
-sSTACK_SIZE=262144) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
noob q: why 262144?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Default was 65536, but it runs out of memory. Doubling it to 131072 still isn't enough, but 262144 ended up being enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess XNNPACK is next?
console.log("Running model..."); | ||
const output = module.forward([imageTensor, pointTensor, labelTensor]); | ||
const endTime = performance.now(); | ||
console.log(((endTime - startTime)/1000).toFixed(2) + "s"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this compare to w/o wasm on the same machine?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With optimized kernels and XNNPACK
6.51 seconds with Wasm
1.95 seconds without Wasm on executor_runner
|
||
CMAKE_OUT=build | ||
|
||
emcmake cmake . -DEXECUTORCH_BUILD_WASM=ON \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No XNNPACK yet?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Requires pytorch/executorch#13234
Looks like that's been merged so I can add that in now
) | ||
|
||
prog = export(model, example_inputs) | ||
edge = to_edge_transform_and_lower(prog, partitioner=[XnnpackPartitioner()]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, LGTM!
Summary
Added instructions on how to build a demo webpage that takes allows users to upload a copy of efficient_sam.pte along with an image to select a point and segment the image.
Test plan
Following the steps in the README.md:
Then, go to http://localhost:8000/demo.html and upload efficient_sam.pte and an image to segment different parts of the image.