(self, image)
| 267 | FUNCTION = "execute" |
| 268 | |
| 269 | def execute(self, image): |
| 270 | image_path = folder_paths.get_annotated_filepath(image) |
| 271 | |
| 272 | imgF = Image.open(image_path) |
| 273 | img, prompt, metadata = buildMetadata(image_path) |
| 274 | if imgF.format == 'WEBP': |
| 275 | # Use piexif to extract EXIF data from WebP image |
| 276 | try: |
| 277 | exif_data = piexif.load(image_path) |
| 278 | prompt, metadata = self.process_exif_data(exif_data) |
| 279 | except ValueError: |
| 280 | prompt = {} |
| 281 | |
| 282 | img = ImageOps.exif_transpose(img) |
| 283 | image = img.convert("RGB") |
| 284 | image = np.array(image).astype(np.float32) / 255.0 |
| 285 | image = torch.from_numpy(image)[None,] |
| 286 | if 'A' in img.getbands(): |
| 287 | mask = np.array(img.getchannel('A')).astype(np.float32) / 255.0 |
| 288 | mask = 1. - torch.from_numpy(mask) |
| 289 | else: |
| 290 | mask = torch.zeros((64, 64), dtype=torch.float32, device="cpu") |
| 291 | |
| 292 | return image, mask.unsqueeze(0), prompt, metadata |
| 293 | |
| 294 | def process_exif_data(self, exif_data): |
| 295 | metadata = {} |
nothing calls this directly
no test coverage detected