acheong08 / Diffusion-ColabUI

Choose your diffusion models and spin up a WebUI on Colab in one click
Apache License 2.0
421 stars 64 forks source link

safetensors dont load #97

Closed RayZ3R0 closed 1 year ago

RayZ3R0 commented 1 year ago

I'm getting an error trying to load a safetensor model from civitai, here's the link https://civitai.com/api/download/models/8821

Launching Web UI with arguments: --share --xformers --enable-insecure-extension-access --vae-path /content/stable-diffusion-webui/models/Stable-diffusion/novelAI.vae.pt --gradio-auth a:b
2023-02-24 07:10:54.110652: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2023-02-24 07:10:55.528180: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libnvinfer.so.7'; dlerror: libnvinfer.so.7: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /usr/local/lib/python3.8/dist-packages/cv2/../../lib64:/usr/lib64-nvidia
2023-02-24 07:10:55.528324: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libnvinfer_plugin.so.7'; dlerror: libnvinfer_plugin.so.7: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /usr/local/lib/python3.8/dist-packages/cv2/../../lib64:/usr/lib64-nvidia
2023-02-24 07:10:55.528351: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Cannot dlopen some TensorRT libraries. If you would like to use Nvidia GPU with TensorRT, please make sure the missing libraries mentioned above are installed properly.
Calculating sha256 for /content/stable-diffusion-webui/models/Stable-diffusion/tokisaki.safetensor.safetensors: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
Loading weights [e3b0c44298] from /content/stable-diffusion-webui/models/Stable-diffusion/tokisaki.safetensor.safetensors
loading stable diffusion model: Exception
Traceback (most recent call last):
  File "/content/stable-diffusion-webui/webui.py", line 111, in initialize
    modules.sd_models.load_model()
  File "/content/stable-diffusion-webui/modules/sd_models.py", line 383, in load_model
    state_dict = get_checkpoint_state_dict(checkpoint_info, timer)
  File "/content/stable-diffusion-webui/modules/sd_models.py", line 238, in get_checkpoint_state_dict
    res = read_state_dict(checkpoint_info.filename)
  File "/content/stable-diffusion-webui/modules/sd_models.py", line 217, in read_state_dict
    pl_sd = safetensors.torch.load_file(checkpoint_file, device=device)
  File "/usr/local/lib/python3.8/dist-packages/safetensors/torch.py", line 98, in load_file
    with safe_open(filename, framework="pt", device=device) as f:
Exception: Error while deserializing header: HeaderTooSmall

Stable diffusion model failed to load, exiting
RayZ3R0 commented 1 year ago

btw I edited the Add models cell since it adds ckpt if there's no safetensors in the model url,

#@markdown ## Add models
#@markdown - You can run this multiple times to add more models to the list
#@markdown - Leave input blank to ignore
#@markdown - No spaces allowed in the name

try:
  customModels
except NameError:
  customModels = []
else:
  pass

#@markdown ### Custom
#@markdown The model URL should be a direct download link or Google Drive URL
#@markdown <br> The modelURL should a DIRECT DOWNLOAD LINK.
#@markdown <br>https://huggingface.co/ShadoWxShinigamI/MidJourney-PaperCut/blob/main/Mdjrny-pprct_step_7000.ckpt
#@markdown <br>is actually supposed to be
#@markdown <br>https://huggingface.co/ShadoWxShinigamI/MidJourney-PaperCut/resolve/main/Mdjrny-pprct_step_7000.ckpt
modelName = "tokisaki.safetensor" #@param {'type': 'string'}
modelURL = "https://civitai.com/api/download/models/8821" #@param ["", "https://huggingface.co/ShadoWxShinigamI/MidJourney-PaperCut/resolve/main/Mdjrny-pprct_step_7000.ckpt", "https://huggingface.co/hesw23168/SD-Elysium-Model/resolve/main/Elysium_V1.ckpt", "https://huggingface.co/acheong08/nutmegmix/resolve/main/nutmegmix.ckpt", "https://huggingface.co/hesw23168/SD-Elysium-Model/resolve/main/Elysium_Anime_V2.ckpt", "https://huggingface.co/Linaqruf/anything-v3.0/resolve/main/Anything-V3.0-pruned.ckpt", "https://huggingface.co/prompthero/linkedin-diffusion/resolve/main/lnkdn.ckpt"] {allow-input: true}

#@markdown ## Defaults
#@markdown SDv2.0 and mdjrny-v4 style has been added
defaultModelURLs = ["" ,"https://huggingface.co/acheong08/secretAI/resolve/main/stableckpt/animefull-final-pruned/model.ckpt", "https://huggingface.co/CompVis/stable-diffusion-v-1-4-original/resolve/main/sd-v1-4.ckpt", "https://huggingface.co/hakurei/waifu-diffusion-v1-3/resolve/main/wd-v1-3-float32.ckpt", "https://huggingface.co/Deltaadams/HentaiDiffusion/resolve/main/HD-16.ckpt", "https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.ckpt", "https://huggingface.co/runwayml/stable-diffusion-inpainting/resolve/main/sd-v1-5-inpainting.ckpt", "https://huggingface.co/acheong08/f222/resolve/main/f222.ckpt", "https://huggingface.co/acheong08/Anything/resolve/main/Anything-V3.0-pruned-fp32.ckpt", "https://huggingface.co/acheong08/r34/resolve/main/r34_e4.ckpt", "https://huggingface.co/hassanblend/HassanBlend1.5.1.2/resolve/main/HassanBlend1.5.1.2-pruned.safetensors", "https://huggingface.co/stabilityai/stable-diffusion-2/resolve/main/768-v-ema.ckpt", "https://huggingface.co/prompthero/openjourney/resolve/main/mdjrny-v4.ckpt"]
defaultModels = ["" ,"NovelAI", "SD1-4", "WaifuDiffusion", "HentaiDiffusion", "SD1-5", "SD-inpainting", "f222-NSFW", "Anything-V3", "Rule34", "HassansBlend", "SDv2-0", "OpenMidjourney"]
defaultModel = "" #@param ["" ,"NovelAI", "SD1-4", "WaifuDiffusion", "HentaiDiffusion", "SD1-5", "SD-inpainting", "f222-NSFW", "Anything-V3", "Rule34", "HassansBlend", "SDv2-0", "OpenMidjourney"]

#@markdown # Parameters
#@markdown Select this if the model is based on SD2.0
SD2 = "None" #@param ["None", "V2-512", "V2-768", "V2-inpainting", "V2-upscaling"]

if modelName == "" or modelURL == "":
  pass
else:
  if modelURL.endswith("8821"):
    modelName = modelName + ".safetensors"
  else:
    modelName = modelName + ".ckpt"
  customModels.append((modelName, modelURL, SD2))

if defaultModel != "":
  if defaultModelURLs[defaultModels.index(defaultModel)].endswith("8821"):
    defaultModelName = defaultModel + ".safetensors"
  else:
    defaultModelName = defaultModel + ".ckpt"
  # Map model to URL
  customModels.append((defaultModelName, defaultModelURLs[defaultModels.index(defaultModel)], SD2))

print(customModels)
from IPython import display
display.HTML("<p>Want faster speed? <a href=\"https://www.youtube.com/watch?v=dQw4w9WgXcQ\">Here</a>'s a better version of this Colab!</p>")