Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for newer versions of Pillow library #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions textual_inversion_training.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from diffusers.optimization import get_scheduler
from diffusers.pipelines.stable_diffusion import StableDiffusionSafetyChecker
from PIL import Image
from PIL.Image import Resampling
from torchvision import transforms
from tqdm.auto import tqdm

Expand All @@ -29,7 +28,7 @@

path = Path.home()/'Downloads/photos/'
paths = list(path.iterdir())
images = [Image.open(p).resize((512, 512), resample=Resampling.BICUBIC).convert("RGB") for p in paths]
images = [Image.open(p).resize((512, 512), resample=Image.BICUBIC).convert("RGB") for p in paths]

what_to_teach = "object"
placeholder_token = "<tiny>"
Expand Down Expand Up @@ -67,7 +66,7 @@

class TextualInversionDataset:
def __init__(self, tokenizer, images, learnable_property="object", size=512,
repeats=100, interpolation=Resampling.BICUBIC, flip_p=0.5, set="train", placeholder_token="*"):
repeats=100, interpolation=Image.BICUBIC, flip_p=0.5, set="train", placeholder_token="*"):
fc.store_attr()
self.num_images = len(images)
if set == "train": self._length = self.num_images * repeats
Expand Down