Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Overbill1683
Stable Diffusion Webui
提交
46466f09
S
Stable Diffusion Webui
项目概览
Overbill1683
/
Stable Diffusion Webui
10 个月 前同步成功
通知
1736
Star
81
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
分析
仓库
DevOps
项目成员
Pages
S
Stable Diffusion Webui
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Pages
分析
分析
仓库分析
DevOps
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
提交
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
46466f09
编写于
7月 17, 2023
作者:
A
AUTOMATIC1111
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Lokr support
上级
58c3df32
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
67 addition
and
1 deletion
+67
-1
extensions-builtin/Lora/network_ia3.py
extensions-builtin/Lora/network_ia3.py
+0
-1
extensions-builtin/Lora/network_lokr.py
extensions-builtin/Lora/network_lokr.py
+65
-0
extensions-builtin/Lora/networks.py
extensions-builtin/Lora/networks.py
+2
-0
未找到文件。
extensions-builtin/Lora/network_ia3.py
浏览文件 @
46466f09
import
lyco_helpers
import
network
import
network_lyco
...
...
extensions-builtin/Lora/network_lokr.py
0 → 100644
浏览文件 @
46466f09
import
torch
import
lyco_helpers
import
network
import
network_lyco
class
ModuleTypeLokr
(
network
.
ModuleType
):
def
create_module
(
self
,
net
:
network
.
Network
,
weights
:
network
.
NetworkWeights
):
has_1
=
"lokr_w1"
in
weights
.
w
or
(
"lokr_w1a"
in
weights
.
w
and
"lokr_w1b"
in
weights
.
w
)
has_2
=
"lokr_w2"
in
weights
.
w
or
(
"lokr_w2a"
in
weights
.
w
and
"lokr_w2b"
in
weights
.
w
)
if
has_1
and
has_2
:
return
NetworkModuleLokr
(
net
,
weights
)
return
None
def
make_kron
(
orig_shape
,
w1
,
w2
):
if
len
(
w2
.
shape
)
==
4
:
w1
=
w1
.
unsqueeze
(
2
).
unsqueeze
(
2
)
w2
=
w2
.
contiguous
()
return
torch
.
kron
(
w1
,
w2
).
reshape
(
orig_shape
)
class
NetworkModuleLokr
(
network_lyco
.
NetworkModuleLyco
):
def
__init__
(
self
,
net
:
network
.
Network
,
weights
:
network
.
NetworkWeights
):
super
().
__init__
(
net
,
weights
)
self
.
w1
=
weights
.
w
.
get
(
"lokr_w1"
)
self
.
w1a
=
weights
.
w
.
get
(
"lokr_w1_a"
)
self
.
w1b
=
weights
.
w
.
get
(
"lokr_w1_b"
)
self
.
dim
=
self
.
w1b
.
shape
[
0
]
if
self
.
w1b
else
self
.
dim
self
.
w2
=
weights
.
w
.
get
(
"lokr_w2"
)
self
.
w2a
=
weights
.
w
.
get
(
"lokr_w2_a"
)
self
.
w2b
=
weights
.
w
.
get
(
"lokr_w2_b"
)
self
.
dim
=
self
.
w2b
.
shape
[
0
]
if
self
.
w2b
else
self
.
dim
self
.
t2
=
weights
.
w
.
get
(
"lokr_t2"
)
def
calc_updown
(
self
,
orig_weight
):
if
self
.
w1
is
not
None
:
w1
=
self
.
w1
.
to
(
orig_weight
.
device
,
dtype
=
orig_weight
.
dtype
)
else
:
w1a
=
self
.
w1a
.
to
(
orig_weight
.
device
,
dtype
=
orig_weight
.
dtype
)
w1b
=
self
.
w1b
.
to
(
orig_weight
.
device
,
dtype
=
orig_weight
.
dtype
)
w1
=
w1a
@
w1b
if
self
.
w2
is
not
None
:
w2
=
self
.
w2
.
to
(
orig_weight
.
device
,
dtype
=
orig_weight
.
dtype
)
elif
self
.
t2
is
None
:
w2a
=
self
.
w2a
.
to
(
orig_weight
.
device
,
dtype
=
orig_weight
.
dtype
)
w2b
=
self
.
w2b
.
to
(
orig_weight
.
device
,
dtype
=
orig_weight
.
dtype
)
w2
=
w2a
@
w2b
else
:
t2
=
self
.
t2
.
to
(
orig_weight
.
device
,
dtype
=
orig_weight
.
dtype
)
w2a
=
self
.
w2a
.
to
(
orig_weight
.
device
,
dtype
=
orig_weight
.
dtype
)
w2b
=
self
.
w2b
.
to
(
orig_weight
.
device
,
dtype
=
orig_weight
.
dtype
)
w2
=
lyco_helpers
.
make_weight_cp
(
t2
,
w2a
,
w2b
)
output_shape
=
[
w1
.
size
(
0
)
*
w2
.
size
(
0
),
w1
.
size
(
1
)
*
w2
.
size
(
1
)]
if
len
(
orig_weight
.
shape
)
==
4
:
output_shape
=
orig_weight
.
shape
updown
=
make_kron
(
output_shape
,
w1
,
w2
)
return
self
.
finalize_updown
(
updown
,
orig_weight
,
output_shape
)
extensions-builtin/Lora/networks.py
浏览文件 @
46466f09
...
...
@@ -5,6 +5,7 @@ import network
import
network_lora
import
network_hada
import
network_ia3
import
network_lokr
import
torch
from
typing
import
Union
...
...
@@ -15,6 +16,7 @@ module_types = [
network_lora
.
ModuleTypeLora
(),
network_hada
.
ModuleTypeHada
(),
network_ia3
.
ModuleTypeIa3
(),
network_lokr
.
ModuleTypeLokr
(),
]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录