codeShare commited on
Commit
a84cd10
1 Parent(s): 7563ed2

Upload LoRa_cast_bfp16_to_fp16.ipynb

Browse files
Files changed (1) hide show
  1. LoRa_cast_bfp16_to_fp16.ipynb +84 -0
LoRa_cast_bfp16_to_fp16.ipynb ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "nbformat": 4,
3
+ "nbformat_minor": 0,
4
+ "metadata": {
5
+ "colab": {
6
+ "provenance": []
7
+ },
8
+ "kernelspec": {
9
+ "name": "python3",
10
+ "display_name": "Python 3"
11
+ },
12
+ "language_info": {
13
+ "name": "python"
14
+ }
15
+ },
16
+ "cells": [
17
+ {
18
+ "cell_type": "markdown",
19
+ "source": [
20
+ "# Cast civitai trained LoRa in torch.bfloat16 to Tensor Art Compatible torch.float16 dtype\n",
21
+ "\n",
22
+ "Created by Adcom: https://tensor.art/u/743241123023077878"
23
+ ],
24
+ "metadata": {
25
+ "id": "YDCnQpDdqDe4"
26
+ }
27
+ },
28
+ {
29
+ "cell_type": "code",
30
+ "source": [
31
+ "#initialize\n",
32
+ "import torch\n",
33
+ "from google.colab import drive\n",
34
+ "drive.mount('/content/drive')"
35
+ ],
36
+ "metadata": {
37
+ "id": "1oxeJYHRqxQC"
38
+ },
39
+ "execution_count": null,
40
+ "outputs": []
41
+ },
42
+ {
43
+ "cell_type": "markdown",
44
+ "source": [
45
+ "<---- Upload your civiai trained .safetensor file to Google Colab before running the next cell\n",
46
+ "\n"
47
+ ],
48
+ "metadata": {
49
+ "id": "oDAUwfFzqzgj"
50
+ }
51
+ },
52
+ {
53
+ "cell_type": "code",
54
+ "execution_count": null,
55
+ "metadata": {
56
+ "id": "WQZ3BZn1p-pw"
57
+ },
58
+ "outputs": [],
59
+ "source": [
60
+ "civiai_lora = '' # @param {type:'string' ,placeholder:'ex. civitai_trained_e19.safetensors'}\n",
61
+ "tensor_art_filename = '' # @param {type:'string' ,placeholder:'ex. e19.safetensors'}\n",
62
+ "%cd /content/\n",
63
+ "tgt = load_file(f'{civiai_lora}')\n",
64
+ "for key in tgt:\n",
65
+ " tgt[f'{key}'] = tgt[f'{key}'].to(dtype=torch.float16)\n",
66
+ "%cd /content/\n",
67
+ "save_file(tgt , f'{tensor_art_filename}')"
68
+ ]
69
+ },
70
+ {
71
+ "cell_type": "markdown",
72
+ "source": [
73
+ "Download the new .safetensor file to your device.\n",
74
+ "\n",
75
+ "Downloading from CoLab Notebook will seemingly do nothing for ~5min. Then the file will download , so be patient.\n",
76
+ "\n",
77
+ "For faster/more consistent downloads , download your .safetensor file from your Google Drive"
78
+ ],
79
+ "metadata": {
80
+ "id": "blnBW-U4rAS7"
81
+ }
82
+ }
83
+ ]
84
+ }