Spaces:
Running
on
Zero
Running
on
Zero
Commit
•
6de6264
1
Parent(s):
93ef6a5
Update app.py
Browse files
app.py
CHANGED
@@ -313,13 +313,16 @@ def shuffle_gallery(sdxl_loras):
|
|
313 |
random.shuffle(sdxl_loras)
|
314 |
return [(item["image"], item["title"]) for item in sdxl_loras], sdxl_loras
|
315 |
|
|
|
|
|
|
|
|
|
316 |
def swap_gallery(order, sdxl_loras):
|
317 |
if(order == "random"):
|
318 |
return shuffle_gallery(sdxl_loras)
|
319 |
else:
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
def deselect():
|
324 |
return gr.Gallery(selected_index=None)
|
325 |
|
@@ -335,7 +338,7 @@ with gr.Blocks(css="custom.css") as demo:
|
|
335 |
with gr.Group(elem_id="gallery_box"):
|
336 |
photo = gr.Image(label="Upload a picture of yourself", interactive=True, type="pil", height=300)
|
337 |
selected_loras = gr.Gallery(label="Selected LoRAs", height=80, show_share_button=False, visible=False, elem_id="gallery_selected", )
|
338 |
-
order_gallery = gr.Radio(choices=["random", "likes"], value="random", label="Order by", elem_id="order_radio")
|
339 |
#new_gallery = gr.Gallery(
|
340 |
# label="New LoRAs",
|
341 |
# elem_id="gallery_new",
|
@@ -348,8 +351,9 @@ with gr.Blocks(css="custom.css") as demo:
|
|
348 |
columns=4,
|
349 |
elem_id="gallery",
|
350 |
show_share_button=False,
|
351 |
-
height=
|
352 |
)
|
|
|
353 |
with gr.Column(scale=5):
|
354 |
with gr.Row():
|
355 |
prompt = gr.Textbox(label="Prompt", show_label=False, lines=1, max_lines=1, info="Describe your subject (optional)", value="A person", elem_id="prompt")
|
@@ -373,12 +377,12 @@ with gr.Blocks(css="custom.css") as demo:
|
|
373 |
visible=True,
|
374 |
elem_id="selected_lora",
|
375 |
)
|
376 |
-
order_gallery.change(
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
)
|
382 |
gallery.select(
|
383 |
fn=update_selection,
|
384 |
inputs=[gr_sdxl_loras, face_strength, image_strength, weight, depth_control_scale, negative],
|
@@ -414,6 +418,6 @@ with gr.Blocks(css="custom.css") as demo:
|
|
414 |
outputs=[result, share_group],
|
415 |
)
|
416 |
share_button.click(None, [], [], js=share_js)
|
417 |
-
demo.load(fn=
|
418 |
demo.queue(max_size=20)
|
419 |
demo.launch(share=True)
|
|
|
313 |
random.shuffle(sdxl_loras)
|
314 |
return [(item["image"], item["title"]) for item in sdxl_loras], sdxl_loras
|
315 |
|
316 |
+
def classify_gallery(sdxl_loras):
|
317 |
+
sorted_gallery = sorted(sdxl_loras, key=lambda x: x.get("likes", 0), reverse=True)
|
318 |
+
return [(item["image"], item["title"]) for item in sorted_gallery], sorted_gallery
|
319 |
+
|
320 |
def swap_gallery(order, sdxl_loras):
|
321 |
if(order == "random"):
|
322 |
return shuffle_gallery(sdxl_loras)
|
323 |
else:
|
324 |
+
return classify_gallery(sdxl_loras)
|
325 |
+
|
|
|
326 |
def deselect():
|
327 |
return gr.Gallery(selected_index=None)
|
328 |
|
|
|
338 |
with gr.Group(elem_id="gallery_box"):
|
339 |
photo = gr.Image(label="Upload a picture of yourself", interactive=True, type="pil", height=300)
|
340 |
selected_loras = gr.Gallery(label="Selected LoRAs", height=80, show_share_button=False, visible=False, elem_id="gallery_selected", )
|
341 |
+
#order_gallery = gr.Radio(choices=["random", "likes"], value="random", label="Order by", elem_id="order_radio")
|
342 |
#new_gallery = gr.Gallery(
|
343 |
# label="New LoRAs",
|
344 |
# elem_id="gallery_new",
|
|
|
351 |
columns=4,
|
352 |
elem_id="gallery",
|
353 |
show_share_button=False,
|
354 |
+
height=450
|
355 |
)
|
356 |
+
custom_model = gr.Textbox(label="Enter a custom Hugging Face or CivitAI SDXL LoRA", disabled=True, info="Coming soon...")
|
357 |
with gr.Column(scale=5):
|
358 |
with gr.Row():
|
359 |
prompt = gr.Textbox(label="Prompt", show_label=False, lines=1, max_lines=1, info="Describe your subject (optional)", value="A person", elem_id="prompt")
|
|
|
377 |
visible=True,
|
378 |
elem_id="selected_lora",
|
379 |
)
|
380 |
+
#order_gallery.change(
|
381 |
+
# fn=swap_gallery,
|
382 |
+
# inputs=[order_gallery, gr_sdxl_loras],
|
383 |
+
# outputs=[gallery, gr_sdxl_loras],
|
384 |
+
# queue=False
|
385 |
+
#)
|
386 |
gallery.select(
|
387 |
fn=update_selection,
|
388 |
inputs=[gr_sdxl_loras, face_strength, image_strength, weight, depth_control_scale, negative],
|
|
|
418 |
outputs=[result, share_group],
|
419 |
)
|
420 |
share_button.click(None, [], [], js=share_js)
|
421 |
+
demo.load(fn=classify_gallery, inputs=[gr_sdxl_loras], outputs=[gallery, gr_sdxl_loras], queue=False, js=js)
|
422 |
demo.queue(max_size=20)
|
423 |
demo.launch(share=True)
|