Skip to content

Commit

Permalink
Fix mypy errors (#893)
Browse files Browse the repository at this point in the history
  • Loading branch information
mauicv authored May 21, 2024
1 parent c1297e8 commit 39fff84
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions alibi_detect/utils/perturbation.py
Original file line number Diff line number Diff line change
Expand Up @@ -865,8 +865,8 @@ def pixelate(x: np.ndarray, strength: float, xrange: tuple = None) -> np.ndarray
x = (x - xrange[0]) / (xrange[1] - xrange[0]) * 255

im = Image.fromarray(x.astype('uint8'), mode='RGB')
im = im.resize((int(rows * strength), int(cols * strength)), Image.BOX)
im = im.resize((rows, cols), Image.BOX)
im = im.resize((int(rows * strength), int(cols * strength)), Image.Resampling.BOX)
im = im.resize((rows, cols), Image.Resampling.BOX)
x_pi = np.array(im, dtype=np.float32) / 255
x_pi = x_pi * (xrange[1] - xrange[0]) + xrange[0]
return x_pi
Expand Down Expand Up @@ -898,8 +898,8 @@ def jpeg_compression(x: np.ndarray, strength: float, xrange: tuple = None) -> np
x = Image.fromarray(x.astype('uint8'), mode='RGB')
output = BytesIO()
x.save(output, 'JPEG', quality=strength) # type: ignore[attr-defined] # TODO: allow redefinition
x = Image.open(output)
x_jpeg = np.array(x, dtype=np.float32) / 255
x_image = Image.open(output)
x_jpeg = np.array(x_image, dtype=np.float32) / 255
x_jpeg = x_jpeg * (xrange[1] - xrange[0]) + xrange[0]
return x_jpeg

Expand Down

0 comments on commit 39fff84

Please sign in to comment.