Hi All
I want to make an app that add background images to my product photo just like pebblely dot com did
This is my phyton app code:
from openai import OpenAI
import os
Path ke direktori gambar
image_path = r"DIRECTORY\PB_s412201_1024x1024.png"
Inisialisasi objek OpenAI dengan kunci API
client = OpenAI(api_key=“xxxxxx”)
Membaca file gambar
with open(image_path, “rb”) as image_file:
# Menggunakan API untuk membuat edit gambar
response = client.images.edit(
image=image_file,
prompt=“Latar belakang warna solid, yaitu ungu dan orange membagi menjadi 2 dengan ruang tengah kosong, gambar yang tengah hanya diisi dengan cahaya saja”,
n=1, # Jumlah gambar yang ingin dihasilkan
size=“1024x1024”,
response_format=“url”
)
Mendapatkan URL hasil dari respons
image_url = response.data[0].url
Unduh hasil gambar
result_image_path = r"DIRECTORY\PB_s412201_1024x1024_Edit.png"
os.system(f"powershell -command "(New-Object Net.WebClient).DownloadFile(‘{image_url}’, ‘{result_image_path}’)"")
Informasi tentang hasil
print(f"Gambar hasil edit tersimpan di: {result_image_path}")
this is image source (image product) and example of output
number 1 is product image and the rest is output
the result is not what i expected
Dall E 2 create image background AND edit my images too
How can i make Dall E 2 ONLY generate background for my product without changing my product photo?
Regards