Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
diffusers
Commits
033b77eb
Unverified
Commit
033b77eb
authored
Sep 02, 2022
by
Santiago Víquez
Committed by
GitHub
Sep 02, 2022
Browse files
[Type hint] Latent Diffusion Uncond pipeline (#333)
parent
e54206d0
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
2 deletions
+18
-2
src/diffusers/pipelines/latent_diffusion_uncond/pipeline_latent_diffusion_uncond.py
...tent_diffusion_uncond/pipeline_latent_diffusion_uncond.py
+18
-2
No files found.
src/diffusers/pipelines/latent_diffusion_uncond/pipeline_latent_diffusion_uncond.py
View file @
033b77eb
import
inspect
import
inspect
import
warnings
import
warnings
from
typing
import
Optional
import
torch
import
torch
from
...models
import
UNet2DModel
,
VQModel
from
...pipeline_utils
import
DiffusionPipeline
from
...pipeline_utils
import
DiffusionPipeline
from
...schedulers
import
DDIMScheduler
class
LDMPipeline
(
DiffusionPipeline
):
class
LDMPipeline
(
DiffusionPipeline
):
def
__init__
(
self
,
vqvae
,
unet
,
scheduler
):
vqvae
:
VQModel
unet
:
UNet2DModel
scheduler
:
DDIMScheduler
def
__init__
(
self
,
vqvae
:
VQModel
,
unet
:
UNet2DModel
,
scheduler
:
DDIMScheduler
):
super
().
__init__
()
super
().
__init__
()
scheduler
=
scheduler
.
set_format
(
"pt"
)
scheduler
=
scheduler
.
set_format
(
"pt"
)
self
.
register_modules
(
vqvae
=
vqvae
,
unet
=
unet
,
scheduler
=
scheduler
)
self
.
register_modules
(
vqvae
=
vqvae
,
unet
=
unet
,
scheduler
=
scheduler
)
@
torch
.
no_grad
()
@
torch
.
no_grad
()
def
__call__
(
self
,
batch_size
=
1
,
generator
=
None
,
eta
=
0.0
,
num_inference_steps
=
50
,
output_type
=
"pil"
,
**
kwargs
):
def
__call__
(
self
,
batch_size
:
int
=
1
,
generator
:
Optional
[
torch
.
Generator
]
=
None
,
eta
:
float
=
0.0
,
num_inference_steps
:
int
=
50
,
output_type
:
Optional
[
str
]
=
"pil"
,
**
kwargs
,
):
# eta corresponds to η in paper and should be between [0, 1]
# eta corresponds to η in paper and should be between [0, 1]
if
"torch_device"
in
kwargs
:
if
"torch_device"
in
kwargs
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment