What format is the jpg_0 & jpg_1?

#2
by xzuyn - opened

Trying to make my own set to use with diffusion_dpo, but can't get figure out what way to save the images into the file.

Hi, have you figure out the format?

Hi, have you figure out the format

I haven't. I had to resort to modifying the code to use a different format instead:
https://gist.github.com/xzuyn/e931da62ba32a2aa4f41238c52d7ad3b

The images are converted to bytes, then encoded with base64.

def convert_image_to_base64(image_path):
    with open(image_path, "rb") as image_file:
        im_bytes = image_file.read()
        base64_data = base64.b64encode(im_bytes).decode("utf-8")

        return base64_data

If it helps anyone, i read the images like this into PIL:

import io
from PIL import Image

def decode_image(image: str) -> Image:

    img_byte_arr = io.BytesIO(image)
    img_byte_arr = Image.open(img_byte_arr)
    return img_byte_arr

Sign up or log in to comment