Sean Laurent commited on
Commit ·
0d07e38
1
Parent(s): d2790f2
Update app.py
Browse files- app.py +18 -3
- requirements.txt +2 -0
app.py
CHANGED
|
@@ -1,7 +1,22 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
iface.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import openai
|
| 3 |
+
import os
|
| 4 |
|
| 5 |
+
#Big Web Lab's API Key
|
| 6 |
+
openai.api_key = os.environ.get("OPENAI_API_KEY")
|
| 7 |
|
| 8 |
+
# Dalle API
|
| 9 |
+
def open_ai_txt2img(prompt):
|
| 10 |
+
response = openai.Image.create(
|
| 11 |
+
prompt=prompt,
|
| 12 |
+
size="1024x1024",
|
| 13 |
+
)
|
| 14 |
+
print("Response:", response)
|
| 15 |
+
return response["data"][0]["url"]
|
| 16 |
+
|
| 17 |
+
# Gradio Interface
|
| 18 |
+
def generator(prompt):
|
| 19 |
+
return open_ai_txt2img(prompt)
|
| 20 |
+
|
| 21 |
+
iface = gr.Interface(fn=generator, inputs="text", outputs="image")
|
| 22 |
iface.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio==3.27.0
|
| 2 |
+
openai==0.27.4
|