{ "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" } } ] }