Tonic commited on
Commit
438d350
·
1 Parent(s): 8f94226

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -7
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 = 'path/to/default/image.jpg'
39
- if image_path and os.path.isfile(image_path):
40
- try:
41
- with Image.open(image_path) as img:
42
- print(f"Image {image_path} opened successfully.")
43
- except UnidentifiedImageError:
44
- print(f"Error: The file at {image_path} is not a recognizable image.")
 
 
 
 
 
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 = [