diff options
author | Volpeon <git@volpeon.ink> | 2023-01-16 10:03:05 +0100 |
---|---|---|
committer | Volpeon <git@volpeon.ink> | 2023-01-16 10:03:05 +0100 |
commit | d5696615a84a768307e82d13e50b4aef64f69dbd (patch) | |
tree | 47cfaa5b8922edbfd567739ecd770977e339f8d7 /data | |
parent | Implemented extended Dreambooth training (diff) | |
download | textual-inversion-diff-d5696615a84a768307e82d13e50b4aef64f69dbd.tar.gz textual-inversion-diff-d5696615a84a768307e82d13e50b4aef64f69dbd.tar.bz2 textual-inversion-diff-d5696615a84a768307e82d13e50b4aef64f69dbd.zip |
Extended Dreambooth: Train TI tokens separately
Diffstat (limited to 'data')
-rw-r--r-- | data/csv.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/data/csv.py b/data/csv.py index 2b1e202..002fdd2 100644 --- a/data/csv.py +++ b/data/csv.py | |||
@@ -15,6 +15,9 @@ from data.keywords import prompt_to_keywords, keywords_to_prompt | |||
15 | from models.clip.util import unify_input_ids | 15 | from models.clip.util import unify_input_ids |
16 | 16 | ||
17 | 17 | ||
18 | cache = {} | ||
19 | |||
20 | |||
18 | interpolations = { | 21 | interpolations = { |
19 | "linear": transforms.InterpolationMode.NEAREST, | 22 | "linear": transforms.InterpolationMode.NEAREST, |
20 | "bilinear": transforms.InterpolationMode.BILINEAR, | 23 | "bilinear": transforms.InterpolationMode.BILINEAR, |
@@ -24,9 +27,13 @@ interpolations = { | |||
24 | 27 | ||
25 | 28 | ||
26 | def get_image(path): | 29 | def get_image(path): |
30 | if path in cache: | ||
31 | return cache[path] | ||
32 | |||
27 | image = Image.open(path) | 33 | image = Image.open(path) |
28 | if not image.mode == "RGB": | 34 | if not image.mode == "RGB": |
29 | image = image.convert("RGB") | 35 | image = image.convert("RGB") |
36 | cache[path] = image | ||
30 | return image | 37 | return image |
31 | 38 | ||
32 | 39 | ||