Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from openai import OpenAI
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
def generate_images(token, size, quality, style, prompt):
|
| 6 |
+
client = OpenAI(api_key= token, base_url= "https://zukijourney.xyzbot.net/v1")
|
| 7 |
+
response = client.images.generate(prompt=prompt, model = 'dall-e-3', n=1, quality=quality, size=size, style=style)
|
| 8 |
+
return response.data[0].url
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
with gr.Blocks(analytics_enabled=False) as demo:
|
| 12 |
+
gr.Markdown("Generate images using OpenAI's API")
|
| 13 |
+
with gr.Row():
|
| 14 |
+
token_input = gr.Textbox(label="API Token", placeholder="Enter your OpenAI API token here")
|
| 15 |
+
size_input = gr.Radio(choices=["1024x1024", "1792x1024", "1024x1792"], label="Image Size", value="1024x1024")
|
| 16 |
+
quality_input = gr.Radio(choices=["standard", "hd"], label="Quality", value="standard")
|
| 17 |
+
style_input = gr.Radio(choices=["vivid", "natural"], label="Style", value="vivid")
|
| 18 |
+
prompt_input = gr.Textbox(label="Prompt", placeholder="Enter a prompt for the image generation")
|
| 19 |
+
submit_button = gr.Button("Generate")
|
| 20 |
+
output_images = gr.Gallery(label="Generated Images")
|
| 21 |
+
|
| 22 |
+
submit_button.click(
|
| 23 |
+
generate_images,
|
| 24 |
+
inputs=[token_input, size_input, quality_input, style_input, prompt_input],
|
| 25 |
+
outputs=output_images
|
| 26 |
+
)
|
| 27 |
+
|
| 28 |
+
demo.launch()
|