Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -105,15 +105,31 @@ def inference_calling_idefics(image_path, question=""):
|
|
105 |
return "Error: Invalid image or unable to encode image."
|
106 |
|
107 |
image_info = f"data:image/png;base64,{image_base64}"
|
108 |
-
prompt = f
|
109 |
-
|
110 |
try:
|
111 |
-
response =
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
return response
|
118 |
except Exception as e:
|
119 |
print(f"Error in inference call: {e}")
|
|
|
105 |
return "Error: Invalid image or unable to encode image."
|
106 |
|
107 |
image_info = f"data:image/png;base64,{image_base64}"
|
108 |
+
prompt = f'Describe this image without question mark. {question}'
|
109 |
+
|
110 |
try:
|
111 |
+
response = ""
|
112 |
+
for message in client.chat_completion(
|
113 |
+
model=image_model,
|
114 |
+
messages=[
|
115 |
+
{
|
116 |
+
"role": "system",
|
117 |
+
"content": [
|
118 |
+
{"type": "text", "text": system_prompt},
|
119 |
+
],
|
120 |
+
},
|
121 |
+
{
|
122 |
+
"role": "user",
|
123 |
+
"content": [
|
124 |
+
{"type": "image_url", "image_url": {"url": image_info}},
|
125 |
+
{"type": "text", "text": prompt},
|
126 |
+
],
|
127 |
+
}
|
128 |
+
],
|
129 |
+
max_tokens=2048,
|
130 |
+
stream=True,
|
131 |
+
):
|
132 |
+
response += message.choices[0].delta.content
|
133 |
return response
|
134 |
except Exception as e:
|
135 |
print(f"Error in inference call: {e}")
|