#Trying to generate a variant by submitting a list of images

3 messages · Page 1 of 1 (latest)

mossy needle
#

I am trying to create a program, that generates a new image from the 10 images submitted, the create_variant and create functions only allow 1 image prompt

Any suggestion on how I can fix the code or which other ML I should use?

import openai
from PIL import Image

openai.api_key = 'OPENAI_API_KEY'

image_filenames = [
    open("images/1.png", "rb"),
    open("images/2.png", "rb"),
    open("images/3.png", "rb"),
    open("images/4.png", "rb"),
    open("images/5.png", "rb"),
    open("images/6.png", "rb"),
    open("images/b1.png", "rb"),
    open("images/b2.png", "rb"),
    open("images/b3.png", "rb"),
    open("images/b4.png", "rb"),
    open("images/b5.png", "rb"),
]


response = openai.Image.create_variation(
  image=image_filenames,
  n=1,
  size="1024x1024"
)
image_url = response['data'][0]['url']

print(image_url)
TypeError: a bytes-like object is required, not 'list'
#

FYI: I open files inside a list due to open function being able to open only 1 file 😅

#

I also have a separate function that turns all files in a folder into .png and 1024x1024 resolution