Update app.py
Browse files
app.py
CHANGED
@@ -25,15 +25,18 @@ def respond(
|
|
25 |
## for image
|
26 |
if isinstance(image, np.ndarray):
|
27 |
img = PIL.Image.fromarray(image)
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
|
34 |
-
|
35 |
-
|
36 |
## for image
|
|
|
|
|
|
|
37 |
response = ""
|
38 |
|
39 |
for message in client.chat_completion(
|
|
|
25 |
## for image
|
26 |
if isinstance(image, np.ndarray):
|
27 |
img = PIL.Image.fromarray(image)
|
28 |
+
else:
|
29 |
+
try:
|
30 |
+
img = PIL.Image.open(image)
|
31 |
+
except (AttributeError, IOError) as e:
|
32 |
+
return f"Invalid image provided. Please provide a valid image file. Error: {e}"
|
33 |
|
34 |
+
# Load model
|
35 |
+
model = genai.GenerativeModel("gemini-pro-vision")
|
36 |
## for image
|
37 |
+
response = model.generate_content([messages, img])
|
38 |
+
print (response)
|
39 |
+
return response
|
40 |
response = ""
|
41 |
|
42 |
for message in client.chat_completion(
|