Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from huggingface_hub import InferenceClient
|
| 3 |
-
|
| 4 |
"""
|
| 5 |
For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
|
| 6 |
"""
|
|
@@ -22,6 +22,18 @@ def respond(
|
|
| 22 |
|
| 23 |
messages.append({"role": "user", "content": message})
|
| 24 |
print (message,image)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
response = ""
|
| 26 |
|
| 27 |
for message in client.chat_completion(
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from huggingface_hub import InferenceClient
|
| 3 |
+
import google.generativeai as genai
|
| 4 |
"""
|
| 5 |
For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
|
| 6 |
"""
|
|
|
|
| 22 |
|
| 23 |
messages.append({"role": "user", "content": message})
|
| 24 |
print (message,image)
|
| 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 = ""
|
| 38 |
|
| 39 |
for message in client.chat_completion(
|