toto10 commited on
Commit
71f9f21
·
1 Parent(s): 93fee81

715ee7a5586a2e6afbb764d710102a533d4a880c8e5548c84ce26ca017c69492

Browse files
Files changed (33) hide show
  1. microsoftexcel-controlnet/example/api_img2img.ipynb +105 -0
  2. microsoftexcel-controlnet/example/api_txt2img.ipynb +104 -0
  3. microsoftexcel-controlnet/example/chatgpt.py +676 -0
  4. microsoftexcel-controlnet/example/visual_chatgpt.ipynb +60 -0
  5. microsoftexcel-controlnet/extract_controlnet.py +27 -0
  6. microsoftexcel-controlnet/extract_controlnet_diff.py +91 -0
  7. microsoftexcel-controlnet/install.py +20 -0
  8. microsoftexcel-controlnet/javascript/hints.js +17 -0
  9. microsoftexcel-controlnet/models/cldm_v15.yaml +79 -0
  10. microsoftexcel-controlnet/models/cldm_v21.yaml +85 -0
  11. microsoftexcel-controlnet/models/control_sd15_canny.yaml +79 -0
  12. microsoftexcel-controlnet/models/control_sd15_depth.yaml +79 -0
  13. microsoftexcel-controlnet/models/control_sd15_hed.yaml +79 -0
  14. microsoftexcel-controlnet/models/control_sd15_mlsd.yaml +79 -0
  15. microsoftexcel-controlnet/models/control_sd15_normal.yaml +79 -0
  16. microsoftexcel-controlnet/models/control_sd15_openpose.yaml +79 -0
  17. microsoftexcel-controlnet/models/control_sd15_scribble.yaml +79 -0
  18. microsoftexcel-controlnet/models/control_sd15_seg.yaml +79 -0
  19. microsoftexcel-controlnet/models/control_v11e_sd15_ip2p.yaml +79 -0
  20. microsoftexcel-controlnet/models/control_v11e_sd15_shuffle.yaml +80 -0
  21. microsoftexcel-controlnet/models/control_v11f1e_sd15_tile.yaml +79 -0
  22. microsoftexcel-controlnet/models/control_v11f1p_sd15_depth.yaml +79 -0
  23. microsoftexcel-controlnet/models/control_v11p_sd15_canny.yaml +79 -0
  24. microsoftexcel-controlnet/models/control_v11p_sd15_inpaint.yaml +79 -0
  25. microsoftexcel-controlnet/models/control_v11p_sd15_lineart.safetensors +3 -0
  26. microsoftexcel-controlnet/models/control_v11p_sd15_lineart.yaml +79 -0
  27. microsoftexcel-controlnet/models/control_v11p_sd15_mlsd.yaml +79 -0
  28. microsoftexcel-controlnet/models/control_v11p_sd15_normalbae.yaml +79 -0
  29. microsoftexcel-controlnet/models/control_v11p_sd15_openpose.safetensors +3 -0
  30. microsoftexcel-controlnet/models/control_v11p_sd15_openpose.yaml +79 -0
  31. microsoftexcel-controlnet/models/control_v11p_sd15_scribble.yaml +79 -0
  32. microsoftexcel-controlnet/models/control_v11p_sd15_seg.yaml +79 -0
  33. microsoftexcel-controlnet/models/control_v11p_sd15_softedge.yaml +79 -0
microsoftexcel-controlnet/example/api_img2img.ipynb ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": null,
6
+ "metadata": {},
7
+ "outputs": [],
8
+ "source": [
9
+ "# controlnet + img2img\n",
10
+ "# enable `Allow other script to control this extension` in settings\n",
11
+ "\n",
12
+ "import requests\n",
13
+ "import cv2\n",
14
+ "from base64 import b64encode\n",
15
+ "\n",
16
+ "def readImage(path):\n",
17
+ " img = cv2.imread(path)\n",
18
+ " retval, buffer = cv2.imencode('.jpg', img)\n",
19
+ " b64img = b64encode(buffer).decode(\"utf-8\")\n",
20
+ " return b64img\n",
21
+ "\n",
22
+ "b64img = readImage(\"/root/workspace/nahida/0e17302b9bfa15402f783c29c0d1d34f.jpg\")\n",
23
+ "\n",
24
+ "class controlnetRequest():\n",
25
+ " def __init__(self, prompt):\n",
26
+ " self.url = \"http://localhost:7860/controlnet/img2img\"\n",
27
+ " self.body = {\n",
28
+ " \"init_images\": [b64img],\n",
29
+ " \"prompt\": prompt,\n",
30
+ " \"negative_prompt\": \"\",\n",
31
+ " \"seed\": -1,\n",
32
+ " \"subseed\": -1,\n",
33
+ " \"subseed_strength\": 0,\n",
34
+ " \"batch_size\": 1,\n",
35
+ " \"n_iter\": 1,\n",
36
+ " \"steps\": 20,\n",
37
+ " \"cfg_scale\": 7,\n",
38
+ " \"width\": 512,\n",
39
+ " \"height\": 768,\n",
40
+ " \"restore_faces\": True,\n",
41
+ " \"eta\": 0,\n",
42
+ " \"sampler_index\": \"Euler a\",\n",
43
+ " \"controlnet_input_image\": [b64img],\n",
44
+ " \"controlnet_module\": 'canny',\n",
45
+ " \"controlnet_model\": 'control_canny-fp16 [e3fe7712]',\n",
46
+ " \"controlnet_guidance\": 1.0,\n",
47
+ " }\n",
48
+ "\n",
49
+ " def sendRequest(self):\n",
50
+ " r = requests.post(self.url, json=self.body)\n",
51
+ " return r.json()\n",
52
+ "\n",
53
+ "js = controlnetRequest(\"walter white\").sendRequest()"
54
+ ]
55
+ },
56
+ {
57
+ "cell_type": "code",
58
+ "execution_count": null,
59
+ "metadata": {},
60
+ "outputs": [],
61
+ "source": [
62
+ "import io, base64\n",
63
+ "import matplotlib.pyplot as plt\n",
64
+ "from PIL import Image\n",
65
+ "\n",
66
+ "pil_img = Image.open('/root/workspace/nahida/0e17302b9bfa15402f783c29c0d1d34f.jpg')\n",
67
+ "image = Image.open(io.BytesIO(base64.b64decode(js[\"images\"][0])))\n",
68
+ "mask_image = Image.open(io.BytesIO(base64.b64decode(js[\"images\"][1])))\n",
69
+ "\n",
70
+ "plt.figure()\n",
71
+ "f, axarr = plt.subplots(1,3) \n",
72
+ "axarr[0].imshow(pil_img) \n",
73
+ "axarr[1].imshow(image) \n",
74
+ "axarr[2].imshow(mask_image) "
75
+ ]
76
+ }
77
+ ],
78
+ "metadata": {
79
+ "kernelspec": {
80
+ "display_name": "pynb",
81
+ "language": "python",
82
+ "name": "python3"
83
+ },
84
+ "language_info": {
85
+ "codemirror_mode": {
86
+ "name": "ipython",
87
+ "version": 3
88
+ },
89
+ "file_extension": ".py",
90
+ "mimetype": "text/x-python",
91
+ "name": "python",
92
+ "nbconvert_exporter": "python",
93
+ "pygments_lexer": "ipython3",
94
+ "version": "3.10.9"
95
+ },
96
+ "orig_nbformat": 4,
97
+ "vscode": {
98
+ "interpreter": {
99
+ "hash": "d73345514d8c18d9a1da7351d222dbd2834c7f4a09e728a0d1f4c4580fbec206"
100
+ }
101
+ }
102
+ },
103
+ "nbformat": 4,
104
+ "nbformat_minor": 2
105
+ }
microsoftexcel-controlnet/example/api_txt2img.ipynb ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": null,
6
+ "metadata": {},
7
+ "outputs": [],
8
+ "source": [
9
+ "# controlnet + txt2img\n",
10
+ "# enable `Allow other script to control this extension` in settings\n",
11
+ "\n",
12
+ "import requests\n",
13
+ "import cv2\n",
14
+ "from base64 import b64encode\n",
15
+ "\n",
16
+ "def readImage(path):\n",
17
+ " img = cv2.imread(path)\n",
18
+ " retval, buffer = cv2.imencode('.jpg', img)\n",
19
+ " b64img = b64encode(buffer).decode(\"utf-8\")\n",
20
+ " return b64img\n",
21
+ "\n",
22
+ "b64img = readImage(\"/root/workspace/nahida/0e17302b9bfa15402f783c29c0d1d34f.jpg\")\n",
23
+ "\n",
24
+ "class controlnetRequest():\n",
25
+ " def __init__(self, prompt):\n",
26
+ " self.url = \"http://localhost:7860/controlnet/txt2img\"\n",
27
+ " self.body = {\n",
28
+ " \"prompt\": prompt,\n",
29
+ " \"negative_prompt\": \"\",\n",
30
+ " \"seed\": -1,\n",
31
+ " \"subseed\": -1,\n",
32
+ " \"subseed_strength\": 0,\n",
33
+ " \"batch_size\": 1,\n",
34
+ " \"n_iter\": 1,\n",
35
+ " \"steps\": 15,\n",
36
+ " \"cfg_scale\": 7,\n",
37
+ " \"width\": 512,\n",
38
+ " \"height\": 768,\n",
39
+ " \"restore_faces\": True,\n",
40
+ " \"eta\": 0,\n",
41
+ " \"sampler_index\": \"Euler a\",\n",
42
+ " \"controlnet_input_image\": [b64img],\n",
43
+ " \"controlnet_module\": 'canny',\n",
44
+ " \"controlnet_model\": 'control_canny-fp16 [e3fe7712]',\n",
45
+ " \"controlnet_guidance\": 1.0,\n",
46
+ " }\n",
47
+ "\n",
48
+ " def sendRequest(self):\n",
49
+ " r = requests.post(self.url, json=self.body)\n",
50
+ " return r.json()\n",
51
+ "\n",
52
+ "js = controlnetRequest(\"walter white\").sendRequest()"
53
+ ]
54
+ },
55
+ {
56
+ "cell_type": "code",
57
+ "execution_count": null,
58
+ "metadata": {},
59
+ "outputs": [],
60
+ "source": [
61
+ "import io, base64\n",
62
+ "import matplotlib.pyplot as plt\n",
63
+ "from PIL import Image\n",
64
+ "\n",
65
+ "pil_img = Image.open('/root/workspace/nahida/0e17302b9bfa15402f783c29c0d1d34f.jpg')\n",
66
+ "image = Image.open(io.BytesIO(base64.b64decode(js[\"images\"][0])))\n",
67
+ "mask_image = Image.open(io.BytesIO(base64.b64decode(js[\"images\"][1])))\n",
68
+ "\n",
69
+ "plt.figure()\n",
70
+ "f, axarr = plt.subplots(1,3) \n",
71
+ "axarr[0].imshow(pil_img) \n",
72
+ "axarr[1].imshow(image) \n",
73
+ "axarr[2].imshow(mask_image) "
74
+ ]
75
+ }
76
+ ],
77
+ "metadata": {
78
+ "kernelspec": {
79
+ "display_name": "pynb",
80
+ "language": "python",
81
+ "name": "python3"
82
+ },
83
+ "language_info": {
84
+ "codemirror_mode": {
85
+ "name": "ipython",
86
+ "version": 3
87
+ },
88
+ "file_extension": ".py",
89
+ "mimetype": "text/x-python",
90
+ "name": "python",
91
+ "nbconvert_exporter": "python",
92
+ "pygments_lexer": "ipython3",
93
+ "version": "3.10.9"
94
+ },
95
+ "orig_nbformat": 4,
96
+ "vscode": {
97
+ "interpreter": {
98
+ "hash": "d73345514d8c18d9a1da7351d222dbd2834c7f4a09e728a0d1f4c4580fbec206"
99
+ }
100
+ }
101
+ },
102
+ "nbformat": 4,
103
+ "nbformat_minor": 2
104
+ }
microsoftexcel-controlnet/example/chatgpt.py ADDED
@@ -0,0 +1,676 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import re
3
+ import uuid
4
+ import cv2
5
+ import torch
6
+ import requests
7
+ import io, base64
8
+ import numpy as np
9
+ import gradio as gr
10
+ from PIL import Image
11
+ from base64 import b64encode
12
+ from omegaconf import OmegaConf
13
+ from transformers import pipeline, BlipProcessor, BlipForConditionalGeneration, BlipForQuestionAnswering
14
+ from transformers import AutoModelForCausalLM, AutoTokenizer, CLIPSegProcessor, CLIPSegForImageSegmentation
15
+
16
+ from langchain.agents.initialize import initialize_agent
17
+ from langchain.agents.tools import Tool
18
+ from langchain.chains.conversation.memory import ConversationBufferMemory
19
+ from langchain.llms.openai import OpenAI
20
+
21
+ VISUAL_CHATGPT_PREFIX = """Visual ChatGPT is designed to be able to assist with a wide range of text and visual related tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. Visual ChatGPT is able to generate human-like text based on the input it receives, allowing it to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand.
22
+ Visual ChatGPT is able to process and understand large amounts of text and images. As a language model, Visual ChatGPT can not directly read images, but it has a list of tools to finish different visual tasks. Each image will have a file name formed as "image/xxx.png", and Visual ChatGPT can invoke different tools to indirectly understand pictures. When talking about images, Visual ChatGPT is very strict to the file name and will never fabricate nonexistent files. When using tools to generate new image files, Visual ChatGPT is also known that the image may not be the same as the user's demand, and will use other visual question answering tools or description tools to observe the real image. Visual ChatGPT is able to use tools in a sequence, and is loyal to the tool observation outputs rather than faking the image content and image file name. It will remember to provide the file name from the last tool observation, if a new image is generated.
23
+ Human may provide new figures to Visual ChatGPT with a description. The description helps Visual ChatGPT to understand this image, but Visual ChatGPT should use tools to finish following tasks, rather than directly imagine from the description.
24
+ Overall, Visual ChatGPT is a powerful visual dialogue assistant tool that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics.
25
+ TOOLS:
26
+ ------
27
+ Visual ChatGPT has access to the following tools:"""
28
+
29
+ VISUAL_CHATGPT_FORMAT_INSTRUCTIONS = """To use a tool, please use the following format:
30
+ ```
31
+ Thought: Do I need to use a tool? Yes
32
+ Action: the action to take, should be one of [{tool_names}]
33
+ Action Input: the input to the action
34
+ Observation: the result of the action
35
+ ```
36
+ When you have a response to say to the Human, or if you do not need to use a tool, you MUST use the format:
37
+ ```
38
+ Thought: Do I need to use a tool? No
39
+ {ai_prefix}: [your response here]
40
+ ```
41
+ """
42
+
43
+ VISUAL_CHATGPT_SUFFIX = """You are very strict to the filename correctness and will never fake a file name if it does not exist.
44
+ You will remember to provide the image file name loyally if it's provided in the last tool observation.
45
+ Begin!
46
+ Previous conversation history:
47
+ {chat_history}
48
+ New input: {input}
49
+ Since Visual ChatGPT is a text language model, Visual ChatGPT must use tools to observe images rather than imagination.
50
+ The thoughts and observations are only visible for Visual ChatGPT, Visual ChatGPT should remember to repeat important information in the final response for Human.
51
+ Thought: Do I need to use a tool? {agent_scratchpad}"""
52
+
53
+ ENDPOINT = "http://localhost:7860"
54
+ T2IAPI = ENDPOINT + "/controlnet/txt2img"
55
+ DETECTAPI = ENDPOINT + "/controlnet/detect"
56
+ MODELLIST = ENDPOINT + "/controlnet/model_list"
57
+
58
+ device = "cpu"
59
+ if torch.cuda.is_available():
60
+ device = "cuda"
61
+
62
+ def readImage(path):
63
+ img = cv2.imread(path)
64
+ retval, buffer = cv2.imencode('.jpg', img)
65
+ b64img = b64encode(buffer).decode("utf-8")
66
+ return b64img
67
+
68
+ def get_model(pattern='^control_canny.*'):
69
+ r = requests.get(MODELLIST)
70
+ result = r.json()["model_list"]
71
+ for item in result:
72
+ if re.match(pattern, item):
73
+ return item
74
+
75
+ def do_webui_request(url=T2IAPI, **kwargs):
76
+ reqbody = {
77
+ "prompt": "best quality, extremely detailed",
78
+ "negative_prompt": "longbody, lowres, bad anatomy, bad hands, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality",
79
+ "seed": -1,
80
+ "subseed": -1,
81
+ "subseed_strength": 0,
82
+ "batch_size": 1,
83
+ "n_iter": 1,
84
+ "steps": 15,
85
+ "cfg_scale": 7,
86
+ "width": 512,
87
+ "height": 768,
88
+ "restore_faces": True,
89
+ "eta": 0,
90
+ "sampler_index": "Euler a",
91
+ "controlnet_input_images": [],
92
+ "controlnet_module": 'canny',
93
+ "controlnet_model": 'control_canny-fp16 [e3fe7712]',
94
+ "controlnet_guidance": 1.0,
95
+ }
96
+ reqbody.update(kwargs)
97
+ r = requests.post(url, json=reqbody)
98
+ return r.json()
99
+
100
+
101
+ def cut_dialogue_history(history_memory, keep_last_n_words=500):
102
+ tokens = history_memory.split()
103
+ n_tokens = len(tokens)
104
+ print(f"hitory_memory:{history_memory}, n_tokens: {n_tokens}")
105
+ if n_tokens < keep_last_n_words:
106
+ return history_memory
107
+ else:
108
+ paragraphs = history_memory.split('\n')
109
+ last_n_tokens = n_tokens
110
+ while last_n_tokens >= keep_last_n_words:
111
+ last_n_tokens = last_n_tokens - len(paragraphs[0].split(' '))
112
+ paragraphs = paragraphs[1:]
113
+ return '\n' + '\n'.join(paragraphs)
114
+
115
+ def get_new_image_name(org_img_name, func_name="update"):
116
+ head_tail = os.path.split(org_img_name)
117
+ head = head_tail[0]
118
+ tail = head_tail[1]
119
+ name_split = tail.split('.')[0].split('_')
120
+ this_new_uuid = str(uuid.uuid4())[0:4]
121
+ if len(name_split) == 1:
122
+ most_org_file_name = name_split[0]
123
+ recent_prev_file_name = name_split[0]
124
+ new_file_name = '{}_{}_{}_{}.png'.format(this_new_uuid, func_name, recent_prev_file_name, most_org_file_name)
125
+ else:
126
+ assert len(name_split) == 4
127
+ most_org_file_name = name_split[3]
128
+ recent_prev_file_name = name_split[0]
129
+ new_file_name = '{}_{}_{}_{}.png'.format(this_new_uuid, func_name, recent_prev_file_name, most_org_file_name)
130
+ return os.path.join(head, new_file_name)
131
+
132
+ class MaskFormer:
133
+ def __init__(self, device):
134
+ self.device = device
135
+ self.processor = CLIPSegProcessor.from_pretrained("CIDAS/clipseg-rd64-refined")
136
+ self.model = CLIPSegForImageSegmentation.from_pretrained("CIDAS/clipseg-rd64-refined").to(device)
137
+
138
+ def inference(self, image_path, text):
139
+ threshold = 0.5
140
+ min_area = 0.02
141
+ padding = 20
142
+ original_image = Image.open(image_path)
143
+ image = original_image.resize((512, 512))
144
+ inputs = self.processor(text=text, images=image, padding="max_length", return_tensors="pt",).to(self.device)
145
+ with torch.no_grad():
146
+ outputs = self.model(**inputs)
147
+ mask = torch.sigmoid(outputs[0]).squeeze().cpu().numpy() > threshold
148
+ area_ratio = len(np.argwhere(mask)) / (mask.shape[0] * mask.shape[1])
149
+ if area_ratio < min_area:
150
+ return None
151
+ true_indices = np.argwhere(mask)
152
+ mask_array = np.zeros_like(mask, dtype=bool)
153
+ for idx in true_indices:
154
+ padded_slice = tuple(slice(max(0, i - padding), i + padding + 1) for i in idx)
155
+ mask_array[padded_slice] = True
156
+ visual_mask = (mask_array * 255).astype(np.uint8)
157
+ image_mask = Image.fromarray(visual_mask)
158
+ return image_mask.resize(image.size)
159
+
160
+ # class ImageEditing:
161
+ # def __init__(self, device):
162
+ # print("Initializing StableDiffusionInpaint to %s" % device)
163
+ # self.device = device
164
+ # self.mask_former = MaskFormer(device=self.device)
165
+ # # self.inpainting = StableDiffusionInpaintPipeline.from_pretrained("runwayml/stable-diffusion-inpainting",).to(device)
166
+
167
+ # def remove_part_of_image(self, input):
168
+ # image_path, to_be_removed_txt = input.split(",")
169
+ # print(f'remove_part_of_image: to_be_removed {to_be_removed_txt}')
170
+ # return self.replace_part_of_image(f"{image_path},{to_be_removed_txt},background")
171
+
172
+ # def replace_part_of_image(self, input):
173
+ # image_path, to_be_replaced_txt, replace_with_txt = input.split(",")
174
+ # print(f'replace_part_of_image: replace_with_txt {replace_with_txt}')
175
+ # mask_image = self.mask_former.inference(image_path, to_be_replaced_txt)
176
+ # buffered = io.BytesIO()
177
+ # mask_image.save(buffered, format="JPEG")
178
+ # resp = do_webui_request(
179
+ # url=ENDPOINT + "/sdapi/v1/img2img",
180
+ # init_images=[readImage(image_path)],
181
+ # mask=b64encode(buffered.getvalue()).decode("utf-8"),
182
+ # prompt=replace_with_txt,
183
+ # )
184
+ # image = Image.open(io.BytesIO(base64.b64decode(resp["images"][0])))
185
+ # updated_image_path = get_new_image_name(image_path, func_name="replace-something")
186
+ # updated_image.save(updated_image_path)
187
+ # return updated_image_path
188
+
189
+ # class Pix2Pix:
190
+ # def __init__(self, device):
191
+ # print("Initializing Pix2Pix to %s" % device)
192
+ # self.device = device
193
+ # self.pipe = StableDiffusionInstructPix2PixPipeline.from_pretrained("timbrooks/instruct-pix2pix", torch_dtype=torch.float16, safety_checker=None).to(device)
194
+ # self.pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(self.pipe.scheduler.config)
195
+
196
+ # def inference(self, inputs):
197
+ # """Change style of image."""
198
+ # print("===>Starting Pix2Pix Inference")
199
+ # image_path, instruct_text = inputs.split(",")[0], ','.join(inputs.split(',')[1:])
200
+ # original_image = Image.open(image_path)
201
+ # image = self.pipe(instruct_text,image=original_image,num_inference_steps=40,image_guidance_scale=1.2,).images[0]
202
+ # updated_image_path = get_new_image_name(image_path, func_name="pix2pix")
203
+ # image.save(updated_image_path)
204
+ # return updated_image_path
205
+
206
+
207
+ class T2I:
208
+ def __init__(self, device):
209
+ print("Initializing T2I to %s" % device)
210
+ self.device = device
211
+ self.text_refine_tokenizer = AutoTokenizer.from_pretrained("Gustavosta/MagicPrompt-Stable-Diffusion")
212
+ self.text_refine_model = AutoModelForCausalLM.from_pretrained("Gustavosta/MagicPrompt-Stable-Diffusion")
213
+ self.text_refine_gpt2_pipe = pipeline("text-generation", model=self.text_refine_model, tokenizer=self.text_refine_tokenizer, device=self.device)
214
+
215
+ def inference(self, text):
216
+ image_filename = os.path.join('image', str(uuid.uuid4())[0:8] + ".png")
217
+ refined_text = self.text_refine_gpt2_pipe(text)[0]["generated_text"]
218
+ print(f'{text} refined to {refined_text}')
219
+ resp = do_webui_request(
220
+ url=ENDPOINT + "/sdapi/v1/txt2img",
221
+ prompt=refined_text,
222
+ )
223
+ image = Image.open(io.BytesIO(base64.b64decode(resp["images"][0])))
224
+ image.save(image_filename)
225
+ print(f"Processed T2I.run, text: {text}, image_filename: {image_filename}")
226
+ return image_filename
227
+
228
+
229
+ class ImageCaptioning:
230
+ def __init__(self, device):
231
+ print("Initializing ImageCaptioning to %s" % device)
232
+ self.device = device
233
+ self.processor = BlipProcessor.from_pretrained("Salesforce/blip-image-captioning-base")
234
+ self.model = BlipForConditionalGeneration.from_pretrained("Salesforce/blip-image-captioning-base").to(self.device)
235
+
236
+ def inference(self, image_path):
237
+ inputs = self.processor(Image.open(image_path), return_tensors="pt").to(self.device)
238
+ out = self.model.generate(**inputs)
239
+ captions = self.processor.decode(out[0], skip_special_tokens=True)
240
+ return captions
241
+
242
+
243
+ class image2canny:
244
+ def inference(self, inputs):
245
+ print("===>Starting image2canny Inference")
246
+ resp = do_webui_request(
247
+ url=DETECTAPI,
248
+ controlnet_input_images=[readImage(inputs)],
249
+ controlnet_module="segmentation",
250
+ )
251
+ updated_image_path = get_new_image_name(inputs, func_name="edge")
252
+ image.save(updated_image_path)
253
+ return updated_image_path
254
+
255
+
256
+ class canny2image:
257
+ def inference(self, inputs):
258
+ print("===>Starting canny2image Inference")
259
+ image_path, instruct_text = inputs.split(",")[0], ','.join(inputs.split(',')[1:])
260
+ resp = do_webui_request(
261
+ prompt=instruct_text,
262
+ controlnet_input_images=[readImage(image_path)],
263
+ controlnet_module="none",
264
+ controlnet_model=get_model(pattern='^control_canny.*'),
265
+ )
266
+ image = Image.open(io.BytesIO(base64.b64decode(resp["images"][0])))
267
+ updated_image_path = get_new_image_name(image_path, func_name="canny2image")
268
+ real_image = Image.fromarray(x_samples[0])
269
+ real_image.save(updated_image_path)
270
+ return updated_image_path
271
+
272
+
273
+ class image2line:
274
+ def inference(self, inputs):
275
+ print("===>Starting image2hough Inference")
276
+ resp = do_webui_request(
277
+ url=DETECTAPI,
278
+ controlnet_input_images=[readImage(inputs)],
279
+ controlnet_module="mlsd",
280
+ )
281
+ updated_image_path = get_new_image_name(inputs, func_name="line-of")
282
+ image = Image.open(io.BytesIO(base64.b64decode(resp["images"][0])))
283
+ image.save(updated_image_path)
284
+ return updated_image_path
285
+
286
+
287
+ class line2image:
288
+ def inference(self, inputs):
289
+ print("===>Starting line2image Inference")
290
+ image_path, instruct_text = inputs.split(",")[0], ','.join(inputs.split(',')[1:])
291
+ resp = do_webui_request(
292
+ prompt=instruct_text,
293
+ controlnet_input_images=[readImage(image_path)],
294
+ controlnet_module="none",
295
+ controlnet_model=get_model(pattern='^control_mlsd.*'),
296
+ )
297
+ image = Image.open(io.BytesIO(base64.b64decode(resp["images"][0])))
298
+ updated_image_path = get_new_image_name(image_path, func_name="line2image")
299
+ real_image = Image.fromarray(x_samples[0]) # default the index0 image
300
+ real_image.save(updated_image_path)
301
+ return updated_image_path
302
+
303
+
304
+ class image2hed:
305
+ def inference(self, inputs):
306
+ print("===>Starting image2hed Inference")
307
+ resp = do_webui_request(
308
+ url=DETECTAPI,
309
+ controlnet_input_images=[readImage(inputs)],
310
+ controlnet_module="hed",
311
+ )
312
+ image = Image.open(io.BytesIO(base64.b64decode(resp["images"][0])))
313
+ updated_image_path = get_new_image_name(inputs, func_name="hed-boundary")
314
+ image.save(updated_image_path)
315
+ return updated_image_path
316
+
317
+
318
+ class hed2image:
319
+ def inference(self, inputs):
320
+ print("===>Starting hed2image Inference")
321
+ resp = do_webui_request(
322
+ prompt=instruct_text,
323
+ controlnet_input_images=[readImage(image_path)],
324
+ controlnet_module="none",
325
+ controlnet_model=get_model(pattern='^control_hed.*'),
326
+ )
327
+ image = Image.open(io.BytesIO(base64.b64decode(resp["images"][0])))
328
+ updated_image_path = get_new_image_name(image_path, func_name="hed2image")
329
+ real_image = Image.fromarray(x_samples[0]) # default the index0 image
330
+ real_image.save(updated_image_path)
331
+ return updated_image_path
332
+
333
+
334
+ class image2scribble:
335
+ def inference(self, inputs):
336
+ print("===>Starting image2scribble Inference")
337
+ resp = do_webui_request(
338
+ url=DETECTAPI,
339
+ controlnet_input_images=[readImage(inputs)],
340
+ controlnet_module="scribble",
341
+ )
342
+ image = Image.open(io.BytesIO(base64.b64decode(resp["images"][0])))
343
+ updated_image_path = get_new_image_name(inputs, func_name="scribble")
344
+ image.save(updated_image_path)
345
+ return updated_image_path
346
+
347
+
348
+ class scribble2image:
349
+ def inference(self, inputs):
350
+ print("===>Starting seg2image Inference")
351
+ image_path, instruct_text = inputs.split(",")[0], ','.join(inputs.split(',')[1:])
352
+ resp = do_webui_request(
353
+ prompt=instruct_text,
354
+ controlnet_input_images=[readImage(image_path)],
355
+ controlnet_module="none",
356
+ controlnet_model=get_model(pattern='^control_scribble.*'),
357
+ )
358
+ image = Image.open(io.BytesIO(base64.b64decode(resp["images"][0])))
359
+ updated_image_path = get_new_image_name(image_path, func_name="scribble2image")
360
+ real_image = Image.fromarray(x_samples[0])
361
+ real_image.save(updated_image_path)
362
+ return updated_image_path
363
+
364
+
365
+ class image2pose:
366
+ def inference(self, inputs):
367
+ print("===>Starting image2pose Inference")
368
+ resp = do_webui_request(
369
+ url=DETECTAPI,
370
+ controlnet_input_images=[readImage(inputs)],
371
+ controlnet_module="openpose",
372
+ )
373
+ image = Image.open(io.BytesIO(base64.b64decode(resp["images"][0])))
374
+ updated_image_path = get_new_image_name(inputs, func_name="human-pose")
375
+ image.save(updated_image_path)
376
+ return updated_image_path
377
+
378
+
379
+ class pose2image:
380
+ def inference(self, inputs):
381
+ print("===>Starting pose2image Inference")
382
+ image_path, instruct_text = inputs.split(",")[0], ','.join(inputs.split(',')[1:])
383
+ resp = do_webui_request(
384
+ prompt=instruct_text,
385
+ controlnet_input_images=[readImage(image_path)],
386
+ controlnet_module="none",
387
+ controlnet_model=get_model(pattern='^control_openpose.*'),
388
+ )
389
+ image = Image.open(io.BytesIO(base64.b64decode(resp["images"][0])))
390
+ updated_image_path = get_new_image_name(image_path, func_name="pose2image")
391
+ real_image = Image.fromarray(x_samples[0]) # default the index0 image
392
+ real_image.save(updated_image_path)
393
+ return updated_image_path
394
+
395
+
396
+ class image2seg:
397
+ def inference(self, inputs):
398
+ print("===>Starting image2seg Inference")
399
+ resp = do_webui_request(
400
+ url=DETECTAPI,
401
+ controlnet_input_images=[readImage(inputs)],
402
+ controlnet_module="segmentation",
403
+ )
404
+ image = Image.open(io.BytesIO(base64.b64decode(resp["images"][0])))
405
+ updated_image_path = get_new_image_name(inputs, func_name="segmentation")
406
+ image.save(updated_image_path)
407
+ return updated_image_path
408
+
409
+
410
+ class seg2image:
411
+ def inference(self, inputs):
412
+ print("===>Starting seg2image Inference")
413
+ image_path, instruct_text = inputs.split(",")[0], ','.join(inputs.split(',')[1:])
414
+ resp = do_webui_request(
415
+ prompt=instruct_text,
416
+ controlnet_input_images=[readImage(image_path)],
417
+ controlnet_module="none",
418
+ controlnet_model=get_model(pattern='^control_seg.*'),
419
+ )
420
+ image = Image.open(io.BytesIO(base64.b64decode(resp["images"][0])))
421
+ updated_image_path = get_new_image_name(image_path, func_name="segment2image")
422
+ real_image = Image.fromarray(x_samples[0])
423
+ real_image.save(updated_image_path)
424
+ return updated_image_path
425
+
426
+
427
+ class image2depth:
428
+ def inference(self, inputs):
429
+ print("===>Starting image2depth Inference")
430
+ resp = do_webui_request(
431
+ url=DETECTAPI,
432
+ controlnet_input_images=[readImage(inputs)],
433
+ controlnet_module="depth",
434
+ )
435
+ image = Image.open(io.BytesIO(base64.b64decode(resp["images"][0])))
436
+ updated_image_path = get_new_image_name(inputs, func_name="depth")
437
+ image.save(updated_image_path)
438
+ return updated_image_path
439
+
440
+
441
+ class depth2image:
442
+ def inference(self, inputs):
443
+ print("===>Starting depth2image Inference")
444
+ image_path, instruct_text = inputs.split(",")[0], ','.join(inputs.split(',')[1:])
445
+ resp = do_webui_request(
446
+ prompt=instruct_text,
447
+ controlnet_input_images=[readImage(image_path)],
448
+ controlnet_module="depth",
449
+ controlnet_model=get_model(pattern='^control_depth.*'),
450
+ )
451
+ image = Image.open(io.BytesIO(base64.b64decode(resp["images"][0])))
452
+ updated_image_path = get_new_image_name(image_path, func_name="depth2image")
453
+ real_image = Image.fromarray(x_samples[0]) # default the index0 image
454
+ real_image.save(updated_image_path)
455
+ return updated_image_path
456
+
457
+
458
+ class image2normal:
459
+ def inference(self, inputs):
460
+ print("===>Starting image2 normal Inference")
461
+ resp = do_webui_request(
462
+ url=DETECTAPI,
463
+ controlnet_input_images=[readImage(inputs)],
464
+ controlnet_module="normal",
465
+ )
466
+ image = Image.open(io.BytesIO(base64.b64decode(resp["images"][0])))
467
+ updated_image_path = get_new_image_name(inputs, func_name="normal-map")
468
+ image.save(updated_image_path)
469
+ return updated_image_path
470
+
471
+
472
+ class normal2image:
473
+ def inference(self, inputs):
474
+ print("===>Starting normal2image Inference")
475
+ image_path, instruct_text = inputs.split(",")[0], ','.join(inputs.split(',')[1:])
476
+ resp = do_webui_request(
477
+ prompt=instruct_text,
478
+ controlnet_input_images=[readImage(image_path)],
479
+ controlnet_module="normal",
480
+ controlnet_model=get_model(pattern='^control_normal.*'),
481
+ )
482
+ image = Image.open(io.BytesIO(base64.b64decode(resp["images"][0])))
483
+ updated_image_path = get_new_image_name(image_path, func_name="normal2image")
484
+ real_image = Image.fromarray(x_samples[0]) # default the index0 image
485
+ real_image.save(updated_image_path)
486
+ return updated_image_path
487
+
488
+
489
+ class BLIPVQA:
490
+ def __init__(self, device):
491
+ print("Initializing BLIP VQA to %s" % device)
492
+ self.device = device
493
+ self.processor = BlipProcessor.from_pretrained("Salesforce/blip-vqa-base")
494
+ self.model = BlipForQuestionAnswering.from_pretrained("Salesforce/blip-vqa-base").to(self.device)
495
+
496
+ def get_answer_from_question_and_image(self, inputs):
497
+ image_path, question = inputs.split(",")
498
+ raw_image = Image.open(image_path).convert('RGB')
499
+ print(F'BLIPVQA :question :{question}')
500
+ inputs = self.processor(raw_image, question, return_tensors="pt").to(self.device)
501
+ out = self.model.generate(**inputs)
502
+ answer = self.processor.decode(out[0], skip_special_tokens=True)
503
+ return answer
504
+
505
+
506
+ class ConversationBot:
507
+ def __init__(self):
508
+ print("Initializing VisualChatGPT")
509
+ # self.edit = ImageEditing(device=device)
510
+ self.i2t = ImageCaptioning(device=device)
511
+ self.t2i = T2I(device=device)
512
+ self.image2canny = image2canny()
513
+ self.canny2image = canny2image()
514
+ self.image2line = image2line()
515
+ self.line2image = line2image()
516
+ self.image2hed = image2hed()
517
+ self.hed2image = hed2image()
518
+ self.image2scribble = image2scribble()
519
+ self.scribble2image = scribble2image()
520
+ self.image2pose = image2pose()
521
+ self.pose2image = pose2image()
522
+ self.BLIPVQA = BLIPVQA(device=device)
523
+ self.image2seg = image2seg()
524
+ self.seg2image = seg2image()
525
+ self.image2depth = image2depth()
526
+ self.depth2image = depth2image()
527
+ self.image2normal = image2normal()
528
+ self.normal2image = normal2image()
529
+ # self.pix2pix = Pix2Pix(device="cuda:3")
530
+ self.memory = ConversationBufferMemory(memory_key="chat_history", output_key='output')
531
+ self.tools = [
532
+ Tool(name="Get Photo Description", func=self.i2t.inference,
533
+ description="useful when you want to know what is inside the photo. receives image_path as input. "
534
+ "The input to this tool should be a string, representing the image_path. "),
535
+ Tool(name="Generate Image From User Input Text", func=self.t2i.inference,
536
+ description="useful when you want to generate an image from a user input text and save it to a file. like: generate an image of an object or something, or generate an image that includes some objects. "
537
+ "The input to this tool should be a string, representing the text used to generate image. "),
538
+ # Tool(name="Remove Something From The Photo", func=self.edit.remove_part_of_image,
539
+ # description="useful when you want to remove and object or something from the photo from its description or location. "
540
+ # "The input to this tool should be a comma seperated string of two, representing the image_path and the object need to be removed. "),
541
+ # Tool(name="Replace Something From The Photo", func=self.edit.replace_part_of_image,
542
+ # description="useful when you want to replace an object from the object description or location with another object from its description. "
543
+ # "The input to this tool should be a comma seperated string of three, representing the image_path, the object to be replaced, the object to be replaced with "),
544
+
545
+ # Tool(name="Instruct Image Using Text", func=self.pix2pix.inference,
546
+ # description="useful when you want to the style of the image to be like the text. like: make it look like a painting. or make it like a robot. "
547
+ # "The input to this tool should be a comma seperated string of two, representing the image_path and the text. "),
548
+ Tool(name="Answer Question About The Image", func=self.BLIPVQA.get_answer_from_question_and_image,
549
+ description="useful when you need an answer for a question based on an image. like: what is the background color of the last image, how many cats in this figure, what is in this figure. "
550
+ "The input to this tool should be a comma seperated string of two, representing the image_path and the question"),
551
+ Tool(name="Edge Detection On Image", func=self.image2canny.inference,
552
+ description="useful when you want to detect the edge of the image. like: detect the edges of this image, or canny detection on image, or peform edge detection on this image, or detect the canny image of this image. "
553
+ "The input to this tool should be a string, representing the image_path"),
554
+ Tool(name="Generate Image Condition On Canny Image", func=self.canny2image.inference,
555
+ description="useful when you want to generate a new real image from both the user desciption and a canny image. like: generate a real image of a object or something from this canny image, or generate a new real image of a object or something from this edge image. "
556
+ "The input to this tool should be a comma seperated string of two, representing the image_path and the user description. "),
557
+ Tool(name="Line Detection On Image", func=self.image2line.inference,
558
+ description="useful when you want to detect the straight line of the image. like: detect the straight lines of this image, or straight line detection on image, or peform straight line detection on this image, or detect the straight line image of this image. "
559
+ "The input to this tool should be a string, representing the image_path"),
560
+ Tool(name="Generate Image Condition On Line Image", func=self.line2image.inference,
561
+ description="useful when you want to generate a new real image from both the user desciption and a straight line image. like: generate a real image of a object or something from this straight line image, or generate a new real image of a object or something from this straight lines. "
562
+ "The input to this tool should be a comma seperated string of two, representing the image_path and the user description. "),
563
+ Tool(name="Hed Detection On Image", func=self.image2hed.inference,
564
+ description="useful when you want to detect the soft hed boundary of the image. like: detect the soft hed boundary of this image, or hed boundary detection on image, or peform hed boundary detection on this image, or detect soft hed boundary image of this image. "
565
+ "The input to this tool should be a string, representing the image_path"),
566
+ Tool(name="Generate Image Condition On Soft Hed Boundary Image", func=self.hed2image.inference,
567
+ description="useful when you want to generate a new real image from both the user desciption and a soft hed boundary image. like: generate a real image of a object or something from this soft hed boundary image, or generate a new real image of a object or something from this hed boundary. "
568
+ "The input to this tool should be a comma seperated string of two, representing the image_path and the user description"),
569
+ Tool(name="Segmentation On Image", func=self.image2seg.inference,
570
+ description="useful when you want to detect segmentations of the image. like: segment this image, or generate segmentations on this image, or peform segmentation on this image. "
571
+ "The input to this tool should be a string, representing the image_path"),
572
+ Tool(name="Generate Image Condition On Segmentations", func=self.seg2image.inference,
573
+ description="useful when you want to generate a new real image from both the user desciption and segmentations. like: generate a real image of a object or something from this segmentation image, or generate a new real image of a object or something from these segmentations. "
574
+ "The input to this tool should be a comma seperated string of two, representing the image_path and the user description"),
575
+ Tool(name="Predict Depth On Image", func=self.image2depth.inference,
576
+ description="useful when you want to detect depth of the image. like: generate the depth from this image, or detect the depth map on this image, or predict the depth for this image. "
577
+ "The input to this tool should be a string, representing the image_path"),
578
+ Tool(name="Generate Image Condition On Depth", func=self.depth2image.inference,
579
+ description="useful when you want to generate a new real image from both the user desciption and depth image. like: generate a real image of a object or something from this depth image, or generate a new real image of a object or something from the depth map. "
580
+ "The input to this tool should be a comma seperated string of two, representing the image_path and the user description"),
581
+ Tool(name="Predict Normal Map On Image", func=self.image2normal.inference,
582
+ description="useful when you want to detect norm map of the image. like: generate normal map from this image, or predict normal map of this image. "
583
+ "The input to this tool should be a string, representing the image_path"),
584
+ Tool(name="Generate Image Condition On Normal Map", func=self.normal2image.inference,
585
+ description="useful when you want to generate a new real image from both the user desciption and normal map. like: generate a real image of a object or something from this normal map, or generate a new real image of a object or something from the normal map. "
586
+ "The input to this tool should be a comma seperated string of two, representing the image_path and the user description"),
587
+ Tool(name="Sketch Detection On Image", func=self.image2scribble.inference,
588
+ description="useful when you want to generate a scribble of the image. like: generate a scribble of this image, or generate a sketch from this image, detect the sketch from this image. "
589
+ "The input to this tool should be a string, representing the image_path"),
590
+ Tool(name="Generate Image Condition On Sketch Image", func=self.scribble2image.inference,
591
+ description="useful when you want to generate a new real image from both the user desciption and a scribble image or a sketch image. "
592
+ "The input to this tool should be a comma seperated string of two, representing the image_path and the user description"),
593
+ Tool(name="Pose Detection On Image", func=self.image2pose.inference,
594
+ description="useful when you want to detect the human pose of the image. like: generate human poses of this image, or generate a pose image from this image. "
595
+ "The input to this tool should be a string, representing the image_path"),
596
+ Tool(name="Generate Image Condition On Pose Image", func=self.pose2image.inference,
597
+ description="useful when you want to generate a new real image from both the user desciption and a human pose image. like: generate a real image of a human from this human pose image, or generate a new real image of a human from this pose. "
598
+ "The input to this tool should be a comma seperated string of two, representing the image_path and the user description")]
599
+
600
+ def init_langchain(self, openai_api_key):
601
+ self.llm = OpenAI(temperature=0, openai_api_key=openai_api_key)
602
+ self.agent = initialize_agent(
603
+ self.tools,
604
+ self.llm,
605
+ agent="conversational-react-description",
606
+ verbose=True,
607
+ memory=self.memory,
608
+ return_intermediate_steps=True,
609
+ agent_kwargs={'prefix': VISUAL_CHATGPT_PREFIX, 'format_instructions': VISUAL_CHATGPT_FORMAT_INSTRUCTIONS, 'suffix': VISUAL_CHATGPT_SUFFIX}
610
+ )
611
+
612
+ def run_text(self, openai_api_key, text, state):
613
+ if not hasattr(self, "agent"):
614
+ self.init_langchain(openai_api_key)
615
+ print("===============Running run_text =============")
616
+ print("Inputs:", text, state)
617
+ print("======>Previous memory:\n %s" % self.agent.memory)
618
+ self.agent.memory.buffer = cut_dialogue_history(self.agent.memory.buffer, keep_last_n_words=500)
619
+ res = self.agent({"input": text})
620
+ print("======>Current memory:\n %s" % self.agent.memory)
621
+ response = re.sub('(image/\S*png)', lambda m: f'![](/file={m.group(0)})*{m.group(0)}*', res['output'])
622
+ state = state + [(text, response)]
623
+ print("Outputs:", state)
624
+ return state, state
625
+
626
+ def run_image(self, openai_api_key, image, state, txt):
627
+ if not hasattr(self, "agent"):
628
+ self.init_langchain(openai_api_key)
629
+ print("===============Running run_image =============")
630
+ print("Inputs:", image, state)
631
+ print("======>Previous memory:\n %s" % self.agent.memory)
632
+ image_filename = os.path.join('image', str(uuid.uuid4())[0:8] + ".png")
633
+ print("======>Auto Resize Image...")
634
+ img = Image.open(image.name)
635
+ width, height = img.size
636
+ ratio = min(512 / width, 512 / height)
637
+ width_new, height_new = (round(width * ratio), round(height * ratio))
638
+ img = img.resize((width_new, height_new))
639
+ img = img.convert('RGB')
640
+ img.save(image_filename, "PNG")
641
+ print(f"Resize image form {width}x{height} to {width_new}x{height_new}")
642
+ description = self.i2t.inference(image_filename)
643
+ Human_prompt = "\nHuman: provide a figure named {}. The description is: {}. This information helps you to understand this image, but you should use tools to finish following tasks, " \
644
+ "rather than directly imagine from my description. If you understand, say \"Received\". \n".format(image_filename, description)
645
+ AI_prompt = "Received. "
646
+ self.agent.memory.buffer = self.agent.memory.buffer + Human_prompt + 'AI: ' + AI_prompt
647
+ print("======>Current memory:\n %s" % self.agent.memory)
648
+ state = state + [(f"![](/file={image_filename})*{image_filename}*", AI_prompt)]
649
+ print("Outputs:", state)
650
+ return state, state, txt + ' ' + image_filename + ' '
651
+
652
+
653
+ if __name__ == '__main__':
654
+ os.makedirs("image/", exist_ok=True)
655
+ bot = ConversationBot()
656
+ with gr.Blocks(css="#chatbot .overflow-y-auto{height:500px}") as demo:
657
+ openai_api_key = gr.Textbox(type="password", label="Enter your OpenAI API key here")
658
+ chatbot = gr.Chatbot(elem_id="chatbot", label="Visual ChatGPT")
659
+ state = gr.State([])
660
+ with gr.Row():
661
+ with gr.Column(scale=0.7):
662
+ txt = gr.Textbox(show_label=False, placeholder="Enter text and press enter, or upload an image").style(container=False)
663
+ with gr.Column(scale=0.15, min_width=0):
664
+ clear = gr.Button("Clear️")
665
+ with gr.Column(scale=0.15, min_width=0):
666
+ btn = gr.UploadButton("Upload", file_types=["image"])
667
+
668
+ txt.submit(bot.run_text, [openai_api_key, txt, state], [chatbot, state])
669
+ txt.submit(lambda: "", None, txt)
670
+ btn.upload(bot.run_image, [openai_api_key, btn, state, txt], [chatbot, state, txt])
671
+ clear.click(bot.memory.clear)
672
+ clear.click(lambda: [], None, chatbot)
673
+ clear.click(lambda: [], None, state)
674
+
675
+
676
+ demo.launch(server_name="0.0.0.0", server_port=7864)
microsoftexcel-controlnet/example/visual_chatgpt.ipynb ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": null,
6
+ "metadata": {},
7
+ "outputs": [],
8
+ "source": [
9
+ "# Run WebUI in API mode\n",
10
+ "nohup python launch.py --api --xformers &\n",
11
+ "\n",
12
+ "# Wait until webui fully startup\n",
13
+ "tail -f nohup.out"
14
+ ]
15
+ },
16
+ {
17
+ "cell_type": "code",
18
+ "execution_count": null,
19
+ "metadata": {},
20
+ "outputs": [],
21
+ "source": [
22
+ "# Install/Upgrade transformers\n",
23
+ "pip install -U transformers\n",
24
+ "\n",
25
+ "# Install deps\n",
26
+ "pip install langchain==0.0.101 openai \n",
27
+ "\n",
28
+ "# Run exmaple\n",
29
+ "python example/chatgpt.py"
30
+ ]
31
+ }
32
+ ],
33
+ "metadata": {
34
+ "kernelspec": {
35
+ "display_name": "pynb",
36
+ "language": "python",
37
+ "name": "python3"
38
+ },
39
+ "language_info": {
40
+ "codemirror_mode": {
41
+ "name": "ipython",
42
+ "version": 3
43
+ },
44
+ "file_extension": ".py",
45
+ "mimetype": "text/x-python",
46
+ "name": "python",
47
+ "nbconvert_exporter": "python",
48
+ "pygments_lexer": "ipython3",
49
+ "version": "3.10.9"
50
+ },
51
+ "orig_nbformat": 4,
52
+ "vscode": {
53
+ "interpreter": {
54
+ "hash": "d73345514d8c18d9a1da7351d222dbd2834c7f4a09e728a0d1f4c4580fbec206"
55
+ }
56
+ }
57
+ },
58
+ "nbformat": 4,
59
+ "nbformat_minor": 2
60
+ }
microsoftexcel-controlnet/extract_controlnet.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import argparse
2
+ import torch
3
+ from safetensors.torch import load_file, save_file
4
+
5
+ if __name__ == "__main__":
6
+ parser = argparse.ArgumentParser()
7
+ parser.add_argument("--src", default=None, type=str, required=True, help="Path to the model to convert.")
8
+ parser.add_argument("--dst", default=None, type=str, required=True, help="Path to the output model.")
9
+ parser.add_argument("--half", action="store_true", help="Cast to FP16.")
10
+ args = parser.parse_args()
11
+
12
+ assert args.src is not None, "Must provide a model path!"
13
+ assert args.dst is not None, "Must provide a checkpoint path!"
14
+
15
+ if args.src.endswith(".safetensors"):
16
+ state_dict = load_file(args.src)
17
+ else:
18
+ state_dict = torch.load(args.src)
19
+
20
+ if any([k.startswith("control_model.") for k, v in state_dict.items()]):
21
+ dtype = torch.float16 if args.half else torch.float32
22
+ state_dict = {k.replace("control_model.", ""): v.to(dtype) for k, v in state_dict.items() if k.startswith("control_model.")}
23
+
24
+ if args.dst.endswith(".safetensors"):
25
+ save_file(state_dict, args.dst)
26
+ else:
27
+ torch.save({"state_dict": state_dict}, args.dst)
microsoftexcel-controlnet/extract_controlnet_diff.py ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import argparse
2
+ import torch
3
+ from safetensors.torch import load_file, save_file
4
+
5
+ if __name__ == "__main__":
6
+ parser = argparse.ArgumentParser()
7
+ parser.add_argument("--sd15", default=None, type=str, required=True, help="Path to the original sd15.")
8
+ parser.add_argument("--control", default=None, type=str, required=True, help="Path to the sd15 with control.")
9
+ parser.add_argument("--dst", default=None, type=str, required=True, help="Path to the output difference model.")
10
+ parser.add_argument("--fp16", action="store_true", help="Save as fp16.")
11
+ parser.add_argument("--bf16", action="store_true", help="Save as bf16.")
12
+ args = parser.parse_args()
13
+
14
+ assert args.sd15 is not None, "Must provide a original sd15 model path!"
15
+ assert args.control is not None, "Must provide a sd15 with control model path!"
16
+ assert args.dst is not None, "Must provide a output path!"
17
+
18
+ # make differences: copy from https://github.com/lllyasviel/ControlNet/blob/main/tool_transfer_control.py
19
+
20
+ def get_node_name(name, parent_name):
21
+ if len(name) <= len(parent_name):
22
+ return False, ''
23
+ p = name[:len(parent_name)]
24
+ if p != parent_name:
25
+ return False, ''
26
+ return True, name[len(parent_name):]
27
+
28
+ # remove first/cond stage from sd to reduce memory usage
29
+ def remove_first_and_cond(sd):
30
+ keys = list(sd.keys())
31
+ for key in keys:
32
+ is_first_stage, _ = get_node_name(key, 'first_stage_model')
33
+ is_cond_stage, _ = get_node_name(key, 'cond_stage_model')
34
+ if is_first_stage or is_cond_stage:
35
+ sd.pop(key, None)
36
+ return sd
37
+
38
+ print(f"loading: {args.sd15}")
39
+ if args.sd15.endswith(".safetensors"):
40
+ sd15_state_dict = load_file(args.sd15)
41
+ else:
42
+ sd15_state_dict = torch.load(args.sd15)
43
+ sd15_state_dict = sd15_state_dict.pop("state_dict", sd15_state_dict)
44
+ sd15_state_dict = remove_first_and_cond(sd15_state_dict)
45
+
46
+ print(f"loading: {args.control}")
47
+ if args.control.endswith(".safetensors"):
48
+ control_state_dict = load_file(args.control)
49
+ else:
50
+ control_state_dict = torch.load(args.control)
51
+ control_state_dict = remove_first_and_cond(control_state_dict)
52
+
53
+ # make diff of original and control
54
+ print(f"create difference")
55
+ keys = list(control_state_dict.keys())
56
+ final_state_dict = {"difference": torch.tensor(1.0)} # indicates difference
57
+ for key in keys:
58
+ p = control_state_dict.pop(key)
59
+
60
+ is_control, node_name = get_node_name(key, 'control_')
61
+ if not is_control:
62
+ continue
63
+
64
+ sd15_key_name = 'model.diffusion_' + node_name
65
+ if sd15_key_name in sd15_state_dict: # part of U-Net
66
+ # print("in sd15", key, sd15_key_name)
67
+ p_new = p - sd15_state_dict.pop(sd15_key_name)
68
+ if torch.max(torch.abs(p_new)) < 1e-6: # no difference?
69
+ print("no diff", key, sd15_key_name)
70
+ continue
71
+ else:
72
+ # print("not in sd15", key, sd15_key_name)
73
+ p_new = p # hint or zero_conv
74
+
75
+ final_state_dict[key] = p_new
76
+
77
+ save_dtype = None
78
+ if args.fp16:
79
+ save_dtype = torch.float16
80
+ elif args.bf16:
81
+ save_dtype = torch.bfloat16
82
+ if save_dtype is not None:
83
+ for key in final_state_dict.keys():
84
+ final_state_dict[key] = final_state_dict[key].to(save_dtype)
85
+
86
+ print("saving difference.")
87
+ if args.dst.endswith(".safetensors"):
88
+ save_file(final_state_dict, args.dst)
89
+ else:
90
+ torch.save({"state_dict": final_state_dict}, args.dst)
91
+ print("done!")
microsoftexcel-controlnet/install.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import launch
2
+ import os
3
+ import pkg_resources
4
+
5
+ req_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), "requirements.txt")
6
+
7
+ with open(req_file) as file:
8
+ for package in file:
9
+ try:
10
+ package = package.strip()
11
+ if '==' in package:
12
+ package_name, package_version = package.split('==')
13
+ installed_version = pkg_resources.get_distribution(package_name).version
14
+ if installed_version != package_version:
15
+ launch.run_pip(f"install {package}", f"sd-webui-controlnet requirement: changing {package_name} version from {installed_version} to {package_version}")
16
+ elif not launch.is_installed(package):
17
+ launch.run_pip(f"install {package}", f"sd-webui-controlnet requirement: {package}")
18
+ except Exception as e:
19
+ print(e)
20
+ print(f'Warning: Failed to install {package}, some preprocessors may not work.')
microsoftexcel-controlnet/javascript/hints.js ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ onUiUpdate(function () {
2
+ // mouseover tooltips for various UI elements
3
+ const titles = {
4
+ '🔄': 'Refresh',
5
+ '\u2934': 'Send dimensions to stable diffusion',
6
+ '💥': 'Run preprocessor',
7
+ '📝': 'Open new canvas',
8
+ '📷': 'Enable webcam',
9
+ '⇄': 'Mirror webcam',
10
+ };
11
+ gradioApp().querySelectorAll('.cnet-toolbutton').forEach(function (button) {
12
+ const tooltip = titles[button.textContent];
13
+ if (tooltip) {
14
+ button.title = tooltip;
15
+ }
16
+ })
17
+ });
microsoftexcel-controlnet/models/cldm_v15.yaml ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ model:
2
+ target: cldm.cldm.ControlLDM
3
+ params:
4
+ linear_start: 0.00085
5
+ linear_end: 0.0120
6
+ num_timesteps_cond: 1
7
+ log_every_t: 200
8
+ timesteps: 1000
9
+ first_stage_key: "jpg"
10
+ cond_stage_key: "txt"
11
+ control_key: "hint"
12
+ image_size: 64
13
+ channels: 4
14
+ cond_stage_trainable: false
15
+ conditioning_key: crossattn
16
+ monitor: val/loss_simple_ema
17
+ scale_factor: 0.18215
18
+ use_ema: False
19
+ only_mid_control: False
20
+
21
+ control_stage_config:
22
+ target: cldm.cldm.ControlNet
23
+ params:
24
+ image_size: 32 # unused
25
+ in_channels: 4
26
+ hint_channels: 3
27
+ model_channels: 320
28
+ attention_resolutions: [ 4, 2, 1 ]
29
+ num_res_blocks: 2
30
+ channel_mult: [ 1, 2, 4, 4 ]
31
+ num_heads: 8
32
+ use_spatial_transformer: True
33
+ transformer_depth: 1
34
+ context_dim: 768
35
+ use_checkpoint: True
36
+ legacy: False
37
+
38
+ unet_config:
39
+ target: cldm.cldm.ControlledUnetModel
40
+ params:
41
+ image_size: 32 # unused
42
+ in_channels: 4
43
+ out_channels: 4
44
+ model_channels: 320
45
+ attention_resolutions: [ 4, 2, 1 ]
46
+ num_res_blocks: 2
47
+ channel_mult: [ 1, 2, 4, 4 ]
48
+ num_heads: 8
49
+ use_spatial_transformer: True
50
+ transformer_depth: 1
51
+ context_dim: 768
52
+ use_checkpoint: True
53
+ legacy: False
54
+
55
+ first_stage_config:
56
+ target: ldm.models.autoencoder.AutoencoderKL
57
+ params:
58
+ embed_dim: 4
59
+ monitor: val/rec_loss
60
+ ddconfig:
61
+ double_z: true
62
+ z_channels: 4
63
+ resolution: 256
64
+ in_channels: 3
65
+ out_ch: 3
66
+ ch: 128
67
+ ch_mult:
68
+ - 1
69
+ - 2
70
+ - 4
71
+ - 4
72
+ num_res_blocks: 2
73
+ attn_resolutions: []
74
+ dropout: 0.0
75
+ lossconfig:
76
+ target: torch.nn.Identity
77
+
78
+ cond_stage_config:
79
+ target: ldm.modules.encoders.modules.FrozenCLIPEmbedder
microsoftexcel-controlnet/models/cldm_v21.yaml ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ model:
2
+ target: cldm.cldm.ControlLDM
3
+ params:
4
+ linear_start: 0.00085
5
+ linear_end: 0.0120
6
+ num_timesteps_cond: 1
7
+ log_every_t: 200
8
+ timesteps: 1000
9
+ first_stage_key: "jpg"
10
+ cond_stage_key: "txt"
11
+ control_key: "hint"
12
+ image_size: 64
13
+ channels: 4
14
+ cond_stage_trainable: false
15
+ conditioning_key: crossattn
16
+ monitor: val/loss_simple_ema
17
+ scale_factor: 0.18215
18
+ use_ema: False
19
+ only_mid_control: False
20
+
21
+ control_stage_config:
22
+ target: cldm.cldm.ControlNet
23
+ params:
24
+ use_checkpoint: True
25
+ image_size: 32 # unused
26
+ in_channels: 4
27
+ hint_channels: 3
28
+ model_channels: 320
29
+ attention_resolutions: [ 4, 2, 1 ]
30
+ num_res_blocks: 2
31
+ channel_mult: [ 1, 2, 4, 4 ]
32
+ num_head_channels: 64 # need to fix for flash-attn
33
+ use_spatial_transformer: True
34
+ use_linear_in_transformer: True
35
+ transformer_depth: 1
36
+ context_dim: 1024
37
+ legacy: False
38
+
39
+ unet_config:
40
+ target: cldm.cldm.ControlledUnetModel
41
+ params:
42
+ use_checkpoint: True
43
+ image_size: 32 # unused
44
+ in_channels: 4
45
+ out_channels: 4
46
+ model_channels: 320
47
+ attention_resolutions: [ 4, 2, 1 ]
48
+ num_res_blocks: 2
49
+ channel_mult: [ 1, 2, 4, 4 ]
50
+ num_head_channels: 64 # need to fix for flash-attn
51
+ use_spatial_transformer: True
52
+ use_linear_in_transformer: True
53
+ transformer_depth: 1
54
+ context_dim: 1024
55
+ legacy: False
56
+
57
+ first_stage_config:
58
+ target: ldm.models.autoencoder.AutoencoderKL
59
+ params:
60
+ embed_dim: 4
61
+ monitor: val/rec_loss
62
+ ddconfig:
63
+ #attn_type: "vanilla-xformers"
64
+ double_z: true
65
+ z_channels: 4
66
+ resolution: 256
67
+ in_channels: 3
68
+ out_ch: 3
69
+ ch: 128
70
+ ch_mult:
71
+ - 1
72
+ - 2
73
+ - 4
74
+ - 4
75
+ num_res_blocks: 2
76
+ attn_resolutions: []
77
+ dropout: 0.0
78
+ lossconfig:
79
+ target: torch.nn.Identity
80
+
81
+ cond_stage_config:
82
+ target: ldm.modules.encoders.modules.FrozenOpenCLIPEmbedder
83
+ params:
84
+ freeze: True
85
+ layer: "penultimate"
microsoftexcel-controlnet/models/control_sd15_canny.yaml ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ model:
2
+ target: cldm.cldm.ControlLDM
3
+ params:
4
+ linear_start: 0.00085
5
+ linear_end: 0.0120
6
+ num_timesteps_cond: 1
7
+ log_every_t: 200
8
+ timesteps: 1000
9
+ first_stage_key: "jpg"
10
+ cond_stage_key: "txt"
11
+ control_key: "hint"
12
+ image_size: 64
13
+ channels: 4
14
+ cond_stage_trainable: false
15
+ conditioning_key: crossattn
16
+ monitor: val/loss_simple_ema
17
+ scale_factor: 0.18215
18
+ use_ema: False
19
+ only_mid_control: False
20
+
21
+ control_stage_config:
22
+ target: cldm.cldm.ControlNet
23
+ params:
24
+ image_size: 32 # unused
25
+ in_channels: 4
26
+ hint_channels: 3
27
+ model_channels: 320
28
+ attention_resolutions: [ 4, 2, 1 ]
29
+ num_res_blocks: 2
30
+ channel_mult: [ 1, 2, 4, 4 ]
31
+ num_heads: 8
32
+ use_spatial_transformer: True
33
+ transformer_depth: 1
34
+ context_dim: 768
35
+ use_checkpoint: True
36
+ legacy: False
37
+
38
+ unet_config:
39
+ target: cldm.cldm.ControlledUnetModel
40
+ params:
41
+ image_size: 32 # unused
42
+ in_channels: 4
43
+ out_channels: 4
44
+ model_channels: 320
45
+ attention_resolutions: [ 4, 2, 1 ]
46
+ num_res_blocks: 2
47
+ channel_mult: [ 1, 2, 4, 4 ]
48
+ num_heads: 8
49
+ use_spatial_transformer: True
50
+ transformer_depth: 1
51
+ context_dim: 768
52
+ use_checkpoint: True
53
+ legacy: False
54
+
55
+ first_stage_config:
56
+ target: ldm.models.autoencoder.AutoencoderKL
57
+ params:
58
+ embed_dim: 4
59
+ monitor: val/rec_loss
60
+ ddconfig:
61
+ double_z: true
62
+ z_channels: 4
63
+ resolution: 256
64
+ in_channels: 3
65
+ out_ch: 3
66
+ ch: 128
67
+ ch_mult:
68
+ - 1
69
+ - 2
70
+ - 4
71
+ - 4
72
+ num_res_blocks: 2
73
+ attn_resolutions: []
74
+ dropout: 0.0
75
+ lossconfig:
76
+ target: torch.nn.Identity
77
+
78
+ cond_stage_config:
79
+ target: ldm.modules.encoders.modules.FrozenCLIPEmbedder
microsoftexcel-controlnet/models/control_sd15_depth.yaml ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ model:
2
+ target: cldm.cldm.ControlLDM
3
+ params:
4
+ linear_start: 0.00085
5
+ linear_end: 0.0120
6
+ num_timesteps_cond: 1
7
+ log_every_t: 200
8
+ timesteps: 1000
9
+ first_stage_key: "jpg"
10
+ cond_stage_key: "txt"
11
+ control_key: "hint"
12
+ image_size: 64
13
+ channels: 4
14
+ cond_stage_trainable: false
15
+ conditioning_key: crossattn
16
+ monitor: val/loss_simple_ema
17
+ scale_factor: 0.18215
18
+ use_ema: False
19
+ only_mid_control: False
20
+
21
+ control_stage_config:
22
+ target: cldm.cldm.ControlNet
23
+ params:
24
+ image_size: 32 # unused
25
+ in_channels: 4
26
+ hint_channels: 3
27
+ model_channels: 320
28
+ attention_resolutions: [ 4, 2, 1 ]
29
+ num_res_blocks: 2
30
+ channel_mult: [ 1, 2, 4, 4 ]
31
+ num_heads: 8
32
+ use_spatial_transformer: True
33
+ transformer_depth: 1
34
+ context_dim: 768
35
+ use_checkpoint: True
36
+ legacy: False
37
+
38
+ unet_config:
39
+ target: cldm.cldm.ControlledUnetModel
40
+ params:
41
+ image_size: 32 # unused
42
+ in_channels: 4
43
+ out_channels: 4
44
+ model_channels: 320
45
+ attention_resolutions: [ 4, 2, 1 ]
46
+ num_res_blocks: 2
47
+ channel_mult: [ 1, 2, 4, 4 ]
48
+ num_heads: 8
49
+ use_spatial_transformer: True
50
+ transformer_depth: 1
51
+ context_dim: 768
52
+ use_checkpoint: True
53
+ legacy: False
54
+
55
+ first_stage_config:
56
+ target: ldm.models.autoencoder.AutoencoderKL
57
+ params:
58
+ embed_dim: 4
59
+ monitor: val/rec_loss
60
+ ddconfig:
61
+ double_z: true
62
+ z_channels: 4
63
+ resolution: 256
64
+ in_channels: 3
65
+ out_ch: 3
66
+ ch: 128
67
+ ch_mult:
68
+ - 1
69
+ - 2
70
+ - 4
71
+ - 4
72
+ num_res_blocks: 2
73
+ attn_resolutions: []
74
+ dropout: 0.0
75
+ lossconfig:
76
+ target: torch.nn.Identity
77
+
78
+ cond_stage_config:
79
+ target: ldm.modules.encoders.modules.FrozenCLIPEmbedder
microsoftexcel-controlnet/models/control_sd15_hed.yaml ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ model:
2
+ target: cldm.cldm.ControlLDM
3
+ params:
4
+ linear_start: 0.00085
5
+ linear_end: 0.0120
6
+ num_timesteps_cond: 1
7
+ log_every_t: 200
8
+ timesteps: 1000
9
+ first_stage_key: "jpg"
10
+ cond_stage_key: "txt"
11
+ control_key: "hint"
12
+ image_size: 64
13
+ channels: 4
14
+ cond_stage_trainable: false
15
+ conditioning_key: crossattn
16
+ monitor: val/loss_simple_ema
17
+ scale_factor: 0.18215
18
+ use_ema: False
19
+ only_mid_control: False
20
+
21
+ control_stage_config:
22
+ target: cldm.cldm.ControlNet
23
+ params:
24
+ image_size: 32 # unused
25
+ in_channels: 4
26
+ hint_channels: 3
27
+ model_channels: 320
28
+ attention_resolutions: [ 4, 2, 1 ]
29
+ num_res_blocks: 2
30
+ channel_mult: [ 1, 2, 4, 4 ]
31
+ num_heads: 8
32
+ use_spatial_transformer: True
33
+ transformer_depth: 1
34
+ context_dim: 768
35
+ use_checkpoint: True
36
+ legacy: False
37
+
38
+ unet_config:
39
+ target: cldm.cldm.ControlledUnetModel
40
+ params:
41
+ image_size: 32 # unused
42
+ in_channels: 4
43
+ out_channels: 4
44
+ model_channels: 320
45
+ attention_resolutions: [ 4, 2, 1 ]
46
+ num_res_blocks: 2
47
+ channel_mult: [ 1, 2, 4, 4 ]
48
+ num_heads: 8
49
+ use_spatial_transformer: True
50
+ transformer_depth: 1
51
+ context_dim: 768
52
+ use_checkpoint: True
53
+ legacy: False
54
+
55
+ first_stage_config:
56
+ target: ldm.models.autoencoder.AutoencoderKL
57
+ params:
58
+ embed_dim: 4
59
+ monitor: val/rec_loss
60
+ ddconfig:
61
+ double_z: true
62
+ z_channels: 4
63
+ resolution: 256
64
+ in_channels: 3
65
+ out_ch: 3
66
+ ch: 128
67
+ ch_mult:
68
+ - 1
69
+ - 2
70
+ - 4
71
+ - 4
72
+ num_res_blocks: 2
73
+ attn_resolutions: []
74
+ dropout: 0.0
75
+ lossconfig:
76
+ target: torch.nn.Identity
77
+
78
+ cond_stage_config:
79
+ target: ldm.modules.encoders.modules.FrozenCLIPEmbedder
microsoftexcel-controlnet/models/control_sd15_mlsd.yaml ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ model:
2
+ target: cldm.cldm.ControlLDM
3
+ params:
4
+ linear_start: 0.00085
5
+ linear_end: 0.0120
6
+ num_timesteps_cond: 1
7
+ log_every_t: 200
8
+ timesteps: 1000
9
+ first_stage_key: "jpg"
10
+ cond_stage_key: "txt"
11
+ control_key: "hint"
12
+ image_size: 64
13
+ channels: 4
14
+ cond_stage_trainable: false
15
+ conditioning_key: crossattn
16
+ monitor: val/loss_simple_ema
17
+ scale_factor: 0.18215
18
+ use_ema: False
19
+ only_mid_control: False
20
+
21
+ control_stage_config:
22
+ target: cldm.cldm.ControlNet
23
+ params:
24
+ image_size: 32 # unused
25
+ in_channels: 4
26
+ hint_channels: 3
27
+ model_channels: 320
28
+ attention_resolutions: [ 4, 2, 1 ]
29
+ num_res_blocks: 2
30
+ channel_mult: [ 1, 2, 4, 4 ]
31
+ num_heads: 8
32
+ use_spatial_transformer: True
33
+ transformer_depth: 1
34
+ context_dim: 768
35
+ use_checkpoint: True
36
+ legacy: False
37
+
38
+ unet_config:
39
+ target: cldm.cldm.ControlledUnetModel
40
+ params:
41
+ image_size: 32 # unused
42
+ in_channels: 4
43
+ out_channels: 4
44
+ model_channels: 320
45
+ attention_resolutions: [ 4, 2, 1 ]
46
+ num_res_blocks: 2
47
+ channel_mult: [ 1, 2, 4, 4 ]
48
+ num_heads: 8
49
+ use_spatial_transformer: True
50
+ transformer_depth: 1
51
+ context_dim: 768
52
+ use_checkpoint: True
53
+ legacy: False
54
+
55
+ first_stage_config:
56
+ target: ldm.models.autoencoder.AutoencoderKL
57
+ params:
58
+ embed_dim: 4
59
+ monitor: val/rec_loss
60
+ ddconfig:
61
+ double_z: true
62
+ z_channels: 4
63
+ resolution: 256
64
+ in_channels: 3
65
+ out_ch: 3
66
+ ch: 128
67
+ ch_mult:
68
+ - 1
69
+ - 2
70
+ - 4
71
+ - 4
72
+ num_res_blocks: 2
73
+ attn_resolutions: []
74
+ dropout: 0.0
75
+ lossconfig:
76
+ target: torch.nn.Identity
77
+
78
+ cond_stage_config:
79
+ target: ldm.modules.encoders.modules.FrozenCLIPEmbedder
microsoftexcel-controlnet/models/control_sd15_normal.yaml ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ model:
2
+ target: cldm.cldm.ControlLDM
3
+ params:
4
+ linear_start: 0.00085
5
+ linear_end: 0.0120
6
+ num_timesteps_cond: 1
7
+ log_every_t: 200
8
+ timesteps: 1000
9
+ first_stage_key: "jpg"
10
+ cond_stage_key: "txt"
11
+ control_key: "hint"
12
+ image_size: 64
13
+ channels: 4
14
+ cond_stage_trainable: false
15
+ conditioning_key: crossattn
16
+ monitor: val/loss_simple_ema
17
+ scale_factor: 0.18215
18
+ use_ema: False
19
+ only_mid_control: False
20
+
21
+ control_stage_config:
22
+ target: cldm.cldm.ControlNet
23
+ params:
24
+ image_size: 32 # unused
25
+ in_channels: 4
26
+ hint_channels: 3
27
+ model_channels: 320
28
+ attention_resolutions: [ 4, 2, 1 ]
29
+ num_res_blocks: 2
30
+ channel_mult: [ 1, 2, 4, 4 ]
31
+ num_heads: 8
32
+ use_spatial_transformer: True
33
+ transformer_depth: 1
34
+ context_dim: 768
35
+ use_checkpoint: True
36
+ legacy: False
37
+
38
+ unet_config:
39
+ target: cldm.cldm.ControlledUnetModel
40
+ params:
41
+ image_size: 32 # unused
42
+ in_channels: 4
43
+ out_channels: 4
44
+ model_channels: 320
45
+ attention_resolutions: [ 4, 2, 1 ]
46
+ num_res_blocks: 2
47
+ channel_mult: [ 1, 2, 4, 4 ]
48
+ num_heads: 8
49
+ use_spatial_transformer: True
50
+ transformer_depth: 1
51
+ context_dim: 768
52
+ use_checkpoint: True
53
+ legacy: False
54
+
55
+ first_stage_config:
56
+ target: ldm.models.autoencoder.AutoencoderKL
57
+ params:
58
+ embed_dim: 4
59
+ monitor: val/rec_loss
60
+ ddconfig:
61
+ double_z: true
62
+ z_channels: 4
63
+ resolution: 256
64
+ in_channels: 3
65
+ out_ch: 3
66
+ ch: 128
67
+ ch_mult:
68
+ - 1
69
+ - 2
70
+ - 4
71
+ - 4
72
+ num_res_blocks: 2
73
+ attn_resolutions: []
74
+ dropout: 0.0
75
+ lossconfig:
76
+ target: torch.nn.Identity
77
+
78
+ cond_stage_config:
79
+ target: ldm.modules.encoders.modules.FrozenCLIPEmbedder
microsoftexcel-controlnet/models/control_sd15_openpose.yaml ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ model:
2
+ target: cldm.cldm.ControlLDM
3
+ params:
4
+ linear_start: 0.00085
5
+ linear_end: 0.0120
6
+ num_timesteps_cond: 1
7
+ log_every_t: 200
8
+ timesteps: 1000
9
+ first_stage_key: "jpg"
10
+ cond_stage_key: "txt"
11
+ control_key: "hint"
12
+ image_size: 64
13
+ channels: 4
14
+ cond_stage_trainable: false
15
+ conditioning_key: crossattn
16
+ monitor: val/loss_simple_ema
17
+ scale_factor: 0.18215
18
+ use_ema: False
19
+ only_mid_control: False
20
+
21
+ control_stage_config:
22
+ target: cldm.cldm.ControlNet
23
+ params:
24
+ image_size: 32 # unused
25
+ in_channels: 4
26
+ hint_channels: 3
27
+ model_channels: 320
28
+ attention_resolutions: [ 4, 2, 1 ]
29
+ num_res_blocks: 2
30
+ channel_mult: [ 1, 2, 4, 4 ]
31
+ num_heads: 8
32
+ use_spatial_transformer: True
33
+ transformer_depth: 1
34
+ context_dim: 768
35
+ use_checkpoint: True
36
+ legacy: False
37
+
38
+ unet_config:
39
+ target: cldm.cldm.ControlledUnetModel
40
+ params:
41
+ image_size: 32 # unused
42
+ in_channels: 4
43
+ out_channels: 4
44
+ model_channels: 320
45
+ attention_resolutions: [ 4, 2, 1 ]
46
+ num_res_blocks: 2
47
+ channel_mult: [ 1, 2, 4, 4 ]
48
+ num_heads: 8
49
+ use_spatial_transformer: True
50
+ transformer_depth: 1
51
+ context_dim: 768
52
+ use_checkpoint: True
53
+ legacy: False
54
+
55
+ first_stage_config:
56
+ target: ldm.models.autoencoder.AutoencoderKL
57
+ params:
58
+ embed_dim: 4
59
+ monitor: val/rec_loss
60
+ ddconfig:
61
+ double_z: true
62
+ z_channels: 4
63
+ resolution: 256
64
+ in_channels: 3
65
+ out_ch: 3
66
+ ch: 128
67
+ ch_mult:
68
+ - 1
69
+ - 2
70
+ - 4
71
+ - 4
72
+ num_res_blocks: 2
73
+ attn_resolutions: []
74
+ dropout: 0.0
75
+ lossconfig:
76
+ target: torch.nn.Identity
77
+
78
+ cond_stage_config:
79
+ target: ldm.modules.encoders.modules.FrozenCLIPEmbedder
microsoftexcel-controlnet/models/control_sd15_scribble.yaml ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ model:
2
+ target: cldm.cldm.ControlLDM
3
+ params:
4
+ linear_start: 0.00085
5
+ linear_end: 0.0120
6
+ num_timesteps_cond: 1
7
+ log_every_t: 200
8
+ timesteps: 1000
9
+ first_stage_key: "jpg"
10
+ cond_stage_key: "txt"
11
+ control_key: "hint"
12
+ image_size: 64
13
+ channels: 4
14
+ cond_stage_trainable: false
15
+ conditioning_key: crossattn
16
+ monitor: val/loss_simple_ema
17
+ scale_factor: 0.18215
18
+ use_ema: False
19
+ only_mid_control: False
20
+
21
+ control_stage_config:
22
+ target: cldm.cldm.ControlNet
23
+ params:
24
+ image_size: 32 # unused
25
+ in_channels: 4
26
+ hint_channels: 3
27
+ model_channels: 320
28
+ attention_resolutions: [ 4, 2, 1 ]
29
+ num_res_blocks: 2
30
+ channel_mult: [ 1, 2, 4, 4 ]
31
+ num_heads: 8
32
+ use_spatial_transformer: True
33
+ transformer_depth: 1
34
+ context_dim: 768
35
+ use_checkpoint: True
36
+ legacy: False
37
+
38
+ unet_config:
39
+ target: cldm.cldm.ControlledUnetModel
40
+ params:
41
+ image_size: 32 # unused
42
+ in_channels: 4
43
+ out_channels: 4
44
+ model_channels: 320
45
+ attention_resolutions: [ 4, 2, 1 ]
46
+ num_res_blocks: 2
47
+ channel_mult: [ 1, 2, 4, 4 ]
48
+ num_heads: 8
49
+ use_spatial_transformer: True
50
+ transformer_depth: 1
51
+ context_dim: 768
52
+ use_checkpoint: True
53
+ legacy: False
54
+
55
+ first_stage_config:
56
+ target: ldm.models.autoencoder.AutoencoderKL
57
+ params:
58
+ embed_dim: 4
59
+ monitor: val/rec_loss
60
+ ddconfig:
61
+ double_z: true
62
+ z_channels: 4
63
+ resolution: 256
64
+ in_channels: 3
65
+ out_ch: 3
66
+ ch: 128
67
+ ch_mult:
68
+ - 1
69
+ - 2
70
+ - 4
71
+ - 4
72
+ num_res_blocks: 2
73
+ attn_resolutions: []
74
+ dropout: 0.0
75
+ lossconfig:
76
+ target: torch.nn.Identity
77
+
78
+ cond_stage_config:
79
+ target: ldm.modules.encoders.modules.FrozenCLIPEmbedder
microsoftexcel-controlnet/models/control_sd15_seg.yaml ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ model:
2
+ target: cldm.cldm.ControlLDM
3
+ params:
4
+ linear_start: 0.00085
5
+ linear_end: 0.0120
6
+ num_timesteps_cond: 1
7
+ log_every_t: 200
8
+ timesteps: 1000
9
+ first_stage_key: "jpg"
10
+ cond_stage_key: "txt"
11
+ control_key: "hint"
12
+ image_size: 64
13
+ channels: 4
14
+ cond_stage_trainable: false
15
+ conditioning_key: crossattn
16
+ monitor: val/loss_simple_ema
17
+ scale_factor: 0.18215
18
+ use_ema: False
19
+ only_mid_control: False
20
+
21
+ control_stage_config:
22
+ target: cldm.cldm.ControlNet
23
+ params:
24
+ image_size: 32 # unused
25
+ in_channels: 4
26
+ hint_channels: 3
27
+ model_channels: 320
28
+ attention_resolutions: [ 4, 2, 1 ]
29
+ num_res_blocks: 2
30
+ channel_mult: [ 1, 2, 4, 4 ]
31
+ num_heads: 8
32
+ use_spatial_transformer: True
33
+ transformer_depth: 1
34
+ context_dim: 768
35
+ use_checkpoint: True
36
+ legacy: False
37
+
38
+ unet_config:
39
+ target: cldm.cldm.ControlledUnetModel
40
+ params:
41
+ image_size: 32 # unused
42
+ in_channels: 4
43
+ out_channels: 4
44
+ model_channels: 320
45
+ attention_resolutions: [ 4, 2, 1 ]
46
+ num_res_blocks: 2
47
+ channel_mult: [ 1, 2, 4, 4 ]
48
+ num_heads: 8
49
+ use_spatial_transformer: True
50
+ transformer_depth: 1
51
+ context_dim: 768
52
+ use_checkpoint: True
53
+ legacy: False
54
+
55
+ first_stage_config:
56
+ target: ldm.models.autoencoder.AutoencoderKL
57
+ params:
58
+ embed_dim: 4
59
+ monitor: val/rec_loss
60
+ ddconfig:
61
+ double_z: true
62
+ z_channels: 4
63
+ resolution: 256
64
+ in_channels: 3
65
+ out_ch: 3
66
+ ch: 128
67
+ ch_mult:
68
+ - 1
69
+ - 2
70
+ - 4
71
+ - 4
72
+ num_res_blocks: 2
73
+ attn_resolutions: []
74
+ dropout: 0.0
75
+ lossconfig:
76
+ target: torch.nn.Identity
77
+
78
+ cond_stage_config:
79
+ target: ldm.modules.encoders.modules.FrozenCLIPEmbedder
microsoftexcel-controlnet/models/control_v11e_sd15_ip2p.yaml ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ model:
2
+ target: cldm.cldm.ControlLDM
3
+ params:
4
+ linear_start: 0.00085
5
+ linear_end: 0.0120
6
+ num_timesteps_cond: 1
7
+ log_every_t: 200
8
+ timesteps: 1000
9
+ first_stage_key: "jpg"
10
+ cond_stage_key: "txt"
11
+ control_key: "hint"
12
+ image_size: 64
13
+ channels: 4
14
+ cond_stage_trainable: false
15
+ conditioning_key: crossattn
16
+ monitor: val/loss_simple_ema
17
+ scale_factor: 0.18215
18
+ use_ema: False
19
+ only_mid_control: False
20
+
21
+ control_stage_config:
22
+ target: cldm.cldm.ControlNet
23
+ params:
24
+ image_size: 32 # unused
25
+ in_channels: 4
26
+ hint_channels: 3
27
+ model_channels: 320
28
+ attention_resolutions: [ 4, 2, 1 ]
29
+ num_res_blocks: 2
30
+ channel_mult: [ 1, 2, 4, 4 ]
31
+ num_heads: 8
32
+ use_spatial_transformer: True
33
+ transformer_depth: 1
34
+ context_dim: 768
35
+ use_checkpoint: True
36
+ legacy: False
37
+
38
+ unet_config:
39
+ target: cldm.cldm.ControlledUnetModel
40
+ params:
41
+ image_size: 32 # unused
42
+ in_channels: 4
43
+ out_channels: 4
44
+ model_channels: 320
45
+ attention_resolutions: [ 4, 2, 1 ]
46
+ num_res_blocks: 2
47
+ channel_mult: [ 1, 2, 4, 4 ]
48
+ num_heads: 8
49
+ use_spatial_transformer: True
50
+ transformer_depth: 1
51
+ context_dim: 768
52
+ use_checkpoint: True
53
+ legacy: False
54
+
55
+ first_stage_config:
56
+ target: ldm.models.autoencoder.AutoencoderKL
57
+ params:
58
+ embed_dim: 4
59
+ monitor: val/rec_loss
60
+ ddconfig:
61
+ double_z: true
62
+ z_channels: 4
63
+ resolution: 256
64
+ in_channels: 3
65
+ out_ch: 3
66
+ ch: 128
67
+ ch_mult:
68
+ - 1
69
+ - 2
70
+ - 4
71
+ - 4
72
+ num_res_blocks: 2
73
+ attn_resolutions: []
74
+ dropout: 0.0
75
+ lossconfig:
76
+ target: torch.nn.Identity
77
+
78
+ cond_stage_config:
79
+ target: ldm.modules.encoders.modules.FrozenCLIPEmbedder
microsoftexcel-controlnet/models/control_v11e_sd15_shuffle.yaml ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ model:
2
+ target: cldm.cldm.ControlLDM
3
+ params:
4
+ linear_start: 0.00085
5
+ linear_end: 0.0120
6
+ num_timesteps_cond: 1
7
+ log_every_t: 200
8
+ timesteps: 1000
9
+ first_stage_key: "jpg"
10
+ cond_stage_key: "txt"
11
+ control_key: "hint"
12
+ image_size: 64
13
+ channels: 4
14
+ cond_stage_trainable: false
15
+ conditioning_key: crossattn
16
+ monitor: val/loss_simple_ema
17
+ scale_factor: 0.18215
18
+ use_ema: False
19
+ only_mid_control: False
20
+ global_average_pooling: True
21
+
22
+ control_stage_config:
23
+ target: cldm.cldm.ControlNet
24
+ params:
25
+ image_size: 32 # unused
26
+ in_channels: 4
27
+ hint_channels: 3
28
+ model_channels: 320
29
+ attention_resolutions: [ 4, 2, 1 ]
30
+ num_res_blocks: 2
31
+ channel_mult: [ 1, 2, 4, 4 ]
32
+ num_heads: 8
33
+ use_spatial_transformer: True
34
+ transformer_depth: 1
35
+ context_dim: 768
36
+ use_checkpoint: True
37
+ legacy: False
38
+
39
+ unet_config:
40
+ target: cldm.cldm.ControlledUnetModel
41
+ params:
42
+ image_size: 32 # unused
43
+ in_channels: 4
44
+ out_channels: 4
45
+ model_channels: 320
46
+ attention_resolutions: [ 4, 2, 1 ]
47
+ num_res_blocks: 2
48
+ channel_mult: [ 1, 2, 4, 4 ]
49
+ num_heads: 8
50
+ use_spatial_transformer: True
51
+ transformer_depth: 1
52
+ context_dim: 768
53
+ use_checkpoint: True
54
+ legacy: False
55
+
56
+ first_stage_config:
57
+ target: ldm.models.autoencoder.AutoencoderKL
58
+ params:
59
+ embed_dim: 4
60
+ monitor: val/rec_loss
61
+ ddconfig:
62
+ double_z: true
63
+ z_channels: 4
64
+ resolution: 256
65
+ in_channels: 3
66
+ out_ch: 3
67
+ ch: 128
68
+ ch_mult:
69
+ - 1
70
+ - 2
71
+ - 4
72
+ - 4
73
+ num_res_blocks: 2
74
+ attn_resolutions: []
75
+ dropout: 0.0
76
+ lossconfig:
77
+ target: torch.nn.Identity
78
+
79
+ cond_stage_config:
80
+ target: ldm.modules.encoders.modules.FrozenCLIPEmbedder
microsoftexcel-controlnet/models/control_v11f1e_sd15_tile.yaml ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ model:
2
+ target: cldm.cldm.ControlLDM
3
+ params:
4
+ linear_start: 0.00085
5
+ linear_end: 0.0120
6
+ num_timesteps_cond: 1
7
+ log_every_t: 200
8
+ timesteps: 1000
9
+ first_stage_key: "jpg"
10
+ cond_stage_key: "txt"
11
+ control_key: "hint"
12
+ image_size: 64
13
+ channels: 4
14
+ cond_stage_trainable: false
15
+ conditioning_key: crossattn
16
+ monitor: val/loss_simple_ema
17
+ scale_factor: 0.18215
18
+ use_ema: False
19
+ only_mid_control: False
20
+
21
+ control_stage_config:
22
+ target: cldm.cldm.ControlNet
23
+ params:
24
+ image_size: 32 # unused
25
+ in_channels: 4
26
+ hint_channels: 3
27
+ model_channels: 320
28
+ attention_resolutions: [ 4, 2, 1 ]
29
+ num_res_blocks: 2
30
+ channel_mult: [ 1, 2, 4, 4 ]
31
+ num_heads: 8
32
+ use_spatial_transformer: True
33
+ transformer_depth: 1
34
+ context_dim: 768
35
+ use_checkpoint: True
36
+ legacy: False
37
+
38
+ unet_config:
39
+ target: cldm.cldm.ControlledUnetModel
40
+ params:
41
+ image_size: 32 # unused
42
+ in_channels: 4
43
+ out_channels: 4
44
+ model_channels: 320
45
+ attention_resolutions: [ 4, 2, 1 ]
46
+ num_res_blocks: 2
47
+ channel_mult: [ 1, 2, 4, 4 ]
48
+ num_heads: 8
49
+ use_spatial_transformer: True
50
+ transformer_depth: 1
51
+ context_dim: 768
52
+ use_checkpoint: True
53
+ legacy: False
54
+
55
+ first_stage_config:
56
+ target: ldm.models.autoencoder.AutoencoderKL
57
+ params:
58
+ embed_dim: 4
59
+ monitor: val/rec_loss
60
+ ddconfig:
61
+ double_z: true
62
+ z_channels: 4
63
+ resolution: 256
64
+ in_channels: 3
65
+ out_ch: 3
66
+ ch: 128
67
+ ch_mult:
68
+ - 1
69
+ - 2
70
+ - 4
71
+ - 4
72
+ num_res_blocks: 2
73
+ attn_resolutions: []
74
+ dropout: 0.0
75
+ lossconfig:
76
+ target: torch.nn.Identity
77
+
78
+ cond_stage_config:
79
+ target: ldm.modules.encoders.modules.FrozenCLIPEmbedder
microsoftexcel-controlnet/models/control_v11f1p_sd15_depth.yaml ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ model:
2
+ target: cldm.cldm.ControlLDM
3
+ params:
4
+ linear_start: 0.00085
5
+ linear_end: 0.0120
6
+ num_timesteps_cond: 1
7
+ log_every_t: 200
8
+ timesteps: 1000
9
+ first_stage_key: "jpg"
10
+ cond_stage_key: "txt"
11
+ control_key: "hint"
12
+ image_size: 64
13
+ channels: 4
14
+ cond_stage_trainable: false
15
+ conditioning_key: crossattn
16
+ monitor: val/loss_simple_ema
17
+ scale_factor: 0.18215
18
+ use_ema: False
19
+ only_mid_control: False
20
+
21
+ control_stage_config:
22
+ target: cldm.cldm.ControlNet
23
+ params:
24
+ image_size: 32 # unused
25
+ in_channels: 4
26
+ hint_channels: 3
27
+ model_channels: 320
28
+ attention_resolutions: [ 4, 2, 1 ]
29
+ num_res_blocks: 2
30
+ channel_mult: [ 1, 2, 4, 4 ]
31
+ num_heads: 8
32
+ use_spatial_transformer: True
33
+ transformer_depth: 1
34
+ context_dim: 768
35
+ use_checkpoint: True
36
+ legacy: False
37
+
38
+ unet_config:
39
+ target: cldm.cldm.ControlledUnetModel
40
+ params:
41
+ image_size: 32 # unused
42
+ in_channels: 4
43
+ out_channels: 4
44
+ model_channels: 320
45
+ attention_resolutions: [ 4, 2, 1 ]
46
+ num_res_blocks: 2
47
+ channel_mult: [ 1, 2, 4, 4 ]
48
+ num_heads: 8
49
+ use_spatial_transformer: True
50
+ transformer_depth: 1
51
+ context_dim: 768
52
+ use_checkpoint: True
53
+ legacy: False
54
+
55
+ first_stage_config:
56
+ target: ldm.models.autoencoder.AutoencoderKL
57
+ params:
58
+ embed_dim: 4
59
+ monitor: val/rec_loss
60
+ ddconfig:
61
+ double_z: true
62
+ z_channels: 4
63
+ resolution: 256
64
+ in_channels: 3
65
+ out_ch: 3
66
+ ch: 128
67
+ ch_mult:
68
+ - 1
69
+ - 2
70
+ - 4
71
+ - 4
72
+ num_res_blocks: 2
73
+ attn_resolutions: []
74
+ dropout: 0.0
75
+ lossconfig:
76
+ target: torch.nn.Identity
77
+
78
+ cond_stage_config:
79
+ target: ldm.modules.encoders.modules.FrozenCLIPEmbedder
microsoftexcel-controlnet/models/control_v11p_sd15_canny.yaml ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ model:
2
+ target: cldm.cldm.ControlLDM
3
+ params:
4
+ linear_start: 0.00085
5
+ linear_end: 0.0120
6
+ num_timesteps_cond: 1
7
+ log_every_t: 200
8
+ timesteps: 1000
9
+ first_stage_key: "jpg"
10
+ cond_stage_key: "txt"
11
+ control_key: "hint"
12
+ image_size: 64
13
+ channels: 4
14
+ cond_stage_trainable: false
15
+ conditioning_key: crossattn
16
+ monitor: val/loss_simple_ema
17
+ scale_factor: 0.18215
18
+ use_ema: False
19
+ only_mid_control: False
20
+
21
+ control_stage_config:
22
+ target: cldm.cldm.ControlNet
23
+ params:
24
+ image_size: 32 # unused
25
+ in_channels: 4
26
+ hint_channels: 3
27
+ model_channels: 320
28
+ attention_resolutions: [ 4, 2, 1 ]
29
+ num_res_blocks: 2
30
+ channel_mult: [ 1, 2, 4, 4 ]
31
+ num_heads: 8
32
+ use_spatial_transformer: True
33
+ transformer_depth: 1
34
+ context_dim: 768
35
+ use_checkpoint: True
36
+ legacy: False
37
+
38
+ unet_config:
39
+ target: cldm.cldm.ControlledUnetModel
40
+ params:
41
+ image_size: 32 # unused
42
+ in_channels: 4
43
+ out_channels: 4
44
+ model_channels: 320
45
+ attention_resolutions: [ 4, 2, 1 ]
46
+ num_res_blocks: 2
47
+ channel_mult: [ 1, 2, 4, 4 ]
48
+ num_heads: 8
49
+ use_spatial_transformer: True
50
+ transformer_depth: 1
51
+ context_dim: 768
52
+ use_checkpoint: True
53
+ legacy: False
54
+
55
+ first_stage_config:
56
+ target: ldm.models.autoencoder.AutoencoderKL
57
+ params:
58
+ embed_dim: 4
59
+ monitor: val/rec_loss
60
+ ddconfig:
61
+ double_z: true
62
+ z_channels: 4
63
+ resolution: 256
64
+ in_channels: 3
65
+ out_ch: 3
66
+ ch: 128
67
+ ch_mult:
68
+ - 1
69
+ - 2
70
+ - 4
71
+ - 4
72
+ num_res_blocks: 2
73
+ attn_resolutions: []
74
+ dropout: 0.0
75
+ lossconfig:
76
+ target: torch.nn.Identity
77
+
78
+ cond_stage_config:
79
+ target: ldm.modules.encoders.modules.FrozenCLIPEmbedder
microsoftexcel-controlnet/models/control_v11p_sd15_inpaint.yaml ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ model:
2
+ target: cldm.cldm.ControlLDM
3
+ params:
4
+ linear_start: 0.00085
5
+ linear_end: 0.0120
6
+ num_timesteps_cond: 1
7
+ log_every_t: 200
8
+ timesteps: 1000
9
+ first_stage_key: "jpg"
10
+ cond_stage_key: "txt"
11
+ control_key: "hint"
12
+ image_size: 64
13
+ channels: 4
14
+ cond_stage_trainable: false
15
+ conditioning_key: crossattn
16
+ monitor: val/loss_simple_ema
17
+ scale_factor: 0.18215
18
+ use_ema: False
19
+ only_mid_control: False
20
+
21
+ control_stage_config:
22
+ target: cldm.cldm.ControlNet
23
+ params:
24
+ image_size: 32 # unused
25
+ in_channels: 4
26
+ hint_channels: 3
27
+ model_channels: 320
28
+ attention_resolutions: [ 4, 2, 1 ]
29
+ num_res_blocks: 2
30
+ channel_mult: [ 1, 2, 4, 4 ]
31
+ num_heads: 8
32
+ use_spatial_transformer: True
33
+ transformer_depth: 1
34
+ context_dim: 768
35
+ use_checkpoint: True
36
+ legacy: False
37
+
38
+ unet_config:
39
+ target: cldm.cldm.ControlledUnetModel
40
+ params:
41
+ image_size: 32 # unused
42
+ in_channels: 4
43
+ out_channels: 4
44
+ model_channels: 320
45
+ attention_resolutions: [ 4, 2, 1 ]
46
+ num_res_blocks: 2
47
+ channel_mult: [ 1, 2, 4, 4 ]
48
+ num_heads: 8
49
+ use_spatial_transformer: True
50
+ transformer_depth: 1
51
+ context_dim: 768
52
+ use_checkpoint: True
53
+ legacy: False
54
+
55
+ first_stage_config:
56
+ target: ldm.models.autoencoder.AutoencoderKL
57
+ params:
58
+ embed_dim: 4
59
+ monitor: val/rec_loss
60
+ ddconfig:
61
+ double_z: true
62
+ z_channels: 4
63
+ resolution: 256
64
+ in_channels: 3
65
+ out_ch: 3
66
+ ch: 128
67
+ ch_mult:
68
+ - 1
69
+ - 2
70
+ - 4
71
+ - 4
72
+ num_res_blocks: 2
73
+ attn_resolutions: []
74
+ dropout: 0.0
75
+ lossconfig:
76
+ target: torch.nn.Identity
77
+
78
+ cond_stage_config:
79
+ target: ldm.modules.encoders.modules.FrozenCLIPEmbedder
microsoftexcel-controlnet/models/control_v11p_sd15_lineart.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:10559106d1bb8196298b7a81565ede9279295d2b2df15165b9dbe189994def56
3
+ size 722601100
microsoftexcel-controlnet/models/control_v11p_sd15_lineart.yaml ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ model:
2
+ target: cldm.cldm.ControlLDM
3
+ params:
4
+ linear_start: 0.00085
5
+ linear_end: 0.0120
6
+ num_timesteps_cond: 1
7
+ log_every_t: 200
8
+ timesteps: 1000
9
+ first_stage_key: "jpg"
10
+ cond_stage_key: "txt"
11
+ control_key: "hint"
12
+ image_size: 64
13
+ channels: 4
14
+ cond_stage_trainable: false
15
+ conditioning_key: crossattn
16
+ monitor: val/loss_simple_ema
17
+ scale_factor: 0.18215
18
+ use_ema: False
19
+ only_mid_control: False
20
+
21
+ control_stage_config:
22
+ target: cldm.cldm.ControlNet
23
+ params:
24
+ image_size: 32 # unused
25
+ in_channels: 4
26
+ hint_channels: 3
27
+ model_channels: 320
28
+ attention_resolutions: [ 4, 2, 1 ]
29
+ num_res_blocks: 2
30
+ channel_mult: [ 1, 2, 4, 4 ]
31
+ num_heads: 8
32
+ use_spatial_transformer: True
33
+ transformer_depth: 1
34
+ context_dim: 768
35
+ use_checkpoint: True
36
+ legacy: False
37
+
38
+ unet_config:
39
+ target: cldm.cldm.ControlledUnetModel
40
+ params:
41
+ image_size: 32 # unused
42
+ in_channels: 4
43
+ out_channels: 4
44
+ model_channels: 320
45
+ attention_resolutions: [ 4, 2, 1 ]
46
+ num_res_blocks: 2
47
+ channel_mult: [ 1, 2, 4, 4 ]
48
+ num_heads: 8
49
+ use_spatial_transformer: True
50
+ transformer_depth: 1
51
+ context_dim: 768
52
+ use_checkpoint: True
53
+ legacy: False
54
+
55
+ first_stage_config:
56
+ target: ldm.models.autoencoder.AutoencoderKL
57
+ params:
58
+ embed_dim: 4
59
+ monitor: val/rec_loss
60
+ ddconfig:
61
+ double_z: true
62
+ z_channels: 4
63
+ resolution: 256
64
+ in_channels: 3
65
+ out_ch: 3
66
+ ch: 128
67
+ ch_mult:
68
+ - 1
69
+ - 2
70
+ - 4
71
+ - 4
72
+ num_res_blocks: 2
73
+ attn_resolutions: []
74
+ dropout: 0.0
75
+ lossconfig:
76
+ target: torch.nn.Identity
77
+
78
+ cond_stage_config:
79
+ target: ldm.modules.encoders.modules.FrozenCLIPEmbedder
microsoftexcel-controlnet/models/control_v11p_sd15_mlsd.yaml ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ model:
2
+ target: cldm.cldm.ControlLDM
3
+ params:
4
+ linear_start: 0.00085
5
+ linear_end: 0.0120
6
+ num_timesteps_cond: 1
7
+ log_every_t: 200
8
+ timesteps: 1000
9
+ first_stage_key: "jpg"
10
+ cond_stage_key: "txt"
11
+ control_key: "hint"
12
+ image_size: 64
13
+ channels: 4
14
+ cond_stage_trainable: false
15
+ conditioning_key: crossattn
16
+ monitor: val/loss_simple_ema
17
+ scale_factor: 0.18215
18
+ use_ema: False
19
+ only_mid_control: False
20
+
21
+ control_stage_config:
22
+ target: cldm.cldm.ControlNet
23
+ params:
24
+ image_size: 32 # unused
25
+ in_channels: 4
26
+ hint_channels: 3
27
+ model_channels: 320
28
+ attention_resolutions: [ 4, 2, 1 ]
29
+ num_res_blocks: 2
30
+ channel_mult: [ 1, 2, 4, 4 ]
31
+ num_heads: 8
32
+ use_spatial_transformer: True
33
+ transformer_depth: 1
34
+ context_dim: 768
35
+ use_checkpoint: True
36
+ legacy: False
37
+
38
+ unet_config:
39
+ target: cldm.cldm.ControlledUnetModel
40
+ params:
41
+ image_size: 32 # unused
42
+ in_channels: 4
43
+ out_channels: 4
44
+ model_channels: 320
45
+ attention_resolutions: [ 4, 2, 1 ]
46
+ num_res_blocks: 2
47
+ channel_mult: [ 1, 2, 4, 4 ]
48
+ num_heads: 8
49
+ use_spatial_transformer: True
50
+ transformer_depth: 1
51
+ context_dim: 768
52
+ use_checkpoint: True
53
+ legacy: False
54
+
55
+ first_stage_config:
56
+ target: ldm.models.autoencoder.AutoencoderKL
57
+ params:
58
+ embed_dim: 4
59
+ monitor: val/rec_loss
60
+ ddconfig:
61
+ double_z: true
62
+ z_channels: 4
63
+ resolution: 256
64
+ in_channels: 3
65
+ out_ch: 3
66
+ ch: 128
67
+ ch_mult:
68
+ - 1
69
+ - 2
70
+ - 4
71
+ - 4
72
+ num_res_blocks: 2
73
+ attn_resolutions: []
74
+ dropout: 0.0
75
+ lossconfig:
76
+ target: torch.nn.Identity
77
+
78
+ cond_stage_config:
79
+ target: ldm.modules.encoders.modules.FrozenCLIPEmbedder
microsoftexcel-controlnet/models/control_v11p_sd15_normalbae.yaml ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ model:
2
+ target: cldm.cldm.ControlLDM
3
+ params:
4
+ linear_start: 0.00085
5
+ linear_end: 0.0120
6
+ num_timesteps_cond: 1
7
+ log_every_t: 200
8
+ timesteps: 1000
9
+ first_stage_key: "jpg"
10
+ cond_stage_key: "txt"
11
+ control_key: "hint"
12
+ image_size: 64
13
+ channels: 4
14
+ cond_stage_trainable: false
15
+ conditioning_key: crossattn
16
+ monitor: val/loss_simple_ema
17
+ scale_factor: 0.18215
18
+ use_ema: False
19
+ only_mid_control: False
20
+
21
+ control_stage_config:
22
+ target: cldm.cldm.ControlNet
23
+ params:
24
+ image_size: 32 # unused
25
+ in_channels: 4
26
+ hint_channels: 3
27
+ model_channels: 320
28
+ attention_resolutions: [ 4, 2, 1 ]
29
+ num_res_blocks: 2
30
+ channel_mult: [ 1, 2, 4, 4 ]
31
+ num_heads: 8
32
+ use_spatial_transformer: True
33
+ transformer_depth: 1
34
+ context_dim: 768
35
+ use_checkpoint: True
36
+ legacy: False
37
+
38
+ unet_config:
39
+ target: cldm.cldm.ControlledUnetModel
40
+ params:
41
+ image_size: 32 # unused
42
+ in_channels: 4
43
+ out_channels: 4
44
+ model_channels: 320
45
+ attention_resolutions: [ 4, 2, 1 ]
46
+ num_res_blocks: 2
47
+ channel_mult: [ 1, 2, 4, 4 ]
48
+ num_heads: 8
49
+ use_spatial_transformer: True
50
+ transformer_depth: 1
51
+ context_dim: 768
52
+ use_checkpoint: True
53
+ legacy: False
54
+
55
+ first_stage_config:
56
+ target: ldm.models.autoencoder.AutoencoderKL
57
+ params:
58
+ embed_dim: 4
59
+ monitor: val/rec_loss
60
+ ddconfig:
61
+ double_z: true
62
+ z_channels: 4
63
+ resolution: 256
64
+ in_channels: 3
65
+ out_ch: 3
66
+ ch: 128
67
+ ch_mult:
68
+ - 1
69
+ - 2
70
+ - 4
71
+ - 4
72
+ num_res_blocks: 2
73
+ attn_resolutions: []
74
+ dropout: 0.0
75
+ lossconfig:
76
+ target: torch.nn.Identity
77
+
78
+ cond_stage_config:
79
+ target: ldm.modules.encoders.modules.FrozenCLIPEmbedder
microsoftexcel-controlnet/models/control_v11p_sd15_openpose.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4003c1da17b0e4ba444e02140e1c0d83bb24b79e4dcfd613c3a554d38f0f89c7
3
+ size 722601100
microsoftexcel-controlnet/models/control_v11p_sd15_openpose.yaml ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ model:
2
+ target: cldm.cldm.ControlLDM
3
+ params:
4
+ linear_start: 0.00085
5
+ linear_end: 0.0120
6
+ num_timesteps_cond: 1
7
+ log_every_t: 200
8
+ timesteps: 1000
9
+ first_stage_key: "jpg"
10
+ cond_stage_key: "txt"
11
+ control_key: "hint"
12
+ image_size: 64
13
+ channels: 4
14
+ cond_stage_trainable: false
15
+ conditioning_key: crossattn
16
+ monitor: val/loss_simple_ema
17
+ scale_factor: 0.18215
18
+ use_ema: False
19
+ only_mid_control: False
20
+
21
+ control_stage_config:
22
+ target: cldm.cldm.ControlNet
23
+ params:
24
+ image_size: 32 # unused
25
+ in_channels: 4
26
+ hint_channels: 3
27
+ model_channels: 320
28
+ attention_resolutions: [ 4, 2, 1 ]
29
+ num_res_blocks: 2
30
+ channel_mult: [ 1, 2, 4, 4 ]
31
+ num_heads: 8
32
+ use_spatial_transformer: True
33
+ transformer_depth: 1
34
+ context_dim: 768
35
+ use_checkpoint: True
36
+ legacy: False
37
+
38
+ unet_config:
39
+ target: cldm.cldm.ControlledUnetModel
40
+ params:
41
+ image_size: 32 # unused
42
+ in_channels: 4
43
+ out_channels: 4
44
+ model_channels: 320
45
+ attention_resolutions: [ 4, 2, 1 ]
46
+ num_res_blocks: 2
47
+ channel_mult: [ 1, 2, 4, 4 ]
48
+ num_heads: 8
49
+ use_spatial_transformer: True
50
+ transformer_depth: 1
51
+ context_dim: 768
52
+ use_checkpoint: True
53
+ legacy: False
54
+
55
+ first_stage_config:
56
+ target: ldm.models.autoencoder.AutoencoderKL
57
+ params:
58
+ embed_dim: 4
59
+ monitor: val/rec_loss
60
+ ddconfig:
61
+ double_z: true
62
+ z_channels: 4
63
+ resolution: 256
64
+ in_channels: 3
65
+ out_ch: 3
66
+ ch: 128
67
+ ch_mult:
68
+ - 1
69
+ - 2
70
+ - 4
71
+ - 4
72
+ num_res_blocks: 2
73
+ attn_resolutions: []
74
+ dropout: 0.0
75
+ lossconfig:
76
+ target: torch.nn.Identity
77
+
78
+ cond_stage_config:
79
+ target: ldm.modules.encoders.modules.FrozenCLIPEmbedder
microsoftexcel-controlnet/models/control_v11p_sd15_scribble.yaml ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ model:
2
+ target: cldm.cldm.ControlLDM
3
+ params:
4
+ linear_start: 0.00085
5
+ linear_end: 0.0120
6
+ num_timesteps_cond: 1
7
+ log_every_t: 200
8
+ timesteps: 1000
9
+ first_stage_key: "jpg"
10
+ cond_stage_key: "txt"
11
+ control_key: "hint"
12
+ image_size: 64
13
+ channels: 4
14
+ cond_stage_trainable: false
15
+ conditioning_key: crossattn
16
+ monitor: val/loss_simple_ema
17
+ scale_factor: 0.18215
18
+ use_ema: False
19
+ only_mid_control: False
20
+
21
+ control_stage_config:
22
+ target: cldm.cldm.ControlNet
23
+ params:
24
+ image_size: 32 # unused
25
+ in_channels: 4
26
+ hint_channels: 3
27
+ model_channels: 320
28
+ attention_resolutions: [ 4, 2, 1 ]
29
+ num_res_blocks: 2
30
+ channel_mult: [ 1, 2, 4, 4 ]
31
+ num_heads: 8
32
+ use_spatial_transformer: True
33
+ transformer_depth: 1
34
+ context_dim: 768
35
+ use_checkpoint: True
36
+ legacy: False
37
+
38
+ unet_config:
39
+ target: cldm.cldm.ControlledUnetModel
40
+ params:
41
+ image_size: 32 # unused
42
+ in_channels: 4
43
+ out_channels: 4
44
+ model_channels: 320
45
+ attention_resolutions: [ 4, 2, 1 ]
46
+ num_res_blocks: 2
47
+ channel_mult: [ 1, 2, 4, 4 ]
48
+ num_heads: 8
49
+ use_spatial_transformer: True
50
+ transformer_depth: 1
51
+ context_dim: 768
52
+ use_checkpoint: True
53
+ legacy: False
54
+
55
+ first_stage_config:
56
+ target: ldm.models.autoencoder.AutoencoderKL
57
+ params:
58
+ embed_dim: 4
59
+ monitor: val/rec_loss
60
+ ddconfig:
61
+ double_z: true
62
+ z_channels: 4
63
+ resolution: 256
64
+ in_channels: 3
65
+ out_ch: 3
66
+ ch: 128
67
+ ch_mult:
68
+ - 1
69
+ - 2
70
+ - 4
71
+ - 4
72
+ num_res_blocks: 2
73
+ attn_resolutions: []
74
+ dropout: 0.0
75
+ lossconfig:
76
+ target: torch.nn.Identity
77
+
78
+ cond_stage_config:
79
+ target: ldm.modules.encoders.modules.FrozenCLIPEmbedder
microsoftexcel-controlnet/models/control_v11p_sd15_seg.yaml ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ model:
2
+ target: cldm.cldm.ControlLDM
3
+ params:
4
+ linear_start: 0.00085
5
+ linear_end: 0.0120
6
+ num_timesteps_cond: 1
7
+ log_every_t: 200
8
+ timesteps: 1000
9
+ first_stage_key: "jpg"
10
+ cond_stage_key: "txt"
11
+ control_key: "hint"
12
+ image_size: 64
13
+ channels: 4
14
+ cond_stage_trainable: false
15
+ conditioning_key: crossattn
16
+ monitor: val/loss_simple_ema
17
+ scale_factor: 0.18215
18
+ use_ema: False
19
+ only_mid_control: False
20
+
21
+ control_stage_config:
22
+ target: cldm.cldm.ControlNet
23
+ params:
24
+ image_size: 32 # unused
25
+ in_channels: 4
26
+ hint_channels: 3
27
+ model_channels: 320
28
+ attention_resolutions: [ 4, 2, 1 ]
29
+ num_res_blocks: 2
30
+ channel_mult: [ 1, 2, 4, 4 ]
31
+ num_heads: 8
32
+ use_spatial_transformer: True
33
+ transformer_depth: 1
34
+ context_dim: 768
35
+ use_checkpoint: True
36
+ legacy: False
37
+
38
+ unet_config:
39
+ target: cldm.cldm.ControlledUnetModel
40
+ params:
41
+ image_size: 32 # unused
42
+ in_channels: 4
43
+ out_channels: 4
44
+ model_channels: 320
45
+ attention_resolutions: [ 4, 2, 1 ]
46
+ num_res_blocks: 2
47
+ channel_mult: [ 1, 2, 4, 4 ]
48
+ num_heads: 8
49
+ use_spatial_transformer: True
50
+ transformer_depth: 1
51
+ context_dim: 768
52
+ use_checkpoint: True
53
+ legacy: False
54
+
55
+ first_stage_config:
56
+ target: ldm.models.autoencoder.AutoencoderKL
57
+ params:
58
+ embed_dim: 4
59
+ monitor: val/rec_loss
60
+ ddconfig:
61
+ double_z: true
62
+ z_channels: 4
63
+ resolution: 256
64
+ in_channels: 3
65
+ out_ch: 3
66
+ ch: 128
67
+ ch_mult:
68
+ - 1
69
+ - 2
70
+ - 4
71
+ - 4
72
+ num_res_blocks: 2
73
+ attn_resolutions: []
74
+ dropout: 0.0
75
+ lossconfig:
76
+ target: torch.nn.Identity
77
+
78
+ cond_stage_config:
79
+ target: ldm.modules.encoders.modules.FrozenCLIPEmbedder
microsoftexcel-controlnet/models/control_v11p_sd15_softedge.yaml ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ model:
2
+ target: cldm.cldm.ControlLDM
3
+ params:
4
+ linear_start: 0.00085
5
+ linear_end: 0.0120
6
+ num_timesteps_cond: 1
7
+ log_every_t: 200
8
+ timesteps: 1000
9
+ first_stage_key: "jpg"
10
+ cond_stage_key: "txt"
11
+ control_key: "hint"
12
+ image_size: 64
13
+ channels: 4
14
+ cond_stage_trainable: false
15
+ conditioning_key: crossattn
16
+ monitor: val/loss_simple_ema
17
+ scale_factor: 0.18215
18
+ use_ema: False
19
+ only_mid_control: False
20
+
21
+ control_stage_config:
22
+ target: cldm.cldm.ControlNet
23
+ params:
24
+ image_size: 32 # unused
25
+ in_channels: 4
26
+ hint_channels: 3
27
+ model_channels: 320
28
+ attention_resolutions: [ 4, 2, 1 ]
29
+ num_res_blocks: 2
30
+ channel_mult: [ 1, 2, 4, 4 ]
31
+ num_heads: 8
32
+ use_spatial_transformer: True
33
+ transformer_depth: 1
34
+ context_dim: 768
35
+ use_checkpoint: True
36
+ legacy: False
37
+
38
+ unet_config:
39
+ target: cldm.cldm.ControlledUnetModel
40
+ params:
41
+ image_size: 32 # unused
42
+ in_channels: 4
43
+ out_channels: 4
44
+ model_channels: 320
45
+ attention_resolutions: [ 4, 2, 1 ]
46
+ num_res_blocks: 2
47
+ channel_mult: [ 1, 2, 4, 4 ]
48
+ num_heads: 8
49
+ use_spatial_transformer: True
50
+ transformer_depth: 1
51
+ context_dim: 768
52
+ use_checkpoint: True
53
+ legacy: False
54
+
55
+ first_stage_config:
56
+ target: ldm.models.autoencoder.AutoencoderKL
57
+ params:
58
+ embed_dim: 4
59
+ monitor: val/rec_loss
60
+ ddconfig:
61
+ double_z: true
62
+ z_channels: 4
63
+ resolution: 256
64
+ in_channels: 3
65
+ out_ch: 3
66
+ ch: 128
67
+ ch_mult:
68
+ - 1
69
+ - 2
70
+ - 4
71
+ - 4
72
+ num_res_blocks: 2
73
+ attn_resolutions: []
74
+ dropout: 0.0
75
+ lossconfig:
76
+ target: torch.nn.Identity
77
+
78
+ cond_stage_config:
79
+ target: ldm.modules.encoders.modules.FrozenCLIPEmbedder