Open VincentLu91 opened 2 years ago
Hey @VincentLu91 !
I tried the following and it worked for me:
from torchvision.utils import save_image
img1 = images[0] #torch.Size([3, 256, 256])
save_image(img1, 'img1.png’)
This way it doesn't display/plot the image directly but it saves it in your folder.
As for the part
text_embeds = torch.randn(4, 256, 768).cuda()
images = torch.randn(4, 3, 256, 256).cuda()
this is where it gets tricky, as far as I've understood. Here one should train one's own model, and so you have to pass to the variables the relative texts and images.
Maybe somebody with more experience will be able to provide further details!
use this:
images = imagen.sample(texts = [
'a whale breaching from afar',
'young girl blowing out candles on her birthday cake',
'fireworks with blue and green sparkles'
], cond_scale = 3., return_pil_images = True)
count = 0
for image in images:
image.save(f'{count}.png')
count += 1
u can add hyperparameter: return_pil_images = True
I used above method, but it's still appear grainy chart. So, i think have some problem when training, instead of tensor to image. Have anybody can help?
I am testing the "Usage" example code from the README but I have not been successfully able to generate any meaningful images. It hasn't worked when I tried in a Colab notebook. Notebook (make sure GPU is selected as runtime type): https://colab.research.google.com/drive/1EsyMfsgQ5fzSMAccHWTbgTJ8st4RY6DS?usp=sharing
The example code doesn't show us how to print/display/plot an image after the tensor is created. The
images
variable is a 4D tensor value, so I've been looking into showing the tensor as an image. So far I triedBut it only gives a grainy chart. I'm not sure why it's not generating anything meaningful but perhaps I am under training a model? Is it due to the code snippet below?
I haven't worked with 4D tensors but I would love to explore this model and get an understanding of the library in the process but I'm not sure if I'm on the right track.