Skip to content

Commit

Permalink
Bump to 0.6.0.dev0 (huggingface#831)
Browse files Browse the repository at this point in the history
* Bump to 0.6.0.dev0

* Deprecate tensor_format and .samples

* style

* upd

* upd

* style

* sample -> images

* Update src/diffusers/schedulers/scheduling_ddpm.py

Co-authored-by: Patrick von Platen <[email protected]>

* Update src/diffusers/schedulers/scheduling_ddim.py

Co-authored-by: Patrick von Platen <[email protected]>

* Update src/diffusers/schedulers/scheduling_karras_ve.py

Co-authored-by: Patrick von Platen <[email protected]>

* Update src/diffusers/schedulers/scheduling_lms_discrete.py

Co-authored-by: Patrick von Platen <[email protected]>

* Update src/diffusers/schedulers/scheduling_pndm.py

Co-authored-by: Patrick von Platen <[email protected]>

* Update src/diffusers/schedulers/scheduling_sde_ve.py

Co-authored-by: Patrick von Platen <[email protected]>

* Update src/diffusers/schedulers/scheduling_sde_vp.py

Co-authored-by: Patrick von Platen <[email protected]>

Co-authored-by: Patrick von Platen <[email protected]>
  • Loading branch information
anton-l and patrickvonplaten authored Oct 14, 2022
1 parent b8c4d58 commit 52394b5
Show file tree
Hide file tree
Showing 12 changed files with 16 additions and 84 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def run(self):

setup(
name="diffusers",
version="0.5.1", # expected format is one of x.y.z.dev0, or x.y.z.rc1 or x.y.z (no to dashes, yes to dots)
version="0.6.0.dev0", # expected format is one of x.y.z.dev0, or x.y.z.rc1 or x.y.z (no to dashes, yes to dots)
description="Diffusers",
long_description=open("README.md", "r", encoding="utf-8").read(),
long_description_content_type="text/markdown",
Expand Down
2 changes: 1 addition & 1 deletion src/diffusers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
)


__version__ = "0.5.1"
__version__ = "0.6.0.dev0"

from .configuration_utils import ConfigMixin
from .onnx_utils import OnnxRuntimeModel
Expand Down
8 changes: 0 additions & 8 deletions src/diffusers/schedulers/scheduling_ddim.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,7 @@ def __init__(
clip_sample: bool = True,
set_alpha_to_one: bool = True,
steps_offset: int = 0,
**kwargs,
):
deprecate(
"tensor_format",
"0.6.0",
"If you're running your code in PyTorch, you can safely remove this argument.",
take_from=kwargs,
)

if trained_betas is not None:
self.betas = torch.from_numpy(trained_betas)
elif beta_schedule == "linear":
Expand Down
10 changes: 1 addition & 9 deletions src/diffusers/schedulers/scheduling_ddpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import torch

from ..configuration_utils import ConfigMixin, register_to_config
from ..utils import BaseOutput, deprecate
from ..utils import BaseOutput
from .scheduling_utils import SchedulerMixin


Expand Down Expand Up @@ -112,15 +112,7 @@ def __init__(
trained_betas: Optional[np.ndarray] = None,
variance_type: str = "fixed_small",
clip_sample: bool = True,
**kwargs,
):
deprecate(
"tensor_format",
"0.6.0",
"If you're running your code in PyTorch, you can safely remove this argument.",
take_from=kwargs,
)

if trained_betas is not None:
self.betas = torch.from_numpy(trained_betas)
elif beta_schedule == "linear":
Expand Down
10 changes: 1 addition & 9 deletions src/diffusers/schedulers/scheduling_karras_ve.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import torch

from ..configuration_utils import ConfigMixin, register_to_config
from ..utils import BaseOutput, deprecate
from ..utils import BaseOutput
from .scheduling_utils import SchedulerMixin


Expand Down Expand Up @@ -86,15 +86,7 @@ def __init__(
s_churn: float = 80,
s_min: float = 0.05,
s_max: float = 50,
**kwargs,
):
deprecate(
"tensor_format",
"0.6.0",
"If you're running your code in PyTorch, you can safely remove this argument.",
take_from=kwargs,
)

# standard deviation of the initial noise distribution
self.init_noise_sigma = sigma_max

Expand Down
8 changes: 0 additions & 8 deletions src/diffusers/schedulers/scheduling_lms_discrete.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,7 @@ def __init__(
beta_end: float = 0.02,
beta_schedule: str = "linear",
trained_betas: Optional[np.ndarray] = None,
**kwargs,
):
deprecate(
"tensor_format",
"0.6.0",
"If you're running your code in PyTorch, you can safely remove this argument.",
take_from=kwargs,
)

if trained_betas is not None:
self.betas = torch.from_numpy(trained_betas)
elif beta_schedule == "linear":
Expand Down
8 changes: 0 additions & 8 deletions src/diffusers/schedulers/scheduling_pndm.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,7 @@ def __init__(
skip_prk_steps: bool = False,
set_alpha_to_one: bool = False,
steps_offset: int = 0,
**kwargs,
):
deprecate(
"tensor_format",
"0.6.0",
"If you're running your code in PyTorch, you can safely remove this argument.",
take_from=kwargs,
)

if trained_betas is not None:
self.betas = torch.from_numpy(trained_betas)
elif beta_schedule == "linear":
Expand Down
10 changes: 1 addition & 9 deletions src/diffusers/schedulers/scheduling_sde_ve.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import torch

from ..configuration_utils import ConfigMixin, register_to_config
from ..utils import BaseOutput, deprecate
from ..utils import BaseOutput
from .scheduling_utils import SchedulerMixin, SchedulerOutput


Expand Down Expand Up @@ -75,15 +75,7 @@ def __init__(
sigma_max: float = 1348.0,
sampling_eps: float = 1e-5,
correct_steps: int = 1,
**kwargs,
):
deprecate(
"tensor_format",
"0.6.0",
"If you're running your code in PyTorch, you can safely remove this argument.",
take_from=kwargs,
)

# standard deviation of the initial noise distribution
self.init_noise_sigma = sigma_max

Expand Down
9 changes: 1 addition & 8 deletions src/diffusers/schedulers/scheduling_sde_vp.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import torch

from ..configuration_utils import ConfigMixin, register_to_config
from ..utils import deprecate
from .scheduling_utils import SchedulerMixin


Expand All @@ -40,13 +39,7 @@ class ScoreSdeVpScheduler(SchedulerMixin, ConfigMixin):
"""

@register_to_config
def __init__(self, num_train_timesteps=2000, beta_min=0.1, beta_max=20, sampling_eps=1e-3, **kwargs):
deprecate(
"tensor_format",
"0.6.0",
"If you're running your code in PyTorch, you can safely remove this argument.",
take_from=kwargs,
)
def __init__(self, num_train_timesteps=2000, beta_min=0.1, beta_max=20, sampling_eps=1e-3):
self.sigmas = None
self.discrete_sigmas = None
self.timesteps = None
Expand Down
11 changes: 1 addition & 10 deletions src/diffusers/schedulers/scheduling_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import torch

from ..utils import BaseOutput, deprecate
from ..utils import BaseOutput


SCHEDULER_CONFIG_NAME = "scheduler_config.json"
Expand All @@ -41,12 +41,3 @@ class SchedulerMixin:
"""

config_name = SCHEDULER_CONFIG_NAME

def set_format(self, tensor_format="pt"):
deprecate(
"set_format",
"0.6.0",
"If you're running your code in PyTorch, you can safely remove this function as the schedulers are always"
" in Pytorch",
)
return self
4 changes: 0 additions & 4 deletions src/diffusers/utils/outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

import numpy as np

from .deprecation_utils import deprecate
from .import_utils import is_torch_available


Expand Down Expand Up @@ -86,9 +85,6 @@ def update(self, *args, **kwargs):
def __getitem__(self, k):
if isinstance(k, str):
inner_dict = {k: v for (k, v) in self.items()}
if self.__class__.__name__ in ["StableDiffusionPipelineOutput", "ImagePipelineOutput"] and k == "sample":
deprecate("samples", "0.6.0", "Please use `.images` or `'images'` instead.")
return inner_dict["images"]
return inner_dict[k]
else:
return self.to_tuple()[k]
Expand Down
18 changes: 9 additions & 9 deletions tests/test_pipelines.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,14 +318,14 @@ def test_ldm_text2img(self):
# Warmup pass when using mps (see #372)
if torch_device == "mps":
generator = torch.manual_seed(0)
_ = ldm([prompt], generator=generator, guidance_scale=6.0, num_inference_steps=1, output_type="numpy")[
"sample"
]
_ = ldm(
[prompt], generator=generator, guidance_scale=6.0, num_inference_steps=1, output_type="numpy"
).images

generator = torch.manual_seed(0)
image = ldm([prompt], generator=generator, guidance_scale=6.0, num_inference_steps=2, output_type="numpy")[
"sample"
]
image = ldm(
[prompt], generator=generator, guidance_scale=6.0, num_inference_steps=2, output_type="numpy"
).images

generator = torch.manual_seed(0)
image_from_tuple = ldm(
Expand Down Expand Up @@ -1535,9 +1535,9 @@ def test_ldm_text2img(self):

prompt = "A painting of a squirrel eating a burger"
generator = torch.manual_seed(0)
image = ldm([prompt], generator=generator, guidance_scale=6.0, num_inference_steps=20, output_type="numpy")[
"sample"
]
image = ldm(
[prompt], generator=generator, guidance_scale=6.0, num_inference_steps=20, output_type="numpy"
).images

image_slice = image[0, -3:, -3:, -1]

Expand Down

0 comments on commit 52394b5

Please sign in to comment.