Spaces:
Runtime error
Runtime error
remove unnecessary stuff, make stable diffusion the model in chooser
Browse files
app.py
CHANGED
@@ -13,7 +13,6 @@ from PIL import Image
|
|
13 |
|
14 |
# gradio / hf / image gen stuff
|
15 |
import gradio as gr
|
16 |
-
from openai import OpenAI
|
17 |
import replicate
|
18 |
from dotenv import load_dotenv
|
19 |
|
@@ -30,20 +29,16 @@ load_dotenv()
|
|
30 |
|
31 |
REPLICATE_API_TOKEN = os.getenv("REPLICATE_API_TOKEN")
|
32 |
|
33 |
-
openai_key = os.getenv("OPENAI_API_KEY")
|
34 |
pw_key = os.getenv("PW")
|
35 |
|
36 |
-
if openai_key == "<YOUR_OPENAI_API_KEY>":
|
37 |
-
openai_key = ""
|
38 |
-
|
39 |
if pw_key == "<YOUR_PW>":
|
40 |
pw_key = ""
|
41 |
|
42 |
if pw_key == "":
|
43 |
sys.exit("Please Provide A Password in the Environment Variables")
|
44 |
|
45 |
-
if
|
46 |
-
sys.exit("Please Provide Your
|
47 |
|
48 |
# Connect to MongoDB
|
49 |
uri = os.getenv("MONGO_URI")
|
@@ -144,14 +139,6 @@ def generate_images(prompts, pw, model):
|
|
144 |
#make a prompt with the challenge and text
|
145 |
prompt_w_challenge = f"{challenge}: {text}"
|
146 |
|
147 |
-
# response = openai_client.images.generate(
|
148 |
-
# prompt=prompt_w_challenge,
|
149 |
-
# model=model, # dall-e-2 or dall-e-3
|
150 |
-
# quality="standard", # standard or hd
|
151 |
-
# size="512x512" if model == "dall-e-2" else "1024x1024", # varies for dalle-2 and dalle-3
|
152 |
-
# n=1, # Number of images to generate
|
153 |
-
# )
|
154 |
-
|
155 |
# stable diffusion
|
156 |
response = replicate.run(
|
157 |
"stability-ai/stable-diffusion:ac732df83cea7fff18b8472768c88ad041fa750ff7682a21affe81863cbe77e4",
|
@@ -269,7 +256,7 @@ with gr.Blocks(css=css) as demo:
|
|
269 |
with gr.Column(scale=3):
|
270 |
text = gr.Textbox(label="What do you want to create?", placeholder="Enter your text and then click on the \"Image Generate\" button")
|
271 |
with gr.Column(scale=1):
|
272 |
-
model = gr.Dropdown(choices=["
|
273 |
with gr.Row():
|
274 |
btn = gr.Button("Generate Images")
|
275 |
|
|
|
13 |
|
14 |
# gradio / hf / image gen stuff
|
15 |
import gradio as gr
|
|
|
16 |
import replicate
|
17 |
from dotenv import load_dotenv
|
18 |
|
|
|
29 |
|
30 |
REPLICATE_API_TOKEN = os.getenv("REPLICATE_API_TOKEN")
|
31 |
|
|
|
32 |
pw_key = os.getenv("PW")
|
33 |
|
|
|
|
|
|
|
34 |
if pw_key == "<YOUR_PW>":
|
35 |
pw_key = ""
|
36 |
|
37 |
if pw_key == "":
|
38 |
sys.exit("Please Provide A Password in the Environment Variables")
|
39 |
|
40 |
+
if REPLICATE_API_TOKEN == "":
|
41 |
+
sys.exit("Please Provide Your API Key")
|
42 |
|
43 |
# Connect to MongoDB
|
44 |
uri = os.getenv("MONGO_URI")
|
|
|
139 |
#make a prompt with the challenge and text
|
140 |
prompt_w_challenge = f"{challenge}: {text}"
|
141 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
# stable diffusion
|
143 |
response = replicate.run(
|
144 |
"stability-ai/stable-diffusion:ac732df83cea7fff18b8472768c88ad041fa750ff7682a21affe81863cbe77e4",
|
|
|
256 |
with gr.Column(scale=3):
|
257 |
text = gr.Textbox(label="What do you want to create?", placeholder="Enter your text and then click on the \"Image Generate\" button")
|
258 |
with gr.Column(scale=1):
|
259 |
+
model = gr.Dropdown(choices=["stable-diffusion"], label="Model", value="stable-diffusion")
|
260 |
with gr.Row():
|
261 |
btn = gr.Button("Generate Images")
|
262 |
|