Update app.py
Browse files
app.py
CHANGED
|
@@ -7,7 +7,7 @@ import time
|
|
| 7 |
import re
|
| 8 |
import io
|
| 9 |
from PIL import Image, ImageDraw, ImageOps, ImageFont
|
| 10 |
-
|
| 11 |
import shutil
|
| 12 |
|
| 13 |
from langchain.chains import LLMChain, RetrievalQA
|
|
@@ -156,6 +156,10 @@ def umwandeln_fuer_anzeige(image):
|
|
| 156 |
image.save(buffer, format='PNG')
|
| 157 |
return buffer.getvalue()
|
| 158 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 159 |
def process_image(image_path, prompt):
|
| 160 |
#Bild aus tmp in Space ablegen
|
| 161 |
#temp_image_path = "/tmp/gradio/01834b95fcf793903d65ab947cc410dc1600d0df/bbb 1.png"
|
|
@@ -168,7 +172,7 @@ def process_image(image_path, prompt):
|
|
| 168 |
|
| 169 |
# Convert image to base64
|
| 170 |
with open(image_path, "rb") as image_file:
|
| 171 |
-
|
| 172 |
|
| 173 |
|
| 174 |
# Prepare the data for the API request (specific to the API you're using)
|
|
@@ -177,7 +181,7 @@ def process_image(image_path, prompt):
|
|
| 177 |
"content": [
|
| 178 |
{
|
| 179 |
"type": "text",
|
| 180 |
-
"text":
|
| 181 |
},
|
| 182 |
{
|
| 183 |
"type": "image_url",
|
|
|
|
| 7 |
import re
|
| 8 |
import io
|
| 9 |
from PIL import Image, ImageDraw, ImageOps, ImageFont
|
| 10 |
+
import base64
|
| 11 |
import shutil
|
| 12 |
|
| 13 |
from langchain.chains import LLMChain, RetrievalQA
|
|
|
|
| 156 |
image.save(buffer, format='PNG')
|
| 157 |
return buffer.getvalue()
|
| 158 |
|
| 159 |
+
def process_image(image_path, prompt):
|
| 160 |
+
with open(image_path, "rb") as image_file:
|
| 161 |
+
encoded_string = base64.b64encode(image_file.read()).decode('utf-8')
|
| 162 |
+
|
| 163 |
def process_image(image_path, prompt):
|
| 164 |
#Bild aus tmp in Space ablegen
|
| 165 |
#temp_image_path = "/tmp/gradio/01834b95fcf793903d65ab947cc410dc1600d0df/bbb 1.png"
|
|
|
|
| 172 |
|
| 173 |
# Convert image to base64
|
| 174 |
with open(image_path, "rb") as image_file:
|
| 175 |
+
encoded_string = base64.b64encode(image_file.read()).decode('utf-8')
|
| 176 |
|
| 177 |
|
| 178 |
# Prepare the data for the API request (specific to the API you're using)
|
|
|
|
| 181 |
"content": [
|
| 182 |
{
|
| 183 |
"type": "text",
|
| 184 |
+
"text": prompt
|
| 185 |
},
|
| 186 |
{
|
| 187 |
"type": "image_url",
|