File size: 37,158 Bytes
48d2b52
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "provenance": []
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "source": [
        "# Cast civitai trained LoRa in torch.bfloat16 to Tensor Art Compatible torch.float16 dtype\n",
        "\n",
        "Created by Adcom: https://tensor.art/u/743241123023077878"
      ],
      "metadata": {
        "id": "YDCnQpDdqDe4"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "#initialize\n",
        "import torch\n",
        "from safetensors.torch import load_file\n",
        "from google.colab import drive\n",
        "drive.mount('/content/drive')"
      ],
      "metadata": {
        "id": "1oxeJYHRqxQC",
        "outputId": "5397ceb1-cd98-4477-f472-d766beac79fb",
        "colab": {
          "base_uri": "https://localhost:8080/"
        }
      },
      "execution_count": 1,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Mounted at /content/drive\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "cgi = load_file('/content/drive/MyDrive/Saved from Chrome/cgi_style.safetensors')"
      ],
      "metadata": {
        "id": "JuGDCX5272Bh"
      },
      "execution_count": 10,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "cgi = load_file('/content/drive/MyDrive/Saved from Chrome/cgi_style.safetensors')\n",
        "iris = load_file('/content/drive/MyDrive/Saved from Chrome/proud_iris.safetensors')\n",
        "nudism = load_file('/content/drive/MyDrive/Saved from Chrome/nudism.safetensors')"
      ],
      "metadata": {
        "id": "FftDdBRG7su6"
      },
      "execution_count": 107,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "for key in cgi:\n",
        "  cgi[f'{key}'] = cgi[f'{key}'].to(dtype=torch.float16)\n",
        "  iris[f'{key}'] = iris[f'{key}'].to(dtype=torch.float16)\n",
        "  nudism[f'{key}'] = nudism[f'{key}'].to(dtype=torch.float16)"
      ],
      "metadata": {
        "id": "RII9SEqh8KH2"
      },
      "execution_count": 108,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "import torch\n",
        "import torch.nn as nn\n",
        "#define metric for similarity\n",
        "tgt_dim = torch.Size([64, 3072])\n",
        "cos0 = nn.CosineSimilarity(dim=1)\n",
        "cos = nn.CosineSimilarity(dim=1)\n",
        "\n",
        "\n",
        "def sim(tgt , ref ,key):\n",
        "  return torch.sum(torch.abs(cos(tgt, ref[f'{key}'])))  + torch.sum(torch.abs(cos0(tgt, ref[f'{key}'])))\n",
        "#-----#\n",
        "\n",
        "from torch import linalg as LA\n",
        "def rand_search(A , B , key , iters):\n",
        "  tgt_norm = (LA.matrix_norm(A[f'{key}']) + LA.matrix_norm(B[f'{key}']))/2\n",
        "  tgt_avg = (A[f'{key}'] + B[f'{key}'])/2\n",
        "\n",
        "  max_sim = (sim(tgt_avg , A , key) + sim(tgt_avg , B , key))\n",
        "  cand = tgt_avg\n",
        "\n",
        "  for iter in range(iters):\n",
        "    rand = torch.ones(tgt_dim)*(-0.5)  + torch.rand(tgt_dim)\n",
        "    rand = rand  * (tgt_norm/LA.matrix_norm(rand))\n",
        "    #rand = (rand + tgt_avg)/2\n",
        "    #rand = rand  * (tgt_norm/LA.matrix_norm(rand))\n",
        "\n",
        "    tmp = sim(rand,A, key) + sim(rand , B, key)\n",
        "    if (tmp > max_sim):\n",
        "      max_sim = tmp\n",
        "      cand = rand\n",
        "      print('found!')\n",
        "      break\n",
        "  #------#\n",
        "  print('returning')\n",
        "  return cand  , max_sim\n",
        "#-----#"
      ],
      "metadata": {
        "id": "hJL6QEclHdHn"
      },
      "execution_count": 104,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "cand , max_sim = rand_search(cgi , iris , 'lora_unet_double_blocks_0_img_attn_proj.lora_down.weight' , 1000)\n",
        "print(sim(cand , iris , key))\n",
        "print(sim(cand , cgi , key))"
      ],
      "metadata": {
        "id": "ckyBSQi5Ll4F",
        "outputId": "341f7192-083d-4423-f61f-4f49d5756e79",
        "colab": {
          "base_uri": "https://localhost:8080/"
        }
      },
      "execution_count": 106,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "returning\n",
            "tensor(91.1875, dtype=torch.float16)\n",
            "tensor(90.2500, dtype=torch.float16)\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "from safetensors.torch import load_file , save_file\n",
        "\n",
        "merge = load_file('/content/drive/MyDrive/Saved from Chrome/cgi_style.safetensors')\n",
        "for key in cgi:\n",
        "  if cgi[f'{key}'].shape == torch.Size([]): continue\n",
        "  merge[f'{key}'] = (cgi[f'{key}'] + iris[f'{key}'])/2\n",
        "\n",
        "%cd /content/\n",
        "save_file(merge , 'cgi_iris_1_1_1_merge.safetensors')"
      ],
      "metadata": {
        "id": "9L_g5Zp9Du2E",
        "outputId": "38661765-461a-42c3-8480-38fe7f1abe3e",
        "colab": {
          "base_uri": "https://localhost:8080/"
        }
      },
      "execution_count": 113,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "/content\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "tgt_dim = torch.Size([64, 3072])\n",
        "cosa = nn.CosineSimilarity(dim=0)\n",
        "cos_dim1 = nn.CosineSimilarity(dim=1)\n",
        "\n",
        "for key in cgi:\n",
        "  if not cgi[f'{key}'].shape == torch.Size([64, 3072]): continue\n",
        "  print(f'{key} : ')\n",
        "  print(torch.sum(torch.abs(cos_dim1(cgi[f'{key}'] , iris[f'{key}']))))"
      ],
      "metadata": {
        "id": "VFNw0Nck8V6Q",
        "outputId": "e48bab98-18f7-43bb-d1cf-89f3e00f7ccf",
        "colab": {
          "base_uri": "https://localhost:8080/"
        }
      },
      "execution_count": 39,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "lora_unet_double_blocks_0_img_attn_proj.lora_down.weight : \n",
            "tensor(1.6982, dtype=torch.float16)\n",
            "lora_unet_double_blocks_0_img_attn_qkv.lora_down.weight : \n",
            "tensor(1.8145, dtype=torch.float16)\n",
            "lora_unet_double_blocks_0_img_mlp_0.lora_down.weight : \n",
            "tensor(1.6309, dtype=torch.float16)\n",
            "lora_unet_double_blocks_0_img_mod_lin.lora_down.weight : \n",
            "tensor(2.6211, dtype=torch.float16)\n",
            "lora_unet_double_blocks_0_txt_attn_proj.lora_down.weight : \n",
            "tensor(2.3203, dtype=torch.float16)\n",
            "lora_unet_double_blocks_0_txt_attn_qkv.lora_down.weight : \n",
            "tensor(2.3027, dtype=torch.float16)\n",
            "lora_unet_double_blocks_0_txt_mlp_0.lora_down.weight : \n",
            "tensor(2.5898, dtype=torch.float16)\n",
            "lora_unet_double_blocks_0_txt_mod_lin.lora_down.weight : \n",
            "tensor(2.7402, dtype=torch.float16)\n",
            "lora_unet_double_blocks_10_img_attn_proj.lora_down.weight : \n",
            "tensor(2.0410, dtype=torch.float16)\n",
            "lora_unet_double_blocks_10_img_attn_qkv.lora_down.weight : \n",
            "tensor(1.3350, dtype=torch.float16)\n",
            "lora_unet_double_blocks_10_img_mlp_0.lora_down.weight : \n",
            "tensor(2.0020, dtype=torch.float16)\n",
            "lora_unet_double_blocks_10_img_mod_lin.lora_down.weight : \n",
            "tensor(2.6562, dtype=torch.float16)\n",
            "lora_unet_double_blocks_10_txt_attn_proj.lora_down.weight : \n",
            "tensor(1.1816, dtype=torch.float16)\n",
            "lora_unet_double_blocks_10_txt_attn_qkv.lora_down.weight : \n",
            "tensor(1.1348, dtype=torch.float16)\n",
            "lora_unet_double_blocks_10_txt_mlp_0.lora_down.weight : \n",
            "tensor(3.0156, dtype=torch.float16)\n",
            "lora_unet_double_blocks_10_txt_mod_lin.lora_down.weight : \n",
            "tensor(1.4746, dtype=torch.float16)\n",
            "lora_unet_double_blocks_11_img_attn_proj.lora_down.weight : \n",
            "tensor(1.8359, dtype=torch.float16)\n",
            "lora_unet_double_blocks_11_img_attn_qkv.lora_down.weight : \n",
            "tensor(1.5312, dtype=torch.float16)\n",
            "lora_unet_double_blocks_11_img_mlp_0.lora_down.weight : \n",
            "tensor(2.1465, dtype=torch.float16)\n",
            "lora_unet_double_blocks_11_img_mod_lin.lora_down.weight : \n",
            "tensor(3.9277, dtype=torch.float16)\n",
            "lora_unet_double_blocks_11_txt_attn_proj.lora_down.weight : \n",
            "tensor(1.7246, dtype=torch.float16)\n",
            "lora_unet_double_blocks_11_txt_attn_qkv.lora_down.weight : \n",
            "tensor(1.8594, dtype=torch.float16)\n",
            "lora_unet_double_blocks_11_txt_mlp_0.lora_down.weight : \n",
            "tensor(3.6465, dtype=torch.float16)\n",
            "lora_unet_double_blocks_11_txt_mod_lin.lora_down.weight : \n",
            "tensor(2.6152, dtype=torch.float16)\n",
            "lora_unet_double_blocks_12_img_attn_proj.lora_down.weight : \n",
            "tensor(1.7295, dtype=torch.float16)\n",
            "lora_unet_double_blocks_12_img_attn_qkv.lora_down.weight : \n",
            "tensor(1.4795, dtype=torch.float16)\n",
            "lora_unet_double_blocks_12_img_mlp_0.lora_down.weight : \n",
            "tensor(3.4043, dtype=torch.float16)\n",
            "lora_unet_double_blocks_12_img_mod_lin.lora_down.weight : \n",
            "tensor(2.0137, dtype=torch.float16)\n",
            "lora_unet_double_blocks_12_txt_attn_proj.lora_down.weight : \n",
            "tensor(1.4375, dtype=torch.float16)\n",
            "lora_unet_double_blocks_12_txt_attn_qkv.lora_down.weight : \n",
            "tensor(1.8994, dtype=torch.float16)\n",
            "lora_unet_double_blocks_12_txt_mlp_0.lora_down.weight : \n",
            "tensor(2.1152, dtype=torch.float16)\n",
            "lora_unet_double_blocks_12_txt_mod_lin.lora_down.weight : \n",
            "tensor(1.2744, dtype=torch.float16)\n",
            "lora_unet_double_blocks_13_img_attn_proj.lora_down.weight : \n",
            "tensor(3.0742, dtype=torch.float16)\n",
            "lora_unet_double_blocks_13_img_attn_qkv.lora_down.weight : \n",
            "tensor(1.4980, dtype=torch.float16)\n",
            "lora_unet_double_blocks_13_img_mlp_0.lora_down.weight : \n",
            "tensor(1.9609, dtype=torch.float16)\n",
            "lora_unet_double_blocks_13_img_mod_lin.lora_down.weight : \n",
            "tensor(2.6133, dtype=torch.float16)\n",
            "lora_unet_double_blocks_13_txt_attn_proj.lora_down.weight : \n",
            "tensor(1.6904, dtype=torch.float16)\n",
            "lora_unet_double_blocks_13_txt_attn_qkv.lora_down.weight : \n",
            "tensor(2.1680, dtype=torch.float16)\n",
            "lora_unet_double_blocks_13_txt_mlp_0.lora_down.weight : \n",
            "tensor(2.8574, dtype=torch.float16)\n",
            "lora_unet_double_blocks_13_txt_mod_lin.lora_down.weight : \n",
            "tensor(1.9053, dtype=torch.float16)\n",
            "lora_unet_double_blocks_14_img_attn_proj.lora_down.weight : \n",
            "tensor(1.8135, dtype=torch.float16)\n",
            "lora_unet_double_blocks_14_img_attn_qkv.lora_down.weight : \n",
            "tensor(1.4033, dtype=torch.float16)\n",
            "lora_unet_double_blocks_14_img_mlp_0.lora_down.weight : \n",
            "tensor(1.5547, dtype=torch.float16)\n",
            "lora_unet_double_blocks_14_img_mod_lin.lora_down.weight : \n",
            "tensor(2.8906, dtype=torch.float16)\n",
            "lora_unet_double_blocks_14_txt_attn_proj.lora_down.weight : \n",
            "tensor(1.1328, dtype=torch.float16)\n",
            "lora_unet_double_blocks_14_txt_attn_qkv.lora_down.weight : \n",
            "tensor(1.3701, dtype=torch.float16)\n",
            "lora_unet_double_blocks_14_txt_mlp_0.lora_down.weight : \n",
            "tensor(3.3145, dtype=torch.float16)\n",
            "lora_unet_double_blocks_14_txt_mod_lin.lora_down.weight : \n",
            "tensor(1.2031, dtype=torch.float16)\n",
            "lora_unet_double_blocks_15_img_attn_proj.lora_down.weight : \n",
            "tensor(1.5137, dtype=torch.float16)\n",
            "lora_unet_double_blocks_15_img_attn_qkv.lora_down.weight : \n",
            "tensor(1.3809, dtype=torch.float16)\n",
            "lora_unet_double_blocks_15_img_mlp_0.lora_down.weight : \n",
            "tensor(1.4834, dtype=torch.float16)\n",
            "lora_unet_double_blocks_15_img_mod_lin.lora_down.weight : \n",
            "tensor(1.6465, dtype=torch.float16)\n",
            "lora_unet_double_blocks_15_txt_attn_proj.lora_down.weight : \n",
            "tensor(1.7256, dtype=torch.float16)\n",
            "lora_unet_double_blocks_15_txt_attn_qkv.lora_down.weight : \n",
            "tensor(2.8672, dtype=torch.float16)\n",
            "lora_unet_double_blocks_15_txt_mlp_0.lora_down.weight : \n",
            "tensor(2.1953, dtype=torch.float16)\n",
            "lora_unet_double_blocks_15_txt_mod_lin.lora_down.weight : \n",
            "tensor(0.9858, dtype=torch.float16)\n",
            "lora_unet_double_blocks_16_img_attn_proj.lora_down.weight : \n",
            "tensor(1.5703, dtype=torch.float16)\n",
            "lora_unet_double_blocks_16_img_attn_qkv.lora_down.weight : \n",
            "tensor(1.4648, dtype=torch.float16)\n",
            "lora_unet_double_blocks_16_img_mlp_0.lora_down.weight : \n",
            "tensor(1.5537, dtype=torch.float16)\n",
            "lora_unet_double_blocks_16_img_mod_lin.lora_down.weight : \n",
            "tensor(2.6133, dtype=torch.float16)\n",
            "lora_unet_double_blocks_16_txt_attn_proj.lora_down.weight : \n",
            "tensor(2.2559, dtype=torch.float16)\n",
            "lora_unet_double_blocks_16_txt_attn_qkv.lora_down.weight : \n",
            "tensor(1.9365, dtype=torch.float16)\n",
            "lora_unet_double_blocks_16_txt_mlp_0.lora_down.weight : \n",
            "tensor(2.7891, dtype=torch.float16)\n",
            "lora_unet_double_blocks_16_txt_mod_lin.lora_down.weight : \n",
            "tensor(1.3174, dtype=torch.float16)\n",
            "lora_unet_double_blocks_17_img_attn_proj.lora_down.weight : \n",
            "tensor(2.4609, dtype=torch.float16)\n",
            "lora_unet_double_blocks_17_img_attn_qkv.lora_down.weight : \n",
            "tensor(1.6240, dtype=torch.float16)\n",
            "lora_unet_double_blocks_17_img_mlp_0.lora_down.weight : \n",
            "tensor(3.1406, dtype=torch.float16)\n",
            "lora_unet_double_blocks_17_img_mod_lin.lora_down.weight : \n",
            "tensor(2.1055, dtype=torch.float16)\n",
            "lora_unet_double_blocks_17_txt_attn_proj.lora_down.weight : \n",
            "tensor(1.7480, dtype=torch.float16)\n",
            "lora_unet_double_blocks_17_txt_attn_qkv.lora_down.weight : \n",
            "tensor(1.6436, dtype=torch.float16)\n",
            "lora_unet_double_blocks_17_txt_mlp_0.lora_down.weight : \n",
            "tensor(1.9688, dtype=torch.float16)\n",
            "lora_unet_double_blocks_17_txt_mod_lin.lora_down.weight : \n",
            "tensor(1.8184, dtype=torch.float16)\n",
            "lora_unet_double_blocks_18_img_attn_proj.lora_down.weight : \n",
            "tensor(2.3887, dtype=torch.float16)\n",
            "lora_unet_double_blocks_18_img_attn_qkv.lora_down.weight : \n",
            "tensor(1.6738, dtype=torch.float16)\n",
            "lora_unet_double_blocks_18_img_mlp_0.lora_down.weight : \n",
            "tensor(3.7500, dtype=torch.float16)\n",
            "lora_unet_double_blocks_18_img_mod_lin.lora_down.weight : \n",
            "tensor(2.7285, dtype=torch.float16)\n",
            "lora_unet_double_blocks_18_txt_attn_proj.lora_down.weight : \n",
            "tensor(2.0410, dtype=torch.float16)\n",
            "lora_unet_double_blocks_18_txt_attn_qkv.lora_down.weight : \n",
            "tensor(2.0586, dtype=torch.float16)\n",
            "lora_unet_double_blocks_18_txt_mlp_0.lora_down.weight : \n",
            "tensor(2.0801, dtype=torch.float16)\n",
            "lora_unet_double_blocks_18_txt_mod_lin.lora_down.weight : \n",
            "tensor(1.5684, dtype=torch.float16)\n",
            "lora_unet_double_blocks_1_img_attn_proj.lora_down.weight : \n",
            "tensor(4.9844, dtype=torch.float16)\n",
            "lora_unet_double_blocks_1_img_attn_qkv.lora_down.weight : \n",
            "tensor(1.8613, dtype=torch.float16)\n",
            "lora_unet_double_blocks_1_img_mlp_0.lora_down.weight : \n",
            "tensor(2.2266, dtype=torch.float16)\n",
            "lora_unet_double_blocks_1_img_mod_lin.lora_down.weight : \n",
            "tensor(2.8164, dtype=torch.float16)\n",
            "lora_unet_double_blocks_1_txt_attn_proj.lora_down.weight : \n",
            "tensor(1.7500, dtype=torch.float16)\n",
            "lora_unet_double_blocks_1_txt_attn_qkv.lora_down.weight : \n",
            "tensor(2.3105, dtype=torch.float16)\n",
            "lora_unet_double_blocks_1_txt_mlp_0.lora_down.weight : \n",
            "tensor(1.9639, dtype=torch.float16)\n",
            "lora_unet_double_blocks_1_txt_mod_lin.lora_down.weight : \n",
            "tensor(2.6504, dtype=torch.float16)\n",
            "lora_unet_double_blocks_2_img_attn_proj.lora_down.weight : \n",
            "tensor(4.6367, dtype=torch.float16)\n",
            "lora_unet_double_blocks_2_img_attn_qkv.lora_down.weight : \n",
            "tensor(1.7988, dtype=torch.float16)\n",
            "lora_unet_double_blocks_2_img_mlp_0.lora_down.weight : \n",
            "tensor(4.6758, dtype=torch.float16)\n",
            "lora_unet_double_blocks_2_img_mod_lin.lora_down.weight : \n",
            "tensor(3.1445, dtype=torch.float16)\n",
            "lora_unet_double_blocks_2_txt_attn_proj.lora_down.weight : \n",
            "tensor(2.2285, dtype=torch.float16)\n",
            "lora_unet_double_blocks_2_txt_attn_qkv.lora_down.weight : \n",
            "tensor(1.4990, dtype=torch.float16)\n",
            "lora_unet_double_blocks_2_txt_mlp_0.lora_down.weight : \n",
            "tensor(2.3984, dtype=torch.float16)\n",
            "lora_unet_double_blocks_2_txt_mod_lin.lora_down.weight : \n",
            "tensor(1.4443, dtype=torch.float16)\n",
            "lora_unet_double_blocks_3_img_attn_proj.lora_down.weight : \n",
            "tensor(3.6855, dtype=torch.float16)\n",
            "lora_unet_double_blocks_3_img_attn_qkv.lora_down.weight : \n",
            "tensor(1.9971, dtype=torch.float16)\n",
            "lora_unet_double_blocks_3_img_mlp_0.lora_down.weight : \n",
            "tensor(3.3301, dtype=torch.float16)\n",
            "lora_unet_double_blocks_3_img_mod_lin.lora_down.weight : \n",
            "tensor(2.3379, dtype=torch.float16)\n",
            "lora_unet_double_blocks_3_txt_attn_proj.lora_down.weight : \n",
            "tensor(2.0117, dtype=torch.float16)\n",
            "lora_unet_double_blocks_3_txt_attn_qkv.lora_down.weight : \n",
            "tensor(2.1621, dtype=torch.float16)\n",
            "lora_unet_double_blocks_3_txt_mlp_0.lora_down.weight : \n",
            "tensor(2.7676, dtype=torch.float16)\n",
            "lora_unet_double_blocks_3_txt_mod_lin.lora_down.weight : \n",
            "tensor(3.1895, dtype=torch.float16)\n",
            "lora_unet_double_blocks_4_img_attn_proj.lora_down.weight : \n",
            "tensor(2.3848, dtype=torch.float16)\n",
            "lora_unet_double_blocks_4_img_attn_qkv.lora_down.weight : \n",
            "tensor(1.7783, dtype=torch.float16)\n",
            "lora_unet_double_blocks_4_img_mlp_0.lora_down.weight : \n",
            "tensor(2.0234, dtype=torch.float16)\n",
            "lora_unet_double_blocks_4_img_mod_lin.lora_down.weight : \n",
            "tensor(1.9082, dtype=torch.float16)\n",
            "lora_unet_double_blocks_4_txt_attn_proj.lora_down.weight : \n",
            "tensor(1.7588, dtype=torch.float16)\n",
            "lora_unet_double_blocks_4_txt_attn_qkv.lora_down.weight : \n",
            "tensor(2.9902, dtype=torch.float16)\n",
            "lora_unet_double_blocks_4_txt_mlp_0.lora_down.weight : \n",
            "tensor(1.5859, dtype=torch.float16)\n",
            "lora_unet_double_blocks_4_txt_mod_lin.lora_down.weight : \n",
            "tensor(1.5654, dtype=torch.float16)\n",
            "lora_unet_double_blocks_5_img_attn_proj.lora_down.weight : \n",
            "tensor(2.7402, dtype=torch.float16)\n",
            "lora_unet_double_blocks_5_img_attn_qkv.lora_down.weight : \n",
            "tensor(1.6221, dtype=torch.float16)\n",
            "lora_unet_double_blocks_5_img_mlp_0.lora_down.weight : \n",
            "tensor(1.6318, dtype=torch.float16)\n",
            "lora_unet_double_blocks_5_img_mod_lin.lora_down.weight : \n",
            "tensor(1.7988, dtype=torch.float16)\n",
            "lora_unet_double_blocks_5_txt_attn_proj.lora_down.weight : \n",
            "tensor(1.1699, dtype=torch.float16)\n",
            "lora_unet_double_blocks_5_txt_attn_qkv.lora_down.weight : \n",
            "tensor(3.5566, dtype=torch.float16)\n",
            "lora_unet_double_blocks_5_txt_mlp_0.lora_down.weight : \n",
            "tensor(1.5791, dtype=torch.float16)\n",
            "lora_unet_double_blocks_5_txt_mod_lin.lora_down.weight : \n",
            "tensor(1.5547, dtype=torch.float16)\n",
            "lora_unet_double_blocks_6_img_attn_proj.lora_down.weight : \n",
            "tensor(1.7988, dtype=torch.float16)\n",
            "lora_unet_double_blocks_6_img_attn_qkv.lora_down.weight : \n",
            "tensor(1.4531, dtype=torch.float16)\n",
            "lora_unet_double_blocks_6_img_mlp_0.lora_down.weight : \n",
            "tensor(2.4141, dtype=torch.float16)\n",
            "lora_unet_double_blocks_6_img_mod_lin.lora_down.weight : \n",
            "tensor(6.0234, dtype=torch.float16)\n",
            "lora_unet_double_blocks_6_txt_attn_proj.lora_down.weight : \n",
            "tensor(1.0068, dtype=torch.float16)\n",
            "lora_unet_double_blocks_6_txt_attn_qkv.lora_down.weight : \n",
            "tensor(2.0098, dtype=torch.float16)\n",
            "lora_unet_double_blocks_6_txt_mlp_0.lora_down.weight : \n",
            "tensor(4.0312, dtype=torch.float16)\n",
            "lora_unet_double_blocks_6_txt_mod_lin.lora_down.weight : \n",
            "tensor(2.6309, dtype=torch.float16)\n",
            "lora_unet_double_blocks_7_img_attn_proj.lora_down.weight : \n",
            "tensor(1.4814, dtype=torch.float16)\n",
            "lora_unet_double_blocks_7_img_attn_qkv.lora_down.weight : \n",
            "tensor(1.4854, dtype=torch.float16)\n",
            "lora_unet_double_blocks_7_img_mlp_0.lora_down.weight : \n",
            "tensor(1.3877, dtype=torch.float16)\n",
            "lora_unet_double_blocks_7_img_mod_lin.lora_down.weight : \n",
            "tensor(2.3125, dtype=torch.float16)\n",
            "lora_unet_double_blocks_7_txt_attn_proj.lora_down.weight : \n",
            "tensor(3.4746, dtype=torch.float16)\n",
            "lora_unet_double_blocks_7_txt_attn_qkv.lora_down.weight : \n",
            "tensor(2.0430, dtype=torch.float16)\n",
            "lora_unet_double_blocks_7_txt_mlp_0.lora_down.weight : \n",
            "tensor(1.8018, dtype=torch.float16)\n",
            "lora_unet_double_blocks_7_txt_mod_lin.lora_down.weight : \n",
            "tensor(1.1709, dtype=torch.float16)\n",
            "lora_unet_double_blocks_8_img_attn_proj.lora_down.weight : \n",
            "tensor(1.8857, dtype=torch.float16)\n",
            "lora_unet_double_blocks_8_img_attn_qkv.lora_down.weight : \n",
            "tensor(1.8848, dtype=torch.float16)\n",
            "lora_unet_double_blocks_8_img_mlp_0.lora_down.weight : \n",
            "tensor(1.7627, dtype=torch.float16)\n",
            "lora_unet_double_blocks_8_img_mod_lin.lora_down.weight : \n",
            "tensor(4.2852, dtype=torch.float16)\n",
            "lora_unet_double_blocks_8_txt_attn_proj.lora_down.weight : \n",
            "tensor(1.3887, dtype=torch.float16)\n",
            "lora_unet_double_blocks_8_txt_attn_qkv.lora_down.weight : \n",
            "tensor(1.6289, dtype=torch.float16)\n",
            "lora_unet_double_blocks_8_txt_mlp_0.lora_down.weight : \n",
            "tensor(2.2188, dtype=torch.float16)\n",
            "lora_unet_double_blocks_8_txt_mod_lin.lora_down.weight : \n",
            "tensor(1.5742, dtype=torch.float16)\n",
            "lora_unet_double_blocks_9_img_attn_proj.lora_down.weight : \n",
            "tensor(2.3125, dtype=torch.float16)\n",
            "lora_unet_double_blocks_9_img_attn_qkv.lora_down.weight : \n",
            "tensor(1.4854, dtype=torch.float16)\n",
            "lora_unet_double_blocks_9_img_mlp_0.lora_down.weight : \n",
            "tensor(1.9492, dtype=torch.float16)\n",
            "lora_unet_double_blocks_9_img_mod_lin.lora_down.weight : \n",
            "tensor(2.2949, dtype=torch.float16)\n",
            "lora_unet_double_blocks_9_txt_attn_proj.lora_down.weight : \n",
            "tensor(2.0781, dtype=torch.float16)\n",
            "lora_unet_double_blocks_9_txt_attn_qkv.lora_down.weight : \n",
            "tensor(2.6172, dtype=torch.float16)\n",
            "lora_unet_double_blocks_9_txt_mlp_0.lora_down.weight : \n",
            "tensor(3.1367, dtype=torch.float16)\n",
            "lora_unet_double_blocks_9_txt_mod_lin.lora_down.weight : \n",
            "tensor(1.2451, dtype=torch.float16)\n",
            "lora_unet_single_blocks_0_linear1.lora_down.weight : \n",
            "tensor(2.4375, dtype=torch.float16)\n",
            "lora_unet_single_blocks_0_modulation_lin.lora_down.weight : \n",
            "tensor(3.5684, dtype=torch.float16)\n",
            "lora_unet_single_blocks_10_linear1.lora_down.weight : \n",
            "tensor(2.6328, dtype=torch.float16)\n",
            "lora_unet_single_blocks_10_modulation_lin.lora_down.weight : \n",
            "tensor(2.9961, dtype=torch.float16)\n",
            "lora_unet_single_blocks_11_linear1.lora_down.weight : \n",
            "tensor(3.1211, dtype=torch.float16)\n",
            "lora_unet_single_blocks_11_modulation_lin.lora_down.weight : \n",
            "tensor(3.3672, dtype=torch.float16)\n",
            "lora_unet_single_blocks_12_linear1.lora_down.weight : \n",
            "tensor(3.0293, dtype=torch.float16)\n",
            "lora_unet_single_blocks_12_modulation_lin.lora_down.weight : \n",
            "tensor(3.6602, dtype=torch.float16)\n",
            "lora_unet_single_blocks_13_linear1.lora_down.weight : \n",
            "tensor(2.5918, dtype=torch.float16)\n",
            "lora_unet_single_blocks_13_modulation_lin.lora_down.weight : \n",
            "tensor(4.6367, dtype=torch.float16)\n",
            "lora_unet_single_blocks_14_linear1.lora_down.weight : \n",
            "tensor(2.0215, dtype=torch.float16)\n",
            "lora_unet_single_blocks_14_modulation_lin.lora_down.weight : \n",
            "tensor(3.5371, dtype=torch.float16)\n",
            "lora_unet_single_blocks_15_linear1.lora_down.weight : \n",
            "tensor(2.1719, dtype=torch.float16)\n",
            "lora_unet_single_blocks_15_modulation_lin.lora_down.weight : \n",
            "tensor(4.2812, dtype=torch.float16)\n",
            "lora_unet_single_blocks_16_linear1.lora_down.weight : \n",
            "tensor(2.1992, dtype=torch.float16)\n",
            "lora_unet_single_blocks_16_modulation_lin.lora_down.weight : \n",
            "tensor(4.1094, dtype=torch.float16)\n",
            "lora_unet_single_blocks_17_linear1.lora_down.weight : \n",
            "tensor(2.0703, dtype=torch.float16)\n",
            "lora_unet_single_blocks_17_modulation_lin.lora_down.weight : \n",
            "tensor(2.9277, dtype=torch.float16)\n",
            "lora_unet_single_blocks_18_linear1.lora_down.weight : \n",
            "tensor(2.0371, dtype=torch.float16)\n",
            "lora_unet_single_blocks_18_modulation_lin.lora_down.weight : \n",
            "tensor(2.6133, dtype=torch.float16)\n",
            "lora_unet_single_blocks_19_linear1.lora_down.weight : \n",
            "tensor(2.0723, dtype=torch.float16)\n",
            "lora_unet_single_blocks_19_modulation_lin.lora_down.weight : \n",
            "tensor(3.4980, dtype=torch.float16)\n",
            "lora_unet_single_blocks_1_linear1.lora_down.weight : \n",
            "tensor(1.7432, dtype=torch.float16)\n",
            "lora_unet_single_blocks_1_modulation_lin.lora_down.weight : \n",
            "tensor(2.3848, dtype=torch.float16)\n",
            "lora_unet_single_blocks_20_linear1.lora_down.weight : \n",
            "tensor(2.0137, dtype=torch.float16)\n",
            "lora_unet_single_blocks_20_modulation_lin.lora_down.weight : \n",
            "tensor(2.8203, dtype=torch.float16)\n",
            "lora_unet_single_blocks_21_linear1.lora_down.weight : \n",
            "tensor(1.8955, dtype=torch.float16)\n",
            "lora_unet_single_blocks_21_modulation_lin.lora_down.weight : \n",
            "tensor(2.7305, dtype=torch.float16)\n",
            "lora_unet_single_blocks_22_linear1.lora_down.weight : \n",
            "tensor(2.7559, dtype=torch.float16)\n",
            "lora_unet_single_blocks_22_modulation_lin.lora_down.weight : \n",
            "tensor(4.6133, dtype=torch.float16)\n",
            "lora_unet_single_blocks_23_linear1.lora_down.weight : \n",
            "tensor(2.5508, dtype=torch.float16)\n",
            "lora_unet_single_blocks_23_modulation_lin.lora_down.weight : \n",
            "tensor(4.4180, dtype=torch.float16)\n",
            "lora_unet_single_blocks_24_linear1.lora_down.weight : \n",
            "tensor(1.9219, dtype=torch.float16)\n",
            "lora_unet_single_blocks_24_modulation_lin.lora_down.weight : \n",
            "tensor(2.9453, dtype=torch.float16)\n",
            "lora_unet_single_blocks_25_linear1.lora_down.weight : \n",
            "tensor(2.7539, dtype=torch.float16)\n",
            "lora_unet_single_blocks_25_modulation_lin.lora_down.weight : \n",
            "tensor(4.5938, dtype=torch.float16)\n",
            "lora_unet_single_blocks_26_linear1.lora_down.weight : \n",
            "tensor(3.3750, dtype=torch.float16)\n",
            "lora_unet_single_blocks_26_modulation_lin.lora_down.weight : \n",
            "tensor(4.7344, dtype=torch.float16)\n",
            "lora_unet_single_blocks_27_linear1.lora_down.weight : \n",
            "tensor(2.3809, dtype=torch.float16)\n",
            "lora_unet_single_blocks_27_modulation_lin.lora_down.weight : \n",
            "tensor(4.9883, dtype=torch.float16)\n",
            "lora_unet_single_blocks_28_linear1.lora_down.weight : \n",
            "tensor(3.0859, dtype=torch.float16)\n",
            "lora_unet_single_blocks_28_modulation_lin.lora_down.weight : \n",
            "tensor(5.7539, dtype=torch.float16)\n",
            "lora_unet_single_blocks_29_linear1.lora_down.weight : \n",
            "tensor(2.3242, dtype=torch.float16)\n",
            "lora_unet_single_blocks_29_modulation_lin.lora_down.weight : \n",
            "tensor(3.9160, dtype=torch.float16)\n",
            "lora_unet_single_blocks_2_linear1.lora_down.weight : \n",
            "tensor(2.1406, dtype=torch.float16)\n",
            "lora_unet_single_blocks_2_modulation_lin.lora_down.weight : \n",
            "tensor(2.1621, dtype=torch.float16)\n",
            "lora_unet_single_blocks_30_linear1.lora_down.weight : \n",
            "tensor(2.1211, dtype=torch.float16)\n",
            "lora_unet_single_blocks_30_modulation_lin.lora_down.weight : \n",
            "tensor(4.8516, dtype=torch.float16)\n",
            "lora_unet_single_blocks_31_linear1.lora_down.weight : \n",
            "tensor(2.2773, dtype=torch.float16)\n",
            "lora_unet_single_blocks_31_modulation_lin.lora_down.weight : \n",
            "tensor(4.1367, dtype=torch.float16)\n",
            "lora_unet_single_blocks_32_linear1.lora_down.weight : \n",
            "tensor(2.5273, dtype=torch.float16)\n",
            "lora_unet_single_blocks_32_modulation_lin.lora_down.weight : \n",
            "tensor(5.0508, dtype=torch.float16)\n",
            "lora_unet_single_blocks_33_linear1.lora_down.weight : \n",
            "tensor(2.7051, dtype=torch.float16)\n",
            "lora_unet_single_blocks_33_modulation_lin.lora_down.weight : \n",
            "tensor(5.2930, dtype=torch.float16)\n",
            "lora_unet_single_blocks_34_linear1.lora_down.weight : \n",
            "tensor(2.6738, dtype=torch.float16)\n",
            "lora_unet_single_blocks_34_modulation_lin.lora_down.weight : \n",
            "tensor(4.7852, dtype=torch.float16)\n",
            "lora_unet_single_blocks_35_linear1.lora_down.weight : \n",
            "tensor(2.5117, dtype=torch.float16)\n",
            "lora_unet_single_blocks_35_modulation_lin.lora_down.weight : \n",
            "tensor(6.7734, dtype=torch.float16)\n",
            "lora_unet_single_blocks_36_linear1.lora_down.weight : \n",
            "tensor(1.8418, dtype=torch.float16)\n",
            "lora_unet_single_blocks_36_modulation_lin.lora_down.weight : \n",
            "tensor(6.5859, dtype=torch.float16)\n",
            "lora_unet_single_blocks_37_linear1.lora_down.weight : \n",
            "tensor(2.4473, dtype=torch.float16)\n",
            "lora_unet_single_blocks_37_modulation_lin.lora_down.weight : \n",
            "tensor(2.5742, dtype=torch.float16)\n",
            "lora_unet_single_blocks_3_linear1.lora_down.weight : \n",
            "tensor(2.5566, dtype=torch.float16)\n",
            "lora_unet_single_blocks_3_modulation_lin.lora_down.weight : \n",
            "tensor(4.7148, dtype=torch.float16)\n",
            "lora_unet_single_blocks_4_linear1.lora_down.weight : \n",
            "tensor(2.2832, dtype=torch.float16)\n",
            "lora_unet_single_blocks_4_modulation_lin.lora_down.weight : \n",
            "tensor(2.0566, dtype=torch.float16)\n",
            "lora_unet_single_blocks_5_linear1.lora_down.weight : \n",
            "tensor(2.2109, dtype=torch.float16)\n",
            "lora_unet_single_blocks_5_modulation_lin.lora_down.weight : \n",
            "tensor(2.7793, dtype=torch.float16)\n",
            "lora_unet_single_blocks_6_linear1.lora_down.weight : \n",
            "tensor(3.0176, dtype=torch.float16)\n",
            "lora_unet_single_blocks_6_modulation_lin.lora_down.weight : \n",
            "tensor(2.9180, dtype=torch.float16)\n",
            "lora_unet_single_blocks_7_linear1.lora_down.weight : \n",
            "tensor(2.2461, dtype=torch.float16)\n",
            "lora_unet_single_blocks_7_modulation_lin.lora_down.weight : \n",
            "tensor(2.1074, dtype=torch.float16)\n",
            "lora_unet_single_blocks_8_linear1.lora_down.weight : \n",
            "tensor(3.0391, dtype=torch.float16)\n",
            "lora_unet_single_blocks_8_modulation_lin.lora_down.weight : \n",
            "tensor(2.0039, dtype=torch.float16)\n",
            "lora_unet_single_blocks_9_linear1.lora_down.weight : \n",
            "tensor(3.8789, dtype=torch.float16)\n",
            "lora_unet_single_blocks_9_modulation_lin.lora_down.weight : \n",
            "tensor(4.0547, dtype=torch.float16)\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "<---- Upload your civiai trained .safetensor file to Google Colab before running the next cell\n",
        "\n"
      ],
      "metadata": {
        "id": "oDAUwfFzqzgj"
      }
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "WQZ3BZn1p-pw"
      },
      "outputs": [],
      "source": [
        "civiai_lora = '' # @param {type:'string' ,placeholder:'ex. civitai_trained_e19.safetensors'}\n",
        "tensor_art_filename = '' # @param {type:'string' ,placeholder:'ex. e19.safetensors'}\n",
        "%cd /content/\n",
        "tgt = load_file(f'{civiai_lora}')\n",
        "for key in tgt:\n",
        "  tgt[f'{key}'] = tgt[f'{key}'].to(dtype=torch.float16)\n",
        "%cd /content/\n",
        "save_file(tgt , f'{tensor_art_filename}')"
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "Download the new .safetensor file to your device.\n",
        "\n",
        "Downloading from CoLab Notebook will seemingly do nothing for ~5min. Then the file will download , so be patient.\n",
        "\n",
        "For faster/more consistent downloads , download your .safetensor file from your Google Drive"
      ],
      "metadata": {
        "id": "blnBW-U4rAS7"
      }
    }
  ]
}