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

type hints: models/vae.py #346

Merged
merged 4 commits into from
Sep 5, 2022

Conversation

realsama
Copy link
Contributor

@realsama realsama commented Sep 4, 2022

I have added type hints for 5 and 6 from #287

@pcuenca I'll be glad if you can check it out.

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Sep 4, 2022

The documentation is not available anymore as the PR was closed or merged.

@@ -293,7 +293,7 @@ def __init__(self, parameters, deterministic=False):
if self.deterministic:
self.var = self.std = torch.zeros_like(self.mean).to(device=self.parameters.device)

def sample(self, generator=None):
def sample(self, generator=None) -> torch.Tensor:
Copy link
Contributor

@patrickvonplaten patrickvonplaten Sep 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def sample(self, generator=None) -> torch.Tensor:
def sample(self, generator: Optional[torch.Generator] = None) -> torch.FloatTensor:

h = self.encoder(x)
moments = self.quant_conv(h)
posterior = DiagonalGaussianDistribution(moments)
return posterior

def decode(self, z):
def decode(self, z: torch.Tensor) -> torch.FloatTensor:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def decode(self, z: torch.Tensor) -> torch.FloatTensor:
def decode(self, z: torch.FloatTensor) -> torch.FloatTensor:

z = self.post_quant_conv(z)
dec = self.decoder(z)
return dec

def forward(self, sample, sample_posterior=False):
def forward(self, sample: torch.FloatTensor, sample_posterior=False):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def forward(self, sample: torch.FloatTensor, sample_posterior=False):
def forward(self, sample: torch.FloatTensor, sample_posterior: bool = False) -> torch.FloatTensor:

Copy link
Contributor

@patrickvonplaten patrickvonplaten left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot @shepherd1530 - left a couple of suggestions :-) Let me know if you have any questions

@realsama
Copy link
Contributor Author

realsama commented Sep 4, 2022

@patrickvonplaten Thank you for the review. I have made the changes based on your suggestions. Thanks

Copy link
Contributor

@patrickvonplaten patrickvonplaten left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great - merging!

@anton-l
Copy link
Member

anton-l commented Sep 5, 2022

A small merge conflict with recent updates from main here, but should be ok now, thanks @shepherd1530!

@anton-l anton-l merged commit 07f8ebd into huggingface:main Sep 5, 2022
natolambert pushed a commit that referenced this pull request Sep 7, 2022
* type hints: models/vae.py

* modify typings in vae.py

Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com>
Co-authored-by: Anton Lozhkov <anton@huggingface.co>
PhaneeshB pushed a commit to nod-ai/diffusers that referenced this pull request Mar 1, 2023
yoonseokjin pushed a commit to yoonseokjin/diffusers that referenced this pull request Dec 25, 2023
* type hints: models/vae.py

* modify typings in vae.py

Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com>
Co-authored-by: Anton Lozhkov <anton@huggingface.co>
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

Successfully merging this pull request may close these issues.

4 participants