Skip to content

Commit fd0f469

Browse files
Resize image before crop (huggingface#7095)
resize first Co-authored-by: Sayak Paul <[email protected]>
1 parent ae84e40 commit fd0f469

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

examples/textual_inversion/textual_inversion_sdxl.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,8 @@ def __getitem__(self, i):
546546

547547
example["original_size"] = (image.height, image.width)
548548

549+
image = image.resize((self.size, self.size), resample=self.interpolation)
550+
549551
if self.center_crop:
550552
y1 = max(0, int(round((image.height - self.size) / 2.0)))
551553
x1 = max(0, int(round((image.width - self.size) / 2.0)))
@@ -576,7 +578,6 @@ def __getitem__(self, i):
576578
img = np.array(image).astype(np.uint8)
577579

578580
image = Image.fromarray(img)
579-
image = image.resize((self.size, self.size), resample=self.interpolation)
580581

581582
image = self.flip_transform(image)
582583
image = np.array(image).astype(np.uint8)

0 commit comments

Comments
 (0)