Spaces:
Running
Running
Upload 7 files
Browse files- build/m.d.ts +4 -10
- build/m.js +223 -54
- build/m_bg.wasm +2 -2
- build/m_bg.wasm.d.ts +2 -2
- code.js +4 -0
- moondreamWorker.js +9 -8
build/m.d.ts
CHANGED
@@ -15,16 +15,10 @@ export class Model {
|
|
15 |
*/
|
16 |
set_image_embeddings(image: Uint8Array): void;
|
17 |
/**
|
18 |
-
* @param {
|
19 |
-
* @param {bigint} seed
|
20 |
-
* @param {number} temp
|
21 |
-
* @param {number} top_p
|
22 |
-
* @param {number} repeat_penalty
|
23 |
-
* @param {number} repeat_last_n
|
24 |
-
* @param {boolean} verbose_prompt
|
25 |
* @returns {any}
|
26 |
*/
|
27 |
-
init_with_image_prompt(
|
28 |
/**
|
29 |
* @returns {any}
|
30 |
*/
|
@@ -38,12 +32,12 @@ export interface InitOutput {
|
|
38 |
readonly __wbg_model_free: (a: number) => void;
|
39 |
readonly model_load: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
40 |
readonly model_set_image_embeddings: (a: number, b: number, c: number, d: number) => void;
|
41 |
-
readonly model_init_with_image_prompt: (a: number, b: number, c: number
|
42 |
readonly model_next_token: (a: number, b: number) => void;
|
43 |
readonly main: (a: number, b: number) => number;
|
44 |
-
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
45 |
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
46 |
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
|
47 |
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
48 |
readonly __wbindgen_exn_store: (a: number) => void;
|
49 |
readonly __wbindgen_start: () => void;
|
|
|
15 |
*/
|
16 |
set_image_embeddings(image: Uint8Array): void;
|
17 |
/**
|
18 |
+
* @param {any} input
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
* @returns {any}
|
20 |
*/
|
21 |
+
init_with_image_prompt(input: any): any;
|
22 |
/**
|
23 |
* @returns {any}
|
24 |
*/
|
|
|
32 |
readonly __wbg_model_free: (a: number) => void;
|
33 |
readonly model_load: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
34 |
readonly model_set_image_embeddings: (a: number, b: number, c: number, d: number) => void;
|
35 |
+
readonly model_init_with_image_prompt: (a: number, b: number, c: number) => void;
|
36 |
readonly model_next_token: (a: number, b: number) => void;
|
37 |
readonly main: (a: number, b: number) => number;
|
|
|
38 |
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
39 |
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
40 |
+
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
41 |
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
42 |
readonly __wbindgen_exn_store: (a: number) => void;
|
43 |
readonly __wbindgen_start: () => void;
|
build/m.js
CHANGED
@@ -1,5 +1,25 @@
|
|
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(); };
|
@@ -18,12 +38,6 @@ function getStringFromWasm0(ptr, len) {
|
|
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;
|
@@ -33,38 +47,8 @@ function addHeapObject(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 |
const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
|
69 |
|
70 |
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
@@ -119,6 +103,109 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
119 |
return ptr;
|
120 |
}
|
121 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
function handleError(f, args) {
|
123 |
try {
|
124 |
return f.apply(this, args);
|
@@ -189,21 +276,13 @@ export class Model {
|
|
189 |
}
|
190 |
}
|
191 |
/**
|
192 |
-
* @param {
|
193 |
-
* @param {bigint} seed
|
194 |
-
* @param {number} temp
|
195 |
-
* @param {number} top_p
|
196 |
-
* @param {number} repeat_penalty
|
197 |
-
* @param {number} repeat_last_n
|
198 |
-
* @param {boolean} verbose_prompt
|
199 |
* @returns {any}
|
200 |
*/
|
201 |
-
init_with_image_prompt(
|
202 |
try {
|
203 |
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
204 |
-
|
205 |
-
const len0 = WASM_VECTOR_LEN;
|
206 |
-
wasm.model_init_with_image_prompt(retptr, this.__wbg_ptr, ptr0, len0, seed, temp, top_p, repeat_penalty, repeat_last_n, verbose_prompt);
|
207 |
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
208 |
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
209 |
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
@@ -269,15 +348,16 @@ async function __wbg_load(module, imports) {
|
|
269 |
function __wbg_get_imports() {
|
270 |
const imports = {};
|
271 |
imports.wbg = {};
|
272 |
-
imports.wbg.
|
273 |
-
const
|
274 |
-
|
|
|
275 |
};
|
276 |
imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
|
277 |
takeObject(arg0);
|
278 |
};
|
279 |
-
imports.wbg.
|
280 |
-
const ret =
|
281 |
return addHeapObject(ret);
|
282 |
};
|
283 |
imports.wbg.__wbindgen_is_object = function(arg0) {
|
@@ -285,6 +365,52 @@ function __wbg_get_imports() {
|
|
285 |
const ret = typeof(val) === 'object' && val !== null;
|
286 |
return ret;
|
287 |
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
288 |
imports.wbg.__wbg_String_b9412f8799faab3e = function(arg0, arg1) {
|
289 |
const ret = String(getObject(arg1));
|
290 |
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
@@ -300,6 +426,10 @@ function __wbg_get_imports() {
|
|
300 |
const ret = getStringFromWasm0(arg0, arg1);
|
301 |
return addHeapObject(ret);
|
302 |
};
|
|
|
|
|
|
|
|
|
303 |
imports.wbg.__wbg_set_f975102236d3c502 = function(arg0, arg1, arg2) {
|
304 |
getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
|
305 |
};
|
@@ -394,14 +524,24 @@ function __wbg_get_imports() {
|
|
394 |
const ret = global.global;
|
395 |
return addHeapObject(ret);
|
396 |
}, arguments) };
|
397 |
-
imports.wbg.
|
398 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
399 |
return ret;
|
400 |
};
|
401 |
imports.wbg.__wbg_call_01734de55d61e11d = function() { return handleError(function (arg0, arg1, arg2) {
|
402 |
const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
|
403 |
return addHeapObject(ret);
|
404 |
}, arguments) };
|
|
|
|
|
|
|
|
|
405 |
imports.wbg.__wbg_now_9c5990bda04c7e53 = function() {
|
406 |
const ret = Date.now();
|
407 |
return ret;
|
@@ -421,6 +561,20 @@ function __wbg_get_imports() {
|
|
421 |
imports.wbg.__wbg_set_5cf90238115182c3 = function(arg0, arg1, arg2) {
|
422 |
getObject(arg0).set(getObject(arg1), arg2 >>> 0);
|
423 |
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
424 |
imports.wbg.__wbg_newwithlength_e5d69174d6984cd7 = function(arg0) {
|
425 |
const ret = new Uint8Array(arg0 >>> 0);
|
426 |
return addHeapObject(ret);
|
@@ -429,6 +583,19 @@ function __wbg_get_imports() {
|
|
429 |
const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
|
430 |
return addHeapObject(ret);
|
431 |
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
432 |
imports.wbg.__wbindgen_throw = function(arg0, arg1) {
|
433 |
throw new Error(getStringFromWasm0(arg0, arg1));
|
434 |
};
|
@@ -447,6 +614,8 @@ function __wbg_init_memory(imports, maybe_memory) {
|
|
447 |
function __wbg_finalize_init(instance, module) {
|
448 |
wasm = instance.exports;
|
449 |
__wbg_init.__wbindgen_wasm_module = module;
|
|
|
|
|
450 |
cachedInt32Memory0 = null;
|
451 |
cachedUint8Memory0 = null;
|
452 |
|
|
|
1 |
let wasm;
|
2 |
|
3 |
+
const heap = new Array(128).fill(undefined);
|
4 |
+
|
5 |
+
heap.push(undefined, null, true, false);
|
6 |
+
|
7 |
+
function getObject(idx) { return heap[idx]; }
|
8 |
+
|
9 |
+
let heap_next = heap.length;
|
10 |
+
|
11 |
+
function dropObject(idx) {
|
12 |
+
if (idx < 132) return;
|
13 |
+
heap[idx] = heap_next;
|
14 |
+
heap_next = idx;
|
15 |
+
}
|
16 |
+
|
17 |
+
function takeObject(idx) {
|
18 |
+
const ret = getObject(idx);
|
19 |
+
dropObject(idx);
|
20 |
+
return ret;
|
21 |
+
}
|
22 |
+
|
23 |
const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
|
24 |
|
25 |
if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
|
|
|
38 |
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
39 |
}
|
40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
function addHeapObject(obj) {
|
42 |
if (heap_next === heap.length) heap.push(heap.length + 1);
|
43 |
const idx = heap_next;
|
|
|
47 |
return idx;
|
48 |
}
|
49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
let WASM_VECTOR_LEN = 0;
|
51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
|
53 |
|
54 |
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
|
|
103 |
return ptr;
|
104 |
}
|
105 |
|
106 |
+
function isLikeNone(x) {
|
107 |
+
return x === undefined || x === null;
|
108 |
+
}
|
109 |
+
|
110 |
+
let cachedInt32Memory0 = null;
|
111 |
+
|
112 |
+
function getInt32Memory0() {
|
113 |
+
if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
|
114 |
+
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
|
115 |
+
}
|
116 |
+
return cachedInt32Memory0;
|
117 |
+
}
|
118 |
+
|
119 |
+
let cachedFloat64Memory0 = null;
|
120 |
+
|
121 |
+
function getFloat64Memory0() {
|
122 |
+
if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) {
|
123 |
+
cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer);
|
124 |
+
}
|
125 |
+
return cachedFloat64Memory0;
|
126 |
+
}
|
127 |
+
|
128 |
+
let cachedBigInt64Memory0 = null;
|
129 |
+
|
130 |
+
function getBigInt64Memory0() {
|
131 |
+
if (cachedBigInt64Memory0 === null || cachedBigInt64Memory0.byteLength === 0) {
|
132 |
+
cachedBigInt64Memory0 = new BigInt64Array(wasm.memory.buffer);
|
133 |
+
}
|
134 |
+
return cachedBigInt64Memory0;
|
135 |
+
}
|
136 |
+
|
137 |
+
function debugString(val) {
|
138 |
+
// primitive types
|
139 |
+
const type = typeof val;
|
140 |
+
if (type == 'number' || type == 'boolean' || val == null) {
|
141 |
+
return `${val}`;
|
142 |
+
}
|
143 |
+
if (type == 'string') {
|
144 |
+
return `"${val}"`;
|
145 |
+
}
|
146 |
+
if (type == 'symbol') {
|
147 |
+
const description = val.description;
|
148 |
+
if (description == null) {
|
149 |
+
return 'Symbol';
|
150 |
+
} else {
|
151 |
+
return `Symbol(${description})`;
|
152 |
+
}
|
153 |
+
}
|
154 |
+
if (type == 'function') {
|
155 |
+
const name = val.name;
|
156 |
+
if (typeof name == 'string' && name.length > 0) {
|
157 |
+
return `Function(${name})`;
|
158 |
+
} else {
|
159 |
+
return 'Function';
|
160 |
+
}
|
161 |
+
}
|
162 |
+
// objects
|
163 |
+
if (Array.isArray(val)) {
|
164 |
+
const length = val.length;
|
165 |
+
let debug = '[';
|
166 |
+
if (length > 0) {
|
167 |
+
debug += debugString(val[0]);
|
168 |
+
}
|
169 |
+
for(let i = 1; i < length; i++) {
|
170 |
+
debug += ', ' + debugString(val[i]);
|
171 |
+
}
|
172 |
+
debug += ']';
|
173 |
+
return debug;
|
174 |
+
}
|
175 |
+
// Test for built-in
|
176 |
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
177 |
+
let className;
|
178 |
+
if (builtInMatches.length > 1) {
|
179 |
+
className = builtInMatches[1];
|
180 |
+
} else {
|
181 |
+
// Failed to match the standard '[object ClassName]'
|
182 |
+
return toString.call(val);
|
183 |
+
}
|
184 |
+
if (className == 'Object') {
|
185 |
+
// we're a user defined class or Object
|
186 |
+
// JSON.stringify avoids problems with cycles, and is generally much
|
187 |
+
// easier than looping through ownProperties of `val`.
|
188 |
+
try {
|
189 |
+
return 'Object(' + JSON.stringify(val) + ')';
|
190 |
+
} catch (_) {
|
191 |
+
return 'Object';
|
192 |
+
}
|
193 |
+
}
|
194 |
+
// errors
|
195 |
+
if (val instanceof Error) {
|
196 |
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
197 |
+
}
|
198 |
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
199 |
+
return className;
|
200 |
+
}
|
201 |
+
|
202 |
+
function passArray8ToWasm0(arg, malloc) {
|
203 |
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
204 |
+
getUint8Memory0().set(arg, ptr / 1);
|
205 |
+
WASM_VECTOR_LEN = arg.length;
|
206 |
+
return ptr;
|
207 |
+
}
|
208 |
+
|
209 |
function handleError(f, args) {
|
210 |
try {
|
211 |
return f.apply(this, args);
|
|
|
276 |
}
|
277 |
}
|
278 |
/**
|
279 |
+
* @param {any} input
|
|
|
|
|
|
|
|
|
|
|
|
|
280 |
* @returns {any}
|
281 |
*/
|
282 |
+
init_with_image_prompt(input) {
|
283 |
try {
|
284 |
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
285 |
+
wasm.model_init_with_image_prompt(retptr, this.__wbg_ptr, addHeapObject(input));
|
|
|
|
|
286 |
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
287 |
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
288 |
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
|
348 |
function __wbg_get_imports() {
|
349 |
const imports = {};
|
350 |
imports.wbg = {};
|
351 |
+
imports.wbg.__wbindgen_boolean_get = function(arg0) {
|
352 |
+
const v = getObject(arg0);
|
353 |
+
const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2;
|
354 |
+
return ret;
|
355 |
};
|
356 |
imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
|
357 |
takeObject(arg0);
|
358 |
};
|
359 |
+
imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
|
360 |
+
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
361 |
return addHeapObject(ret);
|
362 |
};
|
363 |
imports.wbg.__wbindgen_is_object = function(arg0) {
|
|
|
365 |
const ret = typeof(val) === 'object' && val !== null;
|
366 |
return ret;
|
367 |
};
|
368 |
+
imports.wbg.__wbindgen_is_undefined = function(arg0) {
|
369 |
+
const ret = getObject(arg0) === undefined;
|
370 |
+
return ret;
|
371 |
+
};
|
372 |
+
imports.wbg.__wbindgen_in = function(arg0, arg1) {
|
373 |
+
const ret = getObject(arg0) in getObject(arg1);
|
374 |
+
return ret;
|
375 |
+
};
|
376 |
+
imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
|
377 |
+
const obj = getObject(arg1);
|
378 |
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
379 |
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
380 |
+
var len1 = WASM_VECTOR_LEN;
|
381 |
+
getInt32Memory0()[arg0 / 4 + 1] = len1;
|
382 |
+
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
|
383 |
+
};
|
384 |
+
imports.wbg.__wbindgen_is_bigint = function(arg0) {
|
385 |
+
const ret = typeof(getObject(arg0)) === 'bigint';
|
386 |
+
return ret;
|
387 |
+
};
|
388 |
+
imports.wbg.__wbindgen_bigint_from_u64 = function(arg0) {
|
389 |
+
const ret = BigInt.asUintN(64, arg0);
|
390 |
+
return addHeapObject(ret);
|
391 |
+
};
|
392 |
+
imports.wbg.__wbindgen_jsval_eq = function(arg0, arg1) {
|
393 |
+
const ret = getObject(arg0) === getObject(arg1);
|
394 |
+
return ret;
|
395 |
+
};
|
396 |
+
imports.wbg.__wbindgen_number_get = function(arg0, arg1) {
|
397 |
+
const obj = getObject(arg1);
|
398 |
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
399 |
+
getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
|
400 |
+
getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
|
401 |
+
};
|
402 |
+
imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
|
403 |
+
const ret = getObject(arg0);
|
404 |
+
return addHeapObject(ret);
|
405 |
+
};
|
406 |
+
imports.wbg.__wbindgen_jsval_loose_eq = function(arg0, arg1) {
|
407 |
+
const ret = getObject(arg0) == getObject(arg1);
|
408 |
+
return ret;
|
409 |
+
};
|
410 |
+
imports.wbg.__wbindgen_as_number = function(arg0) {
|
411 |
+
const ret = +getObject(arg0);
|
412 |
+
return ret;
|
413 |
+
};
|
414 |
imports.wbg.__wbg_String_b9412f8799faab3e = function(arg0, arg1) {
|
415 |
const ret = String(getObject(arg1));
|
416 |
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
|
426 |
const ret = getStringFromWasm0(arg0, arg1);
|
427 |
return addHeapObject(ret);
|
428 |
};
|
429 |
+
imports.wbg.__wbg_getwithrefkey_edc2c8960f0f1191 = function(arg0, arg1) {
|
430 |
+
const ret = getObject(arg0)[getObject(arg1)];
|
431 |
+
return addHeapObject(ret);
|
432 |
+
};
|
433 |
imports.wbg.__wbg_set_f975102236d3c502 = function(arg0, arg1, arg2) {
|
434 |
getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
|
435 |
};
|
|
|
524 |
const ret = global.global;
|
525 |
return addHeapObject(ret);
|
526 |
}, arguments) };
|
527 |
+
imports.wbg.__wbg_instanceof_ArrayBuffer_39ac22089b74fddb = function(arg0) {
|
528 |
+
let result;
|
529 |
+
try {
|
530 |
+
result = getObject(arg0) instanceof ArrayBuffer;
|
531 |
+
} catch (_) {
|
532 |
+
result = false;
|
533 |
+
}
|
534 |
+
const ret = result;
|
535 |
return ret;
|
536 |
};
|
537 |
imports.wbg.__wbg_call_01734de55d61e11d = function() { return handleError(function (arg0, arg1, arg2) {
|
538 |
const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
|
539 |
return addHeapObject(ret);
|
540 |
}, arguments) };
|
541 |
+
imports.wbg.__wbg_isSafeInteger_bb8e18dd21c97288 = function(arg0) {
|
542 |
+
const ret = Number.isSafeInteger(getObject(arg0));
|
543 |
+
return ret;
|
544 |
+
};
|
545 |
imports.wbg.__wbg_now_9c5990bda04c7e53 = function() {
|
546 |
const ret = Date.now();
|
547 |
return ret;
|
|
|
561 |
imports.wbg.__wbg_set_5cf90238115182c3 = function(arg0, arg1, arg2) {
|
562 |
getObject(arg0).set(getObject(arg1), arg2 >>> 0);
|
563 |
};
|
564 |
+
imports.wbg.__wbg_length_72e2208bbc0efc61 = function(arg0) {
|
565 |
+
const ret = getObject(arg0).length;
|
566 |
+
return ret;
|
567 |
+
};
|
568 |
+
imports.wbg.__wbg_instanceof_Uint8Array_d8d9cb2b8e8ac1d4 = function(arg0) {
|
569 |
+
let result;
|
570 |
+
try {
|
571 |
+
result = getObject(arg0) instanceof Uint8Array;
|
572 |
+
} catch (_) {
|
573 |
+
result = false;
|
574 |
+
}
|
575 |
+
const ret = result;
|
576 |
+
return ret;
|
577 |
+
};
|
578 |
imports.wbg.__wbg_newwithlength_e5d69174d6984cd7 = function(arg0) {
|
579 |
const ret = new Uint8Array(arg0 >>> 0);
|
580 |
return addHeapObject(ret);
|
|
|
583 |
const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
|
584 |
return addHeapObject(ret);
|
585 |
};
|
586 |
+
imports.wbg.__wbindgen_bigint_get_as_i64 = function(arg0, arg1) {
|
587 |
+
const v = getObject(arg1);
|
588 |
+
const ret = typeof(v) === 'bigint' ? v : undefined;
|
589 |
+
getBigInt64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? BigInt(0) : ret;
|
590 |
+
getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
|
591 |
+
};
|
592 |
+
imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
|
593 |
+
const ret = debugString(getObject(arg1));
|
594 |
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
595 |
+
const len1 = WASM_VECTOR_LEN;
|
596 |
+
getInt32Memory0()[arg0 / 4 + 1] = len1;
|
597 |
+
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
|
598 |
+
};
|
599 |
imports.wbg.__wbindgen_throw = function(arg0, arg1) {
|
600 |
throw new Error(getStringFromWasm0(arg0, arg1));
|
601 |
};
|
|
|
614 |
function __wbg_finalize_init(instance, module) {
|
615 |
wasm = instance.exports;
|
616 |
__wbg_init.__wbindgen_wasm_module = module;
|
617 |
+
cachedBigInt64Memory0 = null;
|
618 |
+
cachedFloat64Memory0 = null;
|
619 |
cachedInt32Memory0 = null;
|
620 |
cachedUint8Memory0 = null;
|
621 |
|
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:a7c97d08221b1b7c8ac5f50142aae73165b35abf29d9a17621c83f1e01761e53
|
3 |
+
size 5367634
|
build/m_bg.wasm.d.ts
CHANGED
@@ -4,12 +4,12 @@ export const memory: WebAssembly.Memory;
|
|
4 |
export function __wbg_model_free(a: number): void;
|
5 |
export function model_load(a: number, b: number, c: number, d: number, e: number, f: number): void;
|
6 |
export function model_set_image_embeddings(a: number, b: number, c: number, d: number): void;
|
7 |
-
export function model_init_with_image_prompt(a: number, b: number, c: number
|
8 |
export function model_next_token(a: number, b: number): void;
|
9 |
export function main(a: number, b: number): number;
|
10 |
-
export function __wbindgen_add_to_stack_pointer(a: number): number;
|
11 |
export function __wbindgen_malloc(a: number, b: number): number;
|
12 |
export function __wbindgen_realloc(a: number, b: number, c: number, d: number): number;
|
|
|
13 |
export function __wbindgen_free(a: number, b: number, c: number): void;
|
14 |
export function __wbindgen_exn_store(a: number): void;
|
15 |
export function __wbindgen_start(): void;
|
|
|
4 |
export function __wbg_model_free(a: number): void;
|
5 |
export function model_load(a: number, b: number, c: number, d: number, e: number, f: number): void;
|
6 |
export function model_set_image_embeddings(a: number, b: number, c: number, d: number): void;
|
7 |
+
export function model_init_with_image_prompt(a: number, b: number, c: number): void;
|
8 |
export function model_next_token(a: number, b: number): void;
|
9 |
export function main(a: number, b: 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_add_to_stack_pointer(a: number): number;
|
13 |
export function __wbindgen_free(a: number, b: number, c: number): void;
|
14 |
export function __wbindgen_exn_store(a: number): void;
|
15 |
export function __wbindgen_start(): void;
|
code.js
CHANGED
@@ -33,6 +33,10 @@ async function generateSequence(controller) {
|
|
33 |
const seed = getValue("seed");
|
34 |
const maxSeqLen = getValue("max-seq");
|
35 |
|
|
|
|
|
|
|
|
|
36 |
function updateStatus(data) {
|
37 |
const outStatus = document.querySelector("#output-status");
|
38 |
const outGen = document.querySelector("#output-generation");
|
|
|
33 |
const seed = getValue("seed");
|
34 |
const maxSeqLen = getValue("max-seq");
|
35 |
|
36 |
+
if (prompt?.value?.trim() === "") {
|
37 |
+
return;
|
38 |
+
}
|
39 |
+
|
40 |
function updateStatus(data) {
|
41 |
const outStatus = document.querySelector("#output-status");
|
42 |
const outGen = document.querySelector("#output-generation");
|
moondreamWorker.js
CHANGED
@@ -136,15 +136,16 @@ async function generate(data) {
|
|
136 |
status: "complete-embedding",
|
137 |
message: "Embeddings Complete",
|
138 |
});
|
139 |
-
const { token, token_id } = model.init_with_image_prompt(
|
140 |
prompt,
|
141 |
-
BigInt(seed),
|
142 |
-
temp,
|
143 |
-
top_p,
|
144 |
-
repeatPenalty,
|
145 |
-
64,
|
146 |
-
verbose_prompt
|
147 |
-
);
|
|
|
148 |
const seq_len = 2048;
|
149 |
|
150 |
let sentence = token;
|
|
|
136 |
status: "complete-embedding",
|
137 |
message: "Embeddings Complete",
|
138 |
});
|
139 |
+
const { token, token_id } = model.init_with_image_prompt({
|
140 |
prompt,
|
141 |
+
seed: BigInt(seed),
|
142 |
+
temp: parseFloat(temp),
|
143 |
+
top_p: parseFloat(top_p),
|
144 |
+
repeat_penalty: parseFloat(repeatPenalty),
|
145 |
+
repeat_last_n: 64,
|
146 |
+
verbose_prompt,
|
147 |
+
});
|
148 |
+
|
149 |
const seq_len = 2048;
|
150 |
|
151 |
let sentence = token;
|