[VLM RLHF] Take Image input for verl vlm rollout (#4915)

Signed-off-by: Xinyuan Tong <justinning0323@outlook.com>
Co-authored-by: GeLee <leege233@gmail.com>
This commit is contained in:
XinyuanTong
2025-04-01 20:03:17 -07:00
committed by GitHub
parent 12047f5e94
commit 9eb49e878b
4 changed files with 18 additions and 12 deletions

View File

@@ -566,10 +566,14 @@ def encode_video(video_path, frame_count_limit=None):
return frames
def load_image(image_file: Union[str, bytes]) -> tuple[Image, tuple[int, int]]:
def load_image(
image_file: Union[Image.Image, str, bytes]
) -> tuple[Image.Image, tuple[int, int]]:
image = image_size = None
if isinstance(image_file, bytes):
if isinstance(image_file, Image.Image):
image = image_file
image_size = (image.width, image.height)
elif isinstance(image_file, bytes):
image = Image.open(BytesIO(image_file))
elif image_file.startswith("http://") or image_file.startswith("https://"):
timeout = int(os.getenv("REQUEST_TIMEOUT", "3"))