cmvr-visual/inference/tests/wan_read_img_fixture.py
zhanghao 88cf14d794 feat: consolidate story studio and editable automatic production
Restructure backend and frontend modules; add story, library, and editor schema migrations.

Support editable automatic production, manual confirmation modes, account and user lifecycle management, compact container scrolling, consistent forms, and per-task result previews.

Update inference and TTS scheduling, deployment guidance, and regression coverage; remove obsolete standalone pages and temporary acceptance artifacts.
2026-11-14 14:07:26 +08:00

28 lines
973 B
Python

# ruff: noqa
# Upstream helper intentionally preserved verbatim, including its unused path branches.
# Copyright 2024-2025 The Alibaba Wan Team Authors. All rights reserved.
# Exact read_img helper captured from Wan2.2 preprocess/pose2d_utils.py.
# Kept in CPU tests to verify upstream ndarray BGR conversion without ONNX/GPU.
import numpy as np
from PIL import Image
def read_img(image, convert='RGB', check_exist=False):
if isinstance(image, str):
if check_exist and not osp.exists(image):
return None
try:
img = Image.open(image)
if convert:
img = img.convert(convert)
except:
raise IOError('File error: ', image)
return np.asarray(img)
else:
if isinstance(image, np.ndarray):
if convert:
return image[..., ::-1]
else:
if convert:
img = img.convert(convert)
return np.asarray(img)