Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reconstruction results #20

Open
Marcelo5444 opened this issue Aug 10, 2023 · 4 comments
Open

Reconstruction results #20

Marcelo5444 opened this issue Aug 10, 2023 · 4 comments

Comments

@Marcelo5444
Copy link

Marcelo5444 commented Aug 10, 2023

Hi, First of all thanks for you work.

Working with vit small, I see that results are far away from VQGAN, did you stop training when reached convergence? Do you think there is more room to improve the model performance/

Results with vit-small
cat
input image
212861459-e4113b34-622d-4602-afe4-f20e2d79425c

@ghost
Copy link

ghost commented Aug 11, 2023

Can you show me your code for reconstruction?I also meet this problem that reconstruction results of the ViT-VQGAN on ImageNet are very terrible.

@Marcelo5444
Copy link
Author

config = OmegaConf.load('configs/imagenet_vitvq_small.yaml')
model = initialize_from_config(config.model)
model.init_from_ckpt('/home/marcelo/Downloads/imagenet_vitvq_small.ckpt')

def preprocess(img):
s = min(img.size)

if s < 256:
    raise ValueError(f'min dim for image {s} < 256')

r = 1024 / s
s = (round(r * img.size[1]), round(r * img.size[0]))
img = TF.resize(img, s, interpolation=PIL.Image.LANCZOS)
img = TF.center_crop(img, output_size=2 * [256])
img = torch.unsqueeze(T.ToTensor()(img), 0)
return img

original=Image.open('/home/marcelo/Downloads/212861459-e4113b34-622d-4602-afe4-f20e2d79425c.png')
image=preprocess(original)
image = image[:,:3,:,:]

quant, _ = model.encode(image)
dec = model.decode(quant)

@ghost
Copy link

ghost commented Aug 12, 2023 via email

@Marcelo5444
Copy link
Author

So, after your training, you obtain a better model weights that improve the reconstruction?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant