lucidrains / muse-maskgit-pytorch

Implementation of Muse: Text-to-Image Generation via Masked Generative Transformers, in Pytorch
MIT License
867 stars 81 forks source link

TypeError: isinstance() arg 2 must be a type or tuple of types #32

Closed edmondja closed 1 year ago

edmondja commented 1 year ago

Hello, after running the below code, it says "TypeError: isinstance() arg 2 must be a type or tuple of types", what did I do wrong ? ` for i in range(len(train)): im = np.array(train[i]) im = cv2.resize(im, dsize=(32, 32), interpolation=cv2.INTERCUBIC)[:, :, None] im = np.concatenate((im,im,im), axis=2) name = './mnist/im'+str(i)+'.png' cv2.imwrite(name, im)

import torch from muse_maskgit_pytorch import VQGanVAE, VQGanVAETrainer

vae = VQGanVAE( dim = 16, vq_codebook_size = 32 )

train on folder of images, as many images as possible

trainer = VQGanVAETrainer( vae = vae, image_size = 32, # you may want to start with small images, and then curriculum learn to larger ones, but because the vae is all convolution, it should generalize to 512 (as in paper) without training on it folder = './mnist', batch_size = 2, grad_accum_every = 8, num_train_steps = 100000 )#.cuda() Traceback (most recent call last):

File "C:\Users\Ext.Edmond_Jacoupeau\AppData\Local\Temp\ipykernel_3136\1437749784.py", line 11, in trainer = VQGanVAETrainer(

File "<@beartype(muse_maskgit_pytorch.trainers.VQGanVAETrainer.init) at 0x278d4d5e040>", line 48, in init

File "C:\Users\Ext.Edmond_Jacoupeau\Anaconda3\envs\py39\lib\site-packages\muse_maskgit_pytorch\trainers.py", line 149, in init ddp_kwargs = find_and_pop(

File "C:\Users\Ext.Edmond_Jacoupeau\Anaconda3\envs\py39\lib\site-packages\muse_maskgit_pytorch\trainers.py", line 47, in find_and_pop ind = find_index(arr, cond)

File "C:\Users\Ext.Edmond_Jacoupeau\Anaconda3\envs\py39\lib\site-packages\muse_maskgit_pytorch\trainers.py", line 42, in find_index if cond(el):

TypeError: isinstance() arg 2 must be a type or tuple of types `

lucidrains commented 1 year ago

@edmondja oh my bad, do you want to try 0.1.5?

edmondja commented 1 year ago

No worries thanks, the fix worked (but I had to use 64x64 pictures instead of 32x32 "RuntimeError: Calculated padded input size per channel: (2 x 2). Kernel size: (4 x 4). Kernel size can't be greater than actual input size")

lucidrains commented 1 year ago

cool, happy training :smile: