lucidrains / DALLE2-pytorch

Implementation of DALL-E 2, OpenAI's updated text-to-image synthesis neural network, in Pytorch
MIT License
11.03k stars 1.07k forks source link

How can I change Cuda to CPU in dalle2 on Mac? #26

Closed iaa2005 closed 2 years ago

iaa2005 commented 2 years ago

AssertionError: Torch not compiled with CUDA enabled

 87 # do above for many steps
 89 dalle2 = DALLE2(
 90     prior = diffusion_prior,
 91     decoder = decoder
 92 )

---> 94 images = dalle2( 95 ['cute puppy chasing after a squirrel'], 96 cond_scale = 2. # classifier free guidance strength (> 1 would strengthen the condition) 97 ) 99 images

lucidrains commented 2 years ago

@iaa2005 Hi Ivanov! I've put in a fix in 0.0.55 (although you'd probably still want to use GPU most of the time)

iaa2005 commented 2 years ago

Ok, it works. I changed cuda in your code to cpu. And I have one question: how to convert images(type: tensor) to png image and save it in the directory?:

dalle2 = DALLE2(
    prior = diffusion_prior,
    decoder = decoder
)

images = dalle2(
    ['cute puppy chasing after a squirrel'],
    cond_scale = 2. # classifier free guidance strength (> 1 would strengthen the condition)
)

# save your image (in this example, of size 256x256)
iaa2005 commented 2 years ago

And what about "# do above for many steps"? What should I do in my code for many steps? Which parts I need to repeat several times in code after "Let's see the whole script below ..( this code)" in README?

iaa2005 commented 2 years ago

?

rom1504 commented 2 years ago

Hey @iaa2005 , what are you trying to build?

This repo currently contains only the model code. You will need to write a training loop, get a dataset and use a high end GPU for training for a few days to get results.

There is no pretrained model to use yet.

rom1504 commented 2 years ago

You may be interested by #23 and #27

lucidrains commented 2 years ago

Ok, it works. I changed cuda in your code to cpu. And I have one question: how to convert images(type: tensor) to png image and save it in the directory?:

dalle2 = DALLE2(
    prior = diffusion_prior,
    decoder = decoder
)

images = dalle2(
    ['cute puppy chasing after a squirrel'],
    cond_scale = 2. # classifier free guidance strength (> 1 would strengthen the condition)
)

# save your image (in this example, of size 256x256)

i've addressed this in the latest version, you'll simply have to do dalle([<prompt>], return_pil_images = True) to get it back as pillow images, which you can then just do a .save('/path/to/<prompt>.png')