Spaces:
Runtime error
Runtime error
remove resizing and cropping (#6)
Browse files- remove resizing and cropping (0ec5ae3c9e76934ad42757dc8b047ae98c5d4282)
1069 unmodified lines10701071107210731074107310741075107610779 unmodified lines1087108810891090109010911092109310941095109610961097109810971098109911001101110011011102110311041105110616 unmodified lines112311241125112411261127112811291130112911301131113111321133113411331134113511361137113811399 unmodified lines11491150115111501151115211531154115511561069 unmodified lines self.original_sizes = [] self.crop_top_lefts = [] self.pixel_values = [] train_resize = transforms.Resize(size, interpolation=transforms.InterpolationMode.BILINEAR) train_crop = transforms.CenterCrop(size) if center_crop else transforms.RandomCrop(size) #train_resize = transforms.Resize(size, interpolation=transforms.InterpolationMode.BILINEAR) #train_crop = transforms.CenterCrop(size) if center_crop else transforms.RandomCrop(size) train_flip = transforms.RandomHorizontalFlip(p=1.0) train_transforms = transforms.Compose( [9 unmodified lines if not image.mode == "RGB": image = image.convert("RGB") self.original_sizes.append((image.height, image.width)) image = train_resize(image) #image = train_resize(image)
if not single_image and args.random_flip and random.random() < 0.5: # flip image = train_flip(image) if args.center_crop or single_image: pass y1 = max(0, int(round((image.height - args.resolution) / 2.0))) x1 = max(0, int(round((image.width - args.resolution) / 2.0))) image = train_crop(image) #y1 = max(0, int(round((image.height - args.resolution) / 2.0))) #x1 = max(0, int(round((image.width - args.resolution) / 2.0))) #image = train_crop(image) else: pass y1, x1, h, w = train_crop.get_params(image, (args.resolution, args.resolution)) image = crop(image, y1, x1, h, w) #y1, x1, h, w = train_crop.get_params(image, (args.resolution, args.resolution)) #image = crop(image, y1, x1, h, w) crop_top_left = (y1, x1) self.crop_top_lefts.append(crop_top_left) image = train_transforms(image)16 unmodified lines if not image.mode == "RGB": image = image.convert("RGB") self.original_sizes_class_imgs.append((image.height, image.width)) image = train_resize(image) # image = train_resize(image) if args.random_flip and random.random() < 0.5: # flip image = train_flip(image) if args.center_crop: y1 = max(0, int(round((image.height - args.resolution) / 2.0))) x1 = max(0, int(round((image.width - args.resolution) / 2.0))) image = train_crop(image) #y1 = max(0, int(round((image.height - args.resolution) / 2.0))) #x1 = max(0, int(round((image.width - args.resolution) / 2.0))) #image = train_crop(image) else: y1, x1, h, w = train_crop.get_params(image, (args.resolution, args.resolution)) image = crop(image, y1, x1, h, w) #y1, x1, h, w = train_crop.get_params(image, (args.resolution, args.resolution)) #image = crop(image, y1, x1, h, w) crop_top_left = (y1, x1) self.crop_top_lefts_class_imgs.append(crop_top_left) image = train_transforms(image)9 unmodified lines
self.image_transforms = transforms.Compose( [ transforms.Resize(size, interpolation=transforms.InterpolationMode.BILINEAR), transforms.CenterCrop(size) if center_crop else transforms.RandomCrop(size), # transforms.Resize(size, interpolation=transforms.InterpolationMode.BILINEAR), # transforms.CenterCrop(size) if center_crop else transforms.RandomCrop(size), transforms.ToTensor(), transforms.Normalize([0.5], [0.5]), ]train_dreambooth_lora_sdxl_advanced.py+18-16