Commit ·
dd133f3
1
Parent(s): 0a1410b
adding more loras
Browse files- flux.2/config.yaml +4 -3
- flux.2/iska_flux2_000001600.safetensors +3 -0
- flux.2/iska_flux2_000001700.safetensors +3 -0
- flux.2/iska_flux2_000001800.safetensors +3 -0
- flux.2/iska_flux2_000001900.safetensors +3 -0
- flux.2/iska_flux2_000002000.safetensors +3 -0
- scripts/check_if_lora_dead.py +64 -0
- scripts/output.png +3 -0
- scripts/test_flux.2_lora.py +23 -0
flux.2/config.yaml
CHANGED
|
@@ -69,7 +69,7 @@ config:
|
|
| 69 |
train:
|
| 70 |
batch_size: 2
|
| 71 |
bypass_guidance_embedding: false
|
| 72 |
-
steps:
|
| 73 |
gradient_accumulation: 1
|
| 74 |
train_unet: true
|
| 75 |
train_text_encoder: false
|
|
@@ -87,7 +87,7 @@ config:
|
|
| 87 |
use_ema: false
|
| 88 |
ema_decay: 0.99
|
| 89 |
skip_first_sample: false
|
| 90 |
-
force_first_sample:
|
| 91 |
disable_sampling: true
|
| 92 |
dtype: "bf16"
|
| 93 |
diff_output_preservation: false
|
|
@@ -119,7 +119,8 @@ config:
|
|
| 119 |
sample_start_step: 0
|
| 120 |
width: 1024
|
| 121 |
height: 1024
|
| 122 |
-
samples:
|
|
|
|
| 123 |
neg: ""
|
| 124 |
seed: 42
|
| 125 |
walk_seed: true
|
|
|
|
| 69 |
train:
|
| 70 |
batch_size: 2
|
| 71 |
bypass_guidance_embedding: false
|
| 72 |
+
steps: 2000
|
| 73 |
gradient_accumulation: 1
|
| 74 |
train_unet: true
|
| 75 |
train_text_encoder: false
|
|
|
|
| 87 |
use_ema: false
|
| 88 |
ema_decay: 0.99
|
| 89 |
skip_first_sample: false
|
| 90 |
+
force_first_sample: true
|
| 91 |
disable_sampling: true
|
| 92 |
dtype: "bf16"
|
| 93 |
diff_output_preservation: false
|
|
|
|
| 119 |
sample_start_step: 0
|
| 120 |
width: 1024
|
| 121 |
height: 1024
|
| 122 |
+
samples:
|
| 123 |
+
- prompt: "The photo of ISKA"
|
| 124 |
neg: ""
|
| 125 |
seed: 42
|
| 126 |
walk_seed: true
|
flux.2/iska_flux2_000001600.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:127740b2a27d5710d06fcff0fbd707cc99986321368b9be281c8303c1f6eb40c
|
| 3 |
+
size 97558704
|
flux.2/iska_flux2_000001700.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1c2260fb1588d5deb800911c28c041703d4a4731993cf4821e6bf26dfe2b911b
|
| 3 |
+
size 97558704
|
flux.2/iska_flux2_000001800.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1fcf5de9625caae69e149ae02b2082d9328d906271862ebb21fc6bf6e08f28f7
|
| 3 |
+
size 97558704
|
flux.2/iska_flux2_000001900.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:95317ed76b73631d3a8c29c36bf5a0b594079469d9340fd563ee19304408cfaf
|
| 3 |
+
size 97558704
|
flux.2/iska_flux2_000002000.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:489bdfb1b0085c5fe4f8073d897321a65301794e5b4a1b8569cc4d0d11eb3c17
|
| 3 |
+
size 97558704
|
scripts/check_if_lora_dead.py
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from safetensors.torch import load_file
|
| 3 |
+
|
| 4 |
+
def check_lora(file_path, threshold=1e-5):
|
| 5 |
+
"""Check if a LoRA safetensors file contains dead (near-zero) weights."""
|
| 6 |
+
try:
|
| 7 |
+
sd = load_file(file_path)
|
| 8 |
+
except Exception as e:
|
| 9 |
+
print(f"❌ Could not load file: {e}")
|
| 10 |
+
return
|
| 11 |
+
|
| 12 |
+
# Collect all LoRA weight tensors (both A and B matrices)
|
| 13 |
+
lora_weights = []
|
| 14 |
+
for key, tensor in sd.items():
|
| 15 |
+
# Look for LoRA keys (adjust pattern if your trainer uses different naming)
|
| 16 |
+
if any(part in key.lower() for part in ['lora_a', 'lora_b', 'lora.']):
|
| 17 |
+
lora_weights.append(tensor)
|
| 18 |
+
|
| 19 |
+
if not lora_weights:
|
| 20 |
+
print("⚠️ No LoRA keys found in this file.")
|
| 21 |
+
print(" Could be a full model, or your trainer uses different naming.")
|
| 22 |
+
# Still check if *any* tensors are present
|
| 23 |
+
if sd:
|
| 24 |
+
print(f" File contains {len(sd)} tensors. Example keys:")
|
| 25 |
+
for k in list(sd.keys())[:5]:
|
| 26 |
+
print(f" - {k}")
|
| 27 |
+
return
|
| 28 |
+
|
| 29 |
+
# Combine all weights
|
| 30 |
+
all_weights = torch.cat([tensor.flatten() for tensor in lora_weights])
|
| 31 |
+
|
| 32 |
+
# Compute stats
|
| 33 |
+
max_abs = torch.max(torch.abs(all_weights)).item()
|
| 34 |
+
mean_abs = torch.mean(torch.abs(all_weights)).item()
|
| 35 |
+
num_zero = (all_weights == 0).sum().item()
|
| 36 |
+
total = all_weights.numel()
|
| 37 |
+
|
| 38 |
+
print(f"📊 LoRA tensor stats:")
|
| 39 |
+
print(f" Total LoRA weights: {total}")
|
| 40 |
+
print(f" Max absolute value: {max_abs:.6g}")
|
| 41 |
+
print(f" Mean absolute value: {mean_abs:.6g}")
|
| 42 |
+
print(f" Percentage exactly zero: {num_zero/total*100:.2f}%")
|
| 43 |
+
print(f" Contains {len(lora_weights)} LoRA tensors.")
|
| 44 |
+
|
| 45 |
+
# Determine if dead
|
| 46 |
+
if max_abs < threshold:
|
| 47 |
+
print(f"\n❌ DEAD LORA: All weights are below {threshold}, effectively zero.")
|
| 48 |
+
print(" This was likely caused by `compile: true` — retrain without it.")
|
| 49 |
+
else:
|
| 50 |
+
print(f"\n✅ LoRA appears to have working weights (max abs > {threshold}).")
|
| 51 |
+
# Check for prefix issues
|
| 52 |
+
mangled_keys = [k for k in sd.keys() if '_orig_mod.' in k]
|
| 53 |
+
if mangled_keys:
|
| 54 |
+
print(" ⚠️ But keys contain '_orig_mod.' prefix — this might cause loading issues!")
|
| 55 |
+
print(" Example:", mangled_keys[0])
|
| 56 |
+
else:
|
| 57 |
+
print(" Keys look normal.")
|
| 58 |
+
|
| 59 |
+
if __name__ == "__main__":
|
| 60 |
+
import sys
|
| 61 |
+
if len(sys.argv) != 2:
|
| 62 |
+
print("Usage: python check_lora.py <path_to_lora.safetensors>")
|
| 63 |
+
sys.exit(1)
|
| 64 |
+
check_lora(sys.argv[1])
|
scripts/output.png
ADDED
|
Git LFS Details
|
scripts/test_flux.2_lora.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import fal_client
|
| 3 |
+
import requests
|
| 4 |
+
os.environ["FAL_KEY"] = "06ac9dcd-73fe-4799-9d80-9954eba39d84:f28d23d6abb91f26d2d337edc8cb9bf8"
|
| 5 |
+
result = fal_client.subscribe(
|
| 6 |
+
"fal-ai/flux-2/lora", # <-- Use FLUX.1 endpoint
|
| 7 |
+
arguments={
|
| 8 |
+
"prompt": "a photo of ISKA", # <-- Include trigger word
|
| 9 |
+
"loras": [
|
| 10 |
+
{
|
| 11 |
+
"path": "https://huggingface.co/YaroslavLinder/ISKA/resolve/main/flux.2/iska_flux2_000001500.safetensors",
|
| 12 |
+
"scale": 1.0
|
| 13 |
+
}
|
| 14 |
+
],
|
| 15 |
+
"guidance_scale": 2.5,
|
| 16 |
+
"num_inference_steps": 28
|
| 17 |
+
}
|
| 18 |
+
)
|
| 19 |
+
print(result)
|
| 20 |
+
output_url=result['images'][0]['url']
|
| 21 |
+
response = requests.get(output_url)
|
| 22 |
+
with open("output.png", "wb") as f:
|
| 23 |
+
f.write(response.content)
|