Aniquel's picture
Update app.py
8421132
raw
history blame
No virus
761 Bytes
import os
import gradio as gr
import requests
import openai
from PIL import Image
from io import BytesIO
openai.api_key = os.getenv("OPENAI_API_KEY")
# Define the function that generates the image
response = openai.Image.create(
prompt=prompt,
n=1,
size="1024x1024"
)
image_url = response['data'][0]['url']
iface = gr.Interface(
fn=generate_image,
inputs=gr.inputs.Textbox(label="Enter Prompt Here"),
outputs="image",
examples=[
["a cat sitting on a couch"],
["a robot walking in the park"],
["a tree made of clouds"],
],
title="TalkGPT Image Generation",
description="Use AI to generate images based on a prompt.",
allow_flagging=False,
analytics_enabled=True,
theme="compact"
)