Spaces:
Runtime error
Runtime error
debout inputs
Browse files- txt2img/index.html +17 -7
txt2img/index.html
CHANGED
@@ -71,6 +71,7 @@
|
|
71 |
|
72 |
async function promptUpdateStream() {
|
73 |
const prompt = promptEl.value;
|
|
|
74 |
const seed = seedEl.value;
|
75 |
const guidance_scale = guidanceEl.value;
|
76 |
websocket.send(JSON.stringify({
|
@@ -79,19 +80,28 @@
|
|
79 |
guidance_scale: guidance_scale,
|
80 |
}));
|
81 |
}
|
82 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
function initPromptStream(userId) {
|
84 |
liveImage.src = `/stream/${userId}`;
|
85 |
-
promptEl.addEventListener("input",
|
86 |
-
seedEl.addEventListener("input",
|
87 |
-
guidanceEl.addEventListener("change",
|
88 |
}
|
89 |
|
90 |
async function stop() {
|
91 |
websocket.close();
|
92 |
-
promptEl.removeEventListener("input",
|
93 |
-
seedEl.removeEventListener("input",
|
94 |
-
guidanceEl.removeEventListener("change",
|
95 |
}
|
96 |
return {
|
97 |
start,
|
|
|
71 |
|
72 |
async function promptUpdateStream() {
|
73 |
const prompt = promptEl.value;
|
74 |
+
console.log(prompt);
|
75 |
const seed = seedEl.value;
|
76 |
const guidance_scale = guidanceEl.value;
|
77 |
websocket.send(JSON.stringify({
|
|
|
80 |
guidance_scale: guidance_scale,
|
81 |
}));
|
82 |
}
|
83 |
+
function debouceInput(fn, delay) {
|
84 |
+
let timer;
|
85 |
+
return function (...args) {
|
86 |
+
clearTimeout(timer);
|
87 |
+
timer = setTimeout(() => {
|
88 |
+
fn(...args);
|
89 |
+
}, delay);
|
90 |
+
}
|
91 |
+
}
|
92 |
+
const debouncedInput = debouceInput(promptUpdateStream, 200);
|
93 |
function initPromptStream(userId) {
|
94 |
liveImage.src = `/stream/${userId}`;
|
95 |
+
promptEl.addEventListener("input", debouncedInput);
|
96 |
+
seedEl.addEventListener("input", debouncedInput);
|
97 |
+
guidanceEl.addEventListener("change", debouncedInput);
|
98 |
}
|
99 |
|
100 |
async function stop() {
|
101 |
websocket.close();
|
102 |
+
promptEl.removeEventListener("input", debouncedInput);
|
103 |
+
seedEl.removeEventListener("input", debouncedInput);
|
104 |
+
guidanceEl.removeEventListener("change", debouncedInput);
|
105 |
}
|
106 |
return {
|
107 |
start,
|