WonwoongCho commited on
Commit
bf2e3fc
·
1 Parent(s): dda2a27

debugging app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -0
app.py CHANGED
@@ -40,6 +40,23 @@ def process_image_and_text(image, scale, seed, text):
40
 
41
  pipe.transformer.set_attn_processor(blended_attn_procs)
42
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  out = pipe(
44
  prompt=text,
45
  height=512,
 
40
 
41
  pipe.transformer.set_attn_processor(blended_attn_procs)
42
 
43
+ model_path = hf_hub_download(
44
+ repo_id="WonwoongCho/IT-Blender",
45
+ filename="FLUX/it-blender.bin",
46
+ token=token
47
+ )
48
+
49
+ pretrained_blended_attn_weights = torch.load(model_path, map_location=pipe._execution_device)
50
+
51
+ key_changed_blended_attn_weights = {}
52
+ for key, value in pretrained_blended_attn_weights.items():
53
+ block_idx = int(key.split(".")[0]) - 21
54
+ k_or_v = key.split("_")[2]
55
+ changed_key = f'single_transformer_blocks.{block_idx}.attn.processor.blended_attention_{k_or_v}_proj.weight'
56
+ key_changed_blended_attn_weights[changed_key] = value.to(dtype)
57
+
58
+ missing_keys, unexpected_keys = pipe.transformer.load_state_dict(key_changed_blended_attn_weights, strict=False)
59
+
60
  out = pipe(
61
  prompt=text,
62
  height=512,