Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -236,11 +236,16 @@ def selected_payload(selected_repo: str):
|
|
| 236 |
gr.update(value=1.0),
|
| 237 |
)
|
| 238 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 239 |
def refresh_lora_selector(family: str, search: str):
|
| 240 |
filtered = filter_loras(family, search)
|
| 241 |
-
|
| 242 |
-
selected_repo = filtered[0]["repo"] if filtered else None
|
| 243 |
count_text = f"**{len(filtered)}** LoRAs · {family_to_label(family)}"
|
|
|
|
| 244 |
|
| 245 |
(
|
| 246 |
preview_update,
|
|
@@ -253,10 +258,10 @@ def refresh_lora_selector(family: str, search: str):
|
|
| 253 |
height_update,
|
| 254 |
scheduler_update,
|
| 255 |
lora_scale_update,
|
| 256 |
-
) = selected_payload(
|
| 257 |
|
| 258 |
return (
|
| 259 |
-
gr.update(
|
| 260 |
count_text,
|
| 261 |
preview_update,
|
| 262 |
info_update,
|
|
@@ -270,6 +275,14 @@ def refresh_lora_selector(family: str, search: str):
|
|
| 270 |
lora_scale_update,
|
| 271 |
)
|
| 272 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 273 |
CURRENT_PIPE: DiffusionPipeline | None = None
|
| 274 |
CURRENT_BASE_MODEL = ""
|
| 275 |
CURRENT_LOADED_REPO = ""
|
|
@@ -703,6 +716,64 @@ textarea:focus, input[type="text"]:focus, .gr-input:focus {
|
|
| 703 |
font-family: 'Syne', sans-serif;
|
| 704 |
}
|
| 705 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 706 |
/* ── Scrollbar ── */
|
| 707 |
::-webkit-scrollbar { width: 6px; }
|
| 708 |
::-webkit-scrollbar-track { background: var(--surface); }
|
|
@@ -767,12 +838,16 @@ with gr.Blocks() as app:
|
|
| 767 |
elem_classes=["count-badge"],
|
| 768 |
)
|
| 769 |
gr.HTML('<div style="height:6px"></div>')
|
| 770 |
-
|
| 771 |
label="",
|
| 772 |
-
|
| 773 |
-
|
| 774 |
-
|
|
|
|
|
|
|
|
|
|
| 775 |
container=False,
|
|
|
|
| 776 |
)
|
| 777 |
|
| 778 |
gr.HTML('<div style="height:20px"></div>')
|
|
@@ -845,7 +920,7 @@ with gr.Blocks() as app:
|
|
| 845 |
)
|
| 846 |
|
| 847 |
_selector_outputs = [
|
| 848 |
-
|
| 849 |
catalog_stats,
|
| 850 |
lora_preview,
|
| 851 |
selected_info,
|
|
@@ -872,10 +947,12 @@ with gr.Blocks() as app:
|
|
| 872 |
lora_scale,
|
| 873 |
]
|
| 874 |
|
|
|
|
|
|
|
| 875 |
family_filter.change(fn=refresh_lora_selector, inputs=[family_filter, search_box], outputs=_selector_outputs)
|
| 876 |
search_box.change(fn=refresh_lora_selector, inputs=[family_filter, search_box], outputs=_selector_outputs)
|
| 877 |
-
|
| 878 |
-
app.load(fn=
|
| 879 |
|
| 880 |
generate_button.click(
|
| 881 |
fn=run_lora,
|
|
@@ -883,5 +960,6 @@ with gr.Blocks() as app:
|
|
| 883 |
outputs=[result],
|
| 884 |
)
|
| 885 |
|
|
|
|
| 886 |
app.queue(max_size=20)
|
| 887 |
app.launch(theme=gr.themes.Base(), css=CSS)
|
|
|
|
| 236 |
gr.update(value=1.0),
|
| 237 |
)
|
| 238 |
|
| 239 |
+
|
| 240 |
+
def build_gallery_items(filtered: list[dict[str, Any]]) -> list[tuple[str, str]]:
|
| 241 |
+
return [(cover_for_entry(item), item["repo"]) for item in filtered]
|
| 242 |
+
|
| 243 |
+
|
| 244 |
def refresh_lora_selector(family: str, search: str):
|
| 245 |
filtered = filter_loras(family, search)
|
| 246 |
+
first_repo = filtered[0]["repo"] if filtered else None
|
|
|
|
| 247 |
count_text = f"**{len(filtered)}** LoRAs · {family_to_label(family)}"
|
| 248 |
+
gallery_items = build_gallery_items(filtered)
|
| 249 |
|
| 250 |
(
|
| 251 |
preview_update,
|
|
|
|
| 258 |
height_update,
|
| 259 |
scheduler_update,
|
| 260 |
lora_scale_update,
|
| 261 |
+
) = selected_payload(first_repo)
|
| 262 |
|
| 263 |
return (
|
| 264 |
+
gr.update(value=gallery_items),
|
| 265 |
count_text,
|
| 266 |
preview_update,
|
| 267 |
info_update,
|
|
|
|
| 275 |
lora_scale_update,
|
| 276 |
)
|
| 277 |
|
| 278 |
+
|
| 279 |
+
def on_gallery_select(evt: gr.SelectData, family: str, search: str):
|
| 280 |
+
filtered = filter_loras(family, search)
|
| 281 |
+
if evt.index >= len(filtered):
|
| 282 |
+
return (gr.update(),) * 10
|
| 283 |
+
repo = filtered[evt.index]["repo"]
|
| 284 |
+
return selected_payload(repo)
|
| 285 |
+
|
| 286 |
CURRENT_PIPE: DiffusionPipeline | None = None
|
| 287 |
CURRENT_BASE_MODEL = ""
|
| 288 |
CURRENT_LOADED_REPO = ""
|
|
|
|
| 716 |
font-family: 'Syne', sans-serif;
|
| 717 |
}
|
| 718 |
|
| 719 |
+
|
| 720 |
+
.lora-gallery {
|
| 721 |
+
border-radius: var(--radius) !important;
|
| 722 |
+
overflow: hidden !important;
|
| 723 |
+
}
|
| 724 |
+
|
| 725 |
+
.lora-gallery .grid-wrap {
|
| 726 |
+
background: var(--surface) !important;
|
| 727 |
+
border: 1px solid var(--border) !important;
|
| 728 |
+
border-radius: var(--radius) !important;
|
| 729 |
+
padding: 8px !important;
|
| 730 |
+
gap: 8px !important;
|
| 731 |
+
}
|
| 732 |
+
|
| 733 |
+
.lora-gallery .thumbnail-item {
|
| 734 |
+
border-radius: 10px !important;
|
| 735 |
+
overflow: hidden !important;
|
| 736 |
+
border: 2px solid transparent !important;
|
| 737 |
+
cursor: pointer !important;
|
| 738 |
+
transition: border-color 0.18s, transform 0.18s, box-shadow 0.18s !important;
|
| 739 |
+
position: relative;
|
| 740 |
+
}
|
| 741 |
+
|
| 742 |
+
.lora-gallery .thumbnail-item:hover {
|
| 743 |
+
border-color: var(--accent) !important;
|
| 744 |
+
transform: scale(1.03) !important;
|
| 745 |
+
box-shadow: 0 4px 20px rgba(124,111,255,0.4) !important;
|
| 746 |
+
z-index: 2;
|
| 747 |
+
}
|
| 748 |
+
|
| 749 |
+
.lora-gallery .thumbnail-item.selected {
|
| 750 |
+
border-color: var(--accent2) !important;
|
| 751 |
+
box-shadow: 0 0 0 3px rgba(255,111,216,0.3) !important;
|
| 752 |
+
}
|
| 753 |
+
|
| 754 |
+
.lora-gallery .thumbnail-item img {
|
| 755 |
+
object-fit: cover !important;
|
| 756 |
+
width: 100% !important;
|
| 757 |
+
height: 100% !important;
|
| 758 |
+
display: block !important;
|
| 759 |
+
}
|
| 760 |
+
|
| 761 |
+
.lora-gallery .caption-label {
|
| 762 |
+
position: absolute !important;
|
| 763 |
+
bottom: 0 !important;
|
| 764 |
+
left: 0 !important;
|
| 765 |
+
right: 0 !important;
|
| 766 |
+
background: linear-gradient(transparent, rgba(0,0,0,0.85)) !important;
|
| 767 |
+
color: #fff !important;
|
| 768 |
+
font-size: 0.72rem !important;
|
| 769 |
+
font-family: 'DM Sans', sans-serif !important;
|
| 770 |
+
padding: 18px 8px 6px !important;
|
| 771 |
+
text-align: center !important;
|
| 772 |
+
white-space: nowrap !important;
|
| 773 |
+
overflow: hidden !important;
|
| 774 |
+
text-overflow: ellipsis !important;
|
| 775 |
+
}
|
| 776 |
+
|
| 777 |
/* ── Scrollbar ── */
|
| 778 |
::-webkit-scrollbar { width: 6px; }
|
| 779 |
::-webkit-scrollbar-track { background: var(--surface); }
|
|
|
|
| 838 |
elem_classes=["count-badge"],
|
| 839 |
)
|
| 840 |
gr.HTML('<div style="height:6px"></div>')
|
| 841 |
+
lora_gallery = gr.Gallery(
|
| 842 |
label="",
|
| 843 |
+
value=build_gallery_items(INITIAL_FILTERED),
|
| 844 |
+
columns=2,
|
| 845 |
+
rows=4,
|
| 846 |
+
height=420,
|
| 847 |
+
object_fit="cover",
|
| 848 |
+
allow_preview=False,
|
| 849 |
container=False,
|
| 850 |
+
elem_classes=["lora-gallery"],
|
| 851 |
)
|
| 852 |
|
| 853 |
gr.HTML('<div style="height:20px"></div>')
|
|
|
|
| 920 |
)
|
| 921 |
|
| 922 |
_selector_outputs = [
|
| 923 |
+
lora_gallery,
|
| 924 |
catalog_stats,
|
| 925 |
lora_preview,
|
| 926 |
selected_info,
|
|
|
|
| 947 |
lora_scale,
|
| 948 |
]
|
| 949 |
|
| 950 |
+
_initial_payload = selected_payload(INITIAL_SELECTED)
|
| 951 |
+
|
| 952 |
family_filter.change(fn=refresh_lora_selector, inputs=[family_filter, search_box], outputs=_selector_outputs)
|
| 953 |
search_box.change(fn=refresh_lora_selector, inputs=[family_filter, search_box], outputs=_selector_outputs)
|
| 954 |
+
lora_gallery.select(fn=on_gallery_select, inputs=[family_filter, search_box], outputs=_payload_outputs)
|
| 955 |
+
app.load(fn=lambda: _initial_payload, outputs=_payload_outputs)
|
| 956 |
|
| 957 |
generate_button.click(
|
| 958 |
fn=run_lora,
|
|
|
|
| 960 |
outputs=[result],
|
| 961 |
)
|
| 962 |
|
| 963 |
+
|
| 964 |
app.queue(max_size=20)
|
| 965 |
app.launch(theme=gr.themes.Base(), css=CSS)
|