Spaces:
Runtime error
Runtime error
File size: 758 Bytes
b43ab03 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
import os
import dotenv
import gradio as gr
import openai
dotenv.load_dotenv()
openai.organization = os.getenv("API_ORG")
openai.api_key = os.getenv("API_KEY")
app_password = os.getenv("APP_PASSWORD")
app_username = os.getenv("APP_USERNAME")
def generate(prompt):
response = openai.Image.create(
prompt=prompt,
n=1,
size="256x256"
)
return response['data'][0]['url']
examples = [
["きのこの山"],
["たけのこの里"],
]
demo = gr.Interface(
fn=generate,
inputs=gr.components.Textbox(lines=5, label="Prompt"),
outputs=gr.components.Image(type="filepath", label="Generated Image"),
flagging_options=[],
examples=examples
)
demo.launch(share=False, auth=(app_username, app_password)) |