Spaces:
Running
Running
gunship999
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -125,12 +125,7 @@ def add_gallery(image, model_str, gallery):
|
|
125 |
return gallery
|
126 |
|
127 |
|
128 |
-
|
129 |
-
.gradio-container { max-width: 1200px; margin: 0 auto; !important; }
|
130 |
-
.output { width=112px; height=112px; max_width=112px; max_height=112px; !important; }
|
131 |
-
.gallery { min_width=512px; min_height=512px; max_height=512px; !important; }
|
132 |
-
.guide { text-align: center; !important; }
|
133 |
-
"""
|
134 |
|
135 |
js_func = """
|
136 |
function refresh() {
|
@@ -158,108 +153,108 @@ js_AutoSave="""
|
|
158 |
|
159 |
"""
|
160 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
161 |
with gr.Blocks(theme='NoCrypt/miku@>=1.2.2', fill_width=True, css=CSS) as demo:
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
#stop_button = gr.Button('Stop', variant='stop', interactive=False, scale=1)
|
183 |
-
#gen_button.click(lambda: gr.update(interactive=True), None, stop_button)
|
184 |
-
gr.Markdown("", elem_classes="guide")
|
185 |
-
|
186 |
-
with gr.Column(scale=1):
|
187 |
-
with gr.Group():
|
188 |
with gr.Row():
|
189 |
-
|
190 |
-
|
191 |
-
visible=True) for m in default_models]
|
192 |
-
current_models = [gr.Textbox(m, visible=False) for m in default_models]
|
193 |
-
|
194 |
-
with gr.Column(scale=2):
|
195 |
-
gallery = gr.Gallery(label="Output", show_download_button=True, elem_classes="gallery",
|
196 |
-
interactive=False, show_share_button=False, container=True, format="png",
|
197 |
-
preview=True, object_fit="cover", columns=2, rows=2)
|
198 |
-
|
199 |
-
for m, o in zip(current_models, output):
|
200 |
-
gen_event = gr.on(triggers=[gen_button.click, txt_input.submit], fn=gen_fn,
|
201 |
-
inputs=[m, txt_input, neg_input, height, width, steps, cfg, seed], outputs=[o],
|
202 |
-
concurrency_limit=None, queue=False) # Be sure to delete ", queue=False" when activating the stop button
|
203 |
-
o.change(add_gallery, [o, m, gallery], [gallery])
|
204 |
-
#stop_button.click(lambda: gr.update(interactive=False), None, stop_button, cancels=[gen_event])
|
205 |
-
|
206 |
-
with gr.Column(scale=4):
|
207 |
-
with gr.Accordion('Model selection'):
|
208 |
-
model_choice = gr.CheckboxGroup(models, label = f'Choose up to {int(num_models)} different models from the {len(models)} available!', value=default_models, interactive=True)
|
209 |
-
model_choice.change(update_imgbox, model_choice, output)
|
210 |
-
model_choice.change(extend_choices, model_choice, current_models)
|
211 |
-
random_button.click(random_choices, None, model_choice)
|
212 |
-
|
213 |
-
with gr.Tab('Single model'):
|
214 |
-
with gr.Column(scale=2):
|
215 |
-
model_choice2 = gr.Dropdown(models, label='Choose model', value=models[0])
|
216 |
-
with gr.Group():
|
217 |
-
# global preSetPrompt
|
218 |
-
# global negPreSetPrompt
|
219 |
-
txt_input2 = gr.Textbox(label='Your prompt:', value = preSetPrompt, lines=3, autofocus=1)
|
220 |
-
neg_input2 = gr.Textbox(label='Negative prompt:', value=negPreSetPrompt, lines=1)
|
221 |
-
with gr.Accordion("Advanced", open=False, visible=True):
|
222 |
-
with gr.Row():
|
223 |
-
width2 = gr.Slider(label="Width", info="If 0, the default value is used.", maximum=1216, step=32, value=0)
|
224 |
-
height2 = gr.Slider(label="Height", info="If 0, the default value is used.", maximum=1216, step=32, value=0)
|
225 |
-
with gr.Row():
|
226 |
-
steps2 = gr.Slider(label="Number of inference steps", info="If 0, the default value is used.", maximum=100, step=1, value=0)
|
227 |
-
cfg2 = gr.Slider(label="Guidance scale", info="If 0, the default value is used.", maximum=30.0, step=0.1, value=0)
|
228 |
-
seed2 = gr.Slider(label="Seed", info="Randomize Seed if -1.", minimum=-1, maximum=MAX_SEED, step=1, value=-1)
|
229 |
-
seed_rand2 = gr.Button("Randomize Seed", size="sm", variant="secondary")
|
230 |
-
seed_rand2.click(randomize_seed, None, [seed2], queue=False)
|
231 |
-
num_images = gr.Slider(1, max_images, value=max_images, step=1, label='Number of images')
|
232 |
-
with gr.Row():
|
233 |
-
gen_button2 = gr.Button('Let the machine halucinate', variant='primary', scale=2)
|
234 |
-
#stop_button2 = gr.Button('Stop', variant='stop', interactive=False, scale=1)
|
235 |
-
#gen_button2.click(lambda: gr.update(interactive=True), None, stop_button2)
|
236 |
-
|
237 |
-
with gr.Column(scale=1):
|
238 |
-
with gr.Group():
|
239 |
with gr.Row():
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
return gallery
|
126 |
|
127 |
|
128 |
+
|
|
|
|
|
|
|
|
|
|
|
129 |
|
130 |
js_func = """
|
131 |
function refresh() {
|
|
|
153 |
|
154 |
"""
|
155 |
|
156 |
+
|
157 |
+
CSS="""
|
158 |
+
.gradio-container { max-width: 1200px; margin: 0 auto; background: linear-gradient(to bottom, #1a1a1a, #2d2d2d); !important; }
|
159 |
+
.output {
|
160 |
+
width: 112px;
|
161 |
+
height: 112px;
|
162 |
+
border-radius: 10px;
|
163 |
+
box-shadow: 0 4px 8px rgba(0,0,0,0.2);
|
164 |
+
transition: transform 0.2s;
|
165 |
+
!important;
|
166 |
+
}
|
167 |
+
.output:hover {
|
168 |
+
transform: scale(1.05);
|
169 |
+
}
|
170 |
+
.gallery {
|
171 |
+
min-width: 512px;
|
172 |
+
min-height: 512px;
|
173 |
+
max-height: 512px;
|
174 |
+
border-radius: 15px;
|
175 |
+
box-shadow: 0 6px 12px rgba(0,0,0,0.3);
|
176 |
+
!important;
|
177 |
+
}
|
178 |
+
.guide { text-align: center; color: #e0e0e0; !important; }
|
179 |
+
.primary-btn {
|
180 |
+
background: linear-gradient(45deg, #4a90e2, #357abd);
|
181 |
+
border-radius: 8px;
|
182 |
+
transition: all 0.3s ease;
|
183 |
+
}
|
184 |
+
.primary-btn:hover {
|
185 |
+
transform: translateY(-2px);
|
186 |
+
box-shadow: 0 5px 15px rgba(74,144,226,0.3);
|
187 |
+
}
|
188 |
+
"""
|
189 |
+
|
190 |
with gr.Blocks(theme='NoCrypt/miku@>=1.2.2', fill_width=True, css=CSS) as demo:
|
191 |
+
gr.HTML("""<a href="https://visitorbadge.io/status?path=https%3A%2F%2Fgunship999-SexyImages.hf.space">
|
192 |
+
<img src="https://api.visitorbadge.io/api/visitors?path=https%3A%2F%2Fgunship999-SexyImages.hf.space&countColor=%23263759" />
|
193 |
+
</a>""")
|
194 |
+
|
195 |
+
with gr.Column(scale=2):
|
196 |
+
with gr.Group():
|
197 |
+
txt_input = gr.Textbox(
|
198 |
+
label='Your prompt:',
|
199 |
+
value=preSetPrompt,
|
200 |
+
lines=3,
|
201 |
+
autofocus=1,
|
202 |
+
container=False,
|
203 |
+
elem_classes="modern-input"
|
204 |
+
)
|
205 |
+
neg_input = gr.Textbox(
|
206 |
+
label='Negative prompt:',
|
207 |
+
value=negPreSetPrompt,
|
208 |
+
lines=1
|
209 |
+
)
|
210 |
+
with gr.Accordion("Advanced Settings", open=False):
|
|
|
|
|
|
|
|
|
|
|
|
|
211 |
with gr.Row():
|
212 |
+
width = gr.Slider(label="Width", maximum=1216, step=32, value=0)
|
213 |
+
height = gr.Slider(label="Height", maximum=1216, step=32, value=0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
214 |
with gr.Row():
|
215 |
+
steps = gr.Slider(label="Steps", maximum=100, step=1, value=0)
|
216 |
+
cfg = gr.Slider(label="Guidance Scale", maximum=30.0, step=0.1, value=0)
|
217 |
+
seed = gr.Slider(label="Seed", minimum=-1, maximum=MAX_SEED, step=1, value=-1)
|
218 |
+
seed_rand = gr.Button("🎲", size="sm", elem_classes="primary-btn")
|
219 |
+
seed_rand.click(randomize_seed, None, [seed], queue=False)
|
220 |
+
|
221 |
+
with gr.Row():
|
222 |
+
gen_button = gr.Button(
|
223 |
+
f'Generate {int(num_models)} Images',
|
224 |
+
variant='primary',
|
225 |
+
scale=3,
|
226 |
+
elem_classes="primary-btn"
|
227 |
+
)
|
228 |
+
random_button = gr.Button(
|
229 |
+
'Randomize Models',
|
230 |
+
variant='secondary',
|
231 |
+
scale=1
|
232 |
+
)
|
233 |
+
|
234 |
+
with gr.Column(scale=1):
|
235 |
+
with gr.Group():
|
236 |
+
with gr.Row():
|
237 |
+
output = [gr.Image(label=m, show_download_button=True,
|
238 |
+
elem_classes="output",
|
239 |
+
interactive=False, width=112, height=112,
|
240 |
+
show_share_button=False, format="png",
|
241 |
+
visible=True) for m in default_models]
|
242 |
+
current_models = [gr.Textbox(m, visible=False)
|
243 |
+
for m in default_models]
|
244 |
+
|
245 |
+
with gr.Column(scale=2):
|
246 |
+
gallery = gr.Gallery(
|
247 |
+
label="Generated Images",
|
248 |
+
show_download_button=True,
|
249 |
+
elem_classes="gallery",
|
250 |
+
interactive=False,
|
251 |
+
show_share_button=False,
|
252 |
+
container=True,
|
253 |
+
format="png",
|
254 |
+
preview=True,
|
255 |
+
object_fit="cover",
|
256 |
+
columns=2,
|
257 |
+
rows=2
|
258 |
+
)
|
259 |
+
|
260 |
+
demo.launch(show_api=False, max_threads=400)
|