new
Browse files- build/m.d.ts +3 -3
- build/m.js +44 -16
- build/m_bg.wasm +2 -2
- build/m_bg.wasm.d.ts +1 -1
- samWorker.js +1 -2
build/m.d.ts
CHANGED
@@ -16,9 +16,9 @@ export class Model {
|
|
16 |
/**
|
17 |
* @param {number} x
|
18 |
* @param {number} y
|
19 |
-
* @returns {
|
20 |
*/
|
21 |
-
mask_for_point(x: number, y: number):
|
22 |
}
|
23 |
|
24 |
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
@@ -32,8 +32,8 @@ export interface InitOutput {
|
|
32 |
readonly main: (a: number, b: number) => number;
|
33 |
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
34 |
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
35 |
-
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
36 |
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
|
37 |
readonly __wbindgen_start: () => void;
|
38 |
}
|
39 |
|
|
|
16 |
/**
|
17 |
* @param {number} x
|
18 |
* @param {number} y
|
19 |
+
* @returns {any}
|
20 |
*/
|
21 |
+
mask_for_point(x: number, y: number): any;
|
22 |
}
|
23 |
|
24 |
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
|
32 |
readonly main: (a: number, b: number) => number;
|
33 |
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
34 |
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
|
35 |
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
36 |
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
37 |
readonly __wbindgen_start: () => void;
|
38 |
}
|
39 |
|
build/m.js
CHANGED
@@ -182,30 +182,21 @@ export class Model {
|
|
182 |
/**
|
183 |
* @param {number} x
|
184 |
* @param {number} y
|
185 |
-
* @returns {
|
186 |
*/
|
187 |
mask_for_point(x, y) {
|
188 |
-
let deferred2_0;
|
189 |
-
let deferred2_1;
|
190 |
try {
|
191 |
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
192 |
wasm.model_mask_for_point(retptr, this.__wbg_ptr, x, y);
|
193 |
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
194 |
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
195 |
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
196 |
-
|
197 |
-
|
198 |
-
var len1 = r1;
|
199 |
-
if (r3) {
|
200 |
-
ptr1 = 0; len1 = 0;
|
201 |
-
throw takeObject(r2);
|
202 |
}
|
203 |
-
|
204 |
-
deferred2_1 = len1;
|
205 |
-
return getStringFromWasm0(ptr1, len1);
|
206 |
} finally {
|
207 |
wasm.__wbindgen_add_to_stack_pointer(16);
|
208 |
-
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
209 |
}
|
210 |
}
|
211 |
}
|
@@ -248,6 +239,35 @@ function __wbg_get_imports() {
|
|
248 |
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
249 |
return addHeapObject(ret);
|
250 |
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
251 |
imports.wbg.__wbg_new_abda76e883ba8a5f = function() {
|
252 |
const ret = new Error();
|
253 |
return addHeapObject(ret);
|
@@ -270,12 +290,20 @@ function __wbg_get_imports() {
|
|
270 |
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
271 |
}
|
272 |
};
|
273 |
-
imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
|
274 |
-
takeObject(arg0);
|
275 |
-
};
|
276 |
imports.wbg.__wbg_log_fa2e12d24033131f = function(arg0, arg1) {
|
277 |
console.log(getStringFromWasm0(arg0, arg1));
|
278 |
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
279 |
imports.wbg.__wbindgen_throw = function(arg0, arg1) {
|
280 |
throw new Error(getStringFromWasm0(arg0, arg1));
|
281 |
};
|
|
|
182 |
/**
|
183 |
* @param {number} x
|
184 |
* @param {number} y
|
185 |
+
* @returns {any}
|
186 |
*/
|
187 |
mask_for_point(x, y) {
|
|
|
|
|
188 |
try {
|
189 |
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
190 |
wasm.model_mask_for_point(retptr, this.__wbg_ptr, x, y);
|
191 |
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
192 |
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
193 |
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
194 |
+
if (r2) {
|
195 |
+
throw takeObject(r1);
|
|
|
|
|
|
|
|
|
196 |
}
|
197 |
+
return takeObject(r0);
|
|
|
|
|
198 |
} finally {
|
199 |
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
|
200 |
}
|
201 |
}
|
202 |
}
|
|
|
239 |
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
240 |
return addHeapObject(ret);
|
241 |
};
|
242 |
+
imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
|
243 |
+
takeObject(arg0);
|
244 |
+
};
|
245 |
+
imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
|
246 |
+
const ret = getObject(arg0);
|
247 |
+
return addHeapObject(ret);
|
248 |
+
};
|
249 |
+
imports.wbg.__wbg_String_4370c5505c674d30 = function(arg0, arg1) {
|
250 |
+
const ret = String(getObject(arg1));
|
251 |
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
252 |
+
const len1 = WASM_VECTOR_LEN;
|
253 |
+
getInt32Memory0()[arg0 / 4 + 1] = len1;
|
254 |
+
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
|
255 |
+
};
|
256 |
+
imports.wbg.__wbindgen_number_new = function(arg0) {
|
257 |
+
const ret = arg0;
|
258 |
+
return addHeapObject(ret);
|
259 |
+
};
|
260 |
+
imports.wbg.__wbindgen_bigint_from_u64 = function(arg0) {
|
261 |
+
const ret = BigInt.asUintN(64, arg0);
|
262 |
+
return addHeapObject(ret);
|
263 |
+
};
|
264 |
+
imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
|
265 |
+
const ret = getStringFromWasm0(arg0, arg1);
|
266 |
+
return addHeapObject(ret);
|
267 |
+
};
|
268 |
+
imports.wbg.__wbg_set_bd72c078edfa51ad = function(arg0, arg1, arg2) {
|
269 |
+
getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
|
270 |
+
};
|
271 |
imports.wbg.__wbg_new_abda76e883ba8a5f = function() {
|
272 |
const ret = new Error();
|
273 |
return addHeapObject(ret);
|
|
|
290 |
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
291 |
}
|
292 |
};
|
|
|
|
|
|
|
293 |
imports.wbg.__wbg_log_fa2e12d24033131f = function(arg0, arg1) {
|
294 |
console.log(getStringFromWasm0(arg0, arg1));
|
295 |
};
|
296 |
+
imports.wbg.__wbg_new_898a68150f225f2e = function() {
|
297 |
+
const ret = new Array();
|
298 |
+
return addHeapObject(ret);
|
299 |
+
};
|
300 |
+
imports.wbg.__wbg_new_b51585de1b234aff = function() {
|
301 |
+
const ret = new Object();
|
302 |
+
return addHeapObject(ret);
|
303 |
+
};
|
304 |
+
imports.wbg.__wbg_set_502d29070ea18557 = function(arg0, arg1, arg2) {
|
305 |
+
getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
|
306 |
+
};
|
307 |
imports.wbg.__wbindgen_throw = function(arg0, arg1) {
|
308 |
throw new Error(getStringFromWasm0(arg0, arg1));
|
309 |
};
|
build/m_bg.wasm
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:acfbd107ec1c84a9ed5388cd1afd0e494bb99426d5e162e1d017c28cca325553
|
3 |
+
size 2579585
|
build/m_bg.wasm.d.ts
CHANGED
@@ -8,6 +8,6 @@ export function model_mask_for_point(a: number, b: number, c: number, d: number)
|
|
8 |
export function main(a: number, b: number): number;
|
9 |
export function __wbindgen_add_to_stack_pointer(a: number): number;
|
10 |
export function __wbindgen_malloc(a: number, b: number): number;
|
11 |
-
export function __wbindgen_free(a: number, b: number, c: number): void;
|
12 |
export function __wbindgen_realloc(a: number, b: number, c: number, d: number): number;
|
|
|
13 |
export function __wbindgen_start(): void;
|
|
|
8 |
export function main(a: number, b: number): number;
|
9 |
export function __wbindgen_add_to_stack_pointer(a: number): number;
|
10 |
export function __wbindgen_malloc(a: number, b: number): number;
|
|
|
11 |
export function __wbindgen_realloc(a: number, b: number, c: number, d: number): number;
|
12 |
+
export function __wbindgen_free(a: number, b: number, c: number): void;
|
13 |
export function __wbindgen_start(): void;
|
samWorker.js
CHANGED
@@ -141,8 +141,7 @@ self.addEventListener("message", async (event) => {
|
|
141 |
}
|
142 |
|
143 |
self.postMessage({ status: "segmenting", message: "Segmenting" });
|
144 |
-
const
|
145 |
-
const { mask, image } = JSON.parse(result);
|
146 |
const maskDataURL = await createImageCanvas(mask, image);
|
147 |
// Send the segment back to the main thread as JSON
|
148 |
self.postMessage({
|
|
|
141 |
}
|
142 |
|
143 |
self.postMessage({ status: "segmenting", message: "Segmenting" });
|
144 |
+
const { mask, image } = sam.mask_for_point(points.x, points.y);
|
|
|
145 |
const maskDataURL = await createImageCanvas(mask, image);
|
146 |
// Send the segment back to the main thread as JSON
|
147 |
self.postMessage({
|