|
| 1 | +""" |
| 2 | + This file is part of ComfyUI. |
| 3 | + Copyright (C) 2024 Comfy |
| 4 | +
|
| 5 | + This program is free software: you can redistribute it and/or modify |
| 6 | + it under the terms of the GNU General Public License as published by |
| 7 | + the Free Software Foundation, either version 3 of the License, or |
| 8 | + (at your option) any later version. |
| 9 | +
|
| 10 | + This program is distributed in the hope that it will be useful, |
| 11 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | + GNU General Public License for more details. |
| 14 | +
|
| 15 | + You should have received a copy of the GNU General Public License |
| 16 | + along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 17 | +""" |
| 18 | + |
| 19 | + |
1 | 20 | import torch |
2 | 21 | import math |
3 | 22 | import struct |
@@ -432,6 +451,12 @@ def flux_to_diffusers(mmdit_config, output_prefix=""): |
432 | 451 | key_map["{}to_k.{}".format(k, end)] = (qkv, (0, hidden_size, hidden_size)) |
433 | 452 | key_map["{}to_v.{}".format(k, end)] = (qkv, (0, hidden_size * 2, hidden_size)) |
434 | 453 |
|
| 454 | + k = "{}.attn.".format(prefix_from) |
| 455 | + qkv = "{}.txt_attn.qkv.{}".format(prefix_to, end) |
| 456 | + key_map["{}add_q_proj.{}".format(k, end)] = (qkv, (0, 0, hidden_size)) |
| 457 | + key_map["{}add_k_proj.{}".format(k, end)] = (qkv, (0, hidden_size, hidden_size)) |
| 458 | + key_map["{}add_v_proj.{}".format(k, end)] = (qkv, (0, hidden_size * 2, hidden_size)) |
| 459 | + |
435 | 460 | block_map = {"attn.to_out.0.weight": "img_attn.proj.weight", |
436 | 461 | "attn.to_out.0.bias": "img_attn.proj.bias", |
437 | 462 | } |
|
0 commit comments