(images, save_path, base_count, num_rows=1, offset_ratio=0.02, step=None)
| 156 | return img |
| 157 | |
| 158 | def view_images(images, save_path, base_count, num_rows=1, offset_ratio=0.02, step=None): |
| 159 | if type(images) is list: |
| 160 | num_empty = len(images) % num_rows |
| 161 | elif images.ndim == 4: |
| 162 | num_empty = images.shape[0] % num_rows |
| 163 | else: |
| 164 | images = [images] |
| 165 | num_empty = 0 |
| 166 | |
| 167 | empty_images = np.ones(images[0].shape, dtype=np.uint8) * 255 |
| 168 | images = [image.astype(np.uint8) for image in images] + [empty_images] * num_empty |
| 169 | num_items = len(images) |
| 170 | |
| 171 | h, w, c = images[0].shape |
| 172 | offset = int(h * offset_ratio) |
| 173 | num_cols = num_items // num_rows |
| 174 | image_ = np.ones((h * num_rows + offset * (num_rows - 1), |
| 175 | w * num_cols + offset * (num_cols - 1), 3), dtype=np.uint8) * 255 |
| 176 | for i in range(num_rows): |
| 177 | for j in range(num_cols): |
| 178 | image_[i * (h + offset): i * (h + offset) + h:, j * (w + offset): j * (w + offset) + w] = images[ |
| 179 | i * num_cols + j] |
| 180 | |
| 181 | pil_img = Image.fromarray(image_) |
| 182 | base_count += 40 |
| 183 | if step is not None: |
| 184 | pil_img.save(os.path.join(save_path, f"{base_count:05}_{step}.png")) |
| 185 | else: |
| 186 | pil_img.save(os.path.join(save_path, f"{base_count:05}.png")) |
| 187 | # display(pil_img) |
| 188 | |
| 189 | def aggregate_attention(prompts, attention_store: AttentionStore, res: int, from_where: List[str], is_cross: bool, select: int): |
| 190 | out = [] |
no outgoing calls
no test coverage detected