Commit
·
658bf45
1
Parent(s):
9920173
✨ Got the alt text
Browse files
server.ts
CHANGED
|
@@ -89,9 +89,23 @@ async function lookupTweets() {
|
|
| 89 |
|
| 90 |
console.log("imageUrl", imageUrl);
|
| 91 |
|
| 92 |
-
const
|
| 93 |
-
|
| 94 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
}
|
| 96 |
|
| 97 |
async function listen() {
|
|
|
|
| 89 |
|
| 90 |
console.log("imageUrl", imageUrl);
|
| 91 |
|
| 92 |
+
const imageResp = await fetch(imageUrl);
|
| 93 |
+
const contentType = imageResp.headers.get("Content-Type");
|
| 94 |
+
const image = await imageResp.arrayBuffer();
|
| 95 |
+
|
| 96 |
+
console.log(contentType, image);
|
| 97 |
+
|
| 98 |
+
const altText = await fetch("https://olivierdehaene-git-large-coco.hf.space/run/predict", {
|
| 99 |
+
method: "POST",
|
| 100 |
+
headers: { "Content-Type": "application/json" },
|
| 101 |
+
body: JSON.stringify({
|
| 102 |
+
data: [`data:${contentType};base64,${Buffer.from(image).toString("base64")}`],
|
| 103 |
+
}),
|
| 104 |
+
})
|
| 105 |
+
.then((r) => r.json())
|
| 106 |
+
.then((r) => r.data);
|
| 107 |
+
|
| 108 |
+
console.log(altText);
|
| 109 |
}
|
| 110 |
|
| 111 |
async function listen() {
|