patrickvonplaten commited on
Commit
ac83cb5
1 Parent(s): 714a42b

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +159 -3
README.md CHANGED
@@ -76,7 +76,165 @@ Experimentally, the checkpoint can be used with other diffusion models such as d
76
  $ pip install diffusers transformers accelerate
77
  ```
78
 
79
- 2. Run code:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
 
81
  ```py
82
  from transformers import AutoImageProcessor, UperNetForSemanticSegmentation
@@ -101,8 +259,6 @@ seg = image_processor.post_process_semantic_segmentation(outputs, target_sizes=[
101
 
102
  color_seg = np.zeros((seg.shape[0], seg.shape[1], 3), dtype=np.uint8) # height, width, 3
103
 
104
- palette = np.array(ade_palette())
105
-
106
  for label, color in enumerate(palette):
107
  color_seg[seg == label, :] = color
108
 
 
76
  $ pip install diffusers transformers accelerate
77
  ```
78
 
79
+ 2. We'll need to make use of a color palette here as described in [semantic_segmentation](https://huggingface.co/docs/transformers/tasks/semantic_segmentation):
80
+
81
+ ```py
82
+ palette = np.asarray([
83
+ [0, 0, 0],
84
+ [120, 120, 120],
85
+ [180, 120, 120],
86
+ [6, 230, 230],
87
+ [80, 50, 50],
88
+ [4, 200, 3],
89
+ [120, 120, 80],
90
+ [140, 140, 140],
91
+ [204, 5, 255],
92
+ [230, 230, 230],
93
+ [4, 250, 7],
94
+ [224, 5, 255],
95
+ [235, 255, 7],
96
+ [150, 5, 61],
97
+ [120, 120, 70],
98
+ [8, 255, 51],
99
+ [255, 6, 82],
100
+ [143, 255, 140],
101
+ [204, 255, 4],
102
+ [255, 51, 7],
103
+ [204, 70, 3],
104
+ [0, 102, 200],
105
+ [61, 230, 250],
106
+ [255, 6, 51],
107
+ [11, 102, 255],
108
+ [255, 7, 71],
109
+ [255, 9, 224],
110
+ [9, 7, 230],
111
+ [220, 220, 220],
112
+ [255, 9, 92],
113
+ [112, 9, 255],
114
+ [8, 255, 214],
115
+ [7, 255, 224],
116
+ [255, 184, 6],
117
+ [10, 255, 71],
118
+ [255, 41, 10],
119
+ [7, 255, 255],
120
+ [224, 255, 8],
121
+ [102, 8, 255],
122
+ [255, 61, 6],
123
+ [255, 194, 7],
124
+ [255, 122, 8],
125
+ [0, 255, 20],
126
+ [255, 8, 41],
127
+ [255, 5, 153],
128
+ [6, 51, 255],
129
+ [235, 12, 255],
130
+ [160, 150, 20],
131
+ [0, 163, 255],
132
+ [140, 140, 140],
133
+ [250, 10, 15],
134
+ [20, 255, 0],
135
+ [31, 255, 0],
136
+ [255, 31, 0],
137
+ [255, 224, 0],
138
+ [153, 255, 0],
139
+ [0, 0, 255],
140
+ [255, 71, 0],
141
+ [0, 235, 255],
142
+ [0, 173, 255],
143
+ [31, 0, 255],
144
+ [11, 200, 200],
145
+ [255, 82, 0],
146
+ [0, 255, 245],
147
+ [0, 61, 255],
148
+ [0, 255, 112],
149
+ [0, 255, 133],
150
+ [255, 0, 0],
151
+ [255, 163, 0],
152
+ [255, 102, 0],
153
+ [194, 255, 0],
154
+ [0, 143, 255],
155
+ [51, 255, 0],
156
+ [0, 82, 255],
157
+ [0, 255, 41],
158
+ [0, 255, 173],
159
+ [10, 0, 255],
160
+ [173, 255, 0],
161
+ [0, 255, 153],
162
+ [255, 92, 0],
163
+ [255, 0, 255],
164
+ [255, 0, 245],
165
+ [255, 0, 102],
166
+ [255, 173, 0],
167
+ [255, 0, 20],
168
+ [255, 184, 184],
169
+ [0, 31, 255],
170
+ [0, 255, 61],
171
+ [0, 71, 255],
172
+ [255, 0, 204],
173
+ [0, 255, 194],
174
+ [0, 255, 82],
175
+ [0, 10, 255],
176
+ [0, 112, 255],
177
+ [51, 0, 255],
178
+ [0, 194, 255],
179
+ [0, 122, 255],
180
+ [0, 255, 163],
181
+ [255, 153, 0],
182
+ [0, 255, 10],
183
+ [255, 112, 0],
184
+ [143, 255, 0],
185
+ [82, 0, 255],
186
+ [163, 255, 0],
187
+ [255, 235, 0],
188
+ [8, 184, 170],
189
+ [133, 0, 255],
190
+ [0, 255, 92],
191
+ [184, 0, 255],
192
+ [255, 0, 31],
193
+ [0, 184, 255],
194
+ [0, 214, 255],
195
+ [255, 0, 112],
196
+ [92, 255, 0],
197
+ [0, 224, 255],
198
+ [112, 224, 255],
199
+ [70, 184, 160],
200
+ [163, 0, 255],
201
+ [153, 0, 255],
202
+ [71, 255, 0],
203
+ [255, 0, 163],
204
+ [255, 204, 0],
205
+ [255, 0, 143],
206
+ [0, 255, 235],
207
+ [133, 255, 0],
208
+ [255, 0, 235],
209
+ [245, 0, 255],
210
+ [255, 0, 122],
211
+ [255, 245, 0],
212
+ [10, 190, 212],
213
+ [214, 255, 0],
214
+ [0, 204, 255],
215
+ [20, 0, 255],
216
+ [255, 255, 0],
217
+ [0, 153, 255],
218
+ [0, 41, 255],
219
+ [0, 255, 204],
220
+ [41, 0, 255],
221
+ [41, 255, 0],
222
+ [173, 0, 255],
223
+ [0, 245, 255],
224
+ [71, 0, 255],
225
+ [122, 0, 255],
226
+ [0, 255, 184],
227
+ [0, 92, 255],
228
+ [184, 255, 0],
229
+ [0, 133, 255],
230
+ [255, 214, 0],
231
+ [25, 194, 194],
232
+ [102, 255, 0],
233
+ [92, 0, 255],
234
+ ])
235
+ ```
236
+
237
+ 3. Having defined the color palette we can now run the whole segmentation + controlnet generation code:
238
 
239
  ```py
240
  from transformers import AutoImageProcessor, UperNetForSemanticSegmentation
 
259
 
260
  color_seg = np.zeros((seg.shape[0], seg.shape[1], 3), dtype=np.uint8) # height, width, 3
261
 
 
 
262
  for label, color in enumerate(palette):
263
  color_seg[seg == label, :] = color
264