diff --git "a/inpaint_noise_issue.ipynb" "b/inpaint_noise_issue.ipynb" new file mode 100644--- /dev/null +++ "b/inpaint_noise_issue.ipynb" @@ -0,0 +1,178 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "# based on https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers/in_painting_with_stable_diffusion_using_diffusers.ipynb#scrollTo=hvdHYdtTu6KA\n", + "\n", + "from diffusers import StableDiffusionInpaintPipelineLegacy\n", + "from diffusers import DPMSolverMultistepScheduler\n", + "from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion_inpaint_legacy import preprocess_image\n", + "import torch\n", + "import PIL\n", + "import requests\n", + "from io import BytesIO" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "06dedd8b44de4a18b45dcd8bb87c60e0", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Fetching 15 files: 0%| | 0/15 [00:00" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "def download_image(url):\n", + " response = requests.get(url)\n", + " return PIL.Image.open(BytesIO(response.content)).convert(\"RGB\")\n", + "\n", + "img_url = \"https://raw.githubusercontent.com/CompVis/latent-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo.png\"\n", + "image = download_image(img_url).resize((512, 512))\n", + "image" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [], + "source": [ + "mask_image = torch.ones(1,512,512,1) # causes shape mismatch error when running pipe inference\n", + "\n", + "mask_image = torch.ones(1,4,64,64) " + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "7ca06b0f6c9e4c3ba5408042f7a18df2", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/4 [00:00" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "images[0] # expected to be original image since mask is all ones (i.e. no inpainting)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3.10.8 ('ml')", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.8" + }, + "orig_nbformat": 4, + "vscode": { + "interpreter": { + "hash": "cbbcdde725e9a65f1cb734ac4223fed46e03daf1eb62d8ccb3c48face3871521" + } + } + }, + "nbformat": 4, + "nbformat_minor": 2 +}