Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -35,15 +35,21 @@ def clean_response(response: str) -> str:
|
|
| 35 |
return response
|
| 36 |
|
| 37 |
def chat_with_model(image_path=None, text_query=None, history=None):
|
| 38 |
-
default_image_path = '
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
image_path = default_image_path
|
| 46 |
else:
|
|
|
|
| 47 |
image_path = default_image_path
|
| 48 |
text_input = text_query if text_query else ""
|
| 49 |
query_elements = [
|
|
|
|
| 35 |
return response
|
| 36 |
|
| 37 |
def chat_with_model(image_path=None, text_query=None, history=None):
|
| 38 |
+
default_image_path = 'https://huggingface.co/spaces/Tonic1/Official-Qwen-VL-Chat/blob/main/2saj7l.png'
|
| 39 |
+
|
| 40 |
+
if image_path:
|
| 41 |
+
if os.path.isfile(image_path):
|
| 42 |
+
try:
|
| 43 |
+
with Image.open(image_path) as img:
|
| 44 |
+
print(f"Image {image_path} opened successfully.")
|
| 45 |
+
except UnidentifiedImageError as e:
|
| 46 |
+
print(f"Error opening image: {e}")
|
| 47 |
+
image_path = default_image_path
|
| 48 |
+
else:
|
| 49 |
+
print(f"Image file does not exist at {image_path}, using default image.")
|
| 50 |
image_path = default_image_path
|
| 51 |
else:
|
| 52 |
+
print("No image path provided, using default image.")
|
| 53 |
image_path = default_image_path
|
| 54 |
text_input = text_query if text_query else ""
|
| 55 |
query_elements = [
|