Spaces:
Runtime error
Runtime error
remove resizing and cropping
#6
by
dkebudi
- opened
train_dreambooth_lora_sdxl_advanced.py
CHANGED
|
@@ -1070,8 +1070,8 @@ class DreamBoothDataset(Dataset):
|
|
| 1070 |
self.original_sizes = []
|
| 1071 |
self.crop_top_lefts = []
|
| 1072 |
self.pixel_values = []
|
| 1073 |
-
train_resize = transforms.Resize(size, interpolation=transforms.InterpolationMode.BILINEAR)
|
| 1074 |
-
train_crop = transforms.CenterCrop(size) if center_crop else transforms.RandomCrop(size)
|
| 1075 |
train_flip = transforms.RandomHorizontalFlip(p=1.0)
|
| 1076 |
train_transforms = transforms.Compose(
|
| 1077 |
[
|
|
@@ -1087,18 +1087,20 @@ class DreamBoothDataset(Dataset):
|
|
| 1087 |
if not image.mode == "RGB":
|
| 1088 |
image = image.convert("RGB")
|
| 1089 |
self.original_sizes.append((image.height, image.width))
|
| 1090 |
-
image = train_resize(image)
|
| 1091 |
|
| 1092 |
if not single_image and args.random_flip and random.random() < 0.5:
|
| 1093 |
# flip
|
| 1094 |
image = train_flip(image)
|
| 1095 |
if args.center_crop or single_image:
|
| 1096 |
-
|
| 1097 |
-
|
| 1098 |
-
|
|
|
|
| 1099 |
else:
|
| 1100 |
-
|
| 1101 |
-
|
|
|
|
| 1102 |
crop_top_left = (y1, x1)
|
| 1103 |
self.crop_top_lefts.append(crop_top_left)
|
| 1104 |
image = train_transforms(image)
|
|
@@ -1121,17 +1123,17 @@ class DreamBoothDataset(Dataset):
|
|
| 1121 |
if not image.mode == "RGB":
|
| 1122 |
image = image.convert("RGB")
|
| 1123 |
self.original_sizes_class_imgs.append((image.height, image.width))
|
| 1124 |
-
image = train_resize(image)
|
| 1125 |
if args.random_flip and random.random() < 0.5:
|
| 1126 |
# flip
|
| 1127 |
image = train_flip(image)
|
| 1128 |
if args.center_crop:
|
| 1129 |
-
y1 = max(0, int(round((image.height - args.resolution) / 2.0)))
|
| 1130 |
-
x1 = max(0, int(round((image.width - args.resolution) / 2.0)))
|
| 1131 |
-
image = train_crop(image)
|
| 1132 |
else:
|
| 1133 |
-
y1, x1, h, w = train_crop.get_params(image, (args.resolution, args.resolution))
|
| 1134 |
-
image = crop(image, y1, x1, h, w)
|
| 1135 |
crop_top_left = (y1, x1)
|
| 1136 |
self.crop_top_lefts_class_imgs.append(crop_top_left)
|
| 1137 |
image = train_transforms(image)
|
|
@@ -1147,8 +1149,8 @@ class DreamBoothDataset(Dataset):
|
|
| 1147 |
|
| 1148 |
self.image_transforms = transforms.Compose(
|
| 1149 |
[
|
| 1150 |
-
transforms.Resize(size, interpolation=transforms.InterpolationMode.BILINEAR),
|
| 1151 |
-
transforms.CenterCrop(size) if center_crop else transforms.RandomCrop(size),
|
| 1152 |
transforms.ToTensor(),
|
| 1153 |
transforms.Normalize([0.5], [0.5]),
|
| 1154 |
]
|
|
|
|
| 1070 |
self.original_sizes = []
|
| 1071 |
self.crop_top_lefts = []
|
| 1072 |
self.pixel_values = []
|
| 1073 |
+
#train_resize = transforms.Resize(size, interpolation=transforms.InterpolationMode.BILINEAR)
|
| 1074 |
+
#train_crop = transforms.CenterCrop(size) if center_crop else transforms.RandomCrop(size)
|
| 1075 |
train_flip = transforms.RandomHorizontalFlip(p=1.0)
|
| 1076 |
train_transforms = transforms.Compose(
|
| 1077 |
[
|
|
|
|
| 1087 |
if not image.mode == "RGB":
|
| 1088 |
image = image.convert("RGB")
|
| 1089 |
self.original_sizes.append((image.height, image.width))
|
| 1090 |
+
#image = train_resize(image)
|
| 1091 |
|
| 1092 |
if not single_image and args.random_flip and random.random() < 0.5:
|
| 1093 |
# flip
|
| 1094 |
image = train_flip(image)
|
| 1095 |
if args.center_crop or single_image:
|
| 1096 |
+
pass
|
| 1097 |
+
#y1 = max(0, int(round((image.height - args.resolution) / 2.0)))
|
| 1098 |
+
#x1 = max(0, int(round((image.width - args.resolution) / 2.0)))
|
| 1099 |
+
#image = train_crop(image)
|
| 1100 |
else:
|
| 1101 |
+
pass
|
| 1102 |
+
#y1, x1, h, w = train_crop.get_params(image, (args.resolution, args.resolution))
|
| 1103 |
+
#image = crop(image, y1, x1, h, w)
|
| 1104 |
crop_top_left = (y1, x1)
|
| 1105 |
self.crop_top_lefts.append(crop_top_left)
|
| 1106 |
image = train_transforms(image)
|
|
|
|
| 1123 |
if not image.mode == "RGB":
|
| 1124 |
image = image.convert("RGB")
|
| 1125 |
self.original_sizes_class_imgs.append((image.height, image.width))
|
| 1126 |
+
# image = train_resize(image)
|
| 1127 |
if args.random_flip and random.random() < 0.5:
|
| 1128 |
# flip
|
| 1129 |
image = train_flip(image)
|
| 1130 |
if args.center_crop:
|
| 1131 |
+
#y1 = max(0, int(round((image.height - args.resolution) / 2.0)))
|
| 1132 |
+
#x1 = max(0, int(round((image.width - args.resolution) / 2.0)))
|
| 1133 |
+
#image = train_crop(image)
|
| 1134 |
else:
|
| 1135 |
+
#y1, x1, h, w = train_crop.get_params(image, (args.resolution, args.resolution))
|
| 1136 |
+
#image = crop(image, y1, x1, h, w)
|
| 1137 |
crop_top_left = (y1, x1)
|
| 1138 |
self.crop_top_lefts_class_imgs.append(crop_top_left)
|
| 1139 |
image = train_transforms(image)
|
|
|
|
| 1149 |
|
| 1150 |
self.image_transforms = transforms.Compose(
|
| 1151 |
[
|
| 1152 |
+
# transforms.Resize(size, interpolation=transforms.InterpolationMode.BILINEAR),
|
| 1153 |
+
# transforms.CenterCrop(size) if center_crop else transforms.RandomCrop(size),
|
| 1154 |
transforms.ToTensor(),
|
| 1155 |
transforms.Normalize([0.5], [0.5]),
|
| 1156 |
]
|