Spaces:
Running on Zero
Running on Zero
Upload lora_loader.py
Browse files- lora_loader.py +124 -80
lora_loader.py
CHANGED
|
@@ -1,96 +1,140 @@
|
|
| 1 |
"""
|
| 2 |
-
LoRA
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
names, titles or descriptions - only the machinery that loads whatever the catalogue lists. With the
|
| 7 |
-
variable unset the Space starts with no built-in presets, and every custom slot still works.
|
| 8 |
-
|
| 9 |
-
Set-up, once:
|
| 10 |
-
|
| 11 |
-
1. create a PRIVATE dataset repo, e.g. `you/wan-lora-catalog`
|
| 12 |
-
2. upload `lora_catalog.json` to it
|
| 13 |
-
3. in the Space, Settings -> Variables and secrets:
|
| 14 |
-
LORA_CATALOG_REPO = you/wan-lora-catalog (variable)
|
| 15 |
-
HF_TOKEN = a token that can read it (secret)
|
| 16 |
-
|
| 17 |
-
Also resolves plain download links (CivitAI and anything else serving a .safetensors), so a slot can
|
| 18 |
-
take a URL instead of a repo file.
|
| 19 |
"""
|
| 20 |
import hashlib
|
| 21 |
import json
|
| 22 |
import os
|
| 23 |
-
import re
|
| 24 |
import struct
|
| 25 |
import tempfile
|
| 26 |
import urllib.parse
|
| 27 |
-
|
| 28 |
from huggingface_hub import hf_hub_download, list_repo_files
|
| 29 |
|
|
|
|
| 30 |
HF_TOKEN = os.environ.get("HF_TOKEN")
|
| 31 |
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
"
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
|
| 95 |
|
| 96 |
def get_lora_choices():
|
|
|
|
| 1 |
"""
|
| 2 |
+
LoRA Loader for WAN 2.2 I2V - multi-repo.
|
| 3 |
+
Baseline: lkzd7/WAN2.2_LoraSet_NSFW. Plus curated I2V act/helper LoRAs from
|
| 4 |
+
Lythiga/WAN2.2_I2V_Lora, rolechar/rc_wan2.2_i2v_loraset_nsfw_private,
|
| 5 |
+
lopi999/Wan2.2-I2V_General-NSFW-LoRA. T2V / lightning / furry / dance / male-char filtered out.
|
| 6 |
|
| 7 |
+
Also resolves plain download links (CivitAI and anything else serving a
|
| 8 |
+
.safetensors), so a slot can take a URL instead of a repo file.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
"""
|
| 10 |
import hashlib
|
| 11 |
import json
|
| 12 |
import os
|
|
|
|
| 13 |
import struct
|
| 14 |
import tempfile
|
| 15 |
import urllib.parse
|
| 16 |
+
import re
|
| 17 |
from huggingface_hub import hf_hub_download, list_repo_files
|
| 18 |
|
| 19 |
+
LORA_REPO = "lkzd7/WAN2.2_LoraSet_NSFW"
|
| 20 |
HF_TOKEN = os.environ.get("HF_TOKEN")
|
| 21 |
|
| 22 |
+
PINNED_REVISIONS = {
|
| 23 |
+
"lkzd7/WAN2.2_LoraSet_NSFW": "ccfa867ce4b1",
|
| 24 |
+
"Lythiga/WAN2.2_I2V_Lora": "67ef542e6faa",
|
| 25 |
+
"rolechar/rc_wan2.2_i2v_loraset_nsfw_private": "4855a2f216ac",
|
| 26 |
+
"lopi999/Wan2.2-I2V_General-NSFW-LoRA": "aeef17d7fa51",
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
LORA_FILES = [
|
| 30 |
+
"Blink_Squatting_Cowgirl_Position_I2V_HIGH.safetensors",
|
| 31 |
+
"Blink_Squatting_Cowgirl_Position_I2V_LOW.safetensors",
|
| 32 |
+
"PENISLORA_22_i2v_HIGH_e320.safetensors",
|
| 33 |
+
"PENISLORA_22_i2v_LOW_e496.safetensors",
|
| 34 |
+
"Pornmaster_wan 2.2_14b_I2V_bukkake_v1.4_high_noise.safetensors",
|
| 35 |
+
"Pornmaster_wan 2.2_14b_I2V_bukkake_v1.4_low_noise.safetensors",
|
| 36 |
+
"W22_Multiscene_Photoshoot_Softcore_i2v_HN.safetensors",
|
| 37 |
+
"W22_Multiscene_Photoshoot_Softcore_i2v_LN.safetensors",
|
| 38 |
+
"WAN-2.2-I2V-Double-Blowjob-HIGH-v1.safetensors",
|
| 39 |
+
"WAN-2.2-I2V-Double-Blowjob-LOW-v1.safetensors",
|
| 40 |
+
"WAN-2.2-I2V-HandjobBlowjobCombo-HIGH-v1.safetensors",
|
| 41 |
+
"WAN-2.2-I2V-HandjobBlowjobCombo-LOW-v1.safetensors",
|
| 42 |
+
"WAN-2.2-I2V-SensualTeasingBlowjob-HIGH-v1.safetensors",
|
| 43 |
+
"WAN-2.2-I2V-SensualTeasingBlowjob-LOW-v1.safetensors",
|
| 44 |
+
"iGOON_Blink_Blowjob_I2V_HIGH.safetensors",
|
| 45 |
+
"iGOON_Blink_Blowjob_I2V_LOW.safetensors",
|
| 46 |
+
"iGoon - Blink_Front_Doggystyle_I2V_HIGH.safetensors",
|
| 47 |
+
"iGoon - Blink_Front_Doggystyle_I2V_LOW.safetensors",
|
| 48 |
+
"iGoon - Blink_Missionary_I2V_HIGH.safetensors",
|
| 49 |
+
"iGoon - Blink_Missionary_I2V_LOW v2.safetensors",
|
| 50 |
+
"iGoon - Blink_Missionary_I2V_LOW.safetensors",
|
| 51 |
+
"iGoon%20-%20Blink_Back_Doggystyle_HIGH.safetensors",
|
| 52 |
+
"iGoon%20-%20Blink_Back_Doggystyle_LOW.safetensors",
|
| 53 |
+
"iGoon%20-%20Blink_Facial_I2V_HIGH.safetensors",
|
| 54 |
+
"iGoon%20-%20Blink_Facial_I2V_LOW.safetensors",
|
| 55 |
+
"iGoon_Blink_Missionary_I2V_HIGH v2.safetensors",
|
| 56 |
+
"iGoon_Blink_Titjob_I2V_HIGH.safetensors",
|
| 57 |
+
"iGoon_Blink_Titjob_I2V_LOW.safetensors",
|
| 58 |
+
"lips-bj_high_noise.safetensors",
|
| 59 |
+
"lips-bj_low_noise.safetensors",
|
| 60 |
+
"mql_casting_sex_doggy_kneel_diagonally_behind_vagina_wan22_i2v_v1_high_noise.safetensors",
|
| 61 |
+
"mql_casting_sex_doggy_kneel_diagonally_behind_vagina_wan22_i2v_v1_low_noise.safetensors",
|
| 62 |
+
"mql_casting_sex_reverse_cowgirl_lie_front_vagina_wan22_i2v_v1_high_noise.safetensors",
|
| 63 |
+
"mql_casting_sex_reverse_cowgirl_lie_front_vagina_wan22_i2v_v1_low_noise.safetensors",
|
| 64 |
+
"mql_casting_sex_spoon_wan22_i2v_v1_high_noise.safetensors",
|
| 65 |
+
"mql_casting_sex_spoon_wan22_i2v_v1_low_noise.safetensors",
|
| 66 |
+
"mql_massage_tits_wan22_i2v_v1_high_noise.safetensors",
|
| 67 |
+
"mql_massage_tits_wan22_i2v_v1_low_noise.safetensors",
|
| 68 |
+
"mql_panties_aside_wan22_i2v_v1_high_noise.safetensors",
|
| 69 |
+
"mql_panties_aside_wan22_i2v_v1_low_noise.safetensors",
|
| 70 |
+
"sfbehind_v2.1_high_noise.safetensors",
|
| 71 |
+
"sfbehind_v2.1_low_noise.safetensors",
|
| 72 |
+
"sid3l3g_transition_v2.0_H.safetensors",
|
| 73 |
+
"sid3l3g_transition_v2.0_L.safetensors",
|
| 74 |
+
"wan2.2_i2v_high_ulitmate_pussy_asshole.safetensors",
|
| 75 |
+
"wan2.2_i2v_low_ulitmate_pussy_asshole.safetensors",
|
| 76 |
+
"wan22-mouthfull-140epoc-high-k3nk.safetensors",
|
| 77 |
+
"wan22-mouthfull-152epoc-low-k3nk.safetensors",
|
| 78 |
+
]
|
| 79 |
+
|
| 80 |
+
LORA_PAIRS = {}
|
| 81 |
+
for f in LORA_FILES:
|
| 82 |
+
name = urllib.parse.unquote(f).replace(".safetensors", "")
|
| 83 |
+
is_high = bool(re.search(r'(high|HN|_H\b)', name, re.IGNORECASE))
|
| 84 |
+
is_low = bool(re.search(r'(low|LN|_L\b)', name, re.IGNORECASE))
|
| 85 |
+
group = re.sub(r'[\s_-]*(high|low|noise|HN|LN)([\s_-]*noise)?[\s_-]*(v?\d+(\.\d+)?)?\s*$', '', name, flags=re.IGNORECASE).strip()
|
| 86 |
+
group = re.sub(r'[\s_]+$', '', group)
|
| 87 |
+
LORA_PAIRS.setdefault(group, {"HIGH": None, "LOW": None})
|
| 88 |
+
if is_high:
|
| 89 |
+
LORA_PAIRS[group]["HIGH"] = (LORA_REPO, f)
|
| 90 |
+
elif is_low:
|
| 91 |
+
LORA_PAIRS[group]["LOW"] = (LORA_REPO, f)
|
| 92 |
+
|
| 93 |
+
L = "Lythiga/WAN2.2_I2V_Lora"
|
| 94 |
+
R = "rolechar/rc_wan2.2_i2v_loraset_nsfw_private"
|
| 95 |
+
P = "lopi999/Wan2.2-I2V_General-NSFW-LoRA"
|
| 96 |
+
|
| 97 |
+
EXTRA = {
|
| 98 |
+
"Ultimate Deepthroat": (L, "wan22-ultimatedeepthroat-i2v-102epoc-high-k3nk.safetensors", "wan22-ultimatedeepthroat-I2V-101epoc-low-k3nk.safetensors"),
|
| 99 |
+
"BBC Deepthroat": (L, "wan22-bbcdeepthroat-115epoc-high-k3nk.safetensors", "wan22-bbcdeepthroat-155epoc-low-720-k3nk.safetensors"),
|
| 100 |
+
"Throat V2": (L, "Wan22_ThroatV2_High.safetensors", "Wan22_ThroatV2_Low.safetensors"),
|
| 101 |
+
"JFJ Deepthroat": (L, "jfj-deepthroat-W22-I2V-HN.safetensors", None),
|
| 102 |
+
"BBC Blowjob Extreme": (L, "BBC Blowjobs Extreme_high_noise.safetensors", "BBC Blowjobs Extreme_low_noise.safetensors"),
|
| 103 |
+
"POV Blowjob": (L, "Pov_Blowjob_Wan2.2_high_I2V_v1.0.safetensors", None),
|
| 104 |
+
"Cunnilingus": (L, "wan22-cunilingus-I2V-106epoc-high.safetensors", "wan22-cunilingus-I2V-72epoc-low.safetensors"),
|
| 105 |
+
"Reverse Cowgirl v2": (L, "wan22.r3v3rs3_c0wg1rl-14b-High-i2v_e70.safetensors", "wan22.r3v3rs3_c0wg1rl-14b-Low-i2v_e70.safetensors"),
|
| 106 |
+
"Doggy Front View v2": (L, "doggy_style_sex_front_view_Wan2.2_I2V_high_v1.0.safetensors", "doggy_style_sex_front_view_Wan2.2_I2V_Low_v1.0.safetensors"),
|
| 107 |
+
"Fucked From Behind": (L, "derpfuckedfrombehind_000002125_high_noise.safetensors", "derpfuckedfrombehind_000002125_low_noise.safetensors"),
|
| 108 |
+
"Prone Bone": (L, "Pronebone_high_noise.safetensors", "Pronebone_low_noise.safetensors"),
|
| 109 |
+
"Reverse Suspended Congress": (L, "reverse_suspended_congress_I2V_high.safetensors", "reverse_suspended_congress_I2V_low.safetensors"),
|
| 110 |
+
"POV Missionary": (L, "wan2.2_i2v_highnoise_pov_missionary_v1.0.safetensors", "wan2.2_i2v_lownoise_pov_missionary_v1.0.safetensors"),
|
| 111 |
+
"Mating Press": (L, "mating_press_high.safetensors", "mating_press_low.safetensors"),
|
| 112 |
+
"Standing Upright Sex": (L, "Upright_sex_Wan2.2_14B_TI2V_HIGH_v1.0.safetensors", "Upright_sex_Wan2.2_14B_TI2V_LOW_v1.0.safetensors"),
|
| 113 |
+
"Oral Insertion": (L, "wan2.2-i2v-high-oral-insertion-v1.0.safetensors", "wan2.2-i2v-low-oral-insertion-v1.0.safetensors"),
|
| 114 |
+
"Handjob": (L, "WAN-2.2-I2V-Handjob-HIGH-v1.safetensors", "WAN-2.2-I2V-Handjob-LOW-v1.safetensors"),
|
| 115 |
+
"Balls Sucking": (L, "WAN-2.2-I2V_Balls_sucking_High_noise.safetensors", "WAN-2.2-I2V_Balls_sucking_Low_noise.safetensors"),
|
| 116 |
+
"Fingering": (R, "Sensual_fingering_v1_high_noise.safetensors", "Sensual_fingering_v1_low_noise.safetensors"),
|
| 117 |
+
"Facesplash Cumshot": (L, "wan22-f4c3spl4sh-100epoc-high-k3nk.safetensors", "wan22-f4c3spl4sh-154epoc-low-k3nk.safetensors"),
|
| 118 |
+
"Creampie CRM": (L, "Creampie CRM-FULL-EPOCH-80-HIGH.safetensors", "Creampie CRM-FULL-EPOCH-80-LOW.safetensors"),
|
| 119 |
+
"Pornmaster Creampie": (L, "Pornmaster_wan 2.2_14b_I2V_Creampie_v1_high_noise.safetensors", "Pornmaster_wan 2.2_14b_I2V_Creampie_v1_low_noise.safetensors"),
|
| 120 |
+
"Cum (generic)": (L, "Wan22_Cum_high_noise_1.V1.safetensors", "Wan22_Cum_low_noise_1.V1.safetensors"),
|
| 121 |
+
"French Kiss": (L, "WAN2.2-FrenchKiss_HighNoise.safetensors", "WAN2.2-FrenchKiss_LowNoise.safetensors"),
|
| 122 |
+
"Twerking": (L, "Twerking_I2V_high_noise.safetensors", "Twerking_I2V_low_noise.safetensors"),
|
| 123 |
+
"Ahegao Drooling": (R, "middlefinger_drooling_ahegao_high.safetensors", "middlefinger_drooling_ahegao_low.safetensors"),
|
| 124 |
+
"General NSFW Booster": (P, "NSFW-22-H-e8.safetensors", "NSFW-22-L-e8.safetensors"),
|
| 125 |
+
"Penetration Insert": (L, "PenInsert_high_noise.safetensors", "PenInsert_low_noise.safetensors"),
|
| 126 |
+
"Biggest Cock (size)": (L, "WAN-2.2-I2V_BiggestCock_high_noise_V1.safetensors", "WAN-2.2-I2V_BiggestCock_low_noise_V1.safetensors"),
|
| 127 |
+
"Doggy Slider": (L, "I2V_doggyslider_high.safetensors", "I2V_doggyslider_low.safetensors"),
|
| 128 |
+
"Pussy Helper": (R, "wan2.2_i2v_ulitmate_pussy_helper_high.safetensors", "wan2.2_i2v_ulitmate_pussy_helper_low.safetensors"),
|
| 129 |
+
"FOV Slider (camera)": (L, "wan2.2-i2v-high-sex-fov-slider-v1.0.safetensors", "wan2.2-i2v-low-sex-fov-slider-v1.0.safetensors"),
|
| 130 |
+
"Smashcut (camera)": (R, "wan2.2-i2v-sex-smashcut-v1.0-high.safetensors", "wan2.2-i2v-sex-smashcut-v1.0-low.safetensors"),
|
| 131 |
+
}
|
| 132 |
+
for label, (repo, hi, lo) in EXTRA.items():
|
| 133 |
+
LORA_PAIRS.setdefault(label, {"HIGH": None, "LOW": None})
|
| 134 |
+
if hi:
|
| 135 |
+
LORA_PAIRS[label]["HIGH"] = (repo, hi)
|
| 136 |
+
if lo:
|
| 137 |
+
LORA_PAIRS[label]["LOW"] = (repo, lo)
|
| 138 |
|
| 139 |
|
| 140 |
def get_lora_choices():
|