mirror of
https://github.com/huggingface/candle.git
synced 2025-06-17 11:08:52 +00:00
[segment-anything] add multi point logic for demo site (#1002)
* [segment-anything] add multi point logic for demo site * [segment-anything] remove libs and update functions
This commit is contained in:
@ -33,6 +33,7 @@
|
||||
url: "sam_vit_b_01ec64.safetensors",
|
||||
},
|
||||
};
|
||||
let pointArr = []
|
||||
const samWorker = new Worker("./samWorker.js", { type: "module" });
|
||||
|
||||
async function segmentPoints(
|
||||
@ -145,6 +146,7 @@
|
||||
//add event listener to clear button
|
||||
clearBtn.addEventListener("click", () => {
|
||||
cleanImageCanvas();
|
||||
pointArr = []
|
||||
});
|
||||
//add click event to canvas
|
||||
canvas.addEventListener("click", async (event) => {
|
||||
@ -155,7 +157,8 @@
|
||||
const x = (event.clientX - targetBox.left) / targetBox.width;
|
||||
const y = (event.clientY - targetBox.top) / targetBox.height;
|
||||
isSegmenting = true;
|
||||
const { maskURL } = await getSegmentationMask({ x, y });
|
||||
pointArr = [...pointArr, [ x, y , true ]]
|
||||
const { maskURL } = await getSegmentationMask(pointArr);
|
||||
isSegmenting = false;
|
||||
drawMask(maskURL);
|
||||
});
|
||||
|
Reference in New Issue
Block a user