mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-09-12 12:37:01 +00:00
fix(OpenAIGPTImage1): set correct MIME type for multipart uploads to OpenAI edits (#9348)
This commit is contained in:
@@ -464,8 +464,6 @@ class OpenAIGPTImage1(ComfyNodeABC):
|
|||||||
path = "/proxy/openai/images/generations"
|
path = "/proxy/openai/images/generations"
|
||||||
content_type = "application/json"
|
content_type = "application/json"
|
||||||
request_class = OpenAIImageGenerationRequest
|
request_class = OpenAIImageGenerationRequest
|
||||||
img_binaries = []
|
|
||||||
mask_binary = None
|
|
||||||
files = []
|
files = []
|
||||||
|
|
||||||
if image is not None:
|
if image is not None:
|
||||||
@@ -484,14 +482,11 @@ class OpenAIGPTImage1(ComfyNodeABC):
|
|||||||
img_byte_arr = io.BytesIO()
|
img_byte_arr = io.BytesIO()
|
||||||
img.save(img_byte_arr, format="PNG")
|
img.save(img_byte_arr, format="PNG")
|
||||||
img_byte_arr.seek(0)
|
img_byte_arr.seek(0)
|
||||||
img_binary = img_byte_arr
|
|
||||||
img_binary.name = f"image_{i}.png"
|
|
||||||
|
|
||||||
img_binaries.append(img_binary)
|
|
||||||
if batch_size == 1:
|
if batch_size == 1:
|
||||||
files.append(("image", img_binary))
|
files.append(("image", (f"image_{i}.png", img_byte_arr, "image/png")))
|
||||||
else:
|
else:
|
||||||
files.append(("image[]", img_binary))
|
files.append(("image[]", (f"image_{i}.png", img_byte_arr, "image/png")))
|
||||||
|
|
||||||
if mask is not None:
|
if mask is not None:
|
||||||
if image is None:
|
if image is None:
|
||||||
@@ -511,9 +506,7 @@ class OpenAIGPTImage1(ComfyNodeABC):
|
|||||||
mask_img_byte_arr = io.BytesIO()
|
mask_img_byte_arr = io.BytesIO()
|
||||||
mask_img.save(mask_img_byte_arr, format="PNG")
|
mask_img.save(mask_img_byte_arr, format="PNG")
|
||||||
mask_img_byte_arr.seek(0)
|
mask_img_byte_arr.seek(0)
|
||||||
mask_binary = mask_img_byte_arr
|
files.append(("mask", ("mask.png", mask_img_byte_arr, "image/png")))
|
||||||
mask_binary.name = "mask.png"
|
|
||||||
files.append(("mask", mask_binary))
|
|
||||||
|
|
||||||
# Build the operation
|
# Build the operation
|
||||||
operation = SynchronousOperation(
|
operation = SynchronousOperation(
|
||||||
|
Reference in New Issue
Block a user