summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRadamés Ajna <radamajna@gmail.com>2023-09-14 22:30:50 -0700
committerGitHub <noreply@github.com>2023-09-15 06:30:50 +0100
commit5cefbba75777547f97abd92affcf9ef10ac36163 (patch)
tree835c1f6a79176163958c76287841d3fab467f880
parent130fe5a087715fc4d7bf9b581ca7c11378736ac5 (diff)
downloadcandle-5cefbba75777547f97abd92affcf9ef10ac36163.tar.gz
candle-5cefbba75777547f97abd92affcf9ef10ac36163.tar.bz2
candle-5cefbba75777547f97abd92affcf9ef10ac36163.zip
minor UI fixes (#856)
* fixes * remove listener * remove event listener
-rw-r--r--candle-wasm-examples/llama2-c/lib-example.html12
-rw-r--r--candle-wasm-examples/whisper/lib-example.html9
-rw-r--r--candle-wasm-examples/yolo/lib-example.html17
3 files changed, 27 insertions, 11 deletions
diff --git a/candle-wasm-examples/llama2-c/lib-example.html b/candle-wasm-examples/llama2-c/lib-example.html
index 22b12517..86fe9811 100644
--- a/candle-wasm-examples/llama2-c/lib-example.html
+++ b/candle-wasm-examples/llama2-c/lib-example.html
@@ -6,7 +6,7 @@
<body></body>
</html>
-<!doctype html>
+<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
@@ -113,8 +113,14 @@
const handleMessage = (event) => {
const { status, error, message, prompt, sentence } = event.data;
if (status) updateStatus(event.data);
- if (error) reject(new Error(error));
- if (status === "complete") resolve(event.data);
+ if (error) {
+ llamaWorker.removeEventListener("message", handleMessage);
+ reject(new Error(error));
+ }
+ if (status === "complete") {
+ llamaWorker.removeEventListener("message", handleMessage);
+ resolve(event.data);
+ }
};
controller.signal.addEventListener("abort", handleAbort);
diff --git a/candle-wasm-examples/whisper/lib-example.html b/candle-wasm-examples/whisper/lib-example.html
index ad48072b..3cfd87a7 100644
--- a/candle-wasm-examples/whisper/lib-example.html
+++ b/candle-wasm-examples/whisper/lib-example.html
@@ -6,7 +6,7 @@
<body></body>
</html>
-<!doctype html>
+<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
@@ -51,18 +51,21 @@
mel_filtersURL,
audioURL,
});
- whisperWorker.addEventListener("message", (event) => {
+ function messageHandler(event) {
console.log(event.data);
if ("status" in event.data) {
updateStatus(event.data);
}
if ("error" in event.data) {
+ whisperWorker.removeEventListener("message", messageHandler);
reject(new Error(event.data.error));
}
if (event.data.status === "complete") {
+ whisperWorker.removeEventListener("message", messageHandler);
resolve(event.data);
}
- });
+ }
+ whisperWorker.addEventListener("message", messageHandler);
});
}
diff --git a/candle-wasm-examples/yolo/lib-example.html b/candle-wasm-examples/yolo/lib-example.html
index 8f7d07c7..d9f18975 100644
--- a/candle-wasm-examples/yolo/lib-example.html
+++ b/candle-wasm-examples/yolo/lib-example.html
@@ -6,7 +6,7 @@
<body></body>
</html>
-<!doctype html>
+<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
@@ -199,17 +199,21 @@
confidence,
iou_threshold,
});
- yoloWorker.addEventListener("message", (event) => {
+ function handleMessage(event) {
+ console.log("message", event.data);
if ("status" in event.data) {
updateStatus(event.data.status);
}
if ("error" in event.data) {
+ yoloWorker.removeEventListener("message", handleMessage);
reject(new Error(event.data.error));
}
if (event.data.status === "complete") {
+ yoloWorker.removeEventListener("message", handleMessage);
resolve(event.data);
}
- });
+ }
+ yoloWorker.addEventListener("message", handleMessage);
});
}
// add event listener to detect button
@@ -393,7 +397,7 @@
</button>
</div>
<!-- drag and drop area -->
- <div class="relative">
+ <div class="relative max-w-lg">
<div class="py-1">
<button
id="clear-btn"
@@ -471,7 +475,10 @@
</div>
</div>
<div>
- <div class="flex gap-3 items-center" id="image-select">
+ <div
+ class="flex gap-3 items-center overflow-x-scroll"
+ id="image-select"
+ >
<h3 class="font-medium">Examples:</h3>
<img