Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
import gradio as gr
|
2 |
from openai import OpenAI
|
3 |
-
import os
|
4 |
import httpx
|
5 |
|
6 |
# List of popular styles
|
@@ -48,6 +47,12 @@ def generate_image(api_key, prompt, style, negative_prompt):
|
|
48 |
|
49 |
return response.data[0].url, enhanced_prompt
|
50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
with gr.Blocks() as demo:
|
52 |
gr.Markdown("# DALL-E 3 Image Generator")
|
53 |
|
@@ -64,7 +69,7 @@ with gr.Blocks() as demo:
|
|
64 |
enhanced_prompt_output = gr.Textbox(label="Enhanced Prompt")
|
65 |
|
66 |
generate_btn.click(
|
67 |
-
|
68 |
inputs=[api_key, prompt, style, negative_prompt],
|
69 |
outputs=[image_output, enhanced_prompt_output]
|
70 |
)
|
|
|
1 |
import gradio as gr
|
2 |
from openai import OpenAI
|
|
|
3 |
import httpx
|
4 |
|
5 |
# List of popular styles
|
|
|
47 |
|
48 |
return response.data[0].url, enhanced_prompt
|
49 |
|
50 |
+
def process_and_generate(api_key, prompt, style, negative_prompt):
|
51 |
+
client = OpenAI(api_key=api_key, http_client=httpx.Client())
|
52 |
+
enhanced_prompt = enhance_prompt(client, prompt, style)
|
53 |
+
image_url, _ = generate_image(api_key, enhanced_prompt, style, negative_prompt)
|
54 |
+
return image_url, enhanced_prompt
|
55 |
+
|
56 |
with gr.Blocks() as demo:
|
57 |
gr.Markdown("# DALL-E 3 Image Generator")
|
58 |
|
|
|
69 |
enhanced_prompt_output = gr.Textbox(label="Enhanced Prompt")
|
70 |
|
71 |
generate_btn.click(
|
72 |
+
process_and_generate,
|
73 |
inputs=[api_key, prompt, style, negative_prompt],
|
74 |
outputs=[image_output, enhanced_prompt_output]
|
75 |
)
|