Spaces:
Runtime error
Runtime error
byaldi
Browse files
app.py
CHANGED
|
@@ -1,9 +1,6 @@
|
|
| 1 |
-
import base64
|
| 2 |
-
import io
|
| 3 |
import json
|
| 4 |
import os
|
| 5 |
from datetime import datetime
|
| 6 |
-
from io import BytesIO
|
| 7 |
|
| 8 |
import dotenv
|
| 9 |
import lancedb
|
|
@@ -11,7 +8,6 @@ import requests
|
|
| 11 |
from datasets import load_dataset
|
| 12 |
from fasthtml.common import * # noqa
|
| 13 |
from huggingface_hub import login, whoami
|
| 14 |
-
from PIL import Image
|
| 15 |
from rerankers import Reranker
|
| 16 |
|
| 17 |
|
|
@@ -257,33 +253,33 @@ def SearchResult(result):
|
|
| 257 |
)
|
| 258 |
|
| 259 |
|
| 260 |
-
def base64_to_pil(base64_string):
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
|
| 265 |
-
|
| 266 |
-
|
| 267 |
|
| 268 |
-
|
| 269 |
-
|
| 270 |
|
| 271 |
-
|
| 272 |
|
| 273 |
|
| 274 |
-
def process_image(image, max_size=(500, 500), quality=85):
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
|
| 281 |
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
|
| 288 |
|
| 289 |
def ImageResult(image):
|
|
|
|
|
|
|
|
|
|
| 1 |
import json
|
| 2 |
import os
|
| 3 |
from datetime import datetime
|
|
|
|
| 4 |
|
| 5 |
import dotenv
|
| 6 |
import lancedb
|
|
|
|
| 8 |
from datasets import load_dataset
|
| 9 |
from fasthtml.common import * # noqa
|
| 10 |
from huggingface_hub import login, whoami
|
|
|
|
| 11 |
from rerankers import Reranker
|
| 12 |
|
| 13 |
|
|
|
|
| 253 |
)
|
| 254 |
|
| 255 |
|
| 256 |
+
# def base64_to_pil(base64_string):
|
| 257 |
+
# # Remove the "data:image/png;base64," part if it exists
|
| 258 |
+
# if "base64," in base64_string:
|
| 259 |
+
# base64_string = base64_string.split("base64,")[1]
|
| 260 |
|
| 261 |
+
# # Decode the base64 string
|
| 262 |
+
# img_data = base64.b64decode(base64_string)
|
| 263 |
|
| 264 |
+
# # Open the image using PIL
|
| 265 |
+
# img = Image.open(BytesIO(img_data))
|
| 266 |
|
| 267 |
+
# return img
|
| 268 |
|
| 269 |
|
| 270 |
+
# def process_image(image, max_size=(500, 500), quality=85):
|
| 271 |
+
# pil_image = base64_to_pil(image)
|
| 272 |
+
# img_byte_arr = io.BytesIO()
|
| 273 |
+
# pil_image.thumbnail(max_size)
|
| 274 |
+
# pil_image.save(img_byte_arr, format="JPEG", quality=quality, optimize=True)
|
| 275 |
+
# return f"data:image/jpeg;base64,{base64.b64encode(img_byte_arr.getvalue()).decode('utf-8')}"
|
| 276 |
|
| 277 |
|
| 278 |
+
def ImageResult(image):
|
| 279 |
+
return Div(
|
| 280 |
+
Img(src=f"data:image/jpeg;base64,{image}", alt="arxiv image"),
|
| 281 |
+
cls="image-result",
|
| 282 |
+
)
|
| 283 |
|
| 284 |
|
| 285 |
def ImageResult(image):
|