silveroxides commited on
Commit
40661de
·
verified ·
1 Parent(s): 337f8d4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -8
app.py CHANGED
@@ -11,11 +11,12 @@ import spaces
11
  from comfy import model_management
12
 
13
  CHROMA_VERSION = "Chroma1-HD-flash-heun/Chroma1-HD-flash-heun-fp8_scaled_original_hybrid_large.safetensors"
14
-
15
  # Download required models
16
  t5_path = hf_hub_download(repo_id="silveroxides/flan-t5-xxl-encoder-only", filename="flan-t5-xxl_float8_e4m3fn_scaled_stochastic.safetensors", local_dir="models/text_encoders/")
17
  vae_path = hf_hub_download(repo_id="lodestones/Chroma", filename="ae.safetensors", local_dir="models/vae")
18
  unet_path = hf_hub_download(repo_id="silveroxides/Chroma-Misc-Models", filename=CHROMA_VERSION, local_dir="models/unet")
 
19
 
20
  # Example prompts with their parameters
21
  EXAMPLES = [
@@ -134,7 +135,7 @@ from nodes import (
134
  CLIPTextEncode,
135
  CLIPLoader,
136
  VAEDecode,
137
- UNETLoader,
138
  VAELoader,
139
  SaveImage,
140
  )
@@ -148,6 +149,7 @@ t5tokenizeroptions = NODE_CLASS_MAPPINGS["T5TokenizerOptions"]()
148
  cliptextencode = CLIPTextEncode()
149
  unetloader = NODE_CLASS_MAPPINGS["ScaledFP8HybridUNetLoader"]()
150
  vaeloader = VAELoader()
 
151
  modelsamplingauraflow = NODE_CLASS_MAPPINGS["ModelSamplingAuraFlow"]()
152
  cfgguider = NODE_CLASS_MAPPINGS["CFGGuider"]()
153
  betascheduler = NODE_CLASS_MAPPINGS["BetaSamplingScheduler"]()
@@ -160,15 +162,24 @@ cliploader_78 = cliploader.load_clip(
160
  clip_name="flan-t5-xxl_float8_e4m3fn_scaled_stochastic.safetensors", type="chroma", device="default"
161
  )
162
  t5tokenizeroptions_82 = t5tokenizeroptions.set_options(
163
- min_padding=0, min_length=0, clip=get_value_at_index(cliploader_78, 0)
 
 
164
  )
165
  unetloader_76 = unetloader.load_unet(
166
  model_name=CHROMA_VERSION, chroma_hybrid_large=True, radiance_hybrid_large=False, chroma_hybrid_small=False, radiance_hybrid_small=False, wan=False, qwen=False
167
  )
168
  vaeloader_80 = vaeloader.load_vae(vae_name="ae.safetensors")
169
 
 
 
 
 
 
 
 
170
  # Add all the models that load a safetensors file
171
- model_loaders = [cliploader_78, unetloader_76, vaeloader_80]
172
 
173
  # Check which models are valid and how to best load them
174
  valid_models = [
@@ -203,15 +214,14 @@ def generate_image(prompt, negative_prompt, width, height, steps, cfg, seed):
203
  clip=get_value_at_index(t5tokenizeroptions_82, 0),
204
  )
205
 
206
-
207
  modelsamplingauraflow_85 = modelsamplingauraflow.patch(
208
  shift=1.0,
209
- model=get_value_at_index(unetloader_76, 0),
210
  )
211
 
212
  cfgguider_73 = cfgguider.get_guider(
213
  cfg=cfg,
214
- model=get_value_at_index(unetloader_76, 0),
215
  positive=get_value_at_index(cliptextencode_74, 0),
216
  negative=get_value_at_index(cliptextencode_75, 0),
217
  )
@@ -220,7 +230,7 @@ def generate_image(prompt, negative_prompt, width, height, steps, cfg, seed):
220
  steps=steps,
221
  alpha=0.45,
222
  beta=0.45,
223
- model=get_value_at_index(unetloader_76, 0),
224
  )
225
 
226
  samplercustomadvanced_67 = samplercustomadvanced.sample(
 
11
  from comfy import model_management
12
 
13
  CHROMA_VERSION = "Chroma1-HD-flash-heun/Chroma1-HD-flash-heun-fp8_scaled_original_hybrid_large.safetensors"
14
+ LORA_VERSION = "flash-heun-pruned/chroma-flash-heun_r01-fp32-pruned.safetensors"
15
  # Download required models
16
  t5_path = hf_hub_download(repo_id="silveroxides/flan-t5-xxl-encoder-only", filename="flan-t5-xxl_float8_e4m3fn_scaled_stochastic.safetensors", local_dir="models/text_encoders/")
17
  vae_path = hf_hub_download(repo_id="lodestones/Chroma", filename="ae.safetensors", local_dir="models/vae")
18
  unet_path = hf_hub_download(repo_id="silveroxides/Chroma-Misc-Models", filename=CHROMA_VERSION, local_dir="models/unet")
19
+ lora_path = hf_hub_download(repo_id="silveroxides/Chroma-LoRAs", filename=LORA_VERSION, local_dir="models/loras")
20
 
21
  # Example prompts with their parameters
22
  EXAMPLES = [
 
135
  CLIPTextEncode,
136
  CLIPLoader,
137
  VAEDecode,
138
+ LoraLoaderModelOnly,
139
  VAELoader,
140
  SaveImage,
141
  )
 
149
  cliptextencode = CLIPTextEncode()
150
  unetloader = NODE_CLASS_MAPPINGS["ScaledFP8HybridUNetLoader"]()
151
  vaeloader = VAELoader()
152
+ loraloader = LoraLoaderModelOnly()
153
  modelsamplingauraflow = NODE_CLASS_MAPPINGS["ModelSamplingAuraFlow"]()
154
  cfgguider = NODE_CLASS_MAPPINGS["CFGGuider"]()
155
  betascheduler = NODE_CLASS_MAPPINGS["BetaSamplingScheduler"]()
 
162
  clip_name="flan-t5-xxl_float8_e4m3fn_scaled_stochastic.safetensors", type="chroma", device="default"
163
  )
164
  t5tokenizeroptions_82 = t5tokenizeroptions.set_options(
165
+ min_padding=0,
166
+ min_length=0,
167
+ clip=get_value_at_index(cliploader_78, 0)
168
  )
169
  unetloader_76 = unetloader.load_unet(
170
  model_name=CHROMA_VERSION, chroma_hybrid_large=True, radiance_hybrid_large=False, chroma_hybrid_small=False, radiance_hybrid_small=False, wan=False, qwen=False
171
  )
172
  vaeloader_80 = vaeloader.load_vae(vae_name="ae.safetensors")
173
 
174
+ loraloader_81 = loraloader.load_lora_model_only(
175
+ lora_name=LORA_VERSION,
176
+ strength_model=1.0,
177
+ model=get_value_at_index(unetloader_76, 0),
178
+ )
179
+
180
+
181
  # Add all the models that load a safetensors file
182
+ model_loaders = [cliploader_78, unetloader_76, vaeloader_80, loraloader_81]
183
 
184
  # Check which models are valid and how to best load them
185
  valid_models = [
 
214
  clip=get_value_at_index(t5tokenizeroptions_82, 0),
215
  )
216
 
 
217
  modelsamplingauraflow_85 = modelsamplingauraflow.patch(
218
  shift=1.0,
219
+ model=get_value_at_index(loraloader_81, 0),
220
  )
221
 
222
  cfgguider_73 = cfgguider.get_guider(
223
  cfg=cfg,
224
+ model=get_value_at_index(loraloader_81, 0),
225
  positive=get_value_at_index(cliptextencode_74, 0),
226
  negative=get_value_at_index(cliptextencode_75, 0),
227
  )
 
230
  steps=steps,
231
  alpha=0.45,
232
  beta=0.45,
233
+ model=get_value_at_index(loraloader_81, 0),
234
  )
235
 
236
  samplercustomadvanced_67 = samplercustomadvanced.sample(