subaqua commited on
Commit
b678a86
1 Parent(s): 3049957

Update as_safetensors+fp16.ipynb

Browse files
Files changed (1) hide show
  1. as_safetensors+fp16.ipynb +2 -1
as_safetensors+fp16.ipynb CHANGED
@@ -107,6 +107,7 @@
107
  "import glob\n",
108
  "import torch\n",
109
  "import safetensors.torch\n",
 
110
  "\n",
111
  "models = \"wd-1-4-anime_e1.ckpt, wd-1-4-anime_e1.yaml\" #@param {type:\"string\"}\n",
112
  "as_fp16 = True #@param {type:\"boolean\"}\n",
@@ -139,7 +140,7 @@
139
  " elif (model_ext != \".safetensors\") & (model_ext != \".ckpt\"):\n",
140
  " print(\"対応形式は.ckpt及び.safetensors並びに.yamlのみです\\n\" + f\"\\\"{model}\\\"は対応形式ではありません\")\n",
141
  " else:\n",
142
- " load_model = safetensors.torch.load_file if model_ext == \".safetensors\" else torch.load\n",
143
  " save_model = safetensors.torch.save_file if save_type == \".safetensors\" else torch.save\n",
144
  " # convert model\n",
145
  " with torch.no_grad():\n",
 
107
  "import glob\n",
108
  "import torch\n",
109
  "import safetensors.torch\n",
110
+ "from functools import partial\n",
111
  "\n",
112
  "models = \"wd-1-4-anime_e1.ckpt, wd-1-4-anime_e1.yaml\" #@param {type:\"string\"}\n",
113
  "as_fp16 = True #@param {type:\"boolean\"}\n",
 
140
  " elif (model_ext != \".safetensors\") & (model_ext != \".ckpt\"):\n",
141
  " print(\"対応形式は.ckpt及び.safetensors並びに.yamlのみです\\n\" + f\"\\\"{model}\\\"は対応形式ではありません\")\n",
142
  " else:\n",
143
+ " load_model = partial(safetensors.torch.load_file, device=\"cpu\") if model_ext == \".safetensors\" else partial(torch.load, map_location=torch.device(\"cpu\"))\n",
144
  " save_model = safetensors.torch.save_file if save_type == \".safetensors\" else torch.save\n",
145
  " # convert model\n",
146
  " with torch.no_grad():\n",