Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -63,24 +63,34 @@ def bot_streaming(message, history, max_new_tokens=250):
|
|
63 |
|
64 |
|
65 |
for x in messages:
|
|
|
66 |
try:
|
67 |
-
if x['
|
68 |
-
url = x['
|
69 |
response = requests.get(url)
|
70 |
img = Image.open(BytesIO(response.content)).convert("RGB")
|
71 |
-
images.append(img)
|
|
|
72 |
except Exception as e:
|
73 |
print(e)
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
|
85 |
print("images ",images)
|
86 |
|
@@ -90,7 +100,7 @@ def bot_streaming(message, history, max_new_tokens=250):
|
|
90 |
|
91 |
|
92 |
print("\n\ntexts final chat text ", texts)
|
93 |
-
|
94 |
if images == []:
|
95 |
inputs = processor(text=texts, return_tensors="pt").to("cuda")
|
96 |
else:
|
|
|
63 |
|
64 |
|
65 |
for x in messages:
|
66 |
+
print("x , ", x)
|
67 |
try:
|
68 |
+
if x['img_url']:
|
69 |
+
url = x['img_url']
|
70 |
response = requests.get(url)
|
71 |
img = Image.open(BytesIO(response.content)).convert("RGB")
|
72 |
+
images.append(img)
|
73 |
+
|
74 |
except Exception as e:
|
75 |
print(e)
|
76 |
+
# try:
|
77 |
+
# if x['content'][1]['type']=='image':
|
78 |
+
# url = x['content'][1]['url']
|
79 |
+
# response = requests.get(url)
|
80 |
+
# img = Image.open(BytesIO(response.content)).convert("RGB")
|
81 |
+
# images.append(img)
|
82 |
+
# except Exception as e:
|
83 |
+
# print(e)
|
84 |
+
# try:
|
85 |
+
# if x['content'][0]['type']=='image':
|
86 |
+
# url = x['content'][0]['url']
|
87 |
+
# response = requests.get(url)
|
88 |
+
# img = Image.open(BytesIO(response.content)).convert("RGB")
|
89 |
+
# images.append(img)
|
90 |
+
|
91 |
+
# except Exception as e:
|
92 |
+
# print(e)
|
93 |
+
# pass
|
94 |
|
95 |
print("images ",images)
|
96 |
|
|
|
100 |
|
101 |
|
102 |
print("\n\ntexts final chat text ", texts)
|
103 |
+
print('len of images ', len(images))
|
104 |
if images == []:
|
105 |
inputs = processor(text=texts, return_tensors="pt").to("cuda")
|
106 |
else:
|