phxdev Claude commited on
Commit
49dd58c
·
1 Parent(s): c54de03

Add Face Realism and Perfection Style LoRAs with optimal scaling

Browse files

- Add Canopus-LoRA-Flux-FaceRealism.safetensors with 1.1 scale
- Add perfection style v1.safetensors with 1.0 scale
- Implement get_optimal_lora_scale() function for per-LoRA optimization
- Apply optimal scaling during LoRA fusion for better performance

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

Files changed (1) hide show
  1. app.py +19 -2
app.py CHANGED
@@ -48,7 +48,9 @@ LORAS = {
48
  "None": None,
49
  "AntiBlur": "Shakker-Labs/FLUX.1-dev-LoRA-AntiBlur",
50
  "Add Details": "Shakker-Labs/FLUX.1-dev-LoRA-add-details",
51
- "Ultra Realism": "https://huggingface.co/its-magick/merlin-test-loras/resolve/main/Canopus-LoRA-Flux-UltraRealism.safetensors"
 
 
52
  }
53
 
54
  # Store loaded LoRA paths
@@ -84,6 +86,17 @@ def preload_loras():
84
 
85
  print(f"All {len(loaded_loras)} LoRAs downloaded and ready!")
86
 
 
 
 
 
 
 
 
 
 
 
 
87
  # Download all LoRAs at startup
88
  preload_loras()
89
 
@@ -106,8 +119,12 @@ def infer(prompt, seed=42, randomize_seed=False, width=1024, height=1024, guidan
106
  pipe.unload_lora_weights()
107
 
108
  if lora_selection != "None" and lora_selection in loaded_loras:
 
 
109
  pipe.load_lora_weights(loaded_loras[lora_selection])
110
- print(f"Loaded LoRA: {lora_selection}")
 
 
111
  except Exception as e:
112
  print(f"Failed to load LoRA {lora_selection}: {e}")
113
 
 
48
  "None": None,
49
  "AntiBlur": "Shakker-Labs/FLUX.1-dev-LoRA-AntiBlur",
50
  "Add Details": "Shakker-Labs/FLUX.1-dev-LoRA-add-details",
51
+ "Ultra Realism": "https://huggingface.co/its-magick/merlin-test-loras/resolve/main/Canopus-LoRA-Flux-UltraRealism.safetensors",
52
+ "Face Realism": "https://huggingface.co/its-magick/merlin-test-loras/resolve/main/Canopus-LoRA-Flux-FaceRealism.safetensors",
53
+ "Perfection Style": "https://huggingface.co/its-magick/merlin-test-loras/resolve/main/perfection%20style%20v1.safetensors"
54
  }
55
 
56
  # Store loaded LoRA paths
 
86
 
87
  print(f"All {len(loaded_loras)} LoRAs downloaded and ready!")
88
 
89
+ def get_optimal_lora_scale(lora_name):
90
+ """Return optimal LoRA scale based on LoRA type for better quality/speed balance"""
91
+ lora_scales = {
92
+ "AntiBlur": 0.8, # Slightly lower for better balance
93
+ "Add Details": 1.2, # Higher for more detail enhancement
94
+ "Ultra Realism": 0.9, # Balanced for realism
95
+ "Face Realism": 1.1, # Optimized for facial features
96
+ "Perfection Style": 1.0, # Balanced for style enhancement
97
+ }
98
+ return lora_scales.get(lora_name, 1.0)
99
+
100
  # Download all LoRAs at startup
101
  preload_loras()
102
 
 
119
  pipe.unload_lora_weights()
120
 
121
  if lora_selection != "None" and lora_selection in loaded_loras:
122
+ # Load with optimized scale for better performance
123
+ optimal_scale = get_optimal_lora_scale(lora_selection)
124
  pipe.load_lora_weights(loaded_loras[lora_selection])
125
+ # Apply optimal scaling during fusion
126
+ pipe.fuse_lora(lora_scale=optimal_scale)
127
+ print(f"Loaded LoRA: {lora_selection} with scale {optimal_scale}")
128
  except Exception as e:
129
  print(f"Failed to load LoRA {lora_selection}: {e}")
130