diff --git a/projects/prompt_to_prompt/models/seq_aligner.py b/projects/prompt_to_prompt/models/seq_aligner.py index 6aeb68ea60..e108a8165c 100644 --- a/projects/prompt_to_prompt/models/seq_aligner.py +++ b/projects/prompt_to_prompt/models/seq_aligner.py @@ -34,16 +34,16 @@ def mis_match_char(self, x, y): def get_matrix(size_x, size_y, gap): matrix = [] - for i in range(len(size_x) + 1): + for i in range(size_x + 1): sub_matrix = [] - for j in range(len(size_y) + 1): + for j in range(size_y + 1): sub_matrix.append(0) matrix.append(sub_matrix) - for j in range(1, len(size_y) + 1): + for j in range(1, size_y + 1): matrix[0][j] = j * gap - for i in range(1, len(size_x) + 1): + for i in range(1, size_x + 1): matrix[i][0] = i * gap - return matrix + return np.array(matrix) # def get_matrix(size_x, size_y, gap): diff --git a/projects/prompt_to_prompt/visualize.ipynb b/projects/prompt_to_prompt/visualize.ipynb index f9535b7d6b..7154fe734b 100644 --- a/projects/prompt_to_prompt/visualize.ipynb +++ b/projects/prompt_to_prompt/visualize.ipynb @@ -98,10 +98,11 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ - "#### 1. VAE reconstruction as the a standard result\n" + "#### 1. VAE reconstruction as the standard result\n" ] }, { @@ -123,11 +124,12 @@ "source": [ "from models import ptp_utils\n", "import torch\n", + "import mmcv\n", "\n", - "image_path = 'projects/prompt_to_prompt/assets/gnochi_mirror.jpeg'\n", + "image = mmcv.imread('https://github.com/open-mmlab/mmagic/assets/12782558/c851dcf8-bcfa-424f-9eeb-d01a48ea7127', channel_order='rgb')\n", "prompt = \"a cat sitting next to a mirror\"\n", "# using vae to reconstruct the image\n", - "image_tensor = ptp_utils.load_512(image_path).to('cuda')\n", + "image_tensor = ptp_utils.load_512(image).to('cuda')\n", "vae = StableDiffuser.vae\n", "with torch.no_grad():\n", " vae_rec = vae(image_tensor, return_dict=False)[0]\n",