summaryrefslogtreecommitdiffstats
path: root/data
diff options
context:
space:
mode:
Diffstat (limited to 'data')
-rw-r--r--data/csv.py7
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
15from models.clip.util import unify_input_ids 15from models.clip.util import unify_input_ids
16 16
17 17
18cache = {}
19
20
18interpolations = { 21interpolations = {
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
26def get_image(path): 29def 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