Spaces:
Sleeping
Sleeping
dhanishetty
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,8 +1,29 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
|
5 |
|
6 |
demo = gr.Interface(fn=get_image,
|
7 |
-
inputs = [gr.Textbox(label="Enter
|
8 |
outputs = gr.Image(type='pil'), title = title, description = description).launch(debug='True')
|
|
|
1 |
+
import openai
|
2 |
import gradio as gr
|
3 |
|
4 |
+
from openai import OpenAI
|
5 |
+
client = OpenAI(api_key= "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")
|
6 |
+
|
7 |
+
|
8 |
+
title = "dall-e image generation"
|
9 |
+
description = "provide prompt to generate an image"
|
10 |
+
|
11 |
+
|
12 |
+
|
13 |
+
def get_image(prompt ):
|
14 |
+
try:
|
15 |
+
response = client.images.generate(
|
16 |
+
model="dall-e-3",
|
17 |
+
prompt= prompt,
|
18 |
+
size="1792x1024",
|
19 |
+
quality="standard",
|
20 |
+
n=1,
|
21 |
+
)
|
22 |
+
except Exception as e:
|
23 |
+
return f"An error occurred: {str(e)}"
|
24 |
|
25 |
|
26 |
|
27 |
demo = gr.Interface(fn=get_image,
|
28 |
+
inputs = [gr.Textbox(label="Enter the Prompt")],
|
29 |
outputs = gr.Image(type='pil'), title = title, description = description).launch(debug='True')
|