Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -85,21 +85,14 @@ def stream_text_chat(message, history, system_prompt, temperature=0.8, max_new_t
|
|
85 |
def process_vision_query(image, text_input):
|
86 |
prompt = f"<|user|>\n<|image_1|>\n{text_input}<|end|>\n<|assistant|>\n"
|
87 |
|
88 |
-
#
|
89 |
-
if isinstance(image,
|
90 |
-
#
|
91 |
-
import io
|
92 |
-
img_byte_arr = io.BytesIO()
|
93 |
-
image.save(img_byte_arr, format='PNG')
|
94 |
-
image = img_byte_arr.getvalue()
|
95 |
-
elif isinstance(image, np.ndarray):
|
96 |
-
# If it's a numpy array, convert to PIL Image first, then to bytes
|
97 |
image = Image.fromarray(image).convert("RGB")
|
98 |
-
|
99 |
-
image.
|
100 |
-
image = img_byte_arr.getvalue()
|
101 |
|
102 |
-
# Now process the image
|
103 |
inputs = vision_processor(prompt, images=image, return_tensors="pt").to(device)
|
104 |
|
105 |
with torch.no_grad():
|
|
|
85 |
def process_vision_query(image, text_input):
|
86 |
prompt = f"<|user|>\n<|image_1|>\n{text_input}<|end|>\n<|assistant|>\n"
|
87 |
|
88 |
+
# Ensure the image is in the correct format
|
89 |
+
if isinstance(image, np.ndarray):
|
90 |
+
# Convert numpy array to PIL Image
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
image = Image.fromarray(image).convert("RGB")
|
92 |
+
elif not isinstance(image, Image.Image):
|
93 |
+
raise ValueError("Invalid image type. Expected PIL.Image.Image or numpy.ndarray")
|
|
|
94 |
|
95 |
+
# Now process the image
|
96 |
inputs = vision_processor(prompt, images=image, return_tensors="pt").to(device)
|
97 |
|
98 |
with torch.no_grad():
|