InvokeAI 2.2.4.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- backend/__init__.py +0 -0
- backend/invoke_ai_web_server.py +1724 -0
- backend/modules/__init__.py +0 -0
- backend/modules/create_cmd_parser.py +55 -0
- backend/modules/get_canvas_generation_mode.py +117 -0
- backend/modules/parameters.py +71 -0
- backend/modules/parse_seed_weights.py +47 -0
- configs/INITIAL_MODELS.yaml +80 -0
- configs/models.yaml.example +29 -0
- configs/sd-concepts.txt +803 -0
- configs/stable-diffusion/v1-finetune.yaml +110 -0
- configs/stable-diffusion/v1-finetune_style.yaml +103 -0
- configs/stable-diffusion/v1-inference.yaml +79 -0
- configs/stable-diffusion/v1-inpainting-inference.yaml +79 -0
- configs/stable-diffusion/v1-m1-finetune.yaml +110 -0
- docs/assets/invoke-web-server-1.png +0 -0
- docs/assets/invoke_ai_banner.png +0 -0
- invokeai-2.2.4.5.data/data/assets/caution.png +0 -0
- invokeai-2.2.4.5.data/data/configs/INITIAL_MODELS.yaml +80 -0
- invokeai-2.2.4.5.data/data/configs/models.yaml.example +29 -0
- invokeai-2.2.4.5.data/data/configs/sd-concepts.txt +803 -0
- invokeai-2.2.4.5.data/data/configs/stable-diffusion/v1-finetune.yaml +110 -0
- invokeai-2.2.4.5.data/data/configs/stable-diffusion/v1-finetune_style.yaml +103 -0
- invokeai-2.2.4.5.data/data/configs/stable-diffusion/v1-inference.yaml +79 -0
- invokeai-2.2.4.5.data/data/configs/stable-diffusion/v1-inpainting-inference.yaml +79 -0
- invokeai-2.2.4.5.data/data/configs/stable-diffusion/v1-m1-finetune.yaml +110 -0
- invokeai-2.2.4.5.data/data/frontend/dist/assets/Inter-Bold.790c108b.ttf +0 -0
- invokeai-2.2.4.5.data/data/frontend/dist/assets/Inter.b9a8e5e2.ttf +0 -0
- invokeai-2.2.4.5.data/data/frontend/dist/assets/favicon.0d253ced.ico +0 -0
- invokeai-2.2.4.5.data/data/frontend/dist/assets/index-legacy-b741077f.js +48 -0
- invokeai-2.2.4.5.data/data/frontend/dist/assets/index.0dadf5d0.css +1 -0
- invokeai-2.2.4.5.data/data/frontend/dist/assets/index.21ff81eb.js +625 -0
- invokeai-2.2.4.5.data/data/frontend/dist/assets/logo.13003d72.png +0 -0
- invokeai-2.2.4.5.data/data/frontend/dist/assets/polyfills-legacy-dde3a68a.js +4 -0
- invokeai-2.2.4.5.data/data/frontend/dist/assets/polyfills.1ff60148.js +1 -0
- invokeai-2.2.4.5.data/data/frontend/dist/index.html +23 -0
- invokeai-2.2.4.5.data/data/scripts/configure_invokeai.py +797 -0
- invokeai-2.2.4.5.data/data/scripts/create_root.py +43 -0
- invokeai-2.2.4.5.data/data/scripts/dream.py +10 -0
- invokeai-2.2.4.5.data/data/scripts/images2prompt.py +30 -0
- invokeai-2.2.4.5.data/data/scripts/invoke.py +5 -0
- invokeai-2.2.4.5.data/data/scripts/legacy_api.py +681 -0
- invokeai-2.2.4.5.data/data/scripts/load_models.py +12 -0
- invokeai-2.2.4.5.data/data/scripts/merge_embeddings.py +124 -0
- invokeai-2.2.4.5.data/data/scripts/preload_models.py +12 -0
- invokeai-2.2.4.5.data/data/scripts/sd-metadata.py +22 -0
- invokeai-2.2.4.5.dist-info/LICENSE +21 -0
- invokeai-2.2.4.5.dist-info/LICENSE-ModelWeights.txt +294 -0
- invokeai-2.2.4.5.dist-info/METADATA +288 -0
- invokeai-2.2.4.5.dist-info/RECORD +169 -0
- invokeai-2.2.4.5.dist-info/WHEEL +5 -0
- invokeai-2.2.4.5.dist-info/entry_points.txt +4 -0
- invokeai-2.2.4.5.dist-info/top_level.txt +6 -0
- invokeai-2.2.4.5.dist-info/zip-safe +1 -0
- ldm/__init__.py +0 -0
- ldm/data/__init__.py +0 -0
- ldm/data/base.py +31 -0
- ldm/data/imagenet.py +466 -0
- ldm/data/lsun.py +126 -0
- ldm/data/personalized.py +202 -0
- ldm/data/personalized_style.py +169 -0
- ldm/generate.py +1159 -0
- ldm/invoke/CLI.py +960 -0
- ldm/invoke/__init__.py +3 -0
- ldm/invoke/args.py +1257 -0
- ldm/invoke/concepts_lib.py +169 -0
- ldm/invoke/conditioning.py +289 -0
- ldm/invoke/devices.py +27 -0
- ldm/invoke/generator/__init__.py +4 -0
- ldm/invoke/generator/base.py +335 -0
- ldm/invoke/generator/embiggen.py +501 -0
- ldm/invoke/generator/img2img.py +97 -0
- ldm/invoke/generator/inpaint.py +358 -0
- ldm/invoke/generator/omnibus.py +175 -0
- ldm/invoke/generator/txt2img.py +88 -0
- ldm/invoke/generator/txt2img2img.py +182 -0
- ldm/invoke/globals.py +31 -0
- ldm/invoke/image_util.py +70 -0
- ldm/invoke/log.py +66 -0
- ldm/invoke/model_cache.py +449 -0
- ldm/invoke/patchmatch.py +44 -0
- ldm/invoke/pngwriter.py +113 -0
- ldm/invoke/prompt_parser.py +655 -0
- ldm/invoke/readline.py +442 -0
- ldm/invoke/restoration/__init__.py +4 -0
- ldm/invoke/restoration/base.py +38 -0
- ldm/invoke/restoration/codeformer.py +103 -0
- ldm/invoke/restoration/codeformer_arch.py +276 -0
- ldm/invoke/restoration/gfpgan.py +84 -0
- ldm/invoke/restoration/outcrop.py +108 -0
- ldm/invoke/restoration/outpaint.py +92 -0
- ldm/invoke/restoration/realesrgan.py +90 -0
- ldm/invoke/restoration/vqgan_arch.py +435 -0
- ldm/invoke/seamless.py +30 -0
- ldm/invoke/server.py +282 -0
- ldm/invoke/server_legacy.py +246 -0
- ldm/invoke/txt2mask.py +136 -0
- ldm/lr_scheduler.py +143 -0
- ldm/models/__init__.py +0 -0
- ldm/models/autoencoder.py +596 -0
- ldm/models/diffusion/__init__.py +0 -0
- ldm/models/diffusion/classifier.py +355 -0
- ldm/models/diffusion/cross_attention_control.py +443 -0
- ldm/models/diffusion/cross_attention_map_saving.py +95 -0
- ldm/models/diffusion/ddim.py +111 -0
- ldm/models/diffusion/ddpm.py +2263 -0
- ldm/models/diffusion/ksampler.py +312 -0
- ldm/models/diffusion/plms.py +146 -0
- ldm/models/diffusion/sampler.py +450 -0
- ldm/models/diffusion/shared_invokeai_diffusion.py +244 -0
- ldm/modules/__init__.py +0 -0
- ldm/modules/attention.py +274 -0
- ldm/modules/diffusionmodules/__init__.py +0 -0
- ldm/modules/diffusionmodules/model.py +894 -0
- ldm/modules/diffusionmodules/openaimodel.py +1036 -0
- ldm/modules/diffusionmodules/util.py +314 -0
- ldm/modules/distributions/__init__.py +0 -0
- ldm/modules/distributions/distributions.py +104 -0
- ldm/modules/ema.py +88 -0
- ldm/modules/embedding_manager.py +413 -0
- ldm/modules/encoders/__init__.py +0 -0
- ldm/modules/encoders/modules.py +772 -0
- ldm/modules/image_degradation/__init__.py +6 -0
- ldm/modules/image_degradation/bsrgan.py +846 -0
- ldm/modules/image_degradation/bsrgan_light.py +751 -0
- ldm/modules/image_degradation/utils_image.py +1024 -0
- ldm/modules/losses/__init__.py +1 -0
- ldm/modules/losses/contperceptual.py +175 -0
- ldm/modules/losses/vqperceptual.py +240 -0
- ldm/modules/x_transformer.py +752 -0
- ldm/simplet2i.py +13 -0
- ldm/util.py +264 -0
- scripts/configure_invokeai.py +797 -0
- scripts/create_root.py +43 -0
- scripts/dream.py +10 -0
- scripts/images2prompt.py +30 -0
- scripts/invoke.py +5 -0
- scripts/legacy_api.py +681 -0
- scripts/load_models.py +12 -0
- scripts/merge_embeddings.py +124 -0
- scripts/orig_scripts/img2img.py +296 -0
- scripts/orig_scripts/inpaint.py +98 -0
- scripts/orig_scripts/knn2img.py +397 -0
- scripts/orig_scripts/sample_diffusion.py +313 -0
- scripts/orig_scripts/train_searcher.py +147 -0
- scripts/orig_scripts/txt2img.py +324 -0
- scripts/preload_models.py +12 -0
- scripts/sd-metadata.py +22 -0
- vendored/clip/clip/__init__.py +1 -0
- vendored/clip/clip/bpe_simple_vocab_16e6.txt.gz +0 -0
- vendored/clip/clip/clip.py +237 -0
- vendored/clip/clip/model.py +436 -0
- vendored/clip/clip/simple_tokenizer.py +132 -0
- vendored/clip/hubconf.py +42 -0
- vendored/clip/setup.py +21 -0
- vendored/clip/tests/test_consistency.py +25 -0
- vendored/clipseg/datasets/coco_wrapper.py +99 -0
- vendored/clipseg/datasets/pascal_zeroshot.py +60 -0
- vendored/clipseg/datasets/pfe_dataset.py +129 -0
- vendored/clipseg/datasets/phrasecut.py +380 -0
- vendored/clipseg/datasets/utils.py +68 -0
- vendored/clipseg/evaluation_utils.py +292 -0
- vendored/clipseg/general_utils.py +272 -0
- vendored/clipseg/metrics.py +271 -0
- vendored/clipseg/models/clipseg.py +538 -0
- vendored/clipseg/models/vitseg.py +286 -0
- vendored/clipseg/score.py +453 -0
- vendored/clipseg/setup.py +30 -0
- vendored/clipseg/training.py +266 -0
ldm/simplet2i.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'''
|
|
2
|
+
This module is provided for backward compatibility with the
|
|
3
|
+
original (hasty) API.
|
|
4
|
+
|
|
5
|
+
Please use ldm.generate instead.
|
|
6
|
+
'''
|
|
7
|
+
|
|
8
|
+
from ldm.generate import Generate
|
|
9
|
+
|
|
10
|
+
class T2I(Generate):
|
|
11
|
+
def __init__(self,**kwargs):
|
|
12
|
+
print(f'>> The ldm.simplet2i module is deprecated. Use ldm.generate instead. It is a drop-in replacement.')
|
|
13
|
+
super().__init__(kwargs)
|
ldm/util.py
ADDED
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import importlib
|
|
2
|
+
|
|
3
|
+
import torch
|
|
4
|
+
import numpy as np
|
|
5
|
+
import math
|
|
6
|
+
from collections import abc
|
|
7
|
+
from einops import rearrange
|
|
8
|
+
from functools import partial
|
|
9
|
+
|
|
10
|
+
import multiprocessing as mp
|
|
11
|
+
from threading import Thread
|
|
12
|
+
from queue import Queue
|
|
13
|
+
|
|
14
|
+
from inspect import isfunction
|
|
15
|
+
from PIL import Image, ImageDraw, ImageFont
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def log_txt_as_img(wh, xc, size=10):
|
|
19
|
+
# wh a tuple of (width, height)
|
|
20
|
+
# xc a list of captions to plot
|
|
21
|
+
b = len(xc)
|
|
22
|
+
txts = list()
|
|
23
|
+
for bi in range(b):
|
|
24
|
+
txt = Image.new('RGB', wh, color='white')
|
|
25
|
+
draw = ImageDraw.Draw(txt)
|
|
26
|
+
font = ImageFont.load_default()
|
|
27
|
+
nc = int(40 * (wh[0] / 256))
|
|
28
|
+
lines = '\n'.join(
|
|
29
|
+
xc[bi][start : start + nc] for start in range(0, len(xc[bi]), nc)
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
try:
|
|
33
|
+
draw.text((0, 0), lines, fill='black', font=font)
|
|
34
|
+
except UnicodeEncodeError:
|
|
35
|
+
print('Cant encode string for logging. Skipping.')
|
|
36
|
+
|
|
37
|
+
txt = np.array(txt).transpose(2, 0, 1) / 127.5 - 1.0
|
|
38
|
+
txts.append(txt)
|
|
39
|
+
txts = np.stack(txts)
|
|
40
|
+
txts = torch.tensor(txts)
|
|
41
|
+
return txts
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def ismap(x):
|
|
45
|
+
if not isinstance(x, torch.Tensor):
|
|
46
|
+
return False
|
|
47
|
+
return (len(x.shape) == 4) and (x.shape[1] > 3)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def isimage(x):
|
|
51
|
+
if not isinstance(x, torch.Tensor):
|
|
52
|
+
return False
|
|
53
|
+
return (len(x.shape) == 4) and (x.shape[1] == 3 or x.shape[1] == 1)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def exists(x):
|
|
57
|
+
return x is not None
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def default(val, d):
|
|
61
|
+
if exists(val):
|
|
62
|
+
return val
|
|
63
|
+
return d() if isfunction(d) else d
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def mean_flat(tensor):
|
|
67
|
+
"""
|
|
68
|
+
https://github.com/openai/guided-diffusion/blob/27c20a8fab9cb472df5d6bdd6c8d11c8f430b924/guided_diffusion/nn.py#L86
|
|
69
|
+
Take the mean over all non-batch dimensions.
|
|
70
|
+
"""
|
|
71
|
+
return tensor.mean(dim=list(range(1, len(tensor.shape))))
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def count_params(model, verbose=False):
|
|
75
|
+
total_params = sum(p.numel() for p in model.parameters())
|
|
76
|
+
if verbose:
|
|
77
|
+
print(
|
|
78
|
+
f' | {model.__class__.__name__} has {total_params * 1.e-6:.2f} M params.'
|
|
79
|
+
)
|
|
80
|
+
return total_params
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def instantiate_from_config(config, **kwargs):
|
|
84
|
+
if not 'target' in config:
|
|
85
|
+
if config == '__is_first_stage__':
|
|
86
|
+
return None
|
|
87
|
+
elif config == '__is_unconditional__':
|
|
88
|
+
return None
|
|
89
|
+
raise KeyError('Expected key `target` to instantiate.')
|
|
90
|
+
return get_obj_from_str(config['target'])(
|
|
91
|
+
**config.get('params', dict()), **kwargs
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def get_obj_from_str(string, reload=False):
|
|
96
|
+
module, cls = string.rsplit('.', 1)
|
|
97
|
+
if reload:
|
|
98
|
+
module_imp = importlib.import_module(module)
|
|
99
|
+
importlib.reload(module_imp)
|
|
100
|
+
return getattr(importlib.import_module(module, package=None), cls)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def _do_parallel_data_prefetch(func, Q, data, idx, idx_to_fn=False):
|
|
104
|
+
# create dummy dataset instance
|
|
105
|
+
|
|
106
|
+
# run prefetching
|
|
107
|
+
if idx_to_fn:
|
|
108
|
+
res = func(data, worker_id=idx)
|
|
109
|
+
else:
|
|
110
|
+
res = func(data)
|
|
111
|
+
Q.put([idx, res])
|
|
112
|
+
Q.put('Done')
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def parallel_data_prefetch(
|
|
116
|
+
func: callable,
|
|
117
|
+
data,
|
|
118
|
+
n_proc,
|
|
119
|
+
target_data_type='ndarray',
|
|
120
|
+
cpu_intensive=True,
|
|
121
|
+
use_worker_id=False,
|
|
122
|
+
):
|
|
123
|
+
# if target_data_type not in ["ndarray", "list"]:
|
|
124
|
+
# raise ValueError(
|
|
125
|
+
# "Data, which is passed to parallel_data_prefetch has to be either of type list or ndarray."
|
|
126
|
+
# )
|
|
127
|
+
if isinstance(data, np.ndarray) and target_data_type == 'list':
|
|
128
|
+
raise ValueError('list expected but function got ndarray.')
|
|
129
|
+
elif isinstance(data, abc.Iterable):
|
|
130
|
+
if isinstance(data, dict):
|
|
131
|
+
print(
|
|
132
|
+
f'WARNING:"data" argument passed to parallel_data_prefetch is a dict: Using only its values and disregarding keys.'
|
|
133
|
+
)
|
|
134
|
+
data = list(data.values())
|
|
135
|
+
if target_data_type == 'ndarray':
|
|
136
|
+
data = np.asarray(data)
|
|
137
|
+
else:
|
|
138
|
+
data = list(data)
|
|
139
|
+
else:
|
|
140
|
+
raise TypeError(
|
|
141
|
+
f'The data, that shall be processed parallel has to be either an np.ndarray or an Iterable, but is actually {type(data)}.'
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
if cpu_intensive:
|
|
145
|
+
Q = mp.Queue(1000)
|
|
146
|
+
proc = mp.Process
|
|
147
|
+
else:
|
|
148
|
+
Q = Queue(1000)
|
|
149
|
+
proc = Thread
|
|
150
|
+
# spawn processes
|
|
151
|
+
if target_data_type == 'ndarray':
|
|
152
|
+
arguments = [
|
|
153
|
+
[func, Q, part, i, use_worker_id]
|
|
154
|
+
for i, part in enumerate(np.array_split(data, n_proc))
|
|
155
|
+
]
|
|
156
|
+
else:
|
|
157
|
+
step = (
|
|
158
|
+
int(len(data) / n_proc + 1)
|
|
159
|
+
if len(data) % n_proc != 0
|
|
160
|
+
else int(len(data) / n_proc)
|
|
161
|
+
)
|
|
162
|
+
arguments = [
|
|
163
|
+
[func, Q, part, i, use_worker_id]
|
|
164
|
+
for i, part in enumerate(
|
|
165
|
+
[data[i : i + step] for i in range(0, len(data), step)]
|
|
166
|
+
)
|
|
167
|
+
]
|
|
168
|
+
processes = []
|
|
169
|
+
for i in range(n_proc):
|
|
170
|
+
p = proc(target=_do_parallel_data_prefetch, args=arguments[i])
|
|
171
|
+
processes += [p]
|
|
172
|
+
|
|
173
|
+
# start processes
|
|
174
|
+
print(f'Start prefetching...')
|
|
175
|
+
import time
|
|
176
|
+
|
|
177
|
+
start = time.time()
|
|
178
|
+
gather_res = [[] for _ in range(n_proc)]
|
|
179
|
+
try:
|
|
180
|
+
for p in processes:
|
|
181
|
+
p.start()
|
|
182
|
+
|
|
183
|
+
k = 0
|
|
184
|
+
while k < n_proc:
|
|
185
|
+
# get result
|
|
186
|
+
res = Q.get()
|
|
187
|
+
if res == 'Done':
|
|
188
|
+
k += 1
|
|
189
|
+
else:
|
|
190
|
+
gather_res[res[0]] = res[1]
|
|
191
|
+
|
|
192
|
+
except Exception as e:
|
|
193
|
+
print('Exception: ', e)
|
|
194
|
+
for p in processes:
|
|
195
|
+
p.terminate()
|
|
196
|
+
|
|
197
|
+
raise e
|
|
198
|
+
finally:
|
|
199
|
+
for p in processes:
|
|
200
|
+
p.join()
|
|
201
|
+
print(f'Prefetching complete. [{time.time() - start} sec.]')
|
|
202
|
+
|
|
203
|
+
if target_data_type == 'ndarray':
|
|
204
|
+
if not isinstance(gather_res[0], np.ndarray):
|
|
205
|
+
return np.concatenate([np.asarray(r) for r in gather_res], axis=0)
|
|
206
|
+
|
|
207
|
+
# order outputs
|
|
208
|
+
return np.concatenate(gather_res, axis=0)
|
|
209
|
+
elif target_data_type == 'list':
|
|
210
|
+
out = []
|
|
211
|
+
for r in gather_res:
|
|
212
|
+
out.extend(r)
|
|
213
|
+
return out
|
|
214
|
+
else:
|
|
215
|
+
return gather_res
|
|
216
|
+
|
|
217
|
+
def rand_perlin_2d(shape, res, device, fade = lambda t: 6*t**5 - 15*t**4 + 10*t**3):
|
|
218
|
+
delta = (res[0] / shape[0], res[1] / shape[1])
|
|
219
|
+
d = (shape[0] // res[0], shape[1] // res[1])
|
|
220
|
+
|
|
221
|
+
grid = torch.stack(torch.meshgrid(torch.arange(0, res[0], delta[0]), torch.arange(0, res[1], delta[1]), indexing='ij'), dim = -1).to(device) % 1
|
|
222
|
+
|
|
223
|
+
rand_val = torch.rand(res[0]+1, res[1]+1)
|
|
224
|
+
|
|
225
|
+
angles = 2*math.pi*rand_val
|
|
226
|
+
gradients = torch.stack((torch.cos(angles), torch.sin(angles)), dim = -1).to(device)
|
|
227
|
+
|
|
228
|
+
tile_grads = lambda slice1, slice2: gradients[slice1[0]:slice1[1], slice2[0]:slice2[1]].repeat_interleave(d[0], 0).repeat_interleave(d[1], 1)
|
|
229
|
+
|
|
230
|
+
dot = lambda grad, shift: (torch.stack((grid[:shape[0],:shape[1],0] + shift[0], grid[:shape[0],:shape[1], 1] + shift[1] ), dim = -1) * grad[:shape[0], :shape[1]]).sum(dim = -1)
|
|
231
|
+
|
|
232
|
+
n00 = dot(tile_grads([0, -1], [0, -1]), [0, 0]).to(device)
|
|
233
|
+
n10 = dot(tile_grads([1, None], [0, -1]), [-1, 0]).to(device)
|
|
234
|
+
n01 = dot(tile_grads([0, -1],[1, None]), [0, -1]).to(device)
|
|
235
|
+
n11 = dot(tile_grads([1, None], [1, None]), [-1,-1]).to(device)
|
|
236
|
+
t = fade(grid[:shape[0], :shape[1]])
|
|
237
|
+
return math.sqrt(2) * torch.lerp(torch.lerp(n00, n10, t[..., 0]), torch.lerp(n01, n11, t[..., 0]), t[..., 1]).to(device)
|
|
238
|
+
|
|
239
|
+
def ask_user(question: str, answers: list):
|
|
240
|
+
from itertools import chain, repeat
|
|
241
|
+
user_prompt = f'\n>> {question} {answers}: '
|
|
242
|
+
invalid_answer_msg = 'Invalid answer. Please try again.'
|
|
243
|
+
pose_question = chain([user_prompt], repeat('\n'.join([invalid_answer_msg, user_prompt])))
|
|
244
|
+
user_answers = map(input, pose_question)
|
|
245
|
+
valid_response = next(filter(answers.__contains__, user_answers))
|
|
246
|
+
return valid_response
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
def debug_image(debug_image, debug_text, debug_show=True, debug_result=False, debug_status=False ):
|
|
250
|
+
if not debug_status:
|
|
251
|
+
return
|
|
252
|
+
|
|
253
|
+
image_copy = debug_image.copy()
|
|
254
|
+
ImageDraw.Draw(image_copy).text(
|
|
255
|
+
(5, 5),
|
|
256
|
+
debug_text,
|
|
257
|
+
(255, 0, 0)
|
|
258
|
+
)
|
|
259
|
+
|
|
260
|
+
if debug_show:
|
|
261
|
+
image_copy.show()
|
|
262
|
+
|
|
263
|
+
if debug_result:
|
|
264
|
+
return image_copy
|