vlm: enforce pybase64 for image and str encode/decode (#10700)

This commit is contained in:
b8zhong
2025-10-21 04:05:32 -07:00
committed by GitHub
parent 05d3667ab9
commit d0a64c7e2c
8 changed files with 20 additions and 36 deletions

View File

@@ -31,7 +31,10 @@ from typing import Any, AsyncGenerator, Dict, List, Optional, Tuple, Union
import aiohttp
import numpy as np
import pybase64
import requests
from datasets import load_dataset
from PIL import Image
from tqdm.asyncio import tqdm
from transformers import (
AutoProcessor,
@@ -1020,14 +1023,6 @@ def sample_mmmu_requests(
Returns:
List of tuples (prompt, prompt_token_len, output_token_len).
"""
try:
import io
import pybase64
from datasets import load_dataset
except ImportError:
raise ImportError("Please install datasets: pip install datasets")
print("Loading MMMU dataset from HuggingFace...")
try:
@@ -1396,13 +1391,6 @@ def sample_image_requests(
- Text lengths follow the 'random' dataset sampling rule. ``prompt_len``
only counts text tokens and excludes image data.
"""
try:
import pybase64
from PIL import Image
except ImportError as e:
raise ImportError(
"Please install Pillow to generate random images: pip install pillow"
) from e
# Parse resolution (supports presets and 'heightxwidth')
width, height = parse_image_resolution(image_resolution)