EYEDOL commited on
Commit
a6a4f0e
·
verified ·
1 Parent(s): 67dfac2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -2
app.py CHANGED
@@ -54,7 +54,10 @@ def chat_response(message, history, image_input):
54
 
55
  # 2. Process inputs (Image + Text)
56
  # Converting image to RGB is important as some PNGs have alpha channels
57
- image = image_input.convert("RGB")
 
 
 
58
 
59
  inputs = processor(text=prompt_text, images=image, return_tensors="pt").to(model.device)
60
 
@@ -93,7 +96,12 @@ with gr.Blocks(title="LLaVA Image Chat", theme=gr.themes.Soft()) as demo:
93
  additional_inputs=[image_box],
94
  title="Chat",
95
  description="Ask about the uploaded image.",
96
- examples=["What is in this image?", "Describe the colors.", "Can you read the text in the image?"],
 
 
 
 
 
97
  )
98
 
99
  if __name__ == "__main__":
 
54
 
55
  # 2. Process inputs (Image + Text)
56
  # Converting image to RGB is important as some PNGs have alpha channels
57
+ try:
58
+ image = image_input.convert("RGB")
59
+ except Exception:
60
+ return "Error processing image. Please ensure it is a valid image file."
61
 
62
  inputs = processor(text=prompt_text, images=image, return_tensors="pt").to(model.device)
63
 
 
96
  additional_inputs=[image_box],
97
  title="Chat",
98
  description="Ask about the uploaded image.",
99
+ # Examples must match the inputs: [text_message, image_input_value]
100
+ examples=[
101
+ ["What is in this image?", None],
102
+ ["Describe the colors.", None],
103
+ ["Can you read the text in the image?", None],
104
+ ],
105
  )
106
 
107
  if __name__ == "__main__":