MCPcopy Create free account
hub / github.com/TPCD/DCCL / plot_with_domains_and_pic

Function plot_with_domains_and_pic

project_utils/visualization_utils.py:164–242  ·  view source on GitHub ↗
(save_path, lowDWeights, labels, pic_path)

Source from the content-addressed store, hash-verified

162
163
164def plot_with_domains_and_pic(save_path, lowDWeights, labels, pic_path):
165 import matplotlib.pyplot as plt
166 padding_rate = 0.1
167 plt.cla()
168 X, Y = lowDWeights[:, 0], lowDWeights[:, 1]
169 unique = np.unique(labels)
170
171 num_type_color = 7
172 colors = sns.color_palette("viridis", n_colors=num_type_color)
173 # label2color_dict = {l: cmap(i) for i, l in enumerate(unique)}
174 box_alpha = 0.3
175 for x, y, s, path in zip(X, Y, labels, pic_path):
176 # path = f'{path.split("/")}'
177 path = path.replace('/data/ReIDDatasets/', '/home/r2d2/r2d2/Datasets/')
178 if s >= 0 and s < 100:
179 im = np.array(Image.open(path))
180 plt.imshow(im, extent=[x, x + 0.2, y, y + 0.4], aspect='auto', cmap='gray')
181 plt.text(x, y, s, fontsize=1,
182 ha='center', va='center', # 水平居中,垂直居中
183 bbox=dict(boxstyle='circle', alpha=box_alpha, # 圆圈
184 ec=colors[0], # 边框颜色
185 fc=colors[0] # 填充颜色
186 ))
187 elif s >= 100 and s < 200:
188 im = np.array(Image.open(path))
189 plt.imshow(im, extent=[x, x + 0.2, y, y + 0.4], aspect='auto', cmap='gray')
190 plt.text(x, y, s, fontsize=1,
191 ha='center', va='center', # 水平居中,垂直居中
192 bbox=dict(boxstyle='circle', alpha=box_alpha, # 圆圈
193 ec=colors[1], # 边框颜色
194 fc=colors[1] # 填充颜色
195 ))
196 elif s >= 200 and s < 300:
197 im = np.array(Image.open(path))
198 plt.imshow(im, extent=[x, x + 0.2, y, y + 0.4], aspect='auto', cmap='gray')
199 plt.text(x, y, s, fontsize=1,
200 ha='center', va='center', # 水平居中,垂直居中
201 bbox=dict(boxstyle='circle', alpha=box_alpha, # 圆圈
202 ec=colors[2], # 边框颜色
203 fc=colors[2] # 填充颜色
204 ))
205 elif s >= 300 and s < 400:
206 im = np.array(Image.open(path))
207 plt.imshow(im, extent=[x, x + 0.2, y, y + 0.4], aspect='auto', cmap='gray')
208 plt.text(x, y, s, fontsize=1,
209 ha='center', va='center', # 水平居中,垂直居中
210 bbox=dict(boxstyle='circle', alpha=box_alpha, # 圆圈
211 ec=colors[3], # 边框颜色
212 fc=colors[3] # 填充颜色
213 ))
214 elif s >= 400 and s < 500:
215 im = np.array(Image.open(path))
216 plt.imshow(im, extent=[x, x + 0.2, y, y + 0.4], aspect='auto', cmap='gray')
217 plt.text(x, y, s, fontsize=1,
218 ha='center', va='center', # 水平居中,垂直居中
219 bbox=dict(boxstyle='circle', alpha=box_alpha, # 圆圈
220 ec=colors[4], # 边框颜色
221 fc=colors[4] # 填充颜色

Callers 1

visualizeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected