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.
Files changed (169) hide show
  1. backend/__init__.py +0 -0
  2. backend/invoke_ai_web_server.py +1724 -0
  3. backend/modules/__init__.py +0 -0
  4. backend/modules/create_cmd_parser.py +55 -0
  5. backend/modules/get_canvas_generation_mode.py +117 -0
  6. backend/modules/parameters.py +71 -0
  7. backend/modules/parse_seed_weights.py +47 -0
  8. configs/INITIAL_MODELS.yaml +80 -0
  9. configs/models.yaml.example +29 -0
  10. configs/sd-concepts.txt +803 -0
  11. configs/stable-diffusion/v1-finetune.yaml +110 -0
  12. configs/stable-diffusion/v1-finetune_style.yaml +103 -0
  13. configs/stable-diffusion/v1-inference.yaml +79 -0
  14. configs/stable-diffusion/v1-inpainting-inference.yaml +79 -0
  15. configs/stable-diffusion/v1-m1-finetune.yaml +110 -0
  16. docs/assets/invoke-web-server-1.png +0 -0
  17. docs/assets/invoke_ai_banner.png +0 -0
  18. invokeai-2.2.4.5.data/data/assets/caution.png +0 -0
  19. invokeai-2.2.4.5.data/data/configs/INITIAL_MODELS.yaml +80 -0
  20. invokeai-2.2.4.5.data/data/configs/models.yaml.example +29 -0
  21. invokeai-2.2.4.5.data/data/configs/sd-concepts.txt +803 -0
  22. invokeai-2.2.4.5.data/data/configs/stable-diffusion/v1-finetune.yaml +110 -0
  23. invokeai-2.2.4.5.data/data/configs/stable-diffusion/v1-finetune_style.yaml +103 -0
  24. invokeai-2.2.4.5.data/data/configs/stable-diffusion/v1-inference.yaml +79 -0
  25. invokeai-2.2.4.5.data/data/configs/stable-diffusion/v1-inpainting-inference.yaml +79 -0
  26. invokeai-2.2.4.5.data/data/configs/stable-diffusion/v1-m1-finetune.yaml +110 -0
  27. invokeai-2.2.4.5.data/data/frontend/dist/assets/Inter-Bold.790c108b.ttf +0 -0
  28. invokeai-2.2.4.5.data/data/frontend/dist/assets/Inter.b9a8e5e2.ttf +0 -0
  29. invokeai-2.2.4.5.data/data/frontend/dist/assets/favicon.0d253ced.ico +0 -0
  30. invokeai-2.2.4.5.data/data/frontend/dist/assets/index-legacy-b741077f.js +48 -0
  31. invokeai-2.2.4.5.data/data/frontend/dist/assets/index.0dadf5d0.css +1 -0
  32. invokeai-2.2.4.5.data/data/frontend/dist/assets/index.21ff81eb.js +625 -0
  33. invokeai-2.2.4.5.data/data/frontend/dist/assets/logo.13003d72.png +0 -0
  34. invokeai-2.2.4.5.data/data/frontend/dist/assets/polyfills-legacy-dde3a68a.js +4 -0
  35. invokeai-2.2.4.5.data/data/frontend/dist/assets/polyfills.1ff60148.js +1 -0
  36. invokeai-2.2.4.5.data/data/frontend/dist/index.html +23 -0
  37. invokeai-2.2.4.5.data/data/scripts/configure_invokeai.py +797 -0
  38. invokeai-2.2.4.5.data/data/scripts/create_root.py +43 -0
  39. invokeai-2.2.4.5.data/data/scripts/dream.py +10 -0
  40. invokeai-2.2.4.5.data/data/scripts/images2prompt.py +30 -0
  41. invokeai-2.2.4.5.data/data/scripts/invoke.py +5 -0
  42. invokeai-2.2.4.5.data/data/scripts/legacy_api.py +681 -0
  43. invokeai-2.2.4.5.data/data/scripts/load_models.py +12 -0
  44. invokeai-2.2.4.5.data/data/scripts/merge_embeddings.py +124 -0
  45. invokeai-2.2.4.5.data/data/scripts/preload_models.py +12 -0
  46. invokeai-2.2.4.5.data/data/scripts/sd-metadata.py +22 -0
  47. invokeai-2.2.4.5.dist-info/LICENSE +21 -0
  48. invokeai-2.2.4.5.dist-info/LICENSE-ModelWeights.txt +294 -0
  49. invokeai-2.2.4.5.dist-info/METADATA +288 -0
  50. invokeai-2.2.4.5.dist-info/RECORD +169 -0
  51. invokeai-2.2.4.5.dist-info/WHEEL +5 -0
  52. invokeai-2.2.4.5.dist-info/entry_points.txt +4 -0
  53. invokeai-2.2.4.5.dist-info/top_level.txt +6 -0
  54. invokeai-2.2.4.5.dist-info/zip-safe +1 -0
  55. ldm/__init__.py +0 -0
  56. ldm/data/__init__.py +0 -0
  57. ldm/data/base.py +31 -0
  58. ldm/data/imagenet.py +466 -0
  59. ldm/data/lsun.py +126 -0
  60. ldm/data/personalized.py +202 -0
  61. ldm/data/personalized_style.py +169 -0
  62. ldm/generate.py +1159 -0
  63. ldm/invoke/CLI.py +960 -0
  64. ldm/invoke/__init__.py +3 -0
  65. ldm/invoke/args.py +1257 -0
  66. ldm/invoke/concepts_lib.py +169 -0
  67. ldm/invoke/conditioning.py +289 -0
  68. ldm/invoke/devices.py +27 -0
  69. ldm/invoke/generator/__init__.py +4 -0
  70. ldm/invoke/generator/base.py +335 -0
  71. ldm/invoke/generator/embiggen.py +501 -0
  72. ldm/invoke/generator/img2img.py +97 -0
  73. ldm/invoke/generator/inpaint.py +358 -0
  74. ldm/invoke/generator/omnibus.py +175 -0
  75. ldm/invoke/generator/txt2img.py +88 -0
  76. ldm/invoke/generator/txt2img2img.py +182 -0
  77. ldm/invoke/globals.py +31 -0
  78. ldm/invoke/image_util.py +70 -0
  79. ldm/invoke/log.py +66 -0
  80. ldm/invoke/model_cache.py +449 -0
  81. ldm/invoke/patchmatch.py +44 -0
  82. ldm/invoke/pngwriter.py +113 -0
  83. ldm/invoke/prompt_parser.py +655 -0
  84. ldm/invoke/readline.py +442 -0
  85. ldm/invoke/restoration/__init__.py +4 -0
  86. ldm/invoke/restoration/base.py +38 -0
  87. ldm/invoke/restoration/codeformer.py +103 -0
  88. ldm/invoke/restoration/codeformer_arch.py +276 -0
  89. ldm/invoke/restoration/gfpgan.py +84 -0
  90. ldm/invoke/restoration/outcrop.py +108 -0
  91. ldm/invoke/restoration/outpaint.py +92 -0
  92. ldm/invoke/restoration/realesrgan.py +90 -0
  93. ldm/invoke/restoration/vqgan_arch.py +435 -0
  94. ldm/invoke/seamless.py +30 -0
  95. ldm/invoke/server.py +282 -0
  96. ldm/invoke/server_legacy.py +246 -0
  97. ldm/invoke/txt2mask.py +136 -0
  98. ldm/lr_scheduler.py +143 -0
  99. ldm/models/__init__.py +0 -0
  100. ldm/models/autoencoder.py +596 -0
  101. ldm/models/diffusion/__init__.py +0 -0
  102. ldm/models/diffusion/classifier.py +355 -0
  103. ldm/models/diffusion/cross_attention_control.py +443 -0
  104. ldm/models/diffusion/cross_attention_map_saving.py +95 -0
  105. ldm/models/diffusion/ddim.py +111 -0
  106. ldm/models/diffusion/ddpm.py +2263 -0
  107. ldm/models/diffusion/ksampler.py +312 -0
  108. ldm/models/diffusion/plms.py +146 -0
  109. ldm/models/diffusion/sampler.py +450 -0
  110. ldm/models/diffusion/shared_invokeai_diffusion.py +244 -0
  111. ldm/modules/__init__.py +0 -0
  112. ldm/modules/attention.py +274 -0
  113. ldm/modules/diffusionmodules/__init__.py +0 -0
  114. ldm/modules/diffusionmodules/model.py +894 -0
  115. ldm/modules/diffusionmodules/openaimodel.py +1036 -0
  116. ldm/modules/diffusionmodules/util.py +314 -0
  117. ldm/modules/distributions/__init__.py +0 -0
  118. ldm/modules/distributions/distributions.py +104 -0
  119. ldm/modules/ema.py +88 -0
  120. ldm/modules/embedding_manager.py +413 -0
  121. ldm/modules/encoders/__init__.py +0 -0
  122. ldm/modules/encoders/modules.py +772 -0
  123. ldm/modules/image_degradation/__init__.py +6 -0
  124. ldm/modules/image_degradation/bsrgan.py +846 -0
  125. ldm/modules/image_degradation/bsrgan_light.py +751 -0
  126. ldm/modules/image_degradation/utils_image.py +1024 -0
  127. ldm/modules/losses/__init__.py +1 -0
  128. ldm/modules/losses/contperceptual.py +175 -0
  129. ldm/modules/losses/vqperceptual.py +240 -0
  130. ldm/modules/x_transformer.py +752 -0
  131. ldm/simplet2i.py +13 -0
  132. ldm/util.py +264 -0
  133. scripts/configure_invokeai.py +797 -0
  134. scripts/create_root.py +43 -0
  135. scripts/dream.py +10 -0
  136. scripts/images2prompt.py +30 -0
  137. scripts/invoke.py +5 -0
  138. scripts/legacy_api.py +681 -0
  139. scripts/load_models.py +12 -0
  140. scripts/merge_embeddings.py +124 -0
  141. scripts/orig_scripts/img2img.py +296 -0
  142. scripts/orig_scripts/inpaint.py +98 -0
  143. scripts/orig_scripts/knn2img.py +397 -0
  144. scripts/orig_scripts/sample_diffusion.py +313 -0
  145. scripts/orig_scripts/train_searcher.py +147 -0
  146. scripts/orig_scripts/txt2img.py +324 -0
  147. scripts/preload_models.py +12 -0
  148. scripts/sd-metadata.py +22 -0
  149. vendored/clip/clip/__init__.py +1 -0
  150. vendored/clip/clip/bpe_simple_vocab_16e6.txt.gz +0 -0
  151. vendored/clip/clip/clip.py +237 -0
  152. vendored/clip/clip/model.py +436 -0
  153. vendored/clip/clip/simple_tokenizer.py +132 -0
  154. vendored/clip/hubconf.py +42 -0
  155. vendored/clip/setup.py +21 -0
  156. vendored/clip/tests/test_consistency.py +25 -0
  157. vendored/clipseg/datasets/coco_wrapper.py +99 -0
  158. vendored/clipseg/datasets/pascal_zeroshot.py +60 -0
  159. vendored/clipseg/datasets/pfe_dataset.py +129 -0
  160. vendored/clipseg/datasets/phrasecut.py +380 -0
  161. vendored/clipseg/datasets/utils.py +68 -0
  162. vendored/clipseg/evaluation_utils.py +292 -0
  163. vendored/clipseg/general_utils.py +272 -0
  164. vendored/clipseg/metrics.py +271 -0
  165. vendored/clipseg/models/clipseg.py +538 -0
  166. vendored/clipseg/models/vitseg.py +286 -0
  167. vendored/clipseg/score.py +453 -0
  168. vendored/clipseg/setup.py +30 -0
  169. vendored/clipseg/training.py +266 -0
@@ -0,0 +1,202 @@
1
+ import os
2
+ import numpy as np
3
+ import PIL
4
+ from PIL import Image
5
+ from torch.utils.data import Dataset
6
+ from torchvision import transforms
7
+
8
+ import random
9
+
10
+ imagenet_templates_smallest = [
11
+ 'a photo of a {}',
12
+ ]
13
+
14
+ imagenet_templates_small = [
15
+ 'a photo of a {}',
16
+ 'a rendering of a {}',
17
+ 'a cropped photo of the {}',
18
+ 'the photo of a {}',
19
+ 'a photo of a clean {}',
20
+ 'a photo of a dirty {}',
21
+ 'a dark photo of the {}',
22
+ 'a photo of my {}',
23
+ 'a photo of the cool {}',
24
+ 'a close-up photo of a {}',
25
+ 'a bright photo of the {}',
26
+ 'a cropped photo of a {}',
27
+ 'a photo of the {}',
28
+ 'a good photo of the {}',
29
+ 'a photo of one {}',
30
+ 'a close-up photo of the {}',
31
+ 'a rendition of the {}',
32
+ 'a photo of the clean {}',
33
+ 'a rendition of a {}',
34
+ 'a photo of a nice {}',
35
+ 'a good photo of a {}',
36
+ 'a photo of the nice {}',
37
+ 'a photo of the small {}',
38
+ 'a photo of the weird {}',
39
+ 'a photo of the large {}',
40
+ 'a photo of a cool {}',
41
+ 'a photo of a small {}',
42
+ ]
43
+
44
+ imagenet_dual_templates_small = [
45
+ 'a photo of a {} with {}',
46
+ 'a rendering of a {} with {}',
47
+ 'a cropped photo of the {} with {}',
48
+ 'the photo of a {} with {}',
49
+ 'a photo of a clean {} with {}',
50
+ 'a photo of a dirty {} with {}',
51
+ 'a dark photo of the {} with {}',
52
+ 'a photo of my {} with {}',
53
+ 'a photo of the cool {} with {}',
54
+ 'a close-up photo of a {} with {}',
55
+ 'a bright photo of the {} with {}',
56
+ 'a cropped photo of a {} with {}',
57
+ 'a photo of the {} with {}',
58
+ 'a good photo of the {} with {}',
59
+ 'a photo of one {} with {}',
60
+ 'a close-up photo of the {} with {}',
61
+ 'a rendition of the {} with {}',
62
+ 'a photo of the clean {} with {}',
63
+ 'a rendition of a {} with {}',
64
+ 'a photo of a nice {} with {}',
65
+ 'a good photo of a {} with {}',
66
+ 'a photo of the nice {} with {}',
67
+ 'a photo of the small {} with {}',
68
+ 'a photo of the weird {} with {}',
69
+ 'a photo of the large {} with {}',
70
+ 'a photo of a cool {} with {}',
71
+ 'a photo of a small {} with {}',
72
+ ]
73
+
74
+ per_img_token_list = [
75
+ 'א',
76
+ 'ב',
77
+ 'ג',
78
+ 'ד',
79
+ 'ה',
80
+ 'ו',
81
+ 'ז',
82
+ 'ח',
83
+ 'ט',
84
+ 'י',
85
+ 'כ',
86
+ 'ל',
87
+ 'מ',
88
+ 'נ',
89
+ 'ס',
90
+ 'ע',
91
+ 'פ',
92
+ 'צ',
93
+ 'ק',
94
+ 'ר',
95
+ 'ש',
96
+ 'ת',
97
+ ]
98
+
99
+
100
+ class PersonalizedBase(Dataset):
101
+ def __init__(
102
+ self,
103
+ data_root,
104
+ size=None,
105
+ repeats=100,
106
+ interpolation='bicubic',
107
+ flip_p=0.5,
108
+ set='train',
109
+ placeholder_token='*',
110
+ per_image_tokens=False,
111
+ center_crop=False,
112
+ mixing_prob=0.25,
113
+ coarse_class_text=None,
114
+ ):
115
+
116
+ self.data_root = data_root
117
+
118
+ self.image_paths = [
119
+ os.path.join(self.data_root, file_path)
120
+ for file_path in os.listdir(self.data_root) if file_path != ".DS_Store"
121
+ ]
122
+
123
+ # self._length = len(self.image_paths)
124
+ self.num_images = len(self.image_paths)
125
+ self._length = self.num_images
126
+
127
+ self.placeholder_token = placeholder_token
128
+
129
+ self.per_image_tokens = per_image_tokens
130
+ self.center_crop = center_crop
131
+ self.mixing_prob = mixing_prob
132
+
133
+ self.coarse_class_text = coarse_class_text
134
+
135
+ if per_image_tokens:
136
+ assert self.num_images < len(
137
+ per_img_token_list
138
+ ), f"Can't use per-image tokens when the training set contains more than {len(per_img_token_list)} tokens. To enable larger sets, add more tokens to 'per_img_token_list'."
139
+
140
+ if set == 'train':
141
+ self._length = self.num_images * repeats
142
+
143
+ self.size = size
144
+ self.interpolation = {
145
+ 'linear': PIL.Image.LINEAR,
146
+ 'bilinear': PIL.Image.BILINEAR,
147
+ 'bicubic': PIL.Image.BICUBIC,
148
+ 'lanczos': PIL.Image.LANCZOS,
149
+ }[interpolation]
150
+ self.flip = transforms.RandomHorizontalFlip(p=flip_p)
151
+
152
+ def __len__(self):
153
+ return self._length
154
+
155
+ def __getitem__(self, i):
156
+ example = {}
157
+ image = Image.open(self.image_paths[i % self.num_images])
158
+
159
+ if not image.mode == 'RGB':
160
+ image = image.convert('RGB')
161
+
162
+ placeholder_string = self.placeholder_token
163
+ if self.coarse_class_text:
164
+ placeholder_string = (
165
+ f'{self.coarse_class_text} {placeholder_string}'
166
+ )
167
+
168
+ if self.per_image_tokens and np.random.uniform() < self.mixing_prob:
169
+ text = random.choice(imagenet_dual_templates_small).format(
170
+ placeholder_string, per_img_token_list[i % self.num_images]
171
+ )
172
+ else:
173
+ text = random.choice(imagenet_templates_small).format(
174
+ placeholder_string
175
+ )
176
+
177
+ example['caption'] = text
178
+
179
+ # default to score-sde preprocessing
180
+ img = np.array(image).astype(np.uint8)
181
+
182
+ if self.center_crop:
183
+ crop = min(img.shape[0], img.shape[1])
184
+ h, w, = (
185
+ img.shape[0],
186
+ img.shape[1],
187
+ )
188
+ img = img[
189
+ (h - crop) // 2 : (h + crop) // 2,
190
+ (w - crop) // 2 : (w + crop) // 2,
191
+ ]
192
+
193
+ image = Image.fromarray(img)
194
+ if self.size is not None:
195
+ image = image.resize(
196
+ (self.size, self.size), resample=self.interpolation
197
+ )
198
+
199
+ image = self.flip(image)
200
+ image = np.array(image).astype(np.uint8)
201
+ example['image'] = (image / 127.5 - 1.0).astype(np.float32)
202
+ return example
@@ -0,0 +1,169 @@
1
+ import os
2
+ import numpy as np
3
+ import PIL
4
+ from PIL import Image
5
+ from torch.utils.data import Dataset
6
+ from torchvision import transforms
7
+
8
+ import random
9
+
10
+ imagenet_templates_small = [
11
+ 'a painting in the style of {}',
12
+ 'a rendering in the style of {}',
13
+ 'a cropped painting in the style of {}',
14
+ 'the painting in the style of {}',
15
+ 'a clean painting in the style of {}',
16
+ 'a dirty painting in the style of {}',
17
+ 'a dark painting in the style of {}',
18
+ 'a picture in the style of {}',
19
+ 'a cool painting in the style of {}',
20
+ 'a close-up painting in the style of {}',
21
+ 'a bright painting in the style of {}',
22
+ 'a cropped painting in the style of {}',
23
+ 'a good painting in the style of {}',
24
+ 'a close-up painting in the style of {}',
25
+ 'a rendition in the style of {}',
26
+ 'a nice painting in the style of {}',
27
+ 'a small painting in the style of {}',
28
+ 'a weird painting in the style of {}',
29
+ 'a large painting in the style of {}',
30
+ ]
31
+
32
+ imagenet_dual_templates_small = [
33
+ 'a painting in the style of {} with {}',
34
+ 'a rendering in the style of {} with {}',
35
+ 'a cropped painting in the style of {} with {}',
36
+ 'the painting in the style of {} with {}',
37
+ 'a clean painting in the style of {} with {}',
38
+ 'a dirty painting in the style of {} with {}',
39
+ 'a dark painting in the style of {} with {}',
40
+ 'a cool painting in the style of {} with {}',
41
+ 'a close-up painting in the style of {} with {}',
42
+ 'a bright painting in the style of {} with {}',
43
+ 'a cropped painting in the style of {} with {}',
44
+ 'a good painting in the style of {} with {}',
45
+ 'a painting of one {} in the style of {}',
46
+ 'a nice painting in the style of {} with {}',
47
+ 'a small painting in the style of {} with {}',
48
+ 'a weird painting in the style of {} with {}',
49
+ 'a large painting in the style of {} with {}',
50
+ ]
51
+
52
+ per_img_token_list = [
53
+ 'א',
54
+ 'ב',
55
+ 'ג',
56
+ 'ד',
57
+ 'ה',
58
+ 'ו',
59
+ 'ז',
60
+ 'ח',
61
+ 'ט',
62
+ 'י',
63
+ 'כ',
64
+ 'ל',
65
+ 'מ',
66
+ 'נ',
67
+ 'ס',
68
+ 'ע',
69
+ 'פ',
70
+ 'צ',
71
+ 'ק',
72
+ 'ר',
73
+ 'ש',
74
+ 'ת',
75
+ ]
76
+
77
+
78
+ class PersonalizedBase(Dataset):
79
+ def __init__(
80
+ self,
81
+ data_root,
82
+ size=None,
83
+ repeats=100,
84
+ interpolation='bicubic',
85
+ flip_p=0.5,
86
+ set='train',
87
+ placeholder_token='*',
88
+ per_image_tokens=False,
89
+ center_crop=False,
90
+ ):
91
+
92
+ self.data_root = data_root
93
+
94
+ self.image_paths = [
95
+ os.path.join(self.data_root, file_path)
96
+ for file_path in os.listdir(self.data_root) if file_path != ".DS_Store"
97
+ ]
98
+
99
+ # self._length = len(self.image_paths)
100
+ self.num_images = len(self.image_paths)
101
+ self._length = self.num_images
102
+
103
+ self.placeholder_token = placeholder_token
104
+
105
+ self.per_image_tokens = per_image_tokens
106
+ self.center_crop = center_crop
107
+
108
+ if per_image_tokens:
109
+ assert self.num_images < len(
110
+ per_img_token_list
111
+ ), f"Can't use per-image tokens when the training set contains more than {len(per_img_token_list)} tokens. To enable larger sets, add more tokens to 'per_img_token_list'."
112
+
113
+ if set == 'train':
114
+ self._length = self.num_images * repeats
115
+
116
+ self.size = size
117
+ self.interpolation = {
118
+ 'linear': PIL.Image.LINEAR,
119
+ 'bilinear': PIL.Image.BILINEAR,
120
+ 'bicubic': PIL.Image.BICUBIC,
121
+ 'lanczos': PIL.Image.LANCZOS,
122
+ }[interpolation]
123
+ self.flip = transforms.RandomHorizontalFlip(p=flip_p)
124
+
125
+ def __len__(self):
126
+ return self._length
127
+
128
+ def __getitem__(self, i):
129
+ example = {}
130
+ image = Image.open(self.image_paths[i % self.num_images])
131
+
132
+ if not image.mode == 'RGB':
133
+ image = image.convert('RGB')
134
+
135
+ if self.per_image_tokens and np.random.uniform() < 0.25:
136
+ text = random.choice(imagenet_dual_templates_small).format(
137
+ self.placeholder_token, per_img_token_list[i % self.num_images]
138
+ )
139
+ else:
140
+ text = random.choice(imagenet_templates_small).format(
141
+ self.placeholder_token
142
+ )
143
+
144
+ example['caption'] = text
145
+
146
+ # default to score-sde preprocessing
147
+ img = np.array(image).astype(np.uint8)
148
+
149
+ if self.center_crop:
150
+ crop = min(img.shape[0], img.shape[1])
151
+ h, w, = (
152
+ img.shape[0],
153
+ img.shape[1],
154
+ )
155
+ img = img[
156
+ (h - crop) // 2 : (h + crop) // 2,
157
+ (w - crop) // 2 : (w + crop) // 2,
158
+ ]
159
+
160
+ image = Image.fromarray(img)
161
+ if self.size is not None:
162
+ image = image.resize(
163
+ (self.size, self.size), resample=self.interpolation
164
+ )
165
+
166
+ image = self.flip(image)
167
+ image = np.array(image).astype(np.uint8)
168
+ example['image'] = (image / 127.5 - 1.0).astype(np.float32)
169
+ return example