-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Conversation
The documentation is not available anymore as the PR was closed or merged. |
src/diffusers/models/vae.py
Outdated
@@ -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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def sample(self, generator=None) -> torch.Tensor: | |
def sample(self, generator: Optional[torch.Generator] = None) -> torch.FloatTensor: |
src/diffusers/models/vae.py
Outdated
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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def decode(self, z: torch.Tensor) -> torch.FloatTensor: | |
def decode(self, z: torch.FloatTensor) -> torch.FloatTensor: |
src/diffusers/models/vae.py
Outdated
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): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def forward(self, sample: torch.FloatTensor, sample_posterior=False): | |
def forward(self, sample: torch.FloatTensor, sample_posterior: bool = False) -> torch.FloatTensor: |
There was a problem hiding this 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
@patrickvonplaten Thank you for the review. I have made the changes based on your suggestions. Thanks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great - merging!
A small merge conflict with recent updates from |
* 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>
* 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>
I have added type hints for 5 and 6 from #287
@pcuenca I'll be glad if you can check it out.