-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinswapper.py
230 lines (225 loc) · 9.48 KB
/
inswapper.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
# !wget https://github.com/dream80/roop_colab/releases/download/v0.0.1/inswapper_128.onnx
# !pip3 install onnx onnx2pytorch
# import onnx
# from onnx2pytorch import ConvertModel
# onnx_model = onnx.load('inswapper_128.onnx')
# pytorch_model = ConvertModel(onnx_model)
# print(pytorch_model)
'''
INSwapper(
(Pad_input): Pad(mode=reflect, padding=None)
(Conv_input.7): Conv2d(3, 128, kernel_size=(7, 7), stride=(1, 1))
(LeakyRelu_onnx::Conv_126): LeakyReLU(negative_slope=0.20000000298023224, inplace=True)
(Conv_input.15): Conv2d(128, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
(LeakyRelu_onnx::Conv_129): LeakyReLU(negative_slope=0.20000000298023224, inplace=True)
(Conv_input.23): Conv2d(256, 512, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1))
(LeakyRelu_onnx::Conv_132): LeakyReLU(negative_slope=0.20000000298023224, inplace=True)
(Conv_input.31): Conv2d(512, 1024, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1))
(LeakyRelu_onnx::Pad_135): LeakyReLU(negative_slope=0.20000000298023224, inplace=True)
(Pad_input.35): Pad(mode=reflect, padding=None)
(Conv_onnx::ReduceMean_159): Conv2d(1024, 1024, kernel_size=(3, 3), stride=(1, 1))
(Sub_onnx::Mul_161): tanh()
(Mul_onnx::ReduceMean_162): tanh()
(Add_onnx::Sqrt_165): Add()
(Sqrt_onnx::Div_166): tanh()
(Div_onnx::Mul_168): Div()
(Mul_onnx::Mul_169): tanh()
(Gemm_onnx::Unsqueeze_170): Linear(in_features=512, out_features=2048, bias=True)
(Unsqueeze_onnx::Unsqueeze_171): Unsqueeze()
(Unsqueeze_onnx::Shape_172): Unsqueeze()
(Slice_onnx::Mul_183): Slice()
(Slice_onnx::Add_186): Slice()
(Mul_onnx::Add_187): tanh()
(Add_input.39): Add()
(Relu_onnx::Pad_189): ReLU(inplace=True)
(Pad_input.43): Pad(mode=reflect, padding=None)
(Conv_onnx::ReduceMean_213): Conv2d(1024, 1024, kernel_size=(3, 3), stride=(1, 1))
(Sub_onnx::Mul_215): tanh()
(Mul_onnx::ReduceMean_216): tanh()
(Add_onnx::Sqrt_219): Add()
(Sqrt_onnx::Div_220): tanh()
(Div_onnx::Mul_222): Div()
(Mul_onnx::Mul_223): tanh()
(Gemm_onnx::Unsqueeze_224): Linear(in_features=512, out_features=2048, bias=True)
(Unsqueeze_onnx::Unsqueeze_225): Unsqueeze()
(Unsqueeze_onnx::Shape_226): Unsqueeze()
(Slice_onnx::Mul_237): Slice()
(Slice_onnx::Add_240): Slice()
(Mul_onnx::Add_241): tanh()
(Add_onnx::Add_242): Add()
(Add_onnx::Pad_243): Add()
(Pad_input.47): Pad(mode=reflect, padding=None)
(Conv_onnx::ReduceMean_267): Conv2d(1024, 1024, kernel_size=(3, 3), stride=(1, 1))
(Sub_onnx::Mul_269): tanh()
(Mul_onnx::ReduceMean_270): tanh()
(Add_onnx::Sqrt_273): Add()
(Sqrt_onnx::Div_274): tanh()
(Div_onnx::Mul_276): Div()
(Mul_onnx::Mul_277): tanh()
(Gemm_onnx::Unsqueeze_278): Linear(in_features=512, out_features=2048, bias=True)
(Unsqueeze_onnx::Unsqueeze_279): Unsqueeze()
(Unsqueeze_onnx::Shape_280): Unsqueeze()
(Slice_onnx::Mul_291): Slice()
(Slice_onnx::Add_294): Slice()
(Mul_onnx::Add_295): tanh()
(Add_input.51): Add()
(Relu_onnx::Pad_297): ReLU(inplace=True)
(Pad_input.55): Pad(mode=reflect, padding=None)
(Conv_onnx::ReduceMean_321): Conv2d(1024, 1024, kernel_size=(3, 3), stride=(1, 1))
(Sub_onnx::Mul_323): tanh()
(Mul_onnx::ReduceMean_324): tanh()
(Add_onnx::Sqrt_327): Add()
(Sqrt_onnx::Div_328): tanh()
(Div_onnx::Mul_330): Div()
(Mul_onnx::Mul_331): tanh()
(Gemm_onnx::Unsqueeze_332): Linear(in_features=512, out_features=2048, bias=True)
(Unsqueeze_onnx::Unsqueeze_333): Unsqueeze()
(Unsqueeze_onnx::Shape_334): Unsqueeze()
(Slice_onnx::Mul_345): Slice()
(Slice_onnx::Add_348): Slice()
(Mul_onnx::Add_349): tanh()
(Add_onnx::Add_350): Add()
(Add_onnx::Pad_351): Add()
(Pad_input.59): Pad(mode=reflect, padding=None)
(Conv_onnx::ReduceMean_375): Conv2d(1024, 1024, kernel_size=(3, 3), stride=(1, 1))
(Sub_onnx::Mul_377): tanh()
(Mul_onnx::ReduceMean_378): tanh()
(Add_onnx::Sqrt_381): Add()
(Sqrt_onnx::Div_382): tanh()
(Div_onnx::Mul_384): Div()
(Mul_onnx::Mul_385): tanh()
(Gemm_onnx::Unsqueeze_386): Linear(in_features=512, out_features=2048, bias=True)
(Unsqueeze_onnx::Unsqueeze_387): Unsqueeze()
(Unsqueeze_onnx::Shape_388): Unsqueeze()
(Slice_onnx::Mul_399): Slice()
(Slice_onnx::Add_402): Slice()
(Mul_onnx::Add_403): tanh()
(Add_input.63): Add()
(Relu_onnx::Pad_405): ReLU(inplace=True)
(Pad_input.67): Pad(mode=reflect, padding=None)
(Conv_onnx::ReduceMean_429): Conv2d(1024, 1024, kernel_size=(3, 3), stride=(1, 1))
(Sub_onnx::Mul_431): tanh()
(Mul_onnx::ReduceMean_432): tanh()
(Add_onnx::Sqrt_435): Add()
(Sqrt_onnx::Div_436): tanh()
(Div_onnx::Mul_438): Div()
(Mul_onnx::Mul_439): tanh()
(Gemm_onnx::Unsqueeze_440): Linear(in_features=512, out_features=2048, bias=True)
(Unsqueeze_onnx::Unsqueeze_441): Unsqueeze()
(Unsqueeze_onnx::Shape_442): Unsqueeze()
(Slice_onnx::Mul_453): Slice()
(Slice_onnx::Add_456): Slice()
(Mul_onnx::Add_457): tanh()
(Add_onnx::Add_458): Add()
(Add_onnx::Pad_459): Add()
(Pad_input.71): Pad(mode=reflect, padding=None)
(Conv_onnx::ReduceMean_483): Conv2d(1024, 1024, kernel_size=(3, 3), stride=(1, 1))
(Sub_onnx::Mul_485): tanh()
(Mul_onnx::ReduceMean_486): tanh()
(Add_onnx::Sqrt_489): Add()
(Sqrt_onnx::Div_490): tanh()
(Div_onnx::Mul_492): Div()
(Mul_onnx::Mul_493): tanh()
(Gemm_onnx::Unsqueeze_494): Linear(in_features=512, out_features=2048, bias=True)
(Unsqueeze_onnx::Unsqueeze_495): Unsqueeze()
(Unsqueeze_onnx::Shape_496): Unsqueeze()
(Slice_onnx::Mul_507): Slice()
(Slice_onnx::Add_510): Slice()
(Mul_onnx::Add_511): tanh()
(Add_input.75): Add()
(Relu_onnx::Pad_513): ReLU(inplace=True)
(Pad_input.79): Pad(mode=reflect, padding=None)
(Conv_onnx::ReduceMean_537): Conv2d(1024, 1024, kernel_size=(3, 3), stride=(1, 1))
(Sub_onnx::Mul_539): tanh()
(Mul_onnx::ReduceMean_540): tanh()
(Add_onnx::Sqrt_543): Add()
(Sqrt_onnx::Div_544): tanh()
(Div_onnx::Mul_546): Div()
(Mul_onnx::Mul_547): tanh()
(Gemm_onnx::Unsqueeze_548): Linear(in_features=512, out_features=2048, bias=True)
(Unsqueeze_onnx::Unsqueeze_549): Unsqueeze()
(Unsqueeze_onnx::Shape_550): Unsqueeze()
(Slice_onnx::Mul_561): Slice()
(Slice_onnx::Add_564): Slice()
(Mul_onnx::Add_565): tanh()
(Add_onnx::Add_566): Add()
(Add_onnx::Pad_567): Add()
(Pad_input.83): Pad(mode=reflect, padding=None)
(Conv_onnx::ReduceMean_591): Conv2d(1024, 1024, kernel_size=(3, 3), stride=(1, 1))
(Sub_onnx::Mul_593): tanh()
(Mul_onnx::ReduceMean_594): tanh()
(Add_onnx::Sqrt_597): Add()
(Sqrt_onnx::Div_598): tanh()
(Div_onnx::Mul_600): Div()
(Mul_onnx::Mul_601): tanh()
(Gemm_onnx::Unsqueeze_602): Linear(in_features=512, out_features=2048, bias=True)
(Unsqueeze_onnx::Unsqueeze_603): Unsqueeze()
(Unsqueeze_onnx::Shape_604): Unsqueeze()
(Slice_onnx::Mul_615): Slice()
(Slice_onnx::Add_618): Slice()
(Mul_onnx::Add_619): tanh()
(Add_input.87): Add()
(Relu_onnx::Pad_621): ReLU(inplace=True)
(Pad_input.91): Pad(mode=reflect, padding=None)
(Conv_onnx::ReduceMean_645): Conv2d(1024, 1024, kernel_size=(3, 3), stride=(1, 1))
(Sub_onnx::Mul_647): tanh()
(Mul_onnx::ReduceMean_648): tanh()
(Add_onnx::Sqrt_651): Add()
(Sqrt_onnx::Div_652): tanh()
(Div_onnx::Mul_654): Div()
(Mul_onnx::Mul_655): tanh()
(Gemm_onnx::Unsqueeze_656): Linear(in_features=512, out_features=2048, bias=True)
(Unsqueeze_onnx::Unsqueeze_657): Unsqueeze()
(Unsqueeze_onnx::Shape_658): Unsqueeze()
(Slice_onnx::Mul_669): Slice()
(Slice_onnx::Add_672): Slice()
(Mul_onnx::Add_673): tanh()
(Add_onnx::Add_674): Add()
(Add_onnx::Pad_675): Add()
(Pad_input.95): Pad(mode=reflect, padding=None)
(Conv_onnx::ReduceMean_699): Conv2d(1024, 1024, kernel_size=(3, 3), stride=(1, 1))
(Sub_onnx::Mul_701): tanh()
(Mul_onnx::ReduceMean_702): tanh()
(Add_onnx::Sqrt_705): Add()
(Sqrt_onnx::Div_706): tanh()
(Div_onnx::Mul_708): Div()
(Mul_onnx::Mul_709): tanh()
(Gemm_onnx::Unsqueeze_710): Linear(in_features=512, out_features=2048, bias=True)
(Unsqueeze_onnx::Unsqueeze_711): Unsqueeze()
(Unsqueeze_onnx::Shape_712): Unsqueeze()
(Slice_onnx::Mul_723): Slice()
(Slice_onnx::Add_726): Slice()
(Mul_onnx::Add_727): tanh()
(Add_input.99): Add()
(Relu_onnx::Pad_729): ReLU(inplace=True)
(Pad_input.103): Pad(mode=reflect, padding=None)
(Conv_onnx::ReduceMean_753): Conv2d(1024, 1024, kernel_size=(3, 3), stride=(1, 1))
(Sub_onnx::Mul_755): tanh()
(Mul_onnx::ReduceMean_756): tanh()
(Add_onnx::Sqrt_759): Add()
(Sqrt_onnx::Div_760): tanh()
(Div_onnx::Mul_762): Div()
(Mul_onnx::Mul_763): tanh()
(Gemm_onnx::Unsqueeze_764): Linear(in_features=512, out_features=2048, bias=True)
(Unsqueeze_onnx::Unsqueeze_765): Unsqueeze()
(Unsqueeze_onnx::Shape_766): Unsqueeze()
(Slice_onnx::Mul_777): Slice()
(Slice_onnx::Add_780): Slice()
(Mul_onnx::Add_781): tanh()
(Add_onnx::Add_782): Add()
(Add_input.107): Add()
(Resize_input.111): Resize()
(Conv_input.119): Conv2d(1024, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
(LeakyRelu_onnx::Resize_791): LeakyReLU(negative_slope=0.20000000298023224, inplace=True)
(Resize_input.123): Resize()
(Conv_input.131): Conv2d(512, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
(LeakyRelu_onnx::Conv_799): LeakyReLU(negative_slope=0.20000000298023224, inplace=True)
(Conv_input.139): Conv2d(256, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
(LeakyRelu_onnx::Pad_802): LeakyReLU(negative_slope=0.20000000298023224, inplace=True)
(Pad_input.143): Pad(mode=reflect, padding=None)
(Conv_onnx::Tanh_826): Conv2d(128, 3, kernel_size=(7, 7), stride=(1, 1))
(Tanh_onnx::Add_827): tanh()
(Add_onnx::Div_829): Add()
(Div_output): Div()
)
'''