[CI][Bugfix]Fix Wan2.2 I2V reference image upload (#3869)
Signed-off-by: bjf-frz <frz123db@gmail.com>
This commit is contained in:
1 parent
cad25fa20c
commit
ec94e83a25
1 file changed
+14
-2
@@ -359,9 +359,18 @@ def _validate_image_source(source: str) -> None:
|
|||||||
|
|
||||||
|
|
||||||
def _build_online_image_reference(source: str) -> str:
|
def _build_online_image_reference(source: str) -> str:
|
||||||
if _is_remote_image_source(source) or source.startswith("data:image"):
|
if source.startswith("data:image"):
|
||||||
return source
|
return source
|
||||||
|
|
||||||
|
if _is_remote_image_source(source):
|
||||||
|
response = requests.get(source, timeout=60)
|
||||||
|
response.raise_for_status()
|
||||||
|
mime_type = response.headers.get("Content-Type", "").split(";", 1)[0].strip()
|
||||||
|
if not mime_type.startswith("image/"):
|
||||||
|
mime_type = guess_type(urlparse(source).path)[0] or "image/png"
|
||||||
|
encoded = b64encode(response.content).decode("ascii")
|
||||||
|
return f"data:{mime_type};base64,{encoded}"
|
||||||
|
|
||||||
image_path = Path(source)
|
image_path = Path(source)
|
||||||
mime_type = guess_type(image_path.name)[0] or "image/png"
|
mime_type = guess_type(image_path.name)[0] or "image/png"
|
||||||
encoded = b64encode(image_path.read_bytes()).decode("ascii")
|
encoded = b64encode(image_path.read_bytes()).decode("ascii")
|
||||||
@@ -479,7 +488,10 @@ def _send_video_request_with_timeout(
|
|||||||
headers={"Accept": "application/json"},
|
headers={"Accept": "application/json"},
|
||||||
timeout=60,
|
timeout=60,
|
||||||
)
|
)
|
||||||
response.raise_for_status()
|
try:
|
||||||
|
response.raise_for_status()
|
||||||
|
except requests.HTTPError as exc:
|
||||||
|
raise requests.HTTPError(f"{exc}; response body: {response.text}", response=response) from exc
|
||||||
job_data = response.json()
|
job_data = response.json()
|
||||||
video_id = job_data["id"]
|
video_id = job_data["id"]
|
||||||
openai_client._wait_until_video_completed(video_id, timeout_seconds=timeout_seconds)
|
openai_client._wait_until_video_completed(video_id, timeout_seconds=timeout_seconds)
|
||||||
|
|||||||
Reference in new issue
Block a user