I’m having trouble displaying image that I’m generating from openai. I get the URL back and if I print it I can see the image but when I try to pass it to the image component it never displays! I can’t tell what I’m doing wrong. Here’s code snippet:
import openai
import gradio as gr
from PIL import Image
output= gr.Image()
def generateImage (prompt):
response = openai.images.generate(
model="dall-e-3",
prompt="People of color doing climate jobs",
size="1024x1024",
quality="standard",
n=1,
)
return response.data[0].url
def handlePrompt(prompt):
urlString = generateImage(prompt)
print(urlString)
output.value = urlString
with gr.Blocks() as demo:
gr.HTML( "<H1> Unified Ground Image generator</H1>" )
with gr.Row():
input = gr.Textbox(label="Enter Prompt")
output= gr.Image("images/ug_logo.jpg", height=200, width=200, type="pil")
generate_btn = gr.Button("Generate Image")
generate_btn.click(fn=handlePrompt, inputs=input, outputs=output)
demo.launch(share=True)