fix: cast URL image columns to HF Image() type in VLM conversion
This commit is contained in:
parent
46550ecf24
commit
34fb9ec973
1 changed files with 7 additions and 0 deletions
|
|
@ -254,8 +254,15 @@ def convert_to_vlm_format(
|
|||
list: List of dicts with 'messages' field
|
||||
"""
|
||||
from PIL import Image
|
||||
from datasets import Image as datasets_Image
|
||||
from .vlm_processing import generate_smart_vlm_instruction
|
||||
|
||||
# Cast string image columns (URLs or local paths) to HF Image() type
|
||||
# so HuggingFace handles downloading, decoding, and caching transparently.
|
||||
sample_value = next(iter(dataset))[image_column]
|
||||
if isinstance(sample_value, str):
|
||||
dataset = dataset.cast_column(image_column, datasets_Image())
|
||||
|
||||
# Generate smart instruction if not provided
|
||||
if instruction is None:
|
||||
instruction_info = generate_smart_vlm_instruction(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue