{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "provenance": [] }, "kernelspec": { "name": "python3", "display_name": "Python 3" }, "language_info": { "name": "python" } }, "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "id": "1-j1H73l7oJ6" }, "outputs": [], "source": [ "!git clone --recursive https://github.com/leejet/stable-diffusion.cpp" ] }, { "cell_type": "code", "source": [ "%cd stable-diffusion.cpp\n", "!ls -al" ], "metadata": { "id": "LbM06Q8-74WL" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "!mkdir build\n", "%cd build\n", "!cmake ..\n", "!cmake --build . --config Release" ], "metadata": { "id": "ri0dMNJj8Y97" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "%cd ../models/\n", "!ls -al" ], "metadata": { "id": "KOK2KZ1u8wqD" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "!pip install -r requirements.txt" ], "metadata": { "id": "L-wInMVJ-35i" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "# !curl -L -O https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.safetensors\n", "# i guess the V51 baked vae is incompatible with this quantisation\n", "# !wget --output-file=realisticVisionV51_v51VAE.safetensors https://civitai.com/api/download/models/130072\n", "\n", "!curl -L -O https://huggingface.co/XpucT/Reliberate/resolve/main/Reliberate.safetensors\n", "!ls -al" ], "metadata": { "id": "S3PPdWaJ-YMP" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "#%cd ../\n", "#%cd models\n", "#!ls -al" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "TuUTHYqqJzM2", "outputId": "ea40c34c-2098-496d-cab2-604811844656" }, "execution_count": 34, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "/content/stable-diffusion.cpp\n", "/content/stable-diffusion.cpp/models\n", "total 17105360\n", "drwxr-xr-x 2 root root 4096 Aug 20 22:59 .\n", "drwxr-xr-x 9 root root 4096 Aug 20 22:07 ..\n", "-rw-r--r-- 1 root root 2132625894 Aug 1 20:18 130072\n", "-rw-r--r-- 1 root root 9582 Aug 20 22:07 convert.py\n", "-rw-r--r-- 1 root root 31 Aug 20 22:07 .gitignore\n", "-rw-r--r-- 1 root root 739 Aug 20 22:07 README.md\n", "-rw-r--r-- 1 root root 3223317 Aug 20 22:12 realisticVisionV51_v51VAE.safetensors\n", "-rw-r--r-- 1 root root 2134446575 Aug 20 22:56 Reliberate-ggml-model-f16.bin\n", "-rw-r--r-- 1 root root 2920423407 Aug 20 22:56 Reliberate-ggml-model-f32.bin\n", "-rw-r--r-- 1 root root 1569525727 Aug 20 22:59 Reliberate-ggml-model-q4_0.bin\n", "-rw-r--r-- 1 root root 1594087503 Aug 20 22:22 Reliberate-ggml-model-q4_1.bin\n", "-rw-r--r-- 1 root root 1618649279 Aug 20 22:58 Reliberate-ggml-model-q5_0.bin\n", "-rw-r--r-- 1 root root 1643211055 Aug 20 22:59 Reliberate-ggml-model-q5_1.bin\n", "-rw-r--r-- 1 root root 1766019935 Aug 20 22:57 Reliberate-ggml-model-q8_0.bin\n", "-rw-r--r-- 1 root root 2132625894 Aug 20 22:19 Reliberate.safetensors\n", "-rw-r--r-- 1 root root 41 Aug 20 22:07 requirements.txt\n", "-rw-r--r-- 1 root root 961143 Aug 20 22:07 vocab.json\n" ] } ] }, { "cell_type": "code", "source": [ "# f16 for 16-bit floating-point\n", "# f32 for 32-bit floating-point\n", "# q8_0 for 8-bit integer quantization\n", "# q5_0 or q5_1 for 5-bit integer quantization\n", "# q4_0 or q4_1 for 4-bit integer quantization\n", "#!python convert.py sd-v1-4.ckpt --out_type f16\n", "\n", "!python convert.py Reliberate.safetensors --out_type f32\n", "!python convert.py Reliberate.safetensors --out_type f16\n", "!python convert.py Reliberate.safetensors --out_type q8_0\n", "!python convert.py Reliberate.safetensors --out_type q5_0\n", "!python convert.py Reliberate.safetensors --out_type q5_1\n", "!python convert.py Reliberate.safetensors --out_type q4_0\n", "!python convert.py Reliberate.safetensors --out_type q4_1" ], "metadata": { "id": "7w6ltMx49g-s" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "%cd ../\n", "%cd build\n", "!ls -al" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "_N0agkB7EuSy", "outputId": "890de3c2-e51b-4c33-de95-379171a52b22" }, "execution_count": 35, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "/content/stable-diffusion.cpp\n", "/content/stable-diffusion.cpp/build\n", "total 636\n", "drwxr-xr-x 6 root root 4096 Aug 20 22:08 .\n", "drwxr-xr-x 9 root root 4096 Aug 20 22:07 ..\n", "drwxr-xr-x 2 root root 4096 Aug 20 22:08 bin\n", "-rw-r--r-- 1 root root 16369 Aug 20 22:07 CMakeCache.txt\n", "drwxr-xr-x 6 root root 4096 Aug 20 22:08 CMakeFiles\n", "-rw-r--r-- 1 root root 1890 Aug 20 22:07 cmake_install.cmake\n", "-rw-r--r-- 1 root root 1988 Aug 20 22:07 compile_commands.json\n", "drwxr-xr-x 3 root root 4096 Aug 20 22:07 examples\n", "drwxr-xr-x 4 root root 4096 Aug 20 22:07 ggml\n", "-rw-r--r-- 1 root root 586046 Aug 20 22:08 libstable-diffusion.a\n", "-rw-r--r-- 1 root root 8829 Aug 20 22:07 Makefile\n" ] } ] }, { "cell_type": "code", "source": [ "#Reliberate-ggml-model-f16.bin\n", "#Reliberate-ggml-model-f32.bin\n", "#Reliberate-ggml-model-q4_0.bin\n", "#Reliberate-ggml-model-q4_1.bin\n", "#Reliberate-ggml-model-q5_0.bin\n", "#Reliberate-ggml-model-q5_1.bin\n", "#Reliberate-ggml-model-q8_0.bin" ], "metadata": { "id": "sfdDE3IULdEP" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "#!./bin/sd -m ../models/Reliberate-ggml-model-q4_1.bin -p \"a lovely cat\" -n \"jpeg artifacts, Problems, Issues, Imperfections, Malfunctions, Defects, Deficits, Deficiencies, Flaws, errors, bad proportions, bokeh, illustration, blurry, fuzzy, grainy, hazy, muzzy, indistinct, painting, overexposed, underexposed, animation, CGI, unreal engine\" -H 768 -W 640 --steps 25 --cfg-scale 4 --strength 1.0" ], "metadata": { "id": "W4CoQMFWDibG" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "!./bin/sd -m ../models/Reliberate-ggml-model-f16.bin -p \"a lovely cat\" -n \"illustration, blurry, fuzzy, grainy, hazy, muzzy, indistinct, painting, overexposed, underexposed, animation, CGI, unreal engine\" -H 512 -W 512 --steps 12 --cfg-scale 4" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "VznmOy2DInrT", "outputId": "eac388ec-85af-4633-ff24-7d8e140bc5d7" }, "execution_count": 40, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "[INFO] stable-diffusion.cpp:2687 - loading model from '../models/Reliberate-ggml-model-f16.bin'\n", "[INFO] stable-diffusion.cpp:2712 - ftype: f16\n", "[INFO] stable-diffusion.cpp:2937 - total params size = 1969.97MB (clip 235.01MB, unet 1640.45MB, vae 94.51MB)\n", "[INFO] stable-diffusion.cpp:2943 - loading model from '../models/Reliberate-ggml-model-f16.bin' completed, taking 11.14s\n", "[INFO] stable-diffusion.cpp:3059 - condition graph use 239.58MB of memory: params 235.01MB, runtime 4.57MB (static 1.64MB, dynamic 2.93MB)\n", "[INFO] stable-diffusion.cpp:3059 - condition graph use 239.58MB of memory: params 235.01MB, runtime 4.57MB (static 1.64MB, dynamic 2.93MB)\n", "[INFO] stable-diffusion.cpp:3552 - get_learned_condition completed, taking 3.09s\n", "[INFO] stable-diffusion.cpp:3568 - start sampling\n", "[INFO] stable-diffusion.cpp:3260 - step 1 sampling completed, taking 157.88s\n", "^C\n" ] } ] }, { "cell_type": "code", "source": [ "!./bin/sd -m ../models/Reliberate-ggml-model-q8_0.bin -p \"a lovely cat\" -n \"illustration, blurry, fuzzy, grainy, hazy, muzzy, indistinct, painting, overexposed, underexposed, animation, CGI, unreal engine\" -H 512 -W 512 --steps 12 --cfg-scale 4" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "jd4473MHNjsy", "outputId": "13f81097-7f4a-4155-b231-0e8f20da48ff" }, "execution_count": 41, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "[INFO] stable-diffusion.cpp:2687 - loading model from '../models/Reliberate-ggml-model-q8_0.bin'\n", "[INFO] stable-diffusion.cpp:2712 - ftype: q8_0\n", "[INFO] stable-diffusion.cpp:2937 - total params size = 1618.61MB (clip 125.09MB, unet 1399.01MB, vae 94.51MB)\n", "[INFO] stable-diffusion.cpp:2943 - loading model from '../models/Reliberate-ggml-model-q8_0.bin' completed, taking 8.65s\n", "[INFO] stable-diffusion.cpp:3059 - condition graph use 129.45MB of memory: params 125.09MB, runtime 4.36MB (static 1.43MB, dynamic 2.93MB)\n", "[INFO] stable-diffusion.cpp:3059 - condition graph use 129.45MB of memory: params 125.09MB, runtime 4.36MB (static 1.43MB, dynamic 2.93MB)\n", "[INFO] stable-diffusion.cpp:3552 - get_learned_condition completed, taking 1.11s\n", "[INFO] stable-diffusion.cpp:3568 - start sampling\n", "[INFO] stable-diffusion.cpp:3260 - step 1 sampling completed, taking 157.10s\n", "^C\n" ] } ] }, { "cell_type": "code", "source": [ "!./bin/sd -m ../models/Reliberate-ggml-model-q5_0.bin -p \"a lovely cat\" -n \"illustration, blurry, fuzzy, grainy, hazy, muzzy, indistinct, painting, overexposed, underexposed, animation, CGI, unreal engine\" -H 512 -W 512 --steps 12 --cfg-scale 4" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "2gXD4eEwOSvH", "outputId": "b2955d95-e1eb-4d8d-86dd-493c2b485c90" }, "execution_count": 42, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "[INFO] stable-diffusion.cpp:2687 - loading model from '../models/Reliberate-ggml-model-q5_0.bin'\n", "[INFO] stable-diffusion.cpp:2712 - ftype: q5_0\n", "[INFO] stable-diffusion.cpp:2937 - total params size = 1478.06MB (clip 81.13MB, unet 1302.43MB, vae 94.51MB)\n", "[INFO] stable-diffusion.cpp:2943 - loading model from '../models/Reliberate-ggml-model-q5_0.bin' completed, taking 9.40s\n", "[INFO] stable-diffusion.cpp:3059 - condition graph use 85.49MB of memory: params 81.13MB, runtime 4.36MB (static 1.43MB, dynamic 2.93MB)\n", "[INFO] stable-diffusion.cpp:3059 - condition graph use 85.49MB of memory: params 81.13MB, runtime 4.36MB (static 1.43MB, dynamic 2.93MB)\n", "[INFO] stable-diffusion.cpp:3552 - get_learned_condition completed, taking 1.67s\n", "[INFO] stable-diffusion.cpp:3568 - start sampling\n", "[INFO] stable-diffusion.cpp:3260 - step 1 sampling completed, taking 161.28s\n", "^C\n" ] } ] }, { "cell_type": "code", "source": [ "!./bin/sd -m ../models/Reliberate-ggml-model-q5_1.bin -p \"a lovely cat\" -n \"illustration, blurry, fuzzy, grainy, hazy, muzzy, indistinct, painting, overexposed, underexposed, animation, CGI, unreal engine\" -H 512 -W 512 --steps 12 --cfg-scale 4" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "S-DEUqqEPkYZ", "outputId": "ea981ba7-02b1-439c-a5aa-16570f7f6c56" }, "execution_count": null, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "[INFO] stable-diffusion.cpp:2687 - loading model from '../models/Reliberate-ggml-model-q5_1.bin'\n", "[INFO] stable-diffusion.cpp:2712 - ftype: q5_1\n", "[INFO] stable-diffusion.cpp:2937 - total params size = 1501.49MB (clip 88.45MB, unet 1318.53MB, vae 94.51MB)\n", "[INFO] stable-diffusion.cpp:2943 - loading model from '../models/Reliberate-ggml-model-q5_1.bin' completed, taking 8.38s\n", "[INFO] stable-diffusion.cpp:3059 - condition graph use 92.86MB of memory: params 88.45MB, runtime 4.40MB (static 1.47MB, dynamic 2.93MB)\n", "[INFO] stable-diffusion.cpp:3059 - condition graph use 92.86MB of memory: params 88.45MB, runtime 4.40MB (static 1.47MB, dynamic 2.93MB)\n", "[INFO] stable-diffusion.cpp:3552 - get_learned_condition completed, taking 1.54s\n", "[INFO] stable-diffusion.cpp:3568 - start sampling\n", "[INFO] stable-diffusion.cpp:3260 - step 1 sampling completed, taking 167.16s\n" ] } ] }, { "cell_type": "code", "source": [ "#from google.colab import files\n", "# download the file\n", "#files.download('Reliberate-ggml-model-q4_1.bin')" ], "metadata": { "id": "hqb2Vq5C77l7" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "IPython.display.FileLink('../models/Reliberate-ggml-model-q4_1.bin')" ], "metadata": { "id": "bcETqgaNKpe4" }, "execution_count": null, "outputs": [] } ] }