Spaces:
Runtime error
Runtime error
Commit
·
9101835
1
Parent(s):
a528ac3
Update app.py
Browse files
app.py
CHANGED
@@ -47,14 +47,141 @@ def infer(prompt, api_key):
|
|
47 |
if artifact.type == generation.ARTIFACT_IMAGE:
|
48 |
img = Image.open(io.BytesIO(artifact.binary))
|
49 |
|
50 |
-
return img
|
51 |
|
52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
gr.Markdown("# Stable Diffusion XL")
|
54 |
#gr.Markdown('<p> For faster inference without waiting in queue, you may duplicate the space and upgrade to GPU in settings. <a href="https://huggingface.co/spaces/RamAnanth1/stable-diffusion-xl?duplicate=true"><img style="display: inline; margin-top: 0em; margin-bottom: 0em" src="https://bit.ly/3gLdBN6" alt="Duplicate Space" /></a></p>')
|
55 |
api_key_input = gr.Textbox(type = "password", label = "Enter your StabilityAI API key here")
|
56 |
-
|
57 |
-
|
|
|
|
|
|
|
58 |
max_lines=1,
|
59 |
placeholder="Enter your prompt",
|
60 |
elem_id="prompt-text-input",
|
@@ -63,7 +190,7 @@ with gr.Blocks(theme = theme) as demo:
|
|
63 |
rounded=(True, False, False, True),
|
64 |
container=False,
|
65 |
)
|
66 |
-
|
67 |
margin=False,
|
68 |
rounded=(False, True, True, False),
|
69 |
full_width=False,
|
@@ -75,6 +202,6 @@ with gr.Blocks(theme = theme) as demo:
|
|
75 |
|
76 |
btn.click(infer, inputs=[text, api_key_input], outputs=[gallery])
|
77 |
|
78 |
-
|
79 |
|
80 |
demo.launch()
|
|
|
47 |
if artifact.type == generation.ARTIFACT_IMAGE:
|
48 |
img = Image.open(io.BytesIO(artifact.binary))
|
49 |
|
50 |
+
return [img]
|
51 |
|
52 |
+
css = """
|
53 |
+
.gradio-container {
|
54 |
+
font-family: 'IBM Plex Sans', sans-serif;
|
55 |
+
}
|
56 |
+
.gr-button {
|
57 |
+
color: white;
|
58 |
+
border-color: black;
|
59 |
+
background: black;
|
60 |
+
}
|
61 |
+
input[type='range'] {
|
62 |
+
accent-color: black;
|
63 |
+
}
|
64 |
+
.dark input[type='range'] {
|
65 |
+
accent-color: #dfdfdf;
|
66 |
+
}
|
67 |
+
.container {
|
68 |
+
max-width: 730px;
|
69 |
+
margin: auto;
|
70 |
+
padding-top: 1.5rem;
|
71 |
+
}
|
72 |
+
#gallery {
|
73 |
+
min-height: 22rem;
|
74 |
+
margin-bottom: 15px;
|
75 |
+
margin-left: auto;
|
76 |
+
margin-right: auto;
|
77 |
+
border-bottom-right-radius: .5rem !important;
|
78 |
+
border-bottom-left-radius: .5rem !important;
|
79 |
+
}
|
80 |
+
#gallery>div>.h-full {
|
81 |
+
min-height: 20rem;
|
82 |
+
}
|
83 |
+
.details:hover {
|
84 |
+
text-decoration: underline;
|
85 |
+
}
|
86 |
+
.gr-button {
|
87 |
+
white-space: nowrap;
|
88 |
+
}
|
89 |
+
.gr-button:focus {
|
90 |
+
border-color: rgb(147 197 253 / var(--tw-border-opacity));
|
91 |
+
outline: none;
|
92 |
+
box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);
|
93 |
+
--tw-border-opacity: 1;
|
94 |
+
--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
|
95 |
+
--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(3px var(--tw-ring-offset-width)) var(--tw-ring-color);
|
96 |
+
--tw-ring-color: rgb(191 219 254 / var(--tw-ring-opacity));
|
97 |
+
--tw-ring-opacity: .5;
|
98 |
+
}
|
99 |
+
#advanced-btn {
|
100 |
+
font-size: .7rem !important;
|
101 |
+
line-height: 19px;
|
102 |
+
margin-top: 12px;
|
103 |
+
margin-bottom: 12px;
|
104 |
+
padding: 2px 8px;
|
105 |
+
border-radius: 14px !important;
|
106 |
+
}
|
107 |
+
#advanced-options {
|
108 |
+
display: none;
|
109 |
+
margin-bottom: 20px;
|
110 |
+
}
|
111 |
+
.footer {
|
112 |
+
margin-bottom: 45px;
|
113 |
+
margin-top: 35px;
|
114 |
+
text-align: center;
|
115 |
+
border-bottom: 1px solid #e5e5e5;
|
116 |
+
}
|
117 |
+
.footer>p {
|
118 |
+
font-size: .8rem;
|
119 |
+
display: inline-block;
|
120 |
+
padding: 0 10px;
|
121 |
+
transform: translateY(10px);
|
122 |
+
background: white;
|
123 |
+
}
|
124 |
+
.dark .footer {
|
125 |
+
border-color: #303030;
|
126 |
+
}
|
127 |
+
.dark .footer>p {
|
128 |
+
background: #0b0f19;
|
129 |
+
}
|
130 |
+
.acknowledgments h4{
|
131 |
+
margin: 1.25em 0 .25em 0;
|
132 |
+
font-weight: bold;
|
133 |
+
font-size: 115%;
|
134 |
+
}
|
135 |
+
.animate-spin {
|
136 |
+
animation: spin 1s linear infinite;
|
137 |
+
}
|
138 |
+
@keyframes spin {
|
139 |
+
from {
|
140 |
+
transform: rotate(0deg);
|
141 |
+
}
|
142 |
+
to {
|
143 |
+
transform: rotate(360deg);
|
144 |
+
}
|
145 |
+
}
|
146 |
+
#share-btn-container {
|
147 |
+
display: flex; padding-left: 0.5rem !important; padding-right: 0.5rem !important; background-color: #000000; justify-content: center; align-items: center; border-radius: 9999px !important; width: 13rem;
|
148 |
+
margin-top: 10px;
|
149 |
+
margin-left: auto;
|
150 |
+
}
|
151 |
+
#share-btn {
|
152 |
+
all: initial; color: #ffffff;font-weight: 600; cursor:pointer; font-family: 'IBM Plex Sans', sans-serif; margin-left: 0.5rem !important; padding-top: 0.25rem !important; padding-bottom: 0.25rem !important;right:0;
|
153 |
+
}
|
154 |
+
#share-btn * {
|
155 |
+
all: unset;
|
156 |
+
}
|
157 |
+
#share-btn-container div:nth-child(-n+2){
|
158 |
+
width: auto !important;
|
159 |
+
min-height: 0px !important;
|
160 |
+
}
|
161 |
+
#share-btn-container .wrap {
|
162 |
+
display: none !important;
|
163 |
+
}
|
164 |
+
|
165 |
+
.gr-form{
|
166 |
+
flex: 1 1 50%; border-top-right-radius: 0; border-bottom-right-radius: 0;
|
167 |
+
}
|
168 |
+
#prompt-container{
|
169 |
+
gap: 0;
|
170 |
+
}
|
171 |
+
#prompt-text-input, #negative-prompt-text-input{padding: .45rem 0.625rem}
|
172 |
+
#component-16{border-top-width: 1px!important;margin-top: 1em}
|
173 |
+
.image_duplication{position: absolute; width: 100px; left: 50px}
|
174 |
+
"""
|
175 |
+
|
176 |
+
with gr.Blocks(theme = theme, css = css) as demo:
|
177 |
gr.Markdown("# Stable Diffusion XL")
|
178 |
#gr.Markdown('<p> For faster inference without waiting in queue, you may duplicate the space and upgrade to GPU in settings. <a href="https://huggingface.co/spaces/RamAnanth1/stable-diffusion-xl?duplicate=true"><img style="display: inline; margin-top: 0em; margin-bottom: 0em" src="https://bit.ly/3gLdBN6" alt="Duplicate Space" /></a></p>')
|
179 |
api_key_input = gr.Textbox(type = "password", label = "Enter your StabilityAI API key here")
|
180 |
+
with gr.Row(elem_id="prompt-container").style(mobile_collapse=False, equal_height=True):
|
181 |
+
with gr.Column():
|
182 |
+
text = gr.Textbox(
|
183 |
+
label="Enter your prompt",
|
184 |
+
show_label=False,
|
185 |
max_lines=1,
|
186 |
placeholder="Enter your prompt",
|
187 |
elem_id="prompt-text-input",
|
|
|
190 |
rounded=(True, False, False, True),
|
191 |
container=False,
|
192 |
)
|
193 |
+
btn = gr.Button("Generate image").style(
|
194 |
margin=False,
|
195 |
rounded=(False, True, True, False),
|
196 |
full_width=False,
|
|
|
202 |
|
203 |
btn.click(infer, inputs=[text, api_key_input], outputs=[gallery])
|
204 |
|
205 |
+
|
206 |
|
207 |
demo.launch()
|