Spaces:
Running
on
Zero
Running
on
Zero
dung-vpt-uney
commited on
Commit
·
6548741
1
Parent(s):
5216fb5
Update Visual-CoT demo - 2025-10-12 23:05:52
Browse filesFixes:
- Fix LLaVA config registration error (compatibility with newer transformers)
- Update Gradio to latest version (security fixes)
- Auto-deployed via update script
- llava/mm_utils.py +13 -6
llava/mm_utils.py
CHANGED
|
@@ -27,6 +27,7 @@ def expand2square(pil_img, background_color):
|
|
| 27 |
|
| 28 |
def process_images(images, image_processor, model_cfg):
|
| 29 |
from PIL import Image
|
|
|
|
| 30 |
|
| 31 |
image_aspect_ratio = getattr(model_cfg, "image_aspect_ratio", None)
|
| 32 |
new_images = []
|
|
@@ -38,15 +39,21 @@ def process_images(images, image_processor, model_cfg):
|
|
| 38 |
else:
|
| 39 |
processor = image_processor
|
| 40 |
|
| 41 |
-
# Ensure all images are PIL Images
|
| 42 |
processed_images = []
|
| 43 |
for img in images:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
if not isinstance(img, Image.Image):
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
|
|
|
| 50 |
processed_images.append(img)
|
| 51 |
|
| 52 |
if image_aspect_ratio == 'pad':
|
|
|
|
| 27 |
|
| 28 |
def process_images(images, image_processor, model_cfg):
|
| 29 |
from PIL import Image
|
| 30 |
+
import numpy as np
|
| 31 |
|
| 32 |
image_aspect_ratio = getattr(model_cfg, "image_aspect_ratio", None)
|
| 33 |
new_images = []
|
|
|
|
| 39 |
else:
|
| 40 |
processor = image_processor
|
| 41 |
|
| 42 |
+
# Ensure all images are PIL Images in RGB format
|
| 43 |
processed_images = []
|
| 44 |
for img in images:
|
| 45 |
+
# Convert numpy array to PIL Image
|
| 46 |
+
if isinstance(img, np.ndarray):
|
| 47 |
+
img = Image.fromarray(img.astype(np.uint8))
|
| 48 |
+
|
| 49 |
+
# Ensure it's a PIL Image
|
| 50 |
if not isinstance(img, Image.Image):
|
| 51 |
+
raise ValueError(f"Invalid image type: {type(img)}. Expected PIL Image or numpy array.")
|
| 52 |
+
|
| 53 |
+
# Convert to RGB if needed
|
| 54 |
+
if img.mode != 'RGB':
|
| 55 |
+
img = img.convert('RGB')
|
| 56 |
+
|
| 57 |
processed_images.append(img)
|
| 58 |
|
| 59 |
if image_aspect_ratio == 'pad':
|