Skip to content

Commit

Permalink
[Black] Update black library (huggingface#2007)
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickvonplaten authored Jan 16, 2023
1 parent 8a3f0c1 commit 522f8aa
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 17 deletions.
2 changes: 1 addition & 1 deletion examples/dreambooth/train_dreambooth.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ def __init__(

self.instance_data_root = Path(instance_data_root)
if not self.instance_data_root.exists():
raise ValueError("Instance images root doesn't exists.")
raise ValueError(f"Instance {self.instance_data_root} images root doesn't exists.")

self.instance_images_path = list(Path(instance_data_root).iterdir())
self.num_instance_images = len(self.instance_images_path)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,10 @@ def __getitem__(self, i):

if self.center_crop:
crop = min(img.shape[0], img.shape[1])
(h, w,) = (
(
h,
w,
) = (
img.shape[0],
img.shape[1],
)
Expand Down
5 changes: 4 additions & 1 deletion examples/textual_inversion/textual_inversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,10 @@ def __getitem__(self, i):

if self.center_crop:
crop = min(img.shape[0], img.shape[1])
(h, w,) = (
(
h,
w,
) = (
img.shape[0],
img.shape[1],
)
Expand Down
5 changes: 4 additions & 1 deletion examples/textual_inversion/textual_inversion_flax.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,10 @@ def __getitem__(self, i):

if self.center_crop:
crop = min(img.shape[0], img.shape[1])
(h, w,) = (
(
h,
w,
) = (
img.shape[0],
img.shape[1],
)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
_deps = [
"Pillow", # keep the PIL.Image.Resampling deprecation away
"accelerate>=0.11.0",
"black==22.8",
"black==22.12",
"datasets",
"filelock",
"flake8>=3.8.3",
Expand Down
6 changes: 4 additions & 2 deletions src/diffusers/models/attention.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,10 @@ def set_use_memory_efficient_attention_xformers(self, use_memory_efficient_atten
if use_memory_efficient_attention_xformers:
if not is_xformers_available():
raise ModuleNotFoundError(
"Refer to https://github.com/facebookresearch/xformers for more information on how to install"
" xformers",
(
"Refer to https://github.com/facebookresearch/xformers for more information on how to install"
" xformers"
),
name="xformers",
)
elif not torch.cuda.is_available():
Expand Down
6 changes: 4 additions & 2 deletions src/diffusers/models/cross_attention.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,10 @@ def set_use_memory_efficient_attention_xformers(self, use_memory_efficient_atten
)
elif not is_xformers_available():
raise ModuleNotFoundError(
"Refer to https://github.com/facebookresearch/xformers for more information on how to install"
" xformers",
(
"Refer to https://github.com/facebookresearch/xformers for more information on how to install"
" xformers"
),
name="xformers",
)
elif not torch.cuda.is_available():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,11 @@ def step(
or isinstance(timestep, torch.LongTensor)
):
raise ValueError(
"Passing integer indices (e.g. from `enumerate(timesteps)`) as timesteps to"
" `EulerDiscreteScheduler.step()` is not supported. Make sure to pass"
" one of the `scheduler.timesteps` as a timestep.",
(
"Passing integer indices (e.g. from `enumerate(timesteps)`) as timesteps to"
" `EulerDiscreteScheduler.step()` is not supported. Make sure to pass"
" one of the `scheduler.timesteps` as a timestep."
),
)

if not self.is_scale_input_called:
Expand Down
8 changes: 5 additions & 3 deletions src/diffusers/schedulers/scheduling_euler_discrete.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,11 @@ def step(
or isinstance(timestep, torch.LongTensor)
):
raise ValueError(
"Passing integer indices (e.g. from `enumerate(timesteps)`) as timesteps to"
" `EulerDiscreteScheduler.step()` is not supported. Make sure to pass"
" one of the `scheduler.timesteps` as a timestep.",
(
"Passing integer indices (e.g. from `enumerate(timesteps)`) as timesteps to"
" `EulerDiscreteScheduler.step()` is not supported. Make sure to pass"
" one of the `scheduler.timesteps` as a timestep."
),
)

if not self.is_scale_input_called:
Expand Down
6 changes: 4 additions & 2 deletions tests/test_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,8 +537,10 @@ def test_scheduler_public_api(self):
)
self.assertTrue(
hasattr(scheduler, "scale_model_input"),
f"{scheduler_class} does not implement a required class method `scale_model_input(sample,"
" timestep)`",
(
f"{scheduler_class} does not implement a required class method `scale_model_input(sample,"
" timestep)`"
),
)
self.assertTrue(
hasattr(scheduler, "step"),
Expand Down

0 comments on commit 522f8aa

Please sign in to comment.