Spaces:
Runtime error
Runtime error
Commit
•
deace36
1
Parent(s):
2514b67
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,9 @@
|
|
1 |
import os
|
2 |
import gradio as gr
|
3 |
import openai
|
|
|
|
|
|
|
4 |
|
5 |
openai.api_key = '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' # your api key
|
6 |
openai.Model.list()
|
@@ -15,7 +18,12 @@ def DALLE(user_input):
|
|
15 |
size="1024x1024"
|
16 |
)
|
17 |
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
iface = gr.Interface(fn=DALLE, inputs="text", outputs="image", title="bhAI")
|
21 |
-
iface.launch()
|
|
|
1 |
import os
|
2 |
import gradio as gr
|
3 |
import openai
|
4 |
+
from PIL import Image
|
5 |
+
import io
|
6 |
+
import numpy as np
|
7 |
|
8 |
openai.api_key = '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' # your api key
|
9 |
openai.Model.list()
|
|
|
18 |
size="1024x1024"
|
19 |
)
|
20 |
|
21 |
+
# Convert the OpenAI output to an image format that Gradio can recognize
|
22 |
+
img_bytes = io.BytesIO(DALLE_reply.get()['data'])
|
23 |
+
img = Image.open(img_bytes)
|
24 |
+
img_arr = np.array(img)
|
25 |
+
|
26 |
+
return img_arr
|
27 |
|
28 |
iface = gr.Interface(fn=DALLE, inputs="text", outputs="image", title="bhAI")
|
29 |
+
iface.launch()
|