{ "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 google.colab import drive\n", "drive.mount('/content/drive')" ], "metadata": { "id": "1oxeJYHRqxQC" }, "execution_count": null, "outputs": [] }, { "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" } } ] }