Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -75,6 +75,9 @@ def process_image(image, shouldConvert=False):
|
|
| 75 |
print("image filename = ", filename)
|
| 76 |
return filename
|
| 77 |
|
|
|
|
|
|
|
|
|
|
| 78 |
|
| 79 |
def on_clear():
|
| 80 |
return {
|
|
@@ -254,7 +257,9 @@ with gr.Blocks(css=css) as demo:
|
|
| 254 |
get_text("Error: Input is empty", "错误:输入内容为空"))
|
| 255 |
if image:
|
| 256 |
imageFile = process_image(image)
|
| 257 |
-
|
|
|
|
|
|
|
| 258 |
if query:
|
| 259 |
content.append({'text': query})
|
| 260 |
|
|
|
|
| 75 |
print("image filename = ", filename)
|
| 76 |
return filename
|
| 77 |
|
| 78 |
+
def encode_image(image_path):
|
| 79 |
+
with open(image_path, "rb") as image_file:
|
| 80 |
+
return base64.b64encode(image_file.read()).decode("utf-8")
|
| 81 |
|
| 82 |
def on_clear():
|
| 83 |
return {
|
|
|
|
| 257 |
get_text("Error: Input is empty", "错误:输入内容为空"))
|
| 258 |
if image:
|
| 259 |
imageFile = process_image(image)
|
| 260 |
+
base64_image = encode_image(imageFile)
|
| 261 |
+
#content.append({'image': f'file://{imageFile}'})
|
| 262 |
+
content.append({'image': f'data:image/png;base64,{base64_image}'})
|
| 263 |
if query:
|
| 264 |
content.append({'text': query})
|
| 265 |
|