(image, res=512)
| 350 | return out.cpu() if is_cpu else out |
| 351 | |
| 352 | def preprocess(image, res=512): |
| 353 | image = image.resize((res, res), resample=Image.LANCZOS) |
| 354 | image = np.array(image).astype(np.float32) / 255.0 |
| 355 | image = image[None].transpose(0, 3, 1, 2) |
| 356 | image = torch.from_numpy(image)[:, :3, :, :].cuda() |
| 357 | return 2.0 * image - 1.0 |
| 358 | |
| 359 | |
| 360 | def encoder(image, model, res=512): |
no outgoing calls
no test coverage detected