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

Consistency Loss - Question on the implementation #8

Closed
pbonazzi opened this issue Aug 22, 2022 · 0 comments
Closed

Consistency Loss - Question on the implementation #8

pbonazzi opened this issue Aug 22, 2022 · 0 comments

Comments

@pbonazzi
Copy link

Assuming

          args.N_importance = 0
          args.consistency_model_type.startswith('clip_vit') = True

Is it right to say that the consistency loss will compare the first pixel row of the first image of the training batch with the first pixel row of a random image in the target batch ?

            with torch.no_grad():
                  targets_resize_model = F.interpolate(targets, (args.consistency_size, args.consistency_size), ....)
                  target_embeddings = embed(targets_resize_model)  # [N_images , Width , Height]
            target_emb = target_embeddings[:, 0]  # from all images take the first rows
            target_i = np.random.randint(target_emb.shape[0]) 
            target_emb = target_emb[target_i] # sample a random image


            rgbs_resize_c = F.interpolate(rgbs, size=(args.consistency_size, args.consistency_size), mode=args.pixel_interp_mode)
            rendered_embeddings = embed(rgbs_resize_c) # [N_images , Width , Height]
            rendered_embedding = rendered_embeddings[0]  # get the first image
            rendered_emb = rendered_embedding[0] # get the first row of pixels

            consistency_loss = -torch.cosine_similarity(target_emb, rendered_emb, dim=-1)

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