{ "cells": [ { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "f76f0bff4fac4dd7b5c4e6ddef1eb1e3", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Fetching 12 files: 0%| | 0/12 [00:00" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from diffusers import StableDiffusionPipeline\n", "import torch\n", "\n", "model_id = \"stabilityai/stable-diffusion-2-base\"\n", "\n", "pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16).to(\n", " \"cuda:1\"\n", ")\n", "\n", "prompt = \"style of sks, flower in a pot\"" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "5d0d98e1659c4cc3915b9fb499f32512", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/51 [00:00" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from lora_diffusion import monkeypatch_lora, tune_lora_scale\n", "\n", "\n", "monkeypatch_lora(pipe.unet, torch.load(\"../lora_illust.pt\"))\n", "\n", "tune_lora_scale(pipe.unet, 1.00)\n", "\n", "torch.manual_seed(0)\n", "image = pipe(prompt, num_inference_steps=50, guidance_scale=7).images[0]\n", "image" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "80df2f9c112046aa95f47a5ea0a329c8", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/51 [00:00" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "tune_lora_scale(pipe.unet, 1.00)\n", "\n", "torch.manual_seed(1)\n", "image = pipe(prompt, num_inference_steps=50, guidance_scale=7).images[0]\n", "image" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "627c9533600a4f56bcb62311d3ae716e", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/51 [00:00