Update app.py
Browse files
app.py
CHANGED
|
@@ -31,7 +31,7 @@ def preprocess_image(image):
|
|
| 31 |
|
| 32 |
return image
|
| 33 |
|
| 34 |
-
#
|
| 35 |
|
| 36 |
def patched_json_schema(schema, defs=None):
|
| 37 |
# Handle boolean schema directly
|
|
@@ -196,8 +196,9 @@ def caption_image(image, model_name=default_caption_model):
|
|
| 196 |
print(f"Unexpected image type: {type(image)}")
|
| 197 |
return "Error: Unsupported image type"
|
| 198 |
|
| 199 |
-
#
|
| 200 |
-
pil_image
|
|
|
|
| 201 |
|
| 202 |
# Check if model is available
|
| 203 |
if model_name not in models or model_name not in processors:
|
|
|
|
| 31 |
|
| 32 |
return image
|
| 33 |
|
| 34 |
+
# DELETE THIS LINE COMPLETELY
|
| 35 |
|
| 36 |
def patched_json_schema(schema, defs=None):
|
| 37 |
# Handle boolean schema directly
|
|
|
|
| 196 |
print(f"Unexpected image type: {type(image)}")
|
| 197 |
return "Error: Unsupported image type"
|
| 198 |
|
| 199 |
+
# Convert input to RGB if needed
|
| 200 |
+
if pil_image.mode != "RGB":
|
| 201 |
+
pil_image = pil_image.convert("RGB")
|
| 202 |
|
| 203 |
# Check if model is available
|
| 204 |
if model_name not in models or model_name not in processors:
|