@@ -45,7 +45,6 @@ def preprocess_image(image):
4545
4646
4747def preprocess_mask (mask , scale_factor = 8 ):
48-
4948 if not isinstance (mask , torch .FloatTensor ):
5049 mask = mask .convert ("L" )
5150 w , h = mask .size
@@ -65,7 +64,8 @@ def preprocess_mask(mask, scale_factor=8):
6564 mask = mask .permute (0 , 3 , 1 , 2 )
6665 elif mask .shape [1 ] not in valid_mask_channel_sizes :
6766 raise ValueError (
68- f"Mask channel dimension of size in { valid_mask_channel_sizes } should be second or fourth dimension, but received mask of shape { tuple (mask .shape )} "
67+ f"Mask channel dimension of size in { valid_mask_channel_sizes } should be second or fourth dimension,"
68+ f" but received mask of shape { tuple (mask .shape )} "
6969 )
7070 # (potentially) reduce mask channel dimension from 3 to 1 for broadcasting to latent shape
7171 mask = mask .mean (dim = 1 , keepdim = True )
@@ -515,7 +515,7 @@ def __call__(
515515 mask_image (`torch.FloatTensor` or `PIL.Image.Image`):
516516 `Image`, or tensor representing an image batch, to mask `image`. White pixels in the mask will be
517517 replaced by noise and therefore repainted, while black pixels will be preserved. If `mask_image` is a
518- PIL image, it will be converted to a single channel (luminance) before use. If mask is a tensor, the
518+ PIL image, it will be converted to a single channel (luminance) before use. If mask is a tensor, the
519519 expected shape should be either `(B, H, W, C)` or `(B, C, H, W)`, where C is 1 or 3.
520520 strength (`float`, *optional*, defaults to 0.8):
521521 Conceptually, indicates how much to inpaint the masked area. Must be between 0 and 1. When `strength`
0 commit comments