[Python] Sending B64 string instead of temporary server link

Discussão em 'Python' iniciado por Stack, Março 6, 2025.

  1. Stack

    Stack Membro Participativo

    I am running an inference model with Python and am getting a resulting image. I now need to return this image to my script (which is running this method off-server) in a readable format. My current code looks like this:

    final_img = final_background.copy()

    gen_img = images[0].resize(crop_size)
    final_img.paste(gen_img, (left_final, top_final))
    print(f"start_tryon: Pasted generated image onto final background at ({left_final}, {top_final})")
    img_path = save_output_image(final_img, base_path="outputs", base_filename='img', seed=current_seed)
    results.append(img_path)

    return results


    When finishing, this simply is returning a link to some /tmp/ directory on the server instead of actually sending me the image. I assume I need to convert this image to some kind of decodable format like B64, but I haven't found a good way to do this, send it over, and convert it into a readable image.

    Is there any recommended way to do this in Python, or maybe a library that can achieve this goal?

    Continue reading...

Compartilhe esta Página