├── Mix_of_Show_fused_multi_anime_colab.ipynb ├── Mix_of_Show_fused_multi_real_colab.ipynb ├── Mix_of_Show_fused_single_anime_colab.ipynb ├── Mix_of_Show_fused_single_real_colab.ipynb ├── Mix_of_Show_hermione_colab.ipynb ├── Mix_of_Show_hina_colab.ipynb ├── Mix_of_Show_kaori_colab.ipynb ├── Mix_of_Show_potter_colab.ipynb ├── Mix_of_Show_tezuka_colab.ipynb ├── Mix_of_Show_thanos_colab.ipynb ├── README.md ├── fuse_colab.ipynb └── test.ipynb /Mix_of_Show_fused_multi_anime_colab.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "id": "view-in-github" 7 | }, 8 | "source": [ 9 | "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/camenduru/Mix-of-Show-colab/blob/main/Mix_of_Show_fused_multi_anime_colab.ipynb)" 10 | ] 11 | }, 12 | { 13 | "cell_type": "code", 14 | "execution_count": null, 15 | "metadata": { 16 | "id": "VjYy0F2gZIPR" 17 | }, 18 | "outputs": [], 19 | "source": [ 20 | "%cd /content\n", 21 | "!git clone -b dev https://github.com/camenduru/Mix-of-Show\n", 22 | "%cd /content/Mix-of-Show\n", 23 | "\n", 24 | "!pip install -q diffusers==0.20.2 transformers accelerate einops omegaconf\n", 25 | "!pip install -q https://download.pytorch.org/whl/cu121/xformers-0.0.22.post7-cp310-cp310-manylinux2014_x86_64.whl\n", 26 | "\n", 27 | "!git clone https://huggingface.co/ckpt/MoS-hina-kario-tezuka-anythingv4\n", 28 | "\n", 29 | "%cd /content/Mix-of-Show\n", 30 | "\n", 31 | "fused_model=\"/content/Mix-of-Show/MoS-hina-kario-tezuka-anythingv4\"\n", 32 | "expdir=\"/content/Mix-of-Show/hina+kario+tezuka_anythingv4\"\n", 33 | "\n", 34 | "keypose_condition='/content/Mix-of-Show/datasets/validation_spatial_condition/multi-characters/anime_pose_2x/hina_tezuka_kario_2x.png'\n", 35 | "keypose_adaptor_weight=1.0\n", 36 | "sketch_condition=''\n", 37 | "sketch_adaptor_weight=1.0\n", 38 | "\n", 39 | "context_prompt='two girls and a boy are standing near a forest'\n", 40 | "context_neg_prompt='longbody, lowres, bad anatomy, bad hands, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality'\n", 41 | "\n", 42 | "region1_prompt='[a , standing near a forest]'\n", 43 | "region1_neg_prompt=\"[${context_neg_prompt}]\"\n", 44 | "region1='[12, 36, 1024, 600]'\n", 45 | "\n", 46 | "region2_prompt='[a , standing near a forest]'\n", 47 | "region2_neg_prompt=\"[${context_neg_prompt}]\"\n", 48 | "region2='[18, 696, 1024, 1180]'\n", 49 | "\n", 50 | "region5_prompt='[a , standing near a forest]'\n", 51 | "region5_neg_prompt=\"[${context_neg_prompt}]\"\n", 52 | "region5='[142, 1259, 1024, 1956]'\n", 53 | "\n", 54 | "prompt_rewrite=f\"{region1_prompt}-*-{region1_neg_prompt}-*-{region1}|{region2_prompt}-*-{region2_neg_prompt}-*-{region2}|{region5_prompt}-*-{region5_neg_prompt}-*-{region5}\"\n", 55 | "\n", 56 | "print(prompt_rewrite)\n", 57 | "\n", 58 | "!python regionally_controlable_sampling.py \\\n", 59 | " --pretrained_model=\"{fused_model}\" \\\n", 60 | " --sketch_adaptor_weight=\"{sketch_adaptor_weight}\" \\\n", 61 | " --sketch_condition=\"{sketch_condition}\" \\\n", 62 | " --keypose_adaptor_weight=\"{keypose_adaptor_weight}\" \\\n", 63 | " --keypose_condition=\"{keypose_condition}\" \\\n", 64 | " --save_dir=\"{expdir}\" \\\n", 65 | " --prompt=\"{context_prompt}\" \\\n", 66 | " --negative_prompt=\"{context_neg_prompt}\" \\\n", 67 | " --prompt_rewrite=\"{prompt_rewrite}\" \\\n", 68 | " --suffix=\"baseline\" \\\n", 69 | " --seed=19" 70 | ] 71 | } 72 | ], 73 | "metadata": { 74 | "accelerator": "GPU", 75 | "colab": { 76 | "gpuType": "T4", 77 | "provenance": [] 78 | }, 79 | "kernelspec": { 80 | "display_name": "Python 3", 81 | "name": "python3" 82 | }, 83 | "language_info": { 84 | "name": "python" 85 | } 86 | }, 87 | "nbformat": 4, 88 | "nbformat_minor": 0 89 | } 90 | -------------------------------------------------------------------------------- /Mix_of_Show_fused_multi_real_colab.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "id": "view-in-github" 7 | }, 8 | "source": [ 9 | "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/camenduru/Mix-of-Show-colab/blob/main/Mix_of_Show_fused_multi_real_colab.ipynb)" 10 | ] 11 | }, 12 | { 13 | "cell_type": "code", 14 | "execution_count": null, 15 | "metadata": { 16 | "id": "VjYy0F2gZIPR" 17 | }, 18 | "outputs": [], 19 | "source": [ 20 | "%cd /content\n", 21 | "!git clone -b dev https://github.com/camenduru/Mix-of-Show\n", 22 | "%cd /content/Mix-of-Show\n", 23 | "\n", 24 | "!pip install -q diffusers==0.20.2 transformers accelerate einops omegaconf\n", 25 | "!pip install -q https://download.pytorch.org/whl/cu121/xformers-0.0.22.post7-cp310-cp310-manylinux2014_x86_64.whl\n", 26 | "\n", 27 | "!git clone https://huggingface.co/ckpt/MoS-potter-hermione-thanos-chilloutmix\n", 28 | "\n", 29 | "%cd /content/Mix-of-Show\n", 30 | "\n", 31 | "fused_model=\"/content/Mix-of-Show/MoS-potter-hermione-thanos-chilloutmix\"\n", 32 | "expdir=\"/content/Mix-of-Show/potter+hermione+thanos_chilloutmix\"\n", 33 | "\n", 34 | "keypose_condition='/content/Mix-of-Show/datasets/validation_spatial_condition/multi-characters/anime_pose_2x/hina_tezuka_kario_2x.png'\n", 35 | "keypose_adaptor_weight=1.0\n", 36 | "sketch_condition=''\n", 37 | "sketch_adaptor_weight=1.0\n", 38 | "\n", 39 | "context_prompt='two boys and a girl are standing near a forest'\n", 40 | "context_neg_prompt='longbody, lowres, bad anatomy, bad hands, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality'\n", 41 | "\n", 42 | "region1_prompt='[a , standing near a forest]'\n", 43 | "region1_neg_prompt=\"[${context_neg_prompt}]\"\n", 44 | "region1='[12, 36, 1024, 600]'\n", 45 | "\n", 46 | "region2_prompt='[a , standing near a forest]'\n", 47 | "region2_neg_prompt=\"[${context_neg_prompt}]\"\n", 48 | "region2='[18, 696, 1024, 1180]'\n", 49 | "\n", 50 | "region5_prompt='[a , standing near a forest]'\n", 51 | "region5_neg_prompt=\"[${context_neg_prompt}]\"\n", 52 | "region5='[142, 1259, 1024, 1956]'\n", 53 | "\n", 54 | "prompt_rewrite=f\"{region1_prompt}-*-{region1_neg_prompt}-*-{region1}|{region2_prompt}-*-{region2_neg_prompt}-*-{region2}|{region5_prompt}-*-{region5_neg_prompt}-*-{region5}\"\n", 55 | "\n", 56 | "print(prompt_rewrite)\n", 57 | "\n", 58 | "!python regionally_controlable_sampling.py \\\n", 59 | " --pretrained_model=\"{fused_model}\" \\\n", 60 | " --sketch_adaptor_weight=\"{sketch_adaptor_weight}\" \\\n", 61 | " --sketch_condition=\"{sketch_condition}\" \\\n", 62 | " --keypose_adaptor_weight=\"{keypose_adaptor_weight}\" \\\n", 63 | " --keypose_condition=\"{keypose_condition}\" \\\n", 64 | " --save_dir=\"{expdir}\" \\\n", 65 | " --prompt=\"{context_prompt}\" \\\n", 66 | " --negative_prompt=\"{context_neg_prompt}\" \\\n", 67 | " --prompt_rewrite=\"{prompt_rewrite}\" \\\n", 68 | " --suffix=\"baseline\" \\\n", 69 | " --seed=19" 70 | ] 71 | } 72 | ], 73 | "metadata": { 74 | "accelerator": "GPU", 75 | "colab": { 76 | "gpuType": "T4", 77 | "provenance": [] 78 | }, 79 | "kernelspec": { 80 | "display_name": "Python 3", 81 | "name": "python3" 82 | }, 83 | "language_info": { 84 | "name": "python" 85 | } 86 | }, 87 | "nbformat": 4, 88 | "nbformat_minor": 0 89 | } 90 | -------------------------------------------------------------------------------- /Mix_of_Show_fused_single_anime_colab.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "id": "view-in-github" 7 | }, 8 | "source": [ 9 | "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/camenduru/Mix-of-Show-colab/blob/main/Mix_of_Show_fused_single_anime_colab.ipynb)" 10 | ] 11 | }, 12 | { 13 | "cell_type": "code", 14 | "execution_count": null, 15 | "metadata": { 16 | "id": "VjYy0F2gZIPR" 17 | }, 18 | "outputs": [], 19 | "source": [ 20 | "%cd /content\n", 21 | "!git clone -b dev https://github.com/camenduru/Mix-of-Show\n", 22 | "%cd /content/Mix-of-Show\n", 23 | "\n", 24 | "!pip install -q diffusers==0.20.2 transformers accelerate einops omegaconf\n", 25 | "!pip install -q https://download.pytorch.org/whl/cu121/xformers-0.0.22.post7-cp310-cp310-manylinux2014_x86_64.whl\n", 26 | "\n", 27 | "!git clone https://huggingface.co/ckpt/MoS-hina-kario-tezuka-anythingv4\n", 28 | "\n", 29 | "import json\n", 30 | "import os\n", 31 | "import torch\n", 32 | "from diffusers import DPMSolverMultistepScheduler\n", 33 | "from mixofshow.pipelines.pipeline_edlora import EDLoRAPipeline\n", 34 | "pretrained_model_path = '/content/Mix-of-Show/MoS-hina-kario-tezuka-anythingv4'\n", 35 | "enable_edlora = True # True for edlora, False for lora\n", 36 | "pipe = EDLoRAPipeline.from_pretrained(pretrained_model_path, scheduler=DPMSolverMultistepScheduler.from_pretrained(pretrained_model_path, subfolder='scheduler'), torch_dtype=torch.float16).to('cuda')\n", 37 | "with open(f'{pretrained_model_path}/new_concept_cfg.json', 'r') as fr:\n", 38 | " new_concept_cfg = json.load(fr)\n", 39 | "pipe.set_new_concept_cfg(new_concept_cfg)" 40 | ] 41 | }, 42 | { 43 | "cell_type": "code", 44 | "execution_count": null, 45 | "metadata": {}, 46 | "outputs": [], 47 | "source": [ 48 | "TOK = ' ' # the TOK is the concept name when training lora/edlora\n", 49 | "prompt = f'a {TOK} in front of mount fuji'\n", 50 | "negative_prompt = 'longbody, lowres, bad anatomy, bad hands, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality'\n", 51 | "image = pipe(prompt, negative_prompt=negative_prompt, height=1024, width=512, num_inference_steps=50, guidance_scale=7.5).images[0]\n", 52 | "image.save(f'res.jpg')\n", 53 | "image" 54 | ] 55 | } 56 | ], 57 | "metadata": { 58 | "accelerator": "GPU", 59 | "colab": { 60 | "gpuType": "T4", 61 | "provenance": [] 62 | }, 63 | "kernelspec": { 64 | "display_name": "Python 3", 65 | "name": "python3" 66 | }, 67 | "language_info": { 68 | "name": "python" 69 | } 70 | }, 71 | "nbformat": 4, 72 | "nbformat_minor": 0 73 | } 74 | -------------------------------------------------------------------------------- /Mix_of_Show_fused_single_real_colab.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "id": "view-in-github" 7 | }, 8 | "source": [ 9 | "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/camenduru/Mix-of-Show-colab/blob/main/Mix_of_Show_fused_single_real_colab.ipynb)" 10 | ] 11 | }, 12 | { 13 | "cell_type": "code", 14 | "execution_count": null, 15 | "metadata": { 16 | "id": "VjYy0F2gZIPR" 17 | }, 18 | "outputs": [], 19 | "source": [ 20 | "%cd /content\n", 21 | "!git clone -b dev https://github.com/camenduru/Mix-of-Show\n", 22 | "%cd /content/Mix-of-Show\n", 23 | "\n", 24 | "!pip install -q diffusers==0.20.2 transformers accelerate einops omegaconf\n", 25 | "!pip install -q https://download.pytorch.org/whl/cu121/xformers-0.0.22.post7-cp310-cp310-manylinux2014_x86_64.whl\n", 26 | "\n", 27 | "!git clone https://huggingface.co/ckpt/MoS-potter-hermione-thanos-chilloutmix\n", 28 | "\n", 29 | "import json\n", 30 | "import os\n", 31 | "import torch\n", 32 | "from diffusers import DPMSolverMultistepScheduler\n", 33 | "from mixofshow.pipelines.pipeline_edlora import EDLoRAPipeline\n", 34 | "pretrained_model_path = '/content/Mix-of-Show/MoS-potter-hermione-thanos-chilloutmix'\n", 35 | "enable_edlora = True # True for edlora, False for lora\n", 36 | "pipe = EDLoRAPipeline.from_pretrained(pretrained_model_path, scheduler=DPMSolverMultistepScheduler.from_pretrained(pretrained_model_path, subfolder='scheduler'), torch_dtype=torch.float16).to('cuda')\n", 37 | "with open(f'{pretrained_model_path}/new_concept_cfg.json', 'r') as fr:\n", 38 | " new_concept_cfg = json.load(fr)\n", 39 | "pipe.set_new_concept_cfg(new_concept_cfg)" 40 | ] 41 | }, 42 | { 43 | "cell_type": "code", 44 | "execution_count": null, 45 | "metadata": {}, 46 | "outputs": [], 47 | "source": [ 48 | "TOK = ' ' # the TOK is the concept name when training lora/edlora\n", 49 | "prompt = f'a {TOK} in front of mount fuji'\n", 50 | "negative_prompt = 'longbody, lowres, bad anatomy, bad hands, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality'\n", 51 | "image = pipe(prompt, negative_prompt=negative_prompt, height=1024, width=512, num_inference_steps=50, guidance_scale=7.5).images[0]\n", 52 | "image.save(f'res.jpg')\n", 53 | "image" 54 | ] 55 | } 56 | ], 57 | "metadata": { 58 | "accelerator": "GPU", 59 | "colab": { 60 | "gpuType": "T4", 61 | "provenance": [] 62 | }, 63 | "kernelspec": { 64 | "display_name": "Python 3", 65 | "name": "python3" 66 | }, 67 | "language_info": { 68 | "name": "python" 69 | } 70 | }, 71 | "nbformat": 4, 72 | "nbformat_minor": 0 73 | } 74 | -------------------------------------------------------------------------------- /Mix_of_Show_hermione_colab.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "id": "view-in-github" 7 | }, 8 | "source": [ 9 | "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/camenduru/Mix-of-Show-colab/blob/main/Mix_of_Show_hermione_colab.ipynb)" 10 | ] 11 | }, 12 | { 13 | "cell_type": "code", 14 | "execution_count": null, 15 | "metadata": { 16 | "id": "VjYy0F2gZIPR" 17 | }, 18 | "outputs": [], 19 | "source": [ 20 | "%cd /content\n", 21 | "!git clone -b dev https://github.com/camenduru/Mix-of-Show\n", 22 | "%cd /content/Mix-of-Show\n", 23 | "\n", 24 | "!pip install -q diffusers==0.20.2 transformers accelerate einops omegaconf\n", 25 | "!pip install -q https://download.pytorch.org/whl/cu121/xformers-0.0.22.post7-cp310-cp310-manylinux2014_x86_64.whl\n", 26 | "\n", 27 | "!mkdir -p /content/Mix-of-Show/models/8102_EDLoRA_hermione_Cmix_B4_Repeat500\n", 28 | "!wget https://huggingface.co/camenduru/Mix-of-Show/resolve/main/single_concept_model/8102_EDLoRA_hermione_Cmix_B4_Repeat500/models/edlora_model-latest.pth?download=true -O /content/Mix-of-Show/models/8102_EDLoRA_hermione_Cmix_B4_Repeat500/edlora_model-latest.pth\n", 29 | "\n", 30 | "import torch\n", 31 | "from diffusers import DPMSolverMultistepScheduler\n", 32 | "from mixofshow.pipelines.pipeline_edlora import EDLoRAPipeline, StableDiffusionPipeline\n", 33 | "from mixofshow.utils.convert_edlora_to_diffusers import convert_edlora\n", 34 | "\n", 35 | "enable_edlora = True\n", 36 | "pipeclass = EDLoRAPipeline if enable_edlora else StableDiffusionPipeline\n", 37 | "pretrained_model_path = 'windwhinny/chilloutmix'\n", 38 | "scheduler = DPMSolverMultistepScheduler.from_pretrained(pretrained_model_path, subfolder='scheduler')\n", 39 | "pipe = pipeclass.from_pretrained(pretrained_model_path, scheduler=scheduler, torch_dtype=torch.float16).to('cuda')\n", 40 | "edlora_path = '/content/Mix-of-Show/models/8102_EDLoRA_hermione_Cmix_B4_Repeat500/edlora_model-latest.pth'\n", 41 | "pipe, new_concept_cfg = convert_edlora(pipe, torch.load(edlora_path), enable_edlora=enable_edlora, alpha=1.0)\n", 42 | "pipe.set_new_concept_cfg(new_concept_cfg)\n", 43 | "pipe.unet.eval()\n", 44 | "pipe.text_encoder.eval()" 45 | ] 46 | }, 47 | { 48 | "cell_type": "code", 49 | "execution_count": null, 50 | "metadata": {}, 51 | "outputs": [], 52 | "source": [ 53 | "TOK = ' ' # the TOK is the concept name when training lora/edlora\n", 54 | "prompt = f'a {TOK} in front of eiffel tower, 4K, high quality, high resolution'\n", 55 | "negative_prompt = 'longbody, lowres, bad anatomy, bad hands, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality'\n", 56 | "image = pipe(prompt, negative_prompt=negative_prompt, height=512, width=512, num_inference_steps=50, guidance_scale=7.5).images[0]\n", 57 | "image.save('res.jpg')\n", 58 | "image" 59 | ] 60 | } 61 | ], 62 | "metadata": { 63 | "accelerator": "GPU", 64 | "colab": { 65 | "gpuType": "T4", 66 | "provenance": [] 67 | }, 68 | "kernelspec": { 69 | "display_name": "Python 3", 70 | "name": "python3" 71 | }, 72 | "language_info": { 73 | "name": "python" 74 | } 75 | }, 76 | "nbformat": 4, 77 | "nbformat_minor": 0 78 | } 79 | -------------------------------------------------------------------------------- /Mix_of_Show_hina_colab.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "id": "view-in-github" 7 | }, 8 | "source": [ 9 | "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/camenduru/Mix-of-Show-colab/blob/main/Mix_of_Show_hina_colab.ipynb)" 10 | ] 11 | }, 12 | { 13 | "cell_type": "code", 14 | "execution_count": null, 15 | "metadata": { 16 | "id": "VjYy0F2gZIPR" 17 | }, 18 | "outputs": [], 19 | "source": [ 20 | "%cd /content\n", 21 | "!git clone -b dev https://github.com/camenduru/Mix-of-Show\n", 22 | "%cd /content/Mix-of-Show\n", 23 | "\n", 24 | "!pip install -q diffusers==0.20.2 transformers accelerate einops omegaconf\n", 25 | "!pip install -q https://download.pytorch.org/whl/cu121/xformers-0.0.22.post7-cp310-cp310-manylinux2014_x86_64.whl\n", 26 | "\n", 27 | "!mkdir -p /content/Mix-of-Show/models/1001_1_EDLoRA_hina_Anyv4_B4_Repeat500\n", 28 | "!wget https://huggingface.co/camenduru/Mix-of-Show/resolve/main/single_concept_model/1001_1_EDLoRA_hina_Anyv4_B4_Repeat500/models/edlora_model-latest.pth?download=true -O /content/Mix-of-Show/models/1001_1_EDLoRA_hina_Anyv4_B4_Repeat500/edlora_model-latest.pth\n", 29 | "\n", 30 | "import torch\n", 31 | "from diffusers import DPMSolverMultistepScheduler\n", 32 | "from mixofshow.pipelines.pipeline_edlora import EDLoRAPipeline, StableDiffusionPipeline\n", 33 | "from mixofshow.utils.convert_edlora_to_diffusers import convert_edlora\n", 34 | "\n", 35 | "enable_edlora = True\n", 36 | "pipeclass = EDLoRAPipeline if enable_edlora else StableDiffusionPipeline\n", 37 | "pretrained_model_path = 'xyn-ai/anything-v4.0'\n", 38 | "scheduler = DPMSolverMultistepScheduler.from_pretrained(pretrained_model_path, subfolder='scheduler')\n", 39 | "pipe = pipeclass.from_pretrained(pretrained_model_path, scheduler=scheduler, torch_dtype=torch.float16).to('cuda')\n", 40 | "edlora_path = '/content/Mix-of-Show/models/1001_1_EDLoRA_hina_Anyv4_B4_Repeat500/edlora_model-latest.pth'\n", 41 | "pipe, new_concept_cfg = convert_edlora(pipe, torch.load(edlora_path), enable_edlora=enable_edlora, alpha=1.0)\n", 42 | "pipe.set_new_concept_cfg(new_concept_cfg)\n", 43 | "pipe.unet.eval()\n", 44 | "pipe.text_encoder.eval()" 45 | ] 46 | }, 47 | { 48 | "cell_type": "code", 49 | "execution_count": null, 50 | "metadata": {}, 51 | "outputs": [], 52 | "source": [ 53 | "TOK = ' ' # the TOK is the concept name when training lora/edlora\n", 54 | "prompt = f'a {TOK} in front of eiffel tower, 4K, high quality, high resolution'\n", 55 | "negative_prompt = 'longbody, lowres, bad anatomy, bad hands, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality'\n", 56 | "image = pipe(prompt, negative_prompt=negative_prompt, height=512, width=512, num_inference_steps=50, guidance_scale=7.5).images[0]\n", 57 | "image.save('res.jpg')\n", 58 | "image" 59 | ] 60 | } 61 | ], 62 | "metadata": { 63 | "accelerator": "GPU", 64 | "colab": { 65 | "gpuType": "T4", 66 | "provenance": [] 67 | }, 68 | "kernelspec": { 69 | "display_name": "Python 3", 70 | "name": "python3" 71 | }, 72 | "language_info": { 73 | "name": "python" 74 | } 75 | }, 76 | "nbformat": 4, 77 | "nbformat_minor": 0 78 | } 79 | -------------------------------------------------------------------------------- /Mix_of_Show_kaori_colab.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "id": "view-in-github" 7 | }, 8 | "source": [ 9 | "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/camenduru/Mix-of-Show-colab/blob/main/Mix_of_Show_kaori_colab.ipynb)" 10 | ] 11 | }, 12 | { 13 | "cell_type": "code", 14 | "execution_count": null, 15 | "metadata": { 16 | "id": "VjYy0F2gZIPR" 17 | }, 18 | "outputs": [], 19 | "source": [ 20 | "%cd /content\n", 21 | "!git clone -b dev https://github.com/camenduru/Mix-of-Show\n", 22 | "%cd /content/Mix-of-Show\n", 23 | "\n", 24 | "!pip install -q diffusers==0.20.2 transformers accelerate einops omegaconf\n", 25 | "!pip install -q https://download.pytorch.org/whl/cu121/xformers-0.0.22.post7-cp310-cp310-manylinux2014_x86_64.whl\n", 26 | "\n", 27 | "!mkdir -p /content/Mix-of-Show/models/1002_1_EDLoRA_kaori_Anyv4_B4_Repeat500\n", 28 | "!wget https://huggingface.co/camenduru/Mix-of-Show/resolve/main/single_concept_model/1002_1_EDLoRA_kaori_Anyv4_B4_Repeat500/models/edlora_model-latest.pth?download=true -O /content/Mix-of-Show/models/1002_1_EDLoRA_kaori_Anyv4_B4_Repeat500/edlora_model-latest.pth\n", 29 | "\n", 30 | "import torch\n", 31 | "from diffusers import DPMSolverMultistepScheduler\n", 32 | "from mixofshow.pipelines.pipeline_edlora import EDLoRAPipeline, StableDiffusionPipeline\n", 33 | "from mixofshow.utils.convert_edlora_to_diffusers import convert_edlora\n", 34 | "\n", 35 | "enable_edlora = True\n", 36 | "pipeclass = EDLoRAPipeline if enable_edlora else StableDiffusionPipeline\n", 37 | "pretrained_model_path = 'xyn-ai/anything-v4.0'\n", 38 | "scheduler = DPMSolverMultistepScheduler.from_pretrained(pretrained_model_path, subfolder='scheduler')\n", 39 | "pipe = pipeclass.from_pretrained(pretrained_model_path, scheduler=scheduler, torch_dtype=torch.float16).to('cuda')\n", 40 | "edlora_path = '/content/Mix-of-Show/models/1002_1_EDLoRA_kaori_Anyv4_B4_Repeat500/edlora_model-latest.pth'\n", 41 | "pipe, new_concept_cfg = convert_edlora(pipe, torch.load(edlora_path), enable_edlora=enable_edlora, alpha=1.0)\n", 42 | "pipe.set_new_concept_cfg(new_concept_cfg)\n", 43 | "pipe.unet.eval()\n", 44 | "pipe.text_encoder.eval()" 45 | ] 46 | }, 47 | { 48 | "cell_type": "code", 49 | "execution_count": null, 50 | "metadata": {}, 51 | "outputs": [], 52 | "source": [ 53 | "TOK = ' ' # the TOK is the concept name when training lora/edlora\n", 54 | "prompt = f'a {TOK} in front of eiffel tower, 4K, high quality, high resolution'\n", 55 | "negative_prompt = 'longbody, lowres, bad anatomy, bad hands, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality'\n", 56 | "image = pipe(prompt, negative_prompt=negative_prompt, height=512, width=512, num_inference_steps=50, guidance_scale=7.5).images[0]\n", 57 | "image.save('res.jpg')\n", 58 | "image" 59 | ] 60 | } 61 | ], 62 | "metadata": { 63 | "accelerator": "GPU", 64 | "colab": { 65 | "gpuType": "T4", 66 | "provenance": [] 67 | }, 68 | "kernelspec": { 69 | "display_name": "Python 3", 70 | "name": "python3" 71 | }, 72 | "language_info": { 73 | "name": "python" 74 | } 75 | }, 76 | "nbformat": 4, 77 | "nbformat_minor": 0 78 | } 79 | -------------------------------------------------------------------------------- /Mix_of_Show_potter_colab.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "id": "view-in-github" 7 | }, 8 | "source": [ 9 | "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/camenduru/Mix-of-Show-colab/blob/main/Mix_of_Show_potter_colab.ipynb)" 10 | ] 11 | }, 12 | { 13 | "cell_type": "code", 14 | "execution_count": null, 15 | "metadata": { 16 | "id": "VjYy0F2gZIPR" 17 | }, 18 | "outputs": [], 19 | "source": [ 20 | "%cd /content\n", 21 | "!git clone -b dev https://github.com/camenduru/Mix-of-Show\n", 22 | "%cd /content/Mix-of-Show\n", 23 | "\n", 24 | "!pip install -q diffusers==0.20.2 transformers accelerate einops omegaconf\n", 25 | "!pip install -q https://download.pytorch.org/whl/cu121/xformers-0.0.22.post7-cp310-cp310-manylinux2014_x86_64.whl\n", 26 | "\n", 27 | "!mkdir -p /content/Mix-of-Show/models/8101_EDLoRA_potter_Cmix_B4_Repeat500\n", 28 | "!wget https://huggingface.co/camenduru/Mix-of-Show/resolve/main/single_concept_model/8101_EDLoRA_potter_Cmix_B4_Repeat500/models/edlora_model-latest.pth?download=true -O /content/Mix-of-Show/models/8101_EDLoRA_potter_Cmix_B4_Repeat500/edlora_model-latest.pth\n", 29 | "\n", 30 | "import torch\n", 31 | "from diffusers import DPMSolverMultistepScheduler\n", 32 | "from mixofshow.pipelines.pipeline_edlora import EDLoRAPipeline, StableDiffusionPipeline\n", 33 | "from mixofshow.utils.convert_edlora_to_diffusers import convert_edlora\n", 34 | "\n", 35 | "enable_edlora = True\n", 36 | "pipeclass = EDLoRAPipeline if enable_edlora else StableDiffusionPipeline\n", 37 | "pretrained_model_path = 'windwhinny/chilloutmix'\n", 38 | "scheduler = DPMSolverMultistepScheduler.from_pretrained(pretrained_model_path, subfolder='scheduler')\n", 39 | "pipe = pipeclass.from_pretrained(pretrained_model_path, scheduler=scheduler, torch_dtype=torch.float16).to('cuda')\n", 40 | "edlora_path = '/content/Mix-of-Show/models/8101_EDLoRA_potter_Cmix_B4_Repeat500/edlora_model-latest.pth'\n", 41 | "pipe, new_concept_cfg = convert_edlora(pipe, torch.load(edlora_path), enable_edlora=enable_edlora, alpha=1.0)\n", 42 | "pipe.set_new_concept_cfg(new_concept_cfg)\n", 43 | "pipe.unet.eval()\n", 44 | "pipe.text_encoder.eval()" 45 | ] 46 | }, 47 | { 48 | "cell_type": "code", 49 | "execution_count": null, 50 | "metadata": {}, 51 | "outputs": [], 52 | "source": [ 53 | "TOK = ' ' # the TOK is the concept name when training lora/edlora\n", 54 | "prompt = f'a {TOK} in front of eiffel tower, 4K, high quality, high resolution'\n", 55 | "negative_prompt = 'longbody, lowres, bad anatomy, bad hands, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality'\n", 56 | "image = pipe(prompt, negative_prompt=negative_prompt, height=512, width=512, num_inference_steps=50, guidance_scale=7.5).images[0]\n", 57 | "image.save('res.jpg')\n", 58 | "image" 59 | ] 60 | } 61 | ], 62 | "metadata": { 63 | "accelerator": "GPU", 64 | "colab": { 65 | "gpuType": "T4", 66 | "provenance": [] 67 | }, 68 | "kernelspec": { 69 | "display_name": "Python 3", 70 | "name": "python3" 71 | }, 72 | "language_info": { 73 | "name": "python" 74 | } 75 | }, 76 | "nbformat": 4, 77 | "nbformat_minor": 0 78 | } 79 | -------------------------------------------------------------------------------- /Mix_of_Show_tezuka_colab.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "id": "view-in-github" 7 | }, 8 | "source": [ 9 | "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/camenduru/Mix-of-Show-colab/blob/main/Mix_of_Show_tezuka_colab.ipynb)" 10 | ] 11 | }, 12 | { 13 | "cell_type": "code", 14 | "execution_count": null, 15 | "metadata": { 16 | "id": "VjYy0F2gZIPR" 17 | }, 18 | "outputs": [], 19 | "source": [ 20 | "%cd /content\n", 21 | "!git clone -b dev https://github.com/camenduru/Mix-of-Show\n", 22 | "%cd /content/Mix-of-Show\n", 23 | "\n", 24 | "!pip install -q diffusers==0.20.2 transformers accelerate einops omegaconf\n", 25 | "!pip install -q https://download.pytorch.org/whl/cu121/xformers-0.0.22.post7-cp310-cp310-manylinux2014_x86_64.whl\n", 26 | "\n", 27 | "!mkdir -p /content/Mix-of-Show/models/1003_1_EDLoRA_tezuka_Anyv4_B4_Repeat500\n", 28 | "!wget https://huggingface.co/camenduru/Mix-of-Show/resolve/main/single_concept_model/1003_1_EDLoRA_tezuka_Anyv4_B4_Repeat500/models/edlora_model-latest.pth?download=true -O /content/Mix-of-Show/models/1003_1_EDLoRA_tezuka_Anyv4_B4_Repeat500/edlora_model-latest.pth\n", 29 | "\n", 30 | "import torch\n", 31 | "from diffusers import DPMSolverMultistepScheduler\n", 32 | "from mixofshow.pipelines.pipeline_edlora import EDLoRAPipeline, StableDiffusionPipeline\n", 33 | "from mixofshow.utils.convert_edlora_to_diffusers import convert_edlora\n", 34 | "\n", 35 | "enable_edlora = True\n", 36 | "pipeclass = EDLoRAPipeline if enable_edlora else StableDiffusionPipeline\n", 37 | "pretrained_model_path = 'xyn-ai/anything-v4.0'\n", 38 | "scheduler = DPMSolverMultistepScheduler.from_pretrained(pretrained_model_path, subfolder='scheduler')\n", 39 | "pipe = pipeclass.from_pretrained(pretrained_model_path, scheduler=scheduler, torch_dtype=torch.float16).to('cuda')\n", 40 | "edlora_path = '/content/Mix-of-Show/models/1003_1_EDLoRA_tezuka_Anyv4_B4_Repeat500/edlora_model-latest.pth'\n", 41 | "pipe, new_concept_cfg = convert_edlora(pipe, torch.load(edlora_path), enable_edlora=enable_edlora, alpha=1.0)\n", 42 | "pipe.set_new_concept_cfg(new_concept_cfg)\n", 43 | "pipe.unet.eval()\n", 44 | "pipe.text_encoder.eval()" 45 | ] 46 | }, 47 | { 48 | "cell_type": "code", 49 | "execution_count": null, 50 | "metadata": {}, 51 | "outputs": [], 52 | "source": [ 53 | "TOK = ' ' # the TOK is the concept name when training lora/edlora\n", 54 | "prompt = f'a {TOK} in front of eiffel tower, 4K, high quality, high resolution'\n", 55 | "negative_prompt = 'longbody, lowres, bad anatomy, bad hands, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality'\n", 56 | "image = pipe(prompt, negative_prompt=negative_prompt, height=512, width=512, num_inference_steps=50, guidance_scale=7.5).images[0]\n", 57 | "image.save('res.jpg')\n", 58 | "image" 59 | ] 60 | } 61 | ], 62 | "metadata": { 63 | "accelerator": "GPU", 64 | "colab": { 65 | "gpuType": "T4", 66 | "provenance": [] 67 | }, 68 | "kernelspec": { 69 | "display_name": "Python 3", 70 | "name": "python3" 71 | }, 72 | "language_info": { 73 | "name": "python" 74 | } 75 | }, 76 | "nbformat": 4, 77 | "nbformat_minor": 0 78 | } 79 | -------------------------------------------------------------------------------- /Mix_of_Show_thanos_colab.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "id": "view-in-github" 7 | }, 8 | "source": [ 9 | "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/camenduru/Mix-of-Show-colab/blob/main/Mix_of_Show_thanos_colab.ipynb)" 10 | ] 11 | }, 12 | { 13 | "cell_type": "code", 14 | "execution_count": null, 15 | "metadata": { 16 | "id": "VjYy0F2gZIPR" 17 | }, 18 | "outputs": [], 19 | "source": [ 20 | "%cd /content\n", 21 | "!git clone -b dev https://github.com/camenduru/Mix-of-Show\n", 22 | "%cd /content/Mix-of-Show\n", 23 | "\n", 24 | "!pip install -q diffusers==0.20.2 transformers accelerate einops omegaconf\n", 25 | "!pip install -q https://download.pytorch.org/whl/cu121/xformers-0.0.22.post7-cp310-cp310-manylinux2014_x86_64.whl\n", 26 | "\n", 27 | "!mkdir -p /content/Mix-of-Show/models/8103_EDLoRA_thanos_Cmix_B4_Repeat250\n", 28 | "!wget https://huggingface.co/camenduru/Mix-of-Show/resolve/main/single_concept_model/8103_EDLoRA_thanos_Cmix_B4_Repeat250/models/edlora_model-latest.pth?download=true -O /content/Mix-of-Show/models/8103_EDLoRA_thanos_Cmix_B4_Repeat250/edlora_model-latest.pth\n", 29 | "\n", 30 | "import torch\n", 31 | "from diffusers import DPMSolverMultistepScheduler\n", 32 | "from mixofshow.pipelines.pipeline_edlora import EDLoRAPipeline, StableDiffusionPipeline\n", 33 | "from mixofshow.utils.convert_edlora_to_diffusers import convert_edlora\n", 34 | "\n", 35 | "enable_edlora = True\n", 36 | "pipeclass = EDLoRAPipeline if enable_edlora else StableDiffusionPipeline\n", 37 | "pretrained_model_path = 'windwhinny/chilloutmix'\n", 38 | "scheduler = DPMSolverMultistepScheduler.from_pretrained(pretrained_model_path, subfolder='scheduler')\n", 39 | "pipe = pipeclass.from_pretrained(pretrained_model_path, scheduler=scheduler, torch_dtype=torch.float16).to('cuda')\n", 40 | "edlora_path = '/content/Mix-of-Show/models/8103_EDLoRA_thanos_Cmix_B4_Repeat250/edlora_model-latest.pth'\n", 41 | "pipe, new_concept_cfg = convert_edlora(pipe, torch.load(edlora_path), enable_edlora=enable_edlora, alpha=1.0)\n", 42 | "pipe.set_new_concept_cfg(new_concept_cfg)\n", 43 | "pipe.unet.eval()\n", 44 | "pipe.text_encoder.eval()" 45 | ] 46 | }, 47 | { 48 | "cell_type": "code", 49 | "execution_count": null, 50 | "metadata": {}, 51 | "outputs": [], 52 | "source": [ 53 | "TOK = ' ' # the TOK is the concept name when training lora/edlora\n", 54 | "prompt = f'a {TOK} in front of eiffel tower, 4K, high quality, high resolution'\n", 55 | "negative_prompt = 'longbody, lowres, bad anatomy, bad hands, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality'\n", 56 | "image = pipe(prompt, negative_prompt=negative_prompt, height=512, width=512, num_inference_steps=50, guidance_scale=7.5).images[0]\n", 57 | "image.save('res.jpg')\n", 58 | "image" 59 | ] 60 | } 61 | ], 62 | "metadata": { 63 | "accelerator": "GPU", 64 | "colab": { 65 | "gpuType": "T4", 66 | "provenance": [] 67 | }, 68 | "kernelspec": { 69 | "display_name": "Python 3", 70 | "name": "python3" 71 | }, 72 | "language_info": { 73 | "name": "python" 74 | } 75 | }, 76 | "nbformat": 4, 77 | "nbformat_minor": 0 78 | } 79 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 🐣 Please follow me for new updates https://twitter.com/camenduru
2 | 🔥 Please join our discord server https://discord.gg/k5BwmmvJJU
3 | 🥳 Please join my patreon community https://patreon.com/camenduru
4 | 5 | ### 🦒 Colab 6 | 7 | | Colab | Info 8 | | --- | --- | 9 | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/camenduru/Mix-of-Show-colab/blob/main/Mix_of_Show_hermione_colab.ipynb) | Mix_of_Show_hermione_colab 10 | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/camenduru/Mix-of-Show-colab/blob/main/Mix_of_Show_potter_colab.ipynb) | Mix_of_Show_potter_colab 11 | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/camenduru/Mix-of-Show-colab/blob/main/Mix_of_Show_thanos_colab.ipynb) | Mix_of_Show_thanos_colab 12 | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/camenduru/Mix-of-Show-colab/blob/main/Mix_of_Show_hina_colab.ipynb) | Mix_of_Show_hina_colab 13 | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/camenduru/Mix-of-Show-colab/blob/main/Mix_of_Show_kaori_colab.ipynb) | Mix_of_Show_kaori_colab 14 | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/camenduru/Mix-of-Show-colab/blob/main/Mix_of_Show_tezuka_colab.ipynb) | Mix_of_Show_tezuka_colab 15 | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/camenduru/Mix-of-Show-colab/blob/main/Mix_of_Show_fused_single_anime_colab.ipynb) | Mix_of_Show_fused_single_anime_colab 16 | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/camenduru/Mix-of-Show-colab/blob/main/Mix_of_Show_fused_single_real_colab.ipynb) | Mix_of_Show_fused_single_real_colab 17 | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/camenduru/Mix-of-Show-colab/blob/main/Mix_of_Show_fused_multi_anime_colab.ipynb) | Mix_of_Show_fused_multi_anime_colab (Pro Colab 😭) 18 | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/camenduru/Mix-of-Show-colab/blob/main/Mix_of_Show_fused_multi_real_colab.ipynb) | Mix_of_Show_fused_multi_real_colab (Pro Colab 😭) 19 | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/camenduru/Mix-of-Show-colab/blob/main/fuse_colab.ipynb) | fuse_colab (Pro Colab 😭) 20 | 21 | ### 🧬 Code 22 | https://github.com/TencentARC/Mix-of-Show 23 | 24 | ### 📄 Paper 25 | https://arxiv.org/abs/2305.18292 26 | 27 | ### 🌐 Page 28 | https://showlab.github.io/Mix-of-Show/ 29 | 30 | ### 📦 Model 31 | https://huggingface.co/camenduru/Mix-of-Show/tree/main/single_concept_model 32 | 33 | ### 🖼 Output 34 | ![Screenshot 2023-12-09 122202](https://github.com/camenduru/Mix-of-Show-colab/assets/54370274/b7a94fde-3aae-4444-acb5-c1d6ae0eb0ae)
35 | 36 | ![photo_of_a_toy---baseline---075e325c](https://github.com/camenduru/Mix-of-Show-colab/assets/54370274/625c6092-2a5a-4f9f-87cd-198d7c95f297)
37 | ![photo_of_a_toy---baseline---c6713dea](https://github.com/camenduru/Mix-of-Show-colab/assets/54370274/e2044923-bba1-4d63-8d61-0a77175bbe9a)
38 | ![photo_of_a_toy---baseline---77b276c6](https://github.com/camenduru/Mix-of-Show-colab/assets/54370274/5d4fc8aa-cba1-493c-93b3-4b1bc2e365b2)
39 | 40 | Alpha 0.0 [1001_1_EDLoRA_hina_Anyv4_B4_Repeat500](https://huggingface.co/camenduru/Mix-of-Show/blob/main/single_concept_model/1001_1_EDLoRA_hina_Anyv4_B4_Repeat500/visualization/PromptDataset/G_7.5_S_50---Iters-latest_Alpha-0.jpg)
41 | Alpha 0.7 [1001_1_EDLoRA_hina_Anyv4_B4_Repeat500](https://huggingface.co/camenduru/Mix-of-Show/blob/main/single_concept_model/1001_1_EDLoRA_hina_Anyv4_B4_Repeat500/visualization/PromptDataset/G_7.5_S_50---Iters-latest_Alpha-0.7.jpg)
42 | Alpha 1.0 [1001_1_EDLoRA_hina_Anyv4_B4_Repeat500](https://huggingface.co/camenduru/Mix-of-Show/blob/main/single_concept_model/1001_1_EDLoRA_hina_Anyv4_B4_Repeat500/visualization/PromptDataset/G_7.5_S_50---Iters-latest_Alpha-1.0.jpg)
43 | 44 | Alpha 0.0 [1002_1_EDLoRA_kaori_Anyv4_B4_Repeat500](https://huggingface.co/camenduru/Mix-of-Show/blob/main/single_concept_model/1002_1_EDLoRA_kaori_Anyv4_B4_Repeat500/visualization/PromptDataset/G_7.5_S_50---Iters-latest_Alpha-0.jpg)
45 | Alpha 0.7 [1002_1_EDLoRA_kaori_Anyv4_B4_Repeat500](https://huggingface.co/camenduru/Mix-of-Show/blob/main/single_concept_model/1002_1_EDLoRA_kaori_Anyv4_B4_Repeat500/visualization/PromptDataset/G_7.5_S_50---Iters-latest_Alpha-0.7.jpg)
46 | Alpha 1.0 [1002_1_EDLoRA_kaori_Anyv4_B4_Repeat500](https://huggingface.co/camenduru/Mix-of-Show/blob/main/single_concept_model/1002_1_EDLoRA_kaori_Anyv4_B4_Repeat500/visualization/PromptDataset/G_7.5_S_50---Iters-latest_Alpha-1.0.jpg)
47 | 48 | Alpha 0.0 [1003_1_EDLoRA_tezuka_Anyv4_B4_Repeat500](https://huggingface.co/camenduru/Mix-of-Show/blob/main/single_concept_model/1003_1_EDLoRA_tezuka_Anyv4_B4_Repeat500/visualization/PromptDataset/G_7.5_S_50---Iters-latest_Alpha-0.jpg)
49 | Alpha 0.7 [1003_1_EDLoRA_tezuka_Anyv4_B4_Repeat500](https://huggingface.co/camenduru/Mix-of-Show/blob/main/single_concept_model/1003_1_EDLoRA_tezuka_Anyv4_B4_Repeat500/visualization/PromptDataset/G_7.5_S_50---Iters-latest_Alpha-0.7.jpg)
50 | Alpha 1.0 [1003_1_EDLoRA_tezuka_Anyv4_B4_Repeat500](https://huggingface.co/camenduru/Mix-of-Show/blob/main/single_concept_model/1003_1_EDLoRA_tezuka_Anyv4_B4_Repeat500/visualization/PromptDataset/G_7.5_S_50---Iters-latest_Alpha-1.0.jpg)
51 | 52 | Alpha 0.0 [8101_EDLoRA_potter_Cmix_B4_Repeat500](https://huggingface.co/camenduru/Mix-of-Show/blob/main/single_concept_model/8101_EDLoRA_potter_Cmix_B4_Repeat500/visualization/PromptDataset/G_7.5_S_50---Iters-latest_Alpha-0.jpg)
53 | Alpha 0.7 [8101_EDLoRA_potter_Cmix_B4_Repeat500](https://huggingface.co/camenduru/Mix-of-Show/blob/main/single_concept_model/8101_EDLoRA_potter_Cmix_B4_Repeat500/visualization/PromptDataset/G_7.5_S_50---Iters-latest_Alpha-0.7.jpg)
54 | Alpha 1.0 [8101_EDLoRA_potter_Cmix_B4_Repeat500](https://huggingface.co/camenduru/Mix-of-Show/blob/main/single_concept_model/8101_EDLoRA_potter_Cmix_B4_Repeat500/visualization/PromptDataset/G_7.5_S_50---Iters-latest_Alpha-1.0.jpg)
55 | 56 | Alpha 0.0 [8102_EDLoRA_hermione_Cmix_B4_Repeat500](https://huggingface.co/camenduru/Mix-of-Show/blob/main/single_concept_model/8102_EDLoRA_hermione_Cmix_B4_Repeat500/visualization/PromptDataset/G_7.5_S_50---Iters-latest_Alpha-0.jpg)
57 | Alpha 0.7 [8102_EDLoRA_hermione_Cmix_B4_Repeat500](https://huggingface.co/camenduru/Mix-of-Show/blob/main/single_concept_model/8102_EDLoRA_hermione_Cmix_B4_Repeat500/visualization/PromptDataset/G_7.5_S_50---Iters-latest_Alpha-0.7.jpg)
58 | Alpha 1.0 [8102_EDLoRA_hermione_Cmix_B4_Repeat500](https://huggingface.co/camenduru/Mix-of-Show/blob/main/single_concept_model/8102_EDLoRA_hermione_Cmix_B4_Repeat500/visualization/PromptDataset/G_7.5_S_50---Iters-latest_Alpha-1.0.jpg)
59 | 60 | Alpha 0.0 [8103_EDLoRA_thanos_Cmix_B4_Repeat250](https://huggingface.co/camenduru/Mix-of-Show/blob/main/single_concept_model/8103_EDLoRA_thanos_Cmix_B4_Repeat250/visualization/PromptDataset/G_7.5_S_50---Iters-latest_Alpha-0.jpg)
61 | Alpha 0.7 [8103_EDLoRA_thanos_Cmix_B4_Repeat250](https://huggingface.co/camenduru/Mix-of-Show/blob/main/single_concept_model/8103_EDLoRA_thanos_Cmix_B4_Repeat250/visualization/PromptDataset/G_7.5_S_50---Iters-latest_Alpha-0.7.jpg)
62 | Alpha 1.0 [8103_EDLoRA_thanos_Cmix_B4_Repeat250](https://huggingface.co/camenduru/Mix-of-Show/blob/main/single_concept_model/8103_EDLoRA_thanos_Cmix_B4_Repeat250/visualization/PromptDataset/G_7.5_S_50---Iters-latest_Alpha-1.0.jpg)
63 | 64 | ### 🏢 Sponsor 65 | https://modelslab.com 66 | -------------------------------------------------------------------------------- /fuse_colab.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "id": "view-in-github" 7 | }, 8 | "source": [ 9 | "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/camenduru/Mix-of-Show-colab/blob/main/fuse_colab.ipynb)" 10 | ] 11 | }, 12 | { 13 | "cell_type": "code", 14 | "execution_count": null, 15 | "metadata": { 16 | "id": "VjYy0F2gZIPR" 17 | }, 18 | "outputs": [], 19 | "source": [ 20 | "%cd /content\n", 21 | "!git clone -b dev https://github.com/camenduru/Mix-of-Show\n", 22 | "%cd /content/Mix-of-Show\n", 23 | "\n", 24 | "!pip install -q diffusers==0.20.2 transformers accelerate einops omegaconf\n", 25 | "!pip install -q https://download.pytorch.org/whl/cu121/xformers-0.0.22.post7-cp310-cp310-manylinux2014_x86_64.whl\n", 26 | "\n", 27 | "!mkdir -p /content/Mix-of-Show/models/1001_1_EDLoRA_hina_Anyv4_B4_Repeat500\n", 28 | "!wget https://huggingface.co/camenduru/Mix-of-Show/resolve/main/single_concept_model/1001_1_EDLoRA_hina_Anyv4_B4_Repeat500/models/edlora_model-latest.pth?download=true -O /content/Mix-of-Show/models/1001_1_EDLoRA_hina_Anyv4_B4_Repeat500/edlora_model-latest.pth\n", 29 | "!mkdir -p /content/Mix-of-Show/models/1002_1_EDLoRA_kaori_Anyv4_B4_Repeat500\n", 30 | "!wget https://huggingface.co/camenduru/Mix-of-Show/resolve/main/single_concept_model/1002_1_EDLoRA_kaori_Anyv4_B4_Repeat500/models/edlora_model-latest.pth?download=true -O /content/Mix-of-Show/models/1002_1_EDLoRA_kaori_Anyv4_B4_Repeat500/edlora_model-latest.pth\n", 31 | "!mkdir -p /content/Mix-of-Show/models/1003_1_EDLoRA_tezuka_Anyv4_B4_Repeat500\n", 32 | "!wget https://huggingface.co/camenduru/Mix-of-Show/resolve/main/single_concept_model/1003_1_EDLoRA_tezuka_Anyv4_B4_Repeat500/models/edlora_model-latest.pth?download=true -O /content/Mix-of-Show/models/1003_1_EDLoRA_tezuka_Anyv4_B4_Repeat500/edlora_model-latest.pth\n", 33 | "!mkdir -p /content/Mix-of-Show/multi-concept\n", 34 | "!python gradient_fusion.py \\\n", 35 | " --concept_cfg=\"/content/Mix-of-Show/datasets/data_cfgs/MixofShow/multi-concept/anime/hina+kario+tezuka_anythingv4.json\" \\\n", 36 | " --save_path=\"/content/Mix-of-Show/multi-concept\" \\\n", 37 | " --pretrained_models=\"xyn-ai/anything-v4.0\" \\\n", 38 | " --optimize_textenc_iters=500 \\\n", 39 | " --optimize_unet_iters=50" 40 | ] 41 | } 42 | ], 43 | "metadata": { 44 | "accelerator": "GPU", 45 | "colab": { 46 | "gpuType": "T4", 47 | "provenance": [] 48 | }, 49 | "kernelspec": { 50 | "display_name": "Python 3", 51 | "name": "python3" 52 | }, 53 | "language_info": { 54 | "name": "python" 55 | } 56 | }, 57 | "nbformat": 4, 58 | "nbformat_minor": 0 59 | } 60 | -------------------------------------------------------------------------------- /test.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "id": "view-in-github" 7 | }, 8 | "source": [ 9 | "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/camenduru/Mix-of-Show-colab/blob/main/test.ipynb)" 10 | ] 11 | }, 12 | { 13 | "cell_type": "code", 14 | "execution_count": null, 15 | "metadata": { 16 | "id": "VjYy0F2gZIPR" 17 | }, 18 | "outputs": [], 19 | "source": [ 20 | "%cd /content\n", 21 | "!git clone -b dev https://github.com/camenduru/Mix-of-Show\n", 22 | "%cd /content/Mix-of-Show\n", 23 | "\n", 24 | "!pip install -q diffusers==0.20.2 transformers accelerate einops omegaconf\n", 25 | "!pip install -q https://download.pytorch.org/whl/cu121/xformers-0.0.22.post7-cp310-cp310-manylinux2014_x86_64.whl\n", 26 | "\n", 27 | "!git clone https://huggingface.co/ckpt/MoS-hina-kario-tezuka-anythingv4\n", 28 | "\n", 29 | "%cd /content/Mix-of-Show\n", 30 | "\n", 31 | "import argparse\n", 32 | "import hashlib\n", 33 | "import json\n", 34 | "import os.path\n", 35 | "\n", 36 | "import torch\n", 37 | "from diffusers import DPMSolverMultistepScheduler\n", 38 | "from diffusers.models import T2IAdapter\n", 39 | "from PIL import Image\n", 40 | "\n", 41 | "from mixofshow.pipelines.pipeline_regionally_t2iadapter import RegionallyT2IAdapterPipeline\n", 42 | "\n", 43 | "\n", 44 | "def sample_image(pipe,\n", 45 | " input_prompt,\n", 46 | " input_neg_prompt=None,\n", 47 | " generator=None,\n", 48 | " num_inference_steps=50,\n", 49 | " guidance_scale=7.5,\n", 50 | " sketch_adaptor_weight=1.0,\n", 51 | " region_sketch_adaptor_weight='',\n", 52 | " keypose_adaptor_weight=1.0,\n", 53 | " region_keypose_adaptor_weight='',\n", 54 | " **extra_kargs\n", 55 | "):\n", 56 | "\n", 57 | " keypose_condition = extra_kargs.pop('keypose_condition')\n", 58 | " if keypose_condition is not None:\n", 59 | " keypose_adapter_input = [keypose_condition] * len(input_prompt)\n", 60 | " else:\n", 61 | " keypose_adapter_input = None\n", 62 | "\n", 63 | " sketch_condition = extra_kargs.pop('sketch_condition')\n", 64 | " if sketch_condition is not None:\n", 65 | " sketch_adapter_input = [sketch_condition] * len(input_prompt)\n", 66 | " else:\n", 67 | " sketch_adapter_input = None\n", 68 | "\n", 69 | " images = pipe(\n", 70 | " prompt=input_prompt,\n", 71 | " negative_prompt=input_neg_prompt,\n", 72 | " keypose_adapter_input=keypose_adapter_input,\n", 73 | " keypose_adaptor_weight=keypose_adaptor_weight,\n", 74 | " region_keypose_adaptor_weight=region_keypose_adaptor_weight,\n", 75 | " sketch_adapter_input=sketch_adapter_input,\n", 76 | " sketch_adaptor_weight=sketch_adaptor_weight,\n", 77 | " region_sketch_adaptor_weight=region_sketch_adaptor_weight,\n", 78 | " generator=generator,\n", 79 | " guidance_scale=guidance_scale,\n", 80 | " num_inference_steps=num_inference_steps,\n", 81 | " **extra_kargs).images\n", 82 | " return images\n", 83 | "\n", 84 | "\n", 85 | "def build_model(pretrained_model, device):\n", 86 | " pipe = RegionallyT2IAdapterPipeline.from_pretrained(pretrained_model, torch_dtype=torch.float16).to(device)\n", 87 | " assert os.path.exists(os.path.join(pretrained_model, 'new_concept_cfg.json'))\n", 88 | " with open(os.path.join(pretrained_model, 'new_concept_cfg.json'), 'r') as json_file:\n", 89 | " new_concept_cfg = json.load(json_file)\n", 90 | " pipe.set_new_concept_cfg(new_concept_cfg)\n", 91 | " pipe.scheduler = DPMSolverMultistepScheduler.from_pretrained(pretrained_model, subfolder='scheduler')\n", 92 | " pipe.keypose_adapter = T2IAdapter.from_pretrained('TencentARC/t2iadapter_openpose_sd14v1', torch_dtype=torch.float16).to(device)\n", 93 | " pipe.sketch_adapter = T2IAdapter.from_pretrained('TencentARC/t2iadapter_sketch_sd14v1', torch_dtype=torch.float16).to(device)\n", 94 | " return pipe\n", 95 | "\n", 96 | "\n", 97 | "def prepare_text(prompt, region_prompts, height, width):\n", 98 | " '''\n", 99 | " Args:\n", 100 | " prompt_entity: [subject1]-*-[attribute1]-*-[Location1]|[subject2]-*-[attribute2]-*-[Location2]|[global text]\n", 101 | " Returns:\n", 102 | " full_prompt: subject1, attribute1 and subject2, attribute2, global text\n", 103 | " context_prompt: subject1 and subject2, global text\n", 104 | " entity_collection: [(subject1, attribute1), Location1]\n", 105 | " '''\n", 106 | " region_collection = []\n", 107 | "\n", 108 | " regions = region_prompts.split('|')\n", 109 | "\n", 110 | " for region in regions:\n", 111 | " if region == '':\n", 112 | " break\n", 113 | " prompt_region, neg_prompt_region, pos = region.split('-*-')\n", 114 | " prompt_region = prompt_region.replace('[', '').replace(']', '')\n", 115 | " neg_prompt_region = neg_prompt_region.replace('[', '').replace(']', '')\n", 116 | " pos = eval(pos)\n", 117 | " if len(pos) == 0:\n", 118 | " pos = [0, 0, 1, 1]\n", 119 | " else:\n", 120 | " pos[0], pos[2] = pos[0] / height, pos[2] / height\n", 121 | " pos[1], pos[3] = pos[1] / width, pos[3] / width\n", 122 | "\n", 123 | " region_collection.append((prompt_region, neg_prompt_region, pos))\n", 124 | " return (prompt, region_collection)\n", 125 | "\n", 126 | "pretrained_model=\"/content/Mix-of-Show/MoS-hina-kario-tezuka-anythingv4\"\n", 127 | "device = torch.device('cuda') if torch.cuda.is_available() else torch.device('cpu')\n", 128 | "pipe = build_model(pretrained_model, device)" 129 | ] 130 | }, 131 | { 132 | "cell_type": "code", 133 | "execution_count": null, 134 | "metadata": {}, 135 | "outputs": [], 136 | "source": [ 137 | "%cd /content/Mix-of-Show\n", 138 | "\n", 139 | "expdir=\"/content/Mix-of-Show/hina+kario+tezuka_anythingv4\"\n", 140 | "\n", 141 | "keypose_condition='/content/Mix-of-Show/datasets/validation_spatial_condition/multi-characters/anime_pose_2x/hina_tezuka_kario_2x.png'\n", 142 | "keypose_adaptor_weight=1.0\n", 143 | "sketch_condition=''\n", 144 | "sketch_adaptor_weight=1.0\n", 145 | "\n", 146 | "context_prompt='two girls and a boy are standing in front of mount fuji'\n", 147 | "negative_prompt='longbody, lowres, bad anatomy, bad hands, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality'\n", 148 | "\n", 149 | "region1_prompt='[a , standing in front of mount fuji]'\n", 150 | "region1_neg_prompt=\"[${context_neg_prompt}]\"\n", 151 | "region1='[12, 36, 1024, 600]'\n", 152 | "\n", 153 | "region2_prompt='[a , standing in front of mount fuji]'\n", 154 | "region2_neg_prompt=\"[${context_neg_prompt}]\"\n", 155 | "region2='[18, 696, 1024, 1180]'\n", 156 | "\n", 157 | "region5_prompt='[a , standing in front of mount fuji]'\n", 158 | "region5_neg_prompt=\"[${context_neg_prompt}]\"\n", 159 | "region5='[142, 1259, 1024, 1956]'\n", 160 | "\n", 161 | "prompt_rewrite=f\"{region1_prompt}-*-{region1_neg_prompt}-*-{region1}|{region2_prompt}-*-{region2_neg_prompt}-*-{region2}|{region5_prompt}-*-{region5_neg_prompt}-*-{region5}\"\n", 162 | "\n", 163 | "print(prompt_rewrite)\n", 164 | "\n", 165 | "if sketch_condition is not None and os.path.exists(sketch_condition):\n", 166 | " sketch_condition = Image.open(sketch_condition).convert('L')\n", 167 | " width_sketch, height_sketch = sketch_condition.size\n", 168 | " print('use sketch condition')\n", 169 | "else:\n", 170 | " sketch_condition, width_sketch, height_sketch = None, 0, 0\n", 171 | " print('skip sketch condition')\n", 172 | "\n", 173 | "if keypose_condition is not None and os.path.exists(keypose_condition):\n", 174 | " keypose_condition = Image.open(keypose_condition).convert('RGB')\n", 175 | " width_pose, height_pose = keypose_condition.size\n", 176 | " print('use pose condition')\n", 177 | "else:\n", 178 | " keypose_condition, width_pose, height_pose = None, 0, 0\n", 179 | " print('skip pose condition')\n", 180 | "\n", 181 | "if width_sketch != 0 and width_pose != 0:\n", 182 | " assert width_sketch == width_pose and height_sketch == height_pose, 'conditions should be same size'\n", 183 | "width, height = max(width_pose, width_sketch), max(height_pose, height_sketch)\n", 184 | "\n", 185 | "kwargs = {\n", 186 | " 'sketch_condition': sketch_condition,\n", 187 | " 'keypose_condition': keypose_condition,\n", 188 | " 'height': height,\n", 189 | " 'width': width,\n", 190 | "}\n", 191 | "\n", 192 | "suffix='baseline'\n", 193 | "save_dir=expdir\n", 194 | "region_keypose_adaptor_weight = ''\n", 195 | "region_sketch_adaptor_weight = ''\n", 196 | "seed = 1\n", 197 | "prompt = 'photo of a toy'\n", 198 | "prompts = [prompt]\n", 199 | "prompts_rewrite = [prompt_rewrite]\n", 200 | "input_prompt = [prepare_text(p, p_w, height, width) for p, p_w in zip(prompts, prompts_rewrite)]\n", 201 | "save_prompt = input_prompt[0][0]\n", 202 | "\n", 203 | "image = sample_image(\n", 204 | " pipe,\n", 205 | " input_prompt=input_prompt,\n", 206 | " input_neg_prompt=[negative_prompt] * len(input_prompt),\n", 207 | " generator=torch.Generator(device).manual_seed(seed),\n", 208 | " sketch_adaptor_weight=sketch_adaptor_weight,\n", 209 | " region_sketch_adaptor_weight=region_sketch_adaptor_weight,\n", 210 | " keypose_adaptor_weight=keypose_adaptor_weight,\n", 211 | " region_keypose_adaptor_weight=region_keypose_adaptor_weight,\n", 212 | " **kwargs)\n", 213 | "\n", 214 | "print(f'save to: {save_dir}')\n", 215 | "\n", 216 | "configs = [\n", 217 | " f'pretrained_model: {pretrained_model}\\n',\n", 218 | " f'context_prompt: {prompt}\\n', f'neg_context_prompt: {negative_prompt}\\n',\n", 219 | " f'sketch_condition: {sketch_condition}\\n', f'sketch_adaptor_weight: {sketch_adaptor_weight}\\n',\n", 220 | " f'region_sketch_adaptor_weight: {region_sketch_adaptor_weight}\\n',\n", 221 | " f'keypose_condition: {keypose_condition}\\n', f'keypose_adaptor_weight: {keypose_adaptor_weight}\\n',\n", 222 | " f'region_keypose_adaptor_weight: {region_keypose_adaptor_weight}\\n', f'random seed: {seed}\\n',\n", 223 | " f'prompt_rewrite: {prompt_rewrite}\\n'\n", 224 | "]\n", 225 | "hash_code = hashlib.sha256(''.join(configs).encode('utf-8')).hexdigest()[:8]\n", 226 | "\n", 227 | "save_prompt = save_prompt.replace(' ', '_')\n", 228 | "save_name = f'{save_prompt}---{suffix}---{hash_code}.png'\n", 229 | "save_dir = os.path.join(save_dir, f'seed_{seed}')\n", 230 | "save_path = os.path.join(save_dir, save_name)\n", 231 | "save_config_path = os.path.join(save_dir, save_name.replace('.png', '.txt'))\n", 232 | "\n", 233 | "os.makedirs(save_dir, exist_ok=True)\n", 234 | "image[0].save(os.path.join(save_dir, save_name))\n", 235 | "\n", 236 | "with open(save_config_path, 'w') as fw:\n", 237 | " fw.writelines(configs)" 238 | ] 239 | } 240 | ], 241 | "metadata": { 242 | "accelerator": "GPU", 243 | "colab": { 244 | "gpuType": "T4", 245 | "provenance": [] 246 | }, 247 | "kernelspec": { 248 | "display_name": "Python 3", 249 | "name": "python3" 250 | }, 251 | "language_info": { 252 | "name": "python" 253 | } 254 | }, 255 | "nbformat": 4, 256 | "nbformat_minor": 0 257 | } 258 | --------------------------------------------------------------------------------