Spaces:
Running
on
Zero
Running
on
Zero
Upload 4 files
Browse files- README.md +1 -1
- app.py +1 -1
- modutils.py +43 -23
README.md
CHANGED
@@ -4,7 +4,7 @@ emoji: 🏆😻
|
|
4 |
colorFrom: red
|
5 |
colorTo: pink
|
6 |
sdk: gradio
|
7 |
-
sdk_version: 5.
|
8 |
app_file: app.py
|
9 |
pinned: true
|
10 |
license: mit
|
|
|
4 |
colorFrom: red
|
5 |
colorTo: pink
|
6 |
sdk: gradio
|
7 |
+
sdk_version: 5.5.0
|
8 |
app_file: app.py
|
9 |
pinned: true
|
10 |
license: mit
|
app.py
CHANGED
@@ -677,7 +677,7 @@ css = '''
|
|
677 |
.info { align-items: center; text-align: center; }
|
678 |
.desc [src$='#float'] { float: right; margin: 20px; }
|
679 |
'''
|
680 |
-
with gr.Blocks(theme='
|
681 |
with gr.Tab("FLUX LoRA the Explorer"):
|
682 |
title = gr.HTML(
|
683 |
"""<h1><img src="https://huggingface.co/spaces/John6666/flux-lora-the-explorer/resolve/main/flux_lora.png" alt="LoRA">FLUX LoRA the Explorer Mod</h1>""",
|
|
|
677 |
.info { align-items: center; text-align: center; }
|
678 |
.desc [src$='#float'] { float: right; margin: 20px; }
|
679 |
'''
|
680 |
+
with gr.Blocks(theme='Nymbo/Nymbo_Theme_5', fill_width=True, css=css, delete_cache=(60, 3600)) as app:
|
681 |
with gr.Tab("FLUX LoRA the Explorer"):
|
682 |
title = gr.HTML(
|
683 |
"""<h1><img src="https://huggingface.co/spaces/John6666/flux-lora-the-explorer/resolve/main/flux_lora.png" alt="LoRA">FLUX LoRA the Explorer Mod</h1>""",
|
modutils.py
CHANGED
@@ -12,6 +12,7 @@ from requests.adapters import HTTPAdapter
|
|
12 |
from urllib3.util import Retry
|
13 |
import urllib.parse
|
14 |
import pandas as pd
|
|
|
15 |
from huggingface_hub import HfApi, HfFolder, hf_hub_download, snapshot_download
|
16 |
from translatepy import Translator
|
17 |
from unidecode import unidecode
|
@@ -52,6 +53,25 @@ def is_repo_name(s):
|
|
52 |
return re.fullmatch(r'^[^/]+?/[^/]+?$', s)
|
53 |
|
54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
translator = Translator()
|
56 |
def translate_to_en(input: str):
|
57 |
try:
|
@@ -753,10 +773,10 @@ def set_prompt_loras(prompt, prompt_syntax, model_name, lora1, lora1_wt, lora2,
|
|
753 |
key = result[0][0]
|
754 |
wt = result[0][1]
|
755 |
path = to_lora_path(key)
|
756 |
-
if not key in loras_dict.keys() or not path:
|
757 |
path = get_valid_lora_name(path)
|
758 |
if not path or path == "None": continue
|
759 |
-
if path in lora_paths:
|
760 |
continue
|
761 |
elif not on1:
|
762 |
lora1 = path
|
@@ -777,7 +797,7 @@ def set_prompt_loras(prompt, prompt_syntax, model_name, lora1, lora1_wt, lora2,
|
|
777 |
lora4 = path
|
778 |
lora_paths = [lora1, lora2, lora3, lora4, lora5]
|
779 |
lora4_wt = safe_float(wt)
|
780 |
-
on4
|
781 |
elif not on5:
|
782 |
lora5 = path
|
783 |
lora_paths = [lora1, lora2, lora3, lora4, lora5]
|
@@ -1320,10 +1340,10 @@ style_list = [
|
|
1320 |
|
1321 |
|
1322 |
optimization_list = {
|
1323 |
-
"None": [28, 7., 'Euler
|
1324 |
-
"Default": [28, 7., 'Euler
|
1325 |
-
"SPO": [28, 7., 'Euler
|
1326 |
-
"DPO": [28, 7., 'Euler
|
1327 |
"DPO Turbo": [8, 2.5, 'LCM', True, 'loras/sd_xl_dpo_turbo_lora_v1-128dim.safetensors', 1.],
|
1328 |
"SDXL Turbo": [8, 2.5, 'LCM', True, 'loras/sd_xl_turbo_lora_v1.safetensors', 1.],
|
1329 |
"Hyper-SDXL 12step": [12, 5., 'TCD', True, 'loras/Hyper-SDXL-12steps-CFG-lora.safetensors', 1.],
|
@@ -1331,10 +1351,10 @@ optimization_list = {
|
|
1331 |
"Hyper-SDXL 4step": [4, 0, 'TCD', True, 'loras/Hyper-SDXL-4steps-lora.safetensors', 1.],
|
1332 |
"Hyper-SDXL 2step": [2, 0, 'TCD', True, 'loras/Hyper-SDXL-2steps-lora.safetensors', 1.],
|
1333 |
"Hyper-SDXL 1step": [1, 0, 'TCD', True, 'loras/Hyper-SDXL-1steps-lora.safetensors', 1.],
|
1334 |
-
"PCM 16step": [16, 4., 'Euler
|
1335 |
-
"PCM 8step": [8, 4., 'Euler
|
1336 |
-
"PCM 4step": [4, 2., 'Euler
|
1337 |
-
"PCM 2step": [2, 1., 'Euler
|
1338 |
}
|
1339 |
|
1340 |
|
@@ -1362,13 +1382,13 @@ def set_optimization(opt, steps_gui, cfg_gui, sampler_gui, clip_skip_gui, lora_g
|
|
1362 |
|
1363 |
# [sampler_gui, steps_gui, cfg_gui, clip_skip_gui, img_width_gui, img_height_gui, optimization_gui]
|
1364 |
preset_sampler_setting = {
|
1365 |
-
"None": ["Euler
|
1366 |
"Anime 3:4 Fast": ["LCM", 8, 2.5, True, 896, 1152, "DPO Turbo"],
|
1367 |
-
"Anime 3:4 Standard": ["Euler
|
1368 |
-
"Anime 3:4 Heavy": ["Euler
|
1369 |
"Anime 1:1 Fast": ["LCM", 8, 2.5, True, 1024, 1024, "DPO Turbo"],
|
1370 |
-
"Anime 1:1 Standard": ["Euler
|
1371 |
-
"Anime 1:1 Heavy": ["Euler
|
1372 |
"Photo 3:4 Fast": ["LCM", 8, 2.5, False, 896, 1152, "DPO Turbo"],
|
1373 |
"Photo 3:4 Standard": ["DPM++ 2M Karras", 28, 7., False, 896, 1152, "None"],
|
1374 |
"Photo 3:4 Heavy": ["DPM++ 2M Karras", 40, 7., False, 896, 1152, "None"],
|
@@ -1380,9 +1400,9 @@ preset_sampler_setting = {
|
|
1380 |
|
1381 |
def set_sampler_settings(sampler_setting):
|
1382 |
if not sampler_setting in list(preset_sampler_setting.keys()) or sampler_setting == "None":
|
1383 |
-
return gr.update(value="Euler
|
1384 |
gr.update(value=1024), gr.update(value=1024), gr.update(value="None")
|
1385 |
-
v = preset_sampler_setting.get(sampler_setting, ["Euler
|
1386 |
# sampler, steps, cfg, clip_skip, width, height, optimization
|
1387 |
return gr.update(value=v[0]), gr.update(value=v[1]), gr.update(value=v[2]), gr.update(value=v[3]),\
|
1388 |
gr.update(value=v[4]), gr.update(value=v[5]), gr.update(value=v[6])
|
@@ -1573,7 +1593,7 @@ EXAMPLES_GUI = [
|
|
1573 |
7.5,
|
1574 |
True,
|
1575 |
-1,
|
1576 |
-
"Euler
|
1577 |
1152,
|
1578 |
896,
|
1579 |
"votepurchase/animagine-xl-3.1",
|
@@ -1586,7 +1606,7 @@ EXAMPLES_GUI = [
|
|
1586 |
5.,
|
1587 |
True,
|
1588 |
-1,
|
1589 |
-
"Euler
|
1590 |
1024,
|
1591 |
1024,
|
1592 |
"votepurchase/ponyDiffusionV6XL",
|
@@ -1599,7 +1619,7 @@ EXAMPLES_GUI = [
|
|
1599 |
7.0,
|
1600 |
True,
|
1601 |
-1,
|
1602 |
-
"Euler
|
1603 |
1024,
|
1604 |
1024,
|
1605 |
"Raelina/Rae-Diffusion-XL-V2",
|
@@ -1612,7 +1632,7 @@ EXAMPLES_GUI = [
|
|
1612 |
7.0,
|
1613 |
True,
|
1614 |
-1,
|
1615 |
-
"Euler
|
1616 |
1024,
|
1617 |
1024,
|
1618 |
"Raelina/Raemu-XL-V4",
|
@@ -1625,7 +1645,7 @@ EXAMPLES_GUI = [
|
|
1625 |
7.,
|
1626 |
True,
|
1627 |
-1,
|
1628 |
-
"Euler
|
1629 |
1024,
|
1630 |
1024,
|
1631 |
"cagliostrolab/animagine-xl-3.1",
|
|
|
12 |
from urllib3.util import Retry
|
13 |
import urllib.parse
|
14 |
import pandas as pd
|
15 |
+
from typing import Any
|
16 |
from huggingface_hub import HfApi, HfFolder, hf_hub_download, snapshot_download
|
17 |
from translatepy import Translator
|
18 |
from unidecode import unidecode
|
|
|
53 |
return re.fullmatch(r'^[^/]+?/[^/]+?$', s)
|
54 |
|
55 |
|
56 |
+
DEFAULT_STATE = {
|
57 |
+
"show_diffusers_model_list_detail": False,
|
58 |
+
}
|
59 |
+
|
60 |
+
|
61 |
+
def get_state(state: dict, key: str):
|
62 |
+
if key in state.keys(): return state[key]
|
63 |
+
elif key in DEFAULT_STATE.keys():
|
64 |
+
print(f"State '{key}' not found. Use dedault value.")
|
65 |
+
return DEFAULT_STATE[key]
|
66 |
+
else:
|
67 |
+
print(f"State '{key}' not found.")
|
68 |
+
return None
|
69 |
+
|
70 |
+
|
71 |
+
def set_state(state: dict, key: str, value: Any):
|
72 |
+
state[key] = value
|
73 |
+
|
74 |
+
|
75 |
translator = Translator()
|
76 |
def translate_to_en(input: str):
|
77 |
try:
|
|
|
773 |
key = result[0][0]
|
774 |
wt = result[0][1]
|
775 |
path = to_lora_path(key)
|
776 |
+
if not key in loras_dict.keys() or not Path(path).exists():
|
777 |
path = get_valid_lora_name(path)
|
778 |
if not path or path == "None": continue
|
779 |
+
if path in lora_paths or key in lora_paths:
|
780 |
continue
|
781 |
elif not on1:
|
782 |
lora1 = path
|
|
|
797 |
lora4 = path
|
798 |
lora_paths = [lora1, lora2, lora3, lora4, lora5]
|
799 |
lora4_wt = safe_float(wt)
|
800 |
+
on4 = True
|
801 |
elif not on5:
|
802 |
lora5 = path
|
803 |
lora_paths = [lora1, lora2, lora3, lora4, lora5]
|
|
|
1340 |
|
1341 |
|
1342 |
optimization_list = {
|
1343 |
+
"None": [28, 7., 'Euler', False, 'None', 1.],
|
1344 |
+
"Default": [28, 7., 'Euler', False, 'None', 1.],
|
1345 |
+
"SPO": [28, 7., 'Euler', True, 'loras/spo_sdxl_10ep_4k-data_lora_diffusers.safetensors', 1.],
|
1346 |
+
"DPO": [28, 7., 'Euler', True, 'loras/sdxl-DPO-LoRA.safetensors', 1.],
|
1347 |
"DPO Turbo": [8, 2.5, 'LCM', True, 'loras/sd_xl_dpo_turbo_lora_v1-128dim.safetensors', 1.],
|
1348 |
"SDXL Turbo": [8, 2.5, 'LCM', True, 'loras/sd_xl_turbo_lora_v1.safetensors', 1.],
|
1349 |
"Hyper-SDXL 12step": [12, 5., 'TCD', True, 'loras/Hyper-SDXL-12steps-CFG-lora.safetensors', 1.],
|
|
|
1351 |
"Hyper-SDXL 4step": [4, 0, 'TCD', True, 'loras/Hyper-SDXL-4steps-lora.safetensors', 1.],
|
1352 |
"Hyper-SDXL 2step": [2, 0, 'TCD', True, 'loras/Hyper-SDXL-2steps-lora.safetensors', 1.],
|
1353 |
"Hyper-SDXL 1step": [1, 0, 'TCD', True, 'loras/Hyper-SDXL-1steps-lora.safetensors', 1.],
|
1354 |
+
"PCM 16step": [16, 4., 'Euler trailing', True, 'loras/pcm_sdxl_normalcfg_16step_converted.safetensors', 1.],
|
1355 |
+
"PCM 8step": [8, 4., 'Euler trailing', True, 'loras/pcm_sdxl_normalcfg_8step_converted.safetensors', 1.],
|
1356 |
+
"PCM 4step": [4, 2., 'Euler trailing', True, 'loras/pcm_sdxl_smallcfg_4step_converted.safetensors', 1.],
|
1357 |
+
"PCM 2step": [2, 1., 'Euler trailing', True, 'loras/pcm_sdxl_smallcfg_2step_converted.safetensors', 1.],
|
1358 |
}
|
1359 |
|
1360 |
|
|
|
1382 |
|
1383 |
# [sampler_gui, steps_gui, cfg_gui, clip_skip_gui, img_width_gui, img_height_gui, optimization_gui]
|
1384 |
preset_sampler_setting = {
|
1385 |
+
"None": ["Euler", 28, 7., True, 1024, 1024, "None"],
|
1386 |
"Anime 3:4 Fast": ["LCM", 8, 2.5, True, 896, 1152, "DPO Turbo"],
|
1387 |
+
"Anime 3:4 Standard": ["Euler", 28, 7., True, 896, 1152, "None"],
|
1388 |
+
"Anime 3:4 Heavy": ["Euler", 40, 7., True, 896, 1152, "None"],
|
1389 |
"Anime 1:1 Fast": ["LCM", 8, 2.5, True, 1024, 1024, "DPO Turbo"],
|
1390 |
+
"Anime 1:1 Standard": ["Euler", 28, 7., True, 1024, 1024, "None"],
|
1391 |
+
"Anime 1:1 Heavy": ["Euler", 40, 7., True, 1024, 1024, "None"],
|
1392 |
"Photo 3:4 Fast": ["LCM", 8, 2.5, False, 896, 1152, "DPO Turbo"],
|
1393 |
"Photo 3:4 Standard": ["DPM++ 2M Karras", 28, 7., False, 896, 1152, "None"],
|
1394 |
"Photo 3:4 Heavy": ["DPM++ 2M Karras", 40, 7., False, 896, 1152, "None"],
|
|
|
1400 |
|
1401 |
def set_sampler_settings(sampler_setting):
|
1402 |
if not sampler_setting in list(preset_sampler_setting.keys()) or sampler_setting == "None":
|
1403 |
+
return gr.update(value="Euler"), gr.update(value=28), gr.update(value=7.), gr.update(value=True),\
|
1404 |
gr.update(value=1024), gr.update(value=1024), gr.update(value="None")
|
1405 |
+
v = preset_sampler_setting.get(sampler_setting, ["Euler", 28, 7., True, 1024, 1024])
|
1406 |
# sampler, steps, cfg, clip_skip, width, height, optimization
|
1407 |
return gr.update(value=v[0]), gr.update(value=v[1]), gr.update(value=v[2]), gr.update(value=v[3]),\
|
1408 |
gr.update(value=v[4]), gr.update(value=v[5]), gr.update(value=v[6])
|
|
|
1593 |
7.5,
|
1594 |
True,
|
1595 |
-1,
|
1596 |
+
"Euler",
|
1597 |
1152,
|
1598 |
896,
|
1599 |
"votepurchase/animagine-xl-3.1",
|
|
|
1606 |
5.,
|
1607 |
True,
|
1608 |
-1,
|
1609 |
+
"Euler",
|
1610 |
1024,
|
1611 |
1024,
|
1612 |
"votepurchase/ponyDiffusionV6XL",
|
|
|
1619 |
7.0,
|
1620 |
True,
|
1621 |
-1,
|
1622 |
+
"Euler",
|
1623 |
1024,
|
1624 |
1024,
|
1625 |
"Raelina/Rae-Diffusion-XL-V2",
|
|
|
1632 |
7.0,
|
1633 |
True,
|
1634 |
-1,
|
1635 |
+
"Euler",
|
1636 |
1024,
|
1637 |
1024,
|
1638 |
"Raelina/Raemu-XL-V4",
|
|
|
1645 |
7.,
|
1646 |
True,
|
1647 |
-1,
|
1648 |
+
"Euler",
|
1649 |
1024,
|
1650 |
1024,
|
1651 |
"cagliostrolab/animagine-xl-3.1",
|