diff --git a/README.md b/README.md index 2097586..2ae0c83 100644 --- a/README.md +++ b/README.md @@ -70,9 +70,9 @@ images = model.generate_images( To get an image into PIL format you will have to first move the images to the CPU and convert the tensor to a numpy array. ```python -images = images.to('cpu').detach().numpy() +images = images.to('cpu').numpy() ``` -Then image $i$ can be coverted to a PIL.Image and saved with its `save` method +Then image $i$ can be coverted to a PIL.Image and saved ```python image = Image.fromarray(images[i]) image.save('image_{}.png'.format(i)) diff --git a/min_dalle/min_dalle.py b/min_dalle/min_dalle.py index 600b319..fedbf3a 100644 --- a/min_dalle/min_dalle.py +++ b/min_dalle/min_dalle.py @@ -161,7 +161,7 @@ class MinDalle: grid_size = int(sqrt(images.shape[0])) images = images.reshape([grid_size] * 2 + list(images.shape[1:])) image = images.flatten(1, 2).transpose(0, 1).flatten(1, 2) - image = Image.fromarray(image.to('cpu').detach().numpy()) + image = Image.fromarray(image.to('cpu').numpy()) return image