Skip to content

Commit 2993257

Browse files
hisushantasayakpaulyiyixuxu
authored
Batter way to write binarize() function. (huggingface#6394)
* I added a new doc string to the class. This is more flexible to understanding other developers what are doing and where it's using. * Update src/diffusers/models/unet_2d_blocks.py This changes suggest by maintener. Co-authored-by: Sayak Paul <spsayakpaul@gmail.com> * Update src/diffusers/models/unet_2d_blocks.py Add suggested text Co-authored-by: Sayak Paul <spsayakpaul@gmail.com> * Update unet_2d_blocks.py I changed the Parameter to Args text. * Update unet_2d_blocks.py proper indentation set in this file. * Update unet_2d_blocks.py a little bit of change in the act_fun argument line. * I run the black command to reformat style in the code * Update unet_2d_blocks.py similar doc-string add to have in the original diffusion repository. * Batter way to write binarize function * Solve check_code_quality error * My mistake to run pull request but not reformated file * Update image_processor.py * remove extra variable and space * Update image_processor.py * Run ruff libarary to reformat my file --------- Co-authored-by: Sayak Paul <spsayakpaul@gmail.com> Co-authored-by: YiYi Xu <yixu310@gmail.com>
1 parent aad18fa commit 2993257

1 file changed

Lines changed: 3 additions & 9 deletions

File tree

src/diffusers/image_processor.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,7 @@
3333
List[torch.FloatTensor],
3434
]
3535

36-
PipelineDepthInput = Union[
37-
PIL.Image.Image,
38-
np.ndarray,
39-
torch.FloatTensor,
40-
List[PIL.Image.Image],
41-
List[np.ndarray],
42-
List[torch.FloatTensor],
43-
]
36+
PipelineDepthInput = PipelineImageInput
4437

4538

4639
class VaeImageProcessor(ConfigMixin):
@@ -169,7 +162,7 @@ def convert_to_grayscale(image: PIL.Image.Image) -> PIL.Image.Image:
169162
@staticmethod
170163
def blur(image: PIL.Image.Image, blur_factor: int = 4) -> PIL.Image.Image:
171164
"""
172-
Blurs an image.
165+
Applies Gaussian blur to an image.
173166
"""
174167
image = image.filter(ImageFilter.GaussianBlur(blur_factor))
175168

@@ -402,6 +395,7 @@ def binarize(self, image: PIL.Image.Image) -> PIL.Image.Image:
402395
"""
403396
image[image < 0.5] = 0
404397
image[image >= 0.5] = 1
398+
405399
return image
406400

407401
def get_default_height_width(

0 commit comments

Comments
 (0)