Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,3 @@
|
|
1 |
-
import numpy as np
|
2 |
-
import gradio as gr
|
3 |
-
|
4 |
import os
|
5 |
from io import BytesIO
|
6 |
|
@@ -10,17 +7,20 @@ import replicate
|
|
10 |
import requests
|
11 |
from PIL import Image
|
12 |
|
13 |
-
|
14 |
-
|
|
|
15 |
"""
|
16 |
γγγ³γγγγηζη»ε(PIL.Image.open)γεεΎ
|
17 |
"""
|
18 |
if secret_key == os.environ["SECRET_KEY"]:
|
19 |
output = replicate.run(
|
20 |
-
|
21 |
-
input={
|
22 |
-
|
23 |
-
|
|
|
|
|
24 |
)
|
25 |
# γͺγ³γ―εεΎ
|
26 |
png_link = output[0]
|
@@ -31,32 +31,42 @@ def generate(prompt: str, secret_key: str, steps: int = 25, seed: int = -1):
|
|
31 |
return img
|
32 |
|
33 |
|
34 |
-
|
35 |
-
default_steps = 25
|
36 |
examples = [
|
|
|
|
|
|
|
|
|
37 |
# ["An astronaut riding a rainbow unicorn, cinematic, dramatic", ""],
|
38 |
# ["A robot painted as graffiti on a brick wall. a sidewalk is in front of the wall, and grass is growing out of cracks in the concrete.", ""],
|
39 |
# ["Panda mad scientist mixing sparkling chemicals, artstation.", ""],
|
40 |
-
["An astronaut riding a rainbow unicorn, cinematic, dramatic"],
|
41 |
-
[
|
42 |
-
|
43 |
-
|
44 |
-
]
|
|
|
|
|
|
|
|
|
45 |
|
46 |
with gr.Blocks(title="Stable Diffusion XL (SDXL 1.0)") as demo:
|
47 |
with gr.Row():
|
48 |
with gr.Column(scale=1, min_width=600):
|
49 |
-
gr_prompt = gr.Textbox(label=
|
50 |
-
gr_password = gr.Textbox(label=
|
51 |
gr_generate_button = gr.Button("ηζ")
|
52 |
-
with gr.Accordion("advanced settings", open=False):
|
53 |
-
|
54 |
-
|
55 |
with gr.Column(scale=1, min_width=600):
|
56 |
gr_image = gr.Image()
|
57 |
# examples=examples
|
58 |
-
gr_generate_button.click(
|
|
|
|
|
|
|
|
|
59 |
with gr.Row():
|
60 |
-
gr.Examples(examples, inputs=[gr_prompt])
|
61 |
|
62 |
-
demo.launch()
|
|
|
|
|
|
|
|
|
1 |
import os
|
2 |
from io import BytesIO
|
3 |
|
|
|
7 |
import requests
|
8 |
from PIL import Image
|
9 |
|
10 |
+
model_id = "stability-ai/sdxl:2b017d9b67edd2ee1401238df49d75da53c523f36e363881e057f5dc3ed3c5b2"
|
11 |
+
default_steps = 25
|
12 |
+
def generate(prompt: str, secret_key: str):
|
13 |
"""
|
14 |
γγγ³γγγγηζη»ε(PIL.Image.open)γεεΎ
|
15 |
"""
|
16 |
if secret_key == os.environ["SECRET_KEY"]:
|
17 |
output = replicate.run(
|
18 |
+
model_id,
|
19 |
+
input={
|
20 |
+
"prompt": prompt,
|
21 |
+
"seed": -1,
|
22 |
+
"num_inference_steps": default_steps,
|
23 |
+
},
|
24 |
)
|
25 |
# γͺγ³γ―εεΎ
|
26 |
png_link = output[0]
|
|
|
31 |
return img
|
32 |
|
33 |
|
|
|
|
|
34 |
examples = [
|
35 |
+
["station"],
|
36 |
+
["station, ghibli style"],
|
37 |
+
["Elon Musk"],
|
38 |
+
["Elon Musk playing Shogi"],
|
39 |
# ["An astronaut riding a rainbow unicorn, cinematic, dramatic", ""],
|
40 |
# ["A robot painted as graffiti on a brick wall. a sidewalk is in front of the wall, and grass is growing out of cracks in the concrete.", ""],
|
41 |
# ["Panda mad scientist mixing sparkling chemicals, artstation.", ""],
|
42 |
+
# ["An astronaut riding a rainbow unicorn, cinematic, dramatic"],
|
43 |
+
# [
|
44 |
+
# "photo of a rhino dressed suit and tie sitting at a table in a bar with a bar stools, award winning photography."
|
45 |
+
# ],
|
46 |
+
# ["a giant monster hybrid of dragon and spider, in dark dense foggy forest"],
|
47 |
+
# [
|
48 |
+
# "a man in a space suit playing a piano, highly detailed illustration, full color illustration, very detailed illustration"
|
49 |
+
# ],
|
50 |
+
]
|
51 |
|
52 |
with gr.Blocks(title="Stable Diffusion XL (SDXL 1.0)") as demo:
|
53 |
with gr.Row():
|
54 |
with gr.Column(scale=1, min_width=600):
|
55 |
+
gr_prompt = gr.Textbox(label="γγγ³γγ")
|
56 |
+
gr_password = gr.Textbox(label="γγΉγ―γΌγ")
|
57 |
gr_generate_button = gr.Button("ηζ")
|
58 |
+
# with gr.Accordion("advanced settings", open=False):
|
59 |
+
# gr_steps = gr.Number(label="steps", value=default_steps)
|
60 |
+
# gr_seed = gr.Number(label="seed", value=-1)
|
61 |
with gr.Column(scale=1, min_width=600):
|
62 |
gr_image = gr.Image()
|
63 |
# examples=examples
|
64 |
+
gr_generate_button.click(
|
65 |
+
generate,
|
66 |
+
inputs=[gr_prompt, gr_password],
|
67 |
+
outputs=[gr_image],
|
68 |
+
)
|
69 |
with gr.Row():
|
70 |
+
gr.Examples(examples, inputs=[gr_prompt], label="γγγ³γγδΎ")
|
71 |
|
72 |
+
demo.launch()
|