dhanishetty commited on
Commit
599a9f1
1 Parent(s): b267289

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -21
app.py CHANGED
@@ -1,27 +1,27 @@
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
-
9
 
10
 
11
- def get_image(prompt ):
12
  response = client.images.generate(
13
- model="dall-e-3",
14
- prompt= prompt,
15
- size="1792x1024",
16
- quality="standard",
17
- n=1,
18
- )
19
-
20
-
21
-
22
-
23
- demo = gr.Interface(fn=get_image,
24
- inputs = [gr.Textbox(label="Enter the Prompt")],
25
- outputs = gr.Image(type='pil'), ).launch(debug='True')
 
 
 
26
 
27
 
 
1
+ from PIL import Image
2
+ import requests
 
3
  from openai import OpenAI
4
+ import gradio as gr
5
+ client = OpenAI(api_key= "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")
 
 
6
 
7
 
8
+ def get_image(prompt):
9
  response = client.images.generate(
10
+ model = "dall-e-3",
11
+ prompt = prompt,
12
+ size = "1024x1024",
13
+ n = 1
14
+ )
15
+ image_url = response.data[0].url
16
+ data = requests.get(image_url).content
17
+ f = open('img.jpg','wb')
18
+ f.write(data)
19
+ f.close()
20
+ img = Image.open('img.jpg')
21
+ return img
22
+
23
+
24
+
25
+ gr.Interface(fn=get_image,inputs = "textbox", outputs= gr.Image(type='pil')).launch()
26
 
27