Spaces:
Sleeping
Sleeping
first commit
Browse files- README.md +5 -5
- app.py +62 -0
- gitattributes +35 -0
- requirements.txt +3 -0
README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: gradio
|
7 |
-
sdk_version:
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
---
|
|
|
1 |
---
|
2 |
+
title: Sdxl Demo
|
3 |
+
emoji: π
|
4 |
+
colorFrom: blue
|
5 |
+
colorTo: gray
|
6 |
sdk: gradio
|
7 |
+
sdk_version: 3.47.1
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
---
|
app.py
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import numpy as np
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
import os
|
5 |
+
from io import BytesIO
|
6 |
+
|
7 |
+
import gradio as gr
|
8 |
+
import numpy as np
|
9 |
+
import replicate
|
10 |
+
import requests
|
11 |
+
from PIL import Image
|
12 |
+
|
13 |
+
|
14 |
+
def generate(prompt: str, secret_key: str, steps: int = 25, seed: int = -1):
|
15 |
+
"""
|
16 |
+
γγγ³γγγγηζη»ε(PIL.Image.open)γεεΎ
|
17 |
+
"""
|
18 |
+
if secret_key == os.environ["SECRET_KEY"]:
|
19 |
+
output = replicate.run(
|
20 |
+
"stability-ai/sdxl:2b017d9b67edd2ee1401238df49d75da53c523f36e363881e057f5dc3ed3c5b2",
|
21 |
+
input={"prompt": prompt,
|
22 |
+
"seed": seed if seed != -1 else np.random.randint(1, 1001),
|
23 |
+
"num_inference_steps": steps},
|
24 |
+
)
|
25 |
+
# γͺγ³γ―εεΎ
|
26 |
+
png_link = output[0]
|
27 |
+
# PNGγγ‘γ€γ«γγͺγ³γ―γγεεΎ
|
28 |
+
response = requests.get(png_link)
|
29 |
+
# γ€γ‘γΌγΈγγ‘γ’γͺδΈγ«ιγ
|
30 |
+
img = Image.open(BytesIO(response.content))
|
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 |
+
["photo of a rhino dressed suit and tie sitting at a table in a bar with a bar stools, award winning photography."],
|
42 |
+
["a giant monster hybrid of dragon and spider, in dark dense foggy forest"],
|
43 |
+
["a man in a space suit playing a piano, highly detailed illustration, full color illustration, very detailed illustration"],
|
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 |
+
gr_steps = gr.Number(label='steps', value=default_steps)
|
54 |
+
gr_seed = gr.Number(label='seed', value=-1)
|
55 |
+
with gr.Column(scale=1, min_width=600):
|
56 |
+
gr_image = gr.Image()
|
57 |
+
# examples=examples
|
58 |
+
gr_generate_button.click(generate, inputs=[gr_prompt, gr_password, gr_steps, gr_seed], outputs=[gr_image])
|
59 |
+
with gr.Row():
|
60 |
+
gr.Examples(examples, inputs=[gr_prompt])
|
61 |
+
|
62 |
+
demo.launch()
|
gitattributes
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
replicate==0.10.0
|
2 |
+
gradio==3.39.0
|
3 |
+
numpy==1.22.4
|