Update app.py
Browse files
app.py
CHANGED
|
@@ -8,6 +8,9 @@ def generate_image(prompt, api_key, request_url):
|
|
| 8 |
}
|
| 9 |
data = {
|
| 10 |
"prompt": prompt,
|
|
|
|
|
|
|
|
|
|
| 11 |
"num_images": 1,
|
| 12 |
}
|
| 13 |
response = requests.post(request_url, headers=headers, json=data)
|
|
@@ -25,13 +28,13 @@ footer {visibility: hidden !important;}
|
|
| 25 |
# Create the interface using Gradio
|
| 26 |
with gr.Blocks(css=css, theme='YTheme/Sketch') as demo:
|
| 27 |
with gr.Row():
|
| 28 |
-
gr.Markdown("
|
| 29 |
-
gr.Markdown("
|
| 30 |
with gr.Row():
|
| 31 |
api_key_input = gr.Textbox(label="API Key", type="password")
|
| 32 |
request_url_input = gr.Textbox(label="Request URL", value="https://api.openai.com/v1/images/generations")
|
| 33 |
with gr.Row():
|
| 34 |
-
prompt_input = gr.Textbox(label="Image Description")
|
| 35 |
submit_btn = gr.Button("Generate Image", variant='primary')
|
| 36 |
image_output = gr.Image(label="Generated Image")
|
| 37 |
|
|
|
|
| 8 |
}
|
| 9 |
data = {
|
| 10 |
"prompt": prompt,
|
| 11 |
+
"model": "dall-e-3",
|
| 12 |
+
"quality": "hd",
|
| 13 |
+
"size":"1792x1024",
|
| 14 |
"num_images": 1,
|
| 15 |
}
|
| 16 |
response = requests.post(request_url, headers=headers, json=data)
|
|
|
|
| 28 |
# Create the interface using Gradio
|
| 29 |
with gr.Blocks(css=css, theme='YTheme/Sketch') as demo:
|
| 30 |
with gr.Row():
|
| 31 |
+
gr.Markdown("# <center> OpenAI dall-e-3 API with Gradio </center>")
|
| 32 |
+
gr.Markdown("This demo uses the OpenAI dall-e-3 API to generate an image from text. You get free session key from https://dongsiqie.me/sess")
|
| 33 |
with gr.Row():
|
| 34 |
api_key_input = gr.Textbox(label="API Key", type="password")
|
| 35 |
request_url_input = gr.Textbox(label="Request URL", value="https://api.openai.com/v1/images/generations")
|
| 36 |
with gr.Row():
|
| 37 |
+
prompt_input = gr.Textbox(label="Image Description",value="A furry, long-haired cat with distinctive orange and white stripes.")
|
| 38 |
submit_btn = gr.Button("Generate Image", variant='primary')
|
| 39 |
image_output = gr.Image(label="Generated Image")
|
| 40 |
|