Spaces:
Running
Running
laurent
commited on
Commit
•
4f3c44a
1
Parent(s):
b09d8b2
Add a build directory with the lib version.
Browse files- build/index.html +23 -0
- build/m.d.ts +52 -0
- build/m.js +361 -0
- build/m_bg.js +310 -0
- build/m_bg.wasm +3 -0
- build/m_bg.wasm.d.ts +12 -0
build/index.html
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<html>
|
2 |
+
<head>
|
3 |
+
<meta content="text/html;charset=utf-8" http-equiv="Content-Type"/>
|
4 |
+
</head>
|
5 |
+
<body>
|
6 |
+
<script type="module">
|
7 |
+
import init, { Model } from './m.js';
|
8 |
+
|
9 |
+
await init();
|
10 |
+
|
11 |
+
const yolo_response = await fetch('../yolo.safetensors');
|
12 |
+
const yolo_data = await yolo_response.arrayBuffer();
|
13 |
+
const model_weights = new Uint8Array(yolo_data);
|
14 |
+
let m = new Model(model_weights);
|
15 |
+
|
16 |
+
const img_response = await fetch('../bike.jpeg');
|
17 |
+
const img_data = await img_response.arrayBuffer();
|
18 |
+
let image_data = new Uint8Array(img_data);
|
19 |
+
let bboxes = m.run(image_data);
|
20 |
+
console.log(bboxes);
|
21 |
+
</script>
|
22 |
+
</body>
|
23 |
+
</html>
|
build/m.d.ts
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/* tslint:disable */
|
2 |
+
/* eslint-disable */
|
3 |
+
/**
|
4 |
+
*/
|
5 |
+
export class Model {
|
6 |
+
free(): void;
|
7 |
+
/**
|
8 |
+
* @param {Uint8Array} data
|
9 |
+
*/
|
10 |
+
constructor(data: Uint8Array);
|
11 |
+
/**
|
12 |
+
* @param {Uint8Array} image
|
13 |
+
* @returns {string}
|
14 |
+
*/
|
15 |
+
run(image: Uint8Array): string;
|
16 |
+
}
|
17 |
+
|
18 |
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
19 |
+
|
20 |
+
export interface InitOutput {
|
21 |
+
readonly memory: WebAssembly.Memory;
|
22 |
+
readonly __wbg_model_free: (a: number) => void;
|
23 |
+
readonly model_new: (a: number, b: number, c: number) => void;
|
24 |
+
readonly model_run: (a: number, b: number, c: number, d: number) => void;
|
25 |
+
readonly main: (a: number, b: number) => number;
|
26 |
+
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
27 |
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
28 |
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
29 |
+
readonly __wbindgen_exn_store: (a: number) => void;
|
30 |
+
readonly __wbindgen_start: () => void;
|
31 |
+
}
|
32 |
+
|
33 |
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
34 |
+
/**
|
35 |
+
* Instantiates the given `module`, which can either be bytes or
|
36 |
+
* a precompiled `WebAssembly.Module`.
|
37 |
+
*
|
38 |
+
* @param {SyncInitInput} module
|
39 |
+
*
|
40 |
+
* @returns {InitOutput}
|
41 |
+
*/
|
42 |
+
export function initSync(module: SyncInitInput): InitOutput;
|
43 |
+
|
44 |
+
/**
|
45 |
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
46 |
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
47 |
+
*
|
48 |
+
* @param {InitInput | Promise<InitInput>} module_or_path
|
49 |
+
*
|
50 |
+
* @returns {Promise<InitOutput>}
|
51 |
+
*/
|
52 |
+
export default function __wbg_init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
let wasm;
|
2 |
+
|
3 |
+
const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
|
4 |
+
|
5 |
+
if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
|
6 |
+
|
7 |
+
let cachedUint8Memory0 = null;
|
8 |
+
|
9 |
+
function getUint8Memory0() {
|
10 |
+
if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
|
11 |
+
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
12 |
+
}
|
13 |
+
return cachedUint8Memory0;
|
14 |
+
}
|
15 |
+
|
16 |
+
function getStringFromWasm0(ptr, len) {
|
17 |
+
ptr = ptr >>> 0;
|
18 |
+
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
19 |
+
}
|
20 |
+
|
21 |
+
const heap = new Array(128).fill(undefined);
|
22 |
+
|
23 |
+
heap.push(undefined, null, true, false);
|
24 |
+
|
25 |
+
let heap_next = heap.length;
|
26 |
+
|
27 |
+
function addHeapObject(obj) {
|
28 |
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
29 |
+
const idx = heap_next;
|
30 |
+
heap_next = heap[idx];
|
31 |
+
|
32 |
+
heap[idx] = obj;
|
33 |
+
return idx;
|
34 |
+
}
|
35 |
+
|
36 |
+
function getObject(idx) { return heap[idx]; }
|
37 |
+
|
38 |
+
function dropObject(idx) {
|
39 |
+
if (idx < 132) return;
|
40 |
+
heap[idx] = heap_next;
|
41 |
+
heap_next = idx;
|
42 |
+
}
|
43 |
+
|
44 |
+
function takeObject(idx) {
|
45 |
+
const ret = getObject(idx);
|
46 |
+
dropObject(idx);
|
47 |
+
return ret;
|
48 |
+
}
|
49 |
+
|
50 |
+
let WASM_VECTOR_LEN = 0;
|
51 |
+
|
52 |
+
function passArray8ToWasm0(arg, malloc) {
|
53 |
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
54 |
+
getUint8Memory0().set(arg, ptr / 1);
|
55 |
+
WASM_VECTOR_LEN = arg.length;
|
56 |
+
return ptr;
|
57 |
+
}
|
58 |
+
|
59 |
+
let cachedInt32Memory0 = null;
|
60 |
+
|
61 |
+
function getInt32Memory0() {
|
62 |
+
if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
|
63 |
+
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
|
64 |
+
}
|
65 |
+
return cachedInt32Memory0;
|
66 |
+
}
|
67 |
+
|
68 |
+
function handleError(f, args) {
|
69 |
+
try {
|
70 |
+
return f.apply(this, args);
|
71 |
+
} catch (e) {
|
72 |
+
wasm.__wbindgen_exn_store(addHeapObject(e));
|
73 |
+
}
|
74 |
+
}
|
75 |
+
/**
|
76 |
+
*/
|
77 |
+
export class Model {
|
78 |
+
|
79 |
+
static __wrap(ptr) {
|
80 |
+
ptr = ptr >>> 0;
|
81 |
+
const obj = Object.create(Model.prototype);
|
82 |
+
obj.__wbg_ptr = ptr;
|
83 |
+
|
84 |
+
return obj;
|
85 |
+
}
|
86 |
+
|
87 |
+
__destroy_into_raw() {
|
88 |
+
const ptr = this.__wbg_ptr;
|
89 |
+
this.__wbg_ptr = 0;
|
90 |
+
|
91 |
+
return ptr;
|
92 |
+
}
|
93 |
+
|
94 |
+
free() {
|
95 |
+
const ptr = this.__destroy_into_raw();
|
96 |
+
wasm.__wbg_model_free(ptr);
|
97 |
+
}
|
98 |
+
/**
|
99 |
+
* @param {Uint8Array} data
|
100 |
+
*/
|
101 |
+
constructor(data) {
|
102 |
+
try {
|
103 |
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
104 |
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
105 |
+
const len0 = WASM_VECTOR_LEN;
|
106 |
+
wasm.model_new(retptr, ptr0, len0);
|
107 |
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
108 |
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
109 |
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
110 |
+
if (r2) {
|
111 |
+
throw takeObject(r1);
|
112 |
+
}
|
113 |
+
return Model.__wrap(r0);
|
114 |
+
} finally {
|
115 |
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
116 |
+
}
|
117 |
+
}
|
118 |
+
/**
|
119 |
+
* @param {Uint8Array} image
|
120 |
+
* @returns {string}
|
121 |
+
*/
|
122 |
+
run(image) {
|
123 |
+
let deferred3_0;
|
124 |
+
let deferred3_1;
|
125 |
+
try {
|
126 |
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
127 |
+
const ptr0 = passArray8ToWasm0(image, wasm.__wbindgen_malloc);
|
128 |
+
const len0 = WASM_VECTOR_LEN;
|
129 |
+
wasm.model_run(retptr, this.__wbg_ptr, ptr0, len0);
|
130 |
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
131 |
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
132 |
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
133 |
+
var r3 = getInt32Memory0()[retptr / 4 + 3];
|
134 |
+
var ptr2 = r0;
|
135 |
+
var len2 = r1;
|
136 |
+
if (r3) {
|
137 |
+
ptr2 = 0; len2 = 0;
|
138 |
+
throw takeObject(r2);
|
139 |
+
}
|
140 |
+
deferred3_0 = ptr2;
|
141 |
+
deferred3_1 = len2;
|
142 |
+
return getStringFromWasm0(ptr2, len2);
|
143 |
+
} finally {
|
144 |
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
145 |
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
146 |
+
}
|
147 |
+
}
|
148 |
+
}
|
149 |
+
|
150 |
+
async function __wbg_load(module, imports) {
|
151 |
+
if (typeof Response === 'function' && module instanceof Response) {
|
152 |
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
153 |
+
try {
|
154 |
+
return await WebAssembly.instantiateStreaming(module, imports);
|
155 |
+
|
156 |
+
} catch (e) {
|
157 |
+
if (module.headers.get('Content-Type') != 'application/wasm') {
|
158 |
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
159 |
+
|
160 |
+
} else {
|
161 |
+
throw e;
|
162 |
+
}
|
163 |
+
}
|
164 |
+
}
|
165 |
+
|
166 |
+
const bytes = await module.arrayBuffer();
|
167 |
+
return await WebAssembly.instantiate(bytes, imports);
|
168 |
+
|
169 |
+
} else {
|
170 |
+
const instance = await WebAssembly.instantiate(module, imports);
|
171 |
+
|
172 |
+
if (instance instanceof WebAssembly.Instance) {
|
173 |
+
return { instance, module };
|
174 |
+
|
175 |
+
} else {
|
176 |
+
return instance;
|
177 |
+
}
|
178 |
+
}
|
179 |
+
}
|
180 |
+
|
181 |
+
function __wbg_get_imports() {
|
182 |
+
const imports = {};
|
183 |
+
imports.wbg = {};
|
184 |
+
imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
|
185 |
+
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
186 |
+
return addHeapObject(ret);
|
187 |
+
};
|
188 |
+
imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
|
189 |
+
takeObject(arg0);
|
190 |
+
};
|
191 |
+
imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
|
192 |
+
const ret = getStringFromWasm0(arg0, arg1);
|
193 |
+
return addHeapObject(ret);
|
194 |
+
};
|
195 |
+
imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
|
196 |
+
const ret = getObject(arg0);
|
197 |
+
return addHeapObject(ret);
|
198 |
+
};
|
199 |
+
imports.wbg.__wbg_log_65d20c5d9fc43b86 = function(arg0, arg1) {
|
200 |
+
console.log(getStringFromWasm0(arg0, arg1));
|
201 |
+
};
|
202 |
+
imports.wbg.__wbg_crypto_c48a774b022d20ac = function(arg0) {
|
203 |
+
const ret = getObject(arg0).crypto;
|
204 |
+
return addHeapObject(ret);
|
205 |
+
};
|
206 |
+
imports.wbg.__wbindgen_is_object = function(arg0) {
|
207 |
+
const val = getObject(arg0);
|
208 |
+
const ret = typeof(val) === 'object' && val !== null;
|
209 |
+
return ret;
|
210 |
+
};
|
211 |
+
imports.wbg.__wbg_process_298734cf255a885d = function(arg0) {
|
212 |
+
const ret = getObject(arg0).process;
|
213 |
+
return addHeapObject(ret);
|
214 |
+
};
|
215 |
+
imports.wbg.__wbg_versions_e2e78e134e3e5d01 = function(arg0) {
|
216 |
+
const ret = getObject(arg0).versions;
|
217 |
+
return addHeapObject(ret);
|
218 |
+
};
|
219 |
+
imports.wbg.__wbg_node_1cd7a5d853dbea79 = function(arg0) {
|
220 |
+
const ret = getObject(arg0).node;
|
221 |
+
return addHeapObject(ret);
|
222 |
+
};
|
223 |
+
imports.wbg.__wbindgen_is_string = function(arg0) {
|
224 |
+
const ret = typeof(getObject(arg0)) === 'string';
|
225 |
+
return ret;
|
226 |
+
};
|
227 |
+
imports.wbg.__wbg_msCrypto_bcb970640f50a1e8 = function(arg0) {
|
228 |
+
const ret = getObject(arg0).msCrypto;
|
229 |
+
return addHeapObject(ret);
|
230 |
+
};
|
231 |
+
imports.wbg.__wbg_require_8f08ceecec0f4fee = function() { return handleError(function () {
|
232 |
+
const ret = module.require;
|
233 |
+
return addHeapObject(ret);
|
234 |
+
}, arguments) };
|
235 |
+
imports.wbg.__wbindgen_is_function = function(arg0) {
|
236 |
+
const ret = typeof(getObject(arg0)) === 'function';
|
237 |
+
return ret;
|
238 |
+
};
|
239 |
+
imports.wbg.__wbg_getRandomValues_37fa2ca9e4e07fab = function() { return handleError(function (arg0, arg1) {
|
240 |
+
getObject(arg0).getRandomValues(getObject(arg1));
|
241 |
+
}, arguments) };
|
242 |
+
imports.wbg.__wbg_randomFillSync_dc1e9a60c158336d = function() { return handleError(function (arg0, arg1) {
|
243 |
+
getObject(arg0).randomFillSync(takeObject(arg1));
|
244 |
+
}, arguments) };
|
245 |
+
imports.wbg.__wbg_newnoargs_581967eacc0e2604 = function(arg0, arg1) {
|
246 |
+
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
247 |
+
return addHeapObject(ret);
|
248 |
+
};
|
249 |
+
imports.wbg.__wbg_call_cb65541d95d71282 = function() { return handleError(function (arg0, arg1) {
|
250 |
+
const ret = getObject(arg0).call(getObject(arg1));
|
251 |
+
return addHeapObject(ret);
|
252 |
+
}, arguments) };
|
253 |
+
imports.wbg.__wbg_self_1ff1d729e9aae938 = function() { return handleError(function () {
|
254 |
+
const ret = self.self;
|
255 |
+
return addHeapObject(ret);
|
256 |
+
}, arguments) };
|
257 |
+
imports.wbg.__wbg_window_5f4faef6c12b79ec = function() { return handleError(function () {
|
258 |
+
const ret = window.window;
|
259 |
+
return addHeapObject(ret);
|
260 |
+
}, arguments) };
|
261 |
+
imports.wbg.__wbg_globalThis_1d39714405582d3c = function() { return handleError(function () {
|
262 |
+
const ret = globalThis.globalThis;
|
263 |
+
return addHeapObject(ret);
|
264 |
+
}, arguments) };
|
265 |
+
imports.wbg.__wbg_global_651f05c6a0944d1c = function() { return handleError(function () {
|
266 |
+
const ret = global.global;
|
267 |
+
return addHeapObject(ret);
|
268 |
+
}, arguments) };
|
269 |
+
imports.wbg.__wbindgen_is_undefined = function(arg0) {
|
270 |
+
const ret = getObject(arg0) === undefined;
|
271 |
+
return ret;
|
272 |
+
};
|
273 |
+
imports.wbg.__wbg_call_01734de55d61e11d = function() { return handleError(function (arg0, arg1, arg2) {
|
274 |
+
const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
|
275 |
+
return addHeapObject(ret);
|
276 |
+
}, arguments) };
|
277 |
+
imports.wbg.__wbg_buffer_085ec1f694018c4f = function(arg0) {
|
278 |
+
const ret = getObject(arg0).buffer;
|
279 |
+
return addHeapObject(ret);
|
280 |
+
};
|
281 |
+
imports.wbg.__wbg_newwithbyteoffsetandlength_6da8e527659b86aa = function(arg0, arg1, arg2) {
|
282 |
+
const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
|
283 |
+
return addHeapObject(ret);
|
284 |
+
};
|
285 |
+
imports.wbg.__wbg_new_8125e318e6245eed = function(arg0) {
|
286 |
+
const ret = new Uint8Array(getObject(arg0));
|
287 |
+
return addHeapObject(ret);
|
288 |
+
};
|
289 |
+
imports.wbg.__wbg_set_5cf90238115182c3 = function(arg0, arg1, arg2) {
|
290 |
+
getObject(arg0).set(getObject(arg1), arg2 >>> 0);
|
291 |
+
};
|
292 |
+
imports.wbg.__wbg_newwithlength_e5d69174d6984cd7 = function(arg0) {
|
293 |
+
const ret = new Uint8Array(arg0 >>> 0);
|
294 |
+
return addHeapObject(ret);
|
295 |
+
};
|
296 |
+
imports.wbg.__wbg_subarray_13db269f57aa838d = function(arg0, arg1, arg2) {
|
297 |
+
const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
|
298 |
+
return addHeapObject(ret);
|
299 |
+
};
|
300 |
+
imports.wbg.__wbindgen_throw = function(arg0, arg1) {
|
301 |
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
302 |
+
};
|
303 |
+
imports.wbg.__wbindgen_memory = function() {
|
304 |
+
const ret = wasm.memory;
|
305 |
+
return addHeapObject(ret);
|
306 |
+
};
|
307 |
+
|
308 |
+
return imports;
|
309 |
+
}
|
310 |
+
|
311 |
+
function __wbg_init_memory(imports, maybe_memory) {
|
312 |
+
|
313 |
+
}
|
314 |
+
|
315 |
+
function __wbg_finalize_init(instance, module) {
|
316 |
+
wasm = instance.exports;
|
317 |
+
__wbg_init.__wbindgen_wasm_module = module;
|
318 |
+
cachedInt32Memory0 = null;
|
319 |
+
cachedUint8Memory0 = null;
|
320 |
+
|
321 |
+
wasm.__wbindgen_start();
|
322 |
+
return wasm;
|
323 |
+
}
|
324 |
+
|
325 |
+
function initSync(module) {
|
326 |
+
if (wasm !== undefined) return wasm;
|
327 |
+
|
328 |
+
const imports = __wbg_get_imports();
|
329 |
+
|
330 |
+
__wbg_init_memory(imports);
|
331 |
+
|
332 |
+
if (!(module instanceof WebAssembly.Module)) {
|
333 |
+
module = new WebAssembly.Module(module);
|
334 |
+
}
|
335 |
+
|
336 |
+
const instance = new WebAssembly.Instance(module, imports);
|
337 |
+
|
338 |
+
return __wbg_finalize_init(instance, module);
|
339 |
+
}
|
340 |
+
|
341 |
+
async function __wbg_init(input) {
|
342 |
+
if (wasm !== undefined) return wasm;
|
343 |
+
|
344 |
+
if (typeof input === 'undefined') {
|
345 |
+
input = new URL('m_bg.wasm', import.meta.url);
|
346 |
+
}
|
347 |
+
const imports = __wbg_get_imports();
|
348 |
+
|
349 |
+
if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
|
350 |
+
input = fetch(input);
|
351 |
+
}
|
352 |
+
|
353 |
+
__wbg_init_memory(imports);
|
354 |
+
|
355 |
+
const { instance, module } = await __wbg_load(await input, imports);
|
356 |
+
|
357 |
+
return __wbg_finalize_init(instance, module);
|
358 |
+
}
|
359 |
+
|
360 |
+
export { initSync }
|
361 |
+
export default __wbg_init;
|
build/m_b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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
let wasm;
|
2 |
+
export function __wbg_set_wasm(val) {
|
3 |
+
wasm = val;
|
4 |
+
}
|
5 |
+
|
6 |
+
|
7 |
+
const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder;
|
8 |
+
|
9 |
+
let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
10 |
+
|
11 |
+
cachedTextDecoder.decode();
|
12 |
+
|
13 |
+
let cachedUint8Memory0 = null;
|
14 |
+
|
15 |
+
function getUint8Memory0() {
|
16 |
+
if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
|
17 |
+
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
18 |
+
}
|
19 |
+
return cachedUint8Memory0;
|
20 |
+
}
|
21 |
+
|
22 |
+
function getStringFromWasm0(ptr, len) {
|
23 |
+
ptr = ptr >>> 0;
|
24 |
+
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
25 |
+
}
|
26 |
+
|
27 |
+
const heap = new Array(128).fill(undefined);
|
28 |
+
|
29 |
+
heap.push(undefined, null, true, false);
|
30 |
+
|
31 |
+
let heap_next = heap.length;
|
32 |
+
|
33 |
+
function addHeapObject(obj) {
|
34 |
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
35 |
+
const idx = heap_next;
|
36 |
+
heap_next = heap[idx];
|
37 |
+
|
38 |
+
heap[idx] = obj;
|
39 |
+
return idx;
|
40 |
+
}
|
41 |
+
|
42 |
+
function getObject(idx) { return heap[idx]; }
|
43 |
+
|
44 |
+
function dropObject(idx) {
|
45 |
+
if (idx < 132) return;
|
46 |
+
heap[idx] = heap_next;
|
47 |
+
heap_next = idx;
|
48 |
+
}
|
49 |
+
|
50 |
+
function takeObject(idx) {
|
51 |
+
const ret = getObject(idx);
|
52 |
+
dropObject(idx);
|
53 |
+
return ret;
|
54 |
+
}
|
55 |
+
|
56 |
+
let WASM_VECTOR_LEN = 0;
|
57 |
+
|
58 |
+
function passArray8ToWasm0(arg, malloc) {
|
59 |
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
60 |
+
getUint8Memory0().set(arg, ptr / 1);
|
61 |
+
WASM_VECTOR_LEN = arg.length;
|
62 |
+
return ptr;
|
63 |
+
}
|
64 |
+
|
65 |
+
let cachedInt32Memory0 = null;
|
66 |
+
|
67 |
+
function getInt32Memory0() {
|
68 |
+
if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
|
69 |
+
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
|
70 |
+
}
|
71 |
+
return cachedInt32Memory0;
|
72 |
+
}
|
73 |
+
|
74 |
+
function handleError(f, args) {
|
75 |
+
try {
|
76 |
+
return f.apply(this, args);
|
77 |
+
} catch (e) {
|
78 |
+
wasm.__wbindgen_exn_store(addHeapObject(e));
|
79 |
+
}
|
80 |
+
}
|
81 |
+
/**
|
82 |
+
*/
|
83 |
+
export class Model {
|
84 |
+
|
85 |
+
static __wrap(ptr) {
|
86 |
+
ptr = ptr >>> 0;
|
87 |
+
const obj = Object.create(Model.prototype);
|
88 |
+
obj.__wbg_ptr = ptr;
|
89 |
+
|
90 |
+
return obj;
|
91 |
+
}
|
92 |
+
|
93 |
+
__destroy_into_raw() {
|
94 |
+
const ptr = this.__wbg_ptr;
|
95 |
+
this.__wbg_ptr = 0;
|
96 |
+
|
97 |
+
return ptr;
|
98 |
+
}
|
99 |
+
|
100 |
+
free() {
|
101 |
+
const ptr = this.__destroy_into_raw();
|
102 |
+
wasm.__wbg_model_free(ptr);
|
103 |
+
}
|
104 |
+
/**
|
105 |
+
* @param {Uint8Array} data
|
106 |
+
*/
|
107 |
+
constructor(data) {
|
108 |
+
try {
|
109 |
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
110 |
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
111 |
+
const len0 = WASM_VECTOR_LEN;
|
112 |
+
wasm.model_new(retptr, ptr0, len0);
|
113 |
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
114 |
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
115 |
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
116 |
+
if (r2) {
|
117 |
+
throw takeObject(r1);
|
118 |
+
}
|
119 |
+
return Model.__wrap(r0);
|
120 |
+
} finally {
|
121 |
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
122 |
+
}
|
123 |
+
}
|
124 |
+
/**
|
125 |
+
* @param {Uint8Array} image
|
126 |
+
* @returns {string}
|
127 |
+
*/
|
128 |
+
run(image) {
|
129 |
+
let deferred3_0;
|
130 |
+
let deferred3_1;
|
131 |
+
try {
|
132 |
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
133 |
+
const ptr0 = passArray8ToWasm0(image, wasm.__wbindgen_malloc);
|
134 |
+
const len0 = WASM_VECTOR_LEN;
|
135 |
+
wasm.model_run(retptr, this.__wbg_ptr, ptr0, len0);
|
136 |
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
137 |
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
138 |
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
139 |
+
var r3 = getInt32Memory0()[retptr / 4 + 3];
|
140 |
+
var ptr2 = r0;
|
141 |
+
var len2 = r1;
|
142 |
+
if (r3) {
|
143 |
+
ptr2 = 0; len2 = 0;
|
144 |
+
throw takeObject(r2);
|
145 |
+
}
|
146 |
+
deferred3_0 = ptr2;
|
147 |
+
deferred3_1 = len2;
|
148 |
+
return getStringFromWasm0(ptr2, len2);
|
149 |
+
} finally {
|
150 |
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
151 |
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
152 |
+
}
|
153 |
+
}
|
154 |
+
}
|
155 |
+
|
156 |
+
export function __wbindgen_error_new(arg0, arg1) {
|
157 |
+
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
158 |
+
return addHeapObject(ret);
|
159 |
+
};
|
160 |
+
|
161 |
+
export function __wbindgen_object_drop_ref(arg0) {
|
162 |
+
takeObject(arg0);
|
163 |
+
};
|
164 |
+
|
165 |
+
export function __wbindgen_string_new(arg0, arg1) {
|
166 |
+
const ret = getStringFromWasm0(arg0, arg1);
|
167 |
+
return addHeapObject(ret);
|
168 |
+
};
|
169 |
+
|
170 |
+
export function __wbindgen_object_clone_ref(arg0) {
|
171 |
+
const ret = getObject(arg0);
|
172 |
+
return addHeapObject(ret);
|
173 |
+
};
|
174 |
+
|
175 |
+
export function __wbg_log_65d20c5d9fc43b86(arg0, arg1) {
|
176 |
+
console.log(getStringFromWasm0(arg0, arg1));
|
177 |
+
};
|
178 |
+
|
179 |
+
export function __wbg_crypto_c48a774b022d20ac(arg0) {
|
180 |
+
const ret = getObject(arg0).crypto;
|
181 |
+
return addHeapObject(ret);
|
182 |
+
};
|
183 |
+
|
184 |
+
export function __wbindgen_is_object(arg0) {
|
185 |
+
const val = getObject(arg0);
|
186 |
+
const ret = typeof(val) === 'object' && val !== null;
|
187 |
+
return ret;
|
188 |
+
};
|
189 |
+
|
190 |
+
export function __wbg_process_298734cf255a885d(arg0) {
|
191 |
+
const ret = getObject(arg0).process;
|
192 |
+
return addHeapObject(ret);
|
193 |
+
};
|
194 |
+
|
195 |
+
export function __wbg_versions_e2e78e134e3e5d01(arg0) {
|
196 |
+
const ret = getObject(arg0).versions;
|
197 |
+
return addHeapObject(ret);
|
198 |
+
};
|
199 |
+
|
200 |
+
export function __wbg_node_1cd7a5d853dbea79(arg0) {
|
201 |
+
const ret = getObject(arg0).node;
|
202 |
+
return addHeapObject(ret);
|
203 |
+
};
|
204 |
+
|
205 |
+
export function __wbindgen_is_string(arg0) {
|
206 |
+
const ret = typeof(getObject(arg0)) === 'string';
|
207 |
+
return ret;
|
208 |
+
};
|
209 |
+
|
210 |
+
export function __wbg_msCrypto_bcb970640f50a1e8(arg0) {
|
211 |
+
const ret = getObject(arg0).msCrypto;
|
212 |
+
return addHeapObject(ret);
|
213 |
+
};
|
214 |
+
|
215 |
+
export function __wbg_require_8f08ceecec0f4fee() { return handleError(function () {
|
216 |
+
const ret = module.require;
|
217 |
+
return addHeapObject(ret);
|
218 |
+
}, arguments) };
|
219 |
+
|
220 |
+
export function __wbindgen_is_function(arg0) {
|
221 |
+
const ret = typeof(getObject(arg0)) === 'function';
|
222 |
+
return ret;
|
223 |
+
};
|
224 |
+
|
225 |
+
export function __wbg_getRandomValues_37fa2ca9e4e07fab() { return handleError(function (arg0, arg1) {
|
226 |
+
getObject(arg0).getRandomValues(getObject(arg1));
|
227 |
+
}, arguments) };
|
228 |
+
|
229 |
+
export function __wbg_randomFillSync_dc1e9a60c158336d() { return handleError(function (arg0, arg1) {
|
230 |
+
getObject(arg0).randomFillSync(takeObject(arg1));
|
231 |
+
}, arguments) };
|
232 |
+
|
233 |
+
export function __wbg_newnoargs_581967eacc0e2604(arg0, arg1) {
|
234 |
+
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
235 |
+
return addHeapObject(ret);
|
236 |
+
};
|
237 |
+
|
238 |
+
export function __wbg_call_cb65541d95d71282() { return handleError(function (arg0, arg1) {
|
239 |
+
const ret = getObject(arg0).call(getObject(arg1));
|
240 |
+
return addHeapObject(ret);
|
241 |
+
}, arguments) };
|
242 |
+
|
243 |
+
export function __wbg_self_1ff1d729e9aae938() { return handleError(function () {
|
244 |
+
const ret = self.self;
|
245 |
+
return addHeapObject(ret);
|
246 |
+
}, arguments) };
|
247 |
+
|
248 |
+
export function __wbg_window_5f4faef6c12b79ec() { return handleError(function () {
|
249 |
+
const ret = window.window;
|
250 |
+
return addHeapObject(ret);
|
251 |
+
}, arguments) };
|
252 |
+
|
253 |
+
export function __wbg_globalThis_1d39714405582d3c() { return handleError(function () {
|
254 |
+
const ret = globalThis.globalThis;
|
255 |
+
return addHeapObject(ret);
|
256 |
+
}, arguments) };
|
257 |
+
|
258 |
+
export function __wbg_global_651f05c6a0944d1c() { return handleError(function () {
|
259 |
+
const ret = global.global;
|
260 |
+
return addHeapObject(ret);
|
261 |
+
}, arguments) };
|
262 |
+
|
263 |
+
export function __wbindgen_is_undefined(arg0) {
|
264 |
+
const ret = getObject(arg0) === undefined;
|
265 |
+
return ret;
|
266 |
+
};
|
267 |
+
|
268 |
+
export function __wbg_call_01734de55d61e11d() { return handleError(function (arg0, arg1, arg2) {
|
269 |
+
const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
|
270 |
+
return addHeapObject(ret);
|
271 |
+
}, arguments) };
|
272 |
+
|
273 |
+
export function __wbg_buffer_085ec1f694018c4f(arg0) {
|
274 |
+
const ret = getObject(arg0).buffer;
|
275 |
+
return addHeapObject(ret);
|
276 |
+
};
|
277 |
+
|
278 |
+
export function __wbg_newwithbyteoffsetandlength_6da8e527659b86aa(arg0, arg1, arg2) {
|
279 |
+
const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
|
280 |
+
return addHeapObject(ret);
|
281 |
+
};
|
282 |
+
|
283 |
+
export function __wbg_new_8125e318e6245eed(arg0) {
|
284 |
+
const ret = new Uint8Array(getObject(arg0));
|
285 |
+
return addHeapObject(ret);
|
286 |
+
};
|
287 |
+
|
288 |
+
export function __wbg_set_5cf90238115182c3(arg0, arg1, arg2) {
|
289 |
+
getObject(arg0).set(getObject(arg1), arg2 >>> 0);
|
290 |
+
};
|
291 |
+
|
292 |
+
export function __wbg_newwithlength_e5d69174d6984cd7(arg0) {
|
293 |
+
const ret = new Uint8Array(arg0 >>> 0);
|
294 |
+
return addHeapObject(ret);
|
295 |
+
};
|
296 |
+
|
297 |
+
export function __wbg_subarray_13db269f57aa838d(arg0, arg1, arg2) {
|
298 |
+
const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
|
299 |
+
return addHeapObject(ret);
|
300 |
+
};
|
301 |
+
|
302 |
+
export function __wbindgen_throw(arg0, arg1) {
|
303 |
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
304 |
+
};
|
305 |
+
|
306 |
+
export function __wbindgen_memory() {
|
307 |
+
const ret = wasm.memory;
|
308 |
+
return addHeapObject(ret);
|
309 |
+
};
|
310 |
+
|
build/m_bg.wasm
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:592230791ffdd18c8bb3ffea9921dbc51f8784be5627e29efc04204ec30912d0
|
3 |
+
size 1507693
|
build/m_bg.wasm.d.ts
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/* tslint:disable */
|
2 |
+
/* eslint-disable */
|
3 |
+
export const memory: WebAssembly.Memory;
|
4 |
+
export function __wbg_model_free(a: number): void;
|
5 |
+
export function model_new(a: number, b: number, c: number): void;
|
6 |
+
export function model_run(a: number, b: number, c: number, d: number): void;
|
7 |
+
export function main(a: number, b: number): number;
|
8 |
+
export function __wbindgen_add_to_stack_pointer(a: number): number;
|
9 |
+
export function __wbindgen_malloc(a: number, b: number): number;
|
10 |
+
export function __wbindgen_free(a: number, b: number, c: number): void;
|
11 |
+
export function __wbindgen_exn_store(a: number): void;
|
12 |
+
export function __wbindgen_start(): void;
|