Spaces:
Running
Running
aifeifei798
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -30,26 +30,30 @@ def encode_image(image_path):
|
|
30 |
return None
|
31 |
|
32 |
def feifeichat(image):
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
|
|
|
|
|
|
|
|
53 |
|
54 |
|
55 |
with gr.Blocks() as demo:
|
|
|
30 |
return None
|
31 |
|
32 |
def feifeichat(image):
|
33 |
+
if image:
|
34 |
+
model = "pixtral-large-2411"
|
35 |
+
base64_image = encode_image(image)
|
36 |
+
# Define the messages for the chat
|
37 |
+
messages = [{
|
38 |
+
"role":
|
39 |
+
"user",
|
40 |
+
"content": [
|
41 |
+
{
|
42 |
+
"type": "text",
|
43 |
+
"text": "Please provide a detailed description of this photo"
|
44 |
+
},
|
45 |
+
{
|
46 |
+
"type": "image_url",
|
47 |
+
"image_url": f"data:image/jpeg;base64,{base64_image}",
|
48 |
+
},
|
49 |
+
],
|
50 |
+
}]
|
51 |
+
|
52 |
+
|
53 |
+
partial_message = Mistralclient.chat.stream(model=model, messages=messages)
|
54 |
+
return partial_message
|
55 |
+
else:
|
56 |
+
return "Please upload a photo"
|
57 |
|
58 |
|
59 |
with gr.Blocks() as demo:
|