Spaces:
Running
on
Zero
Running
on
Zero
fix colormaps
Browse files
app.py
CHANGED
@@ -2186,7 +2186,7 @@ demo = gr.Blocks(
|
|
2186 |
)
|
2187 |
with demo:
|
2188 |
|
2189 |
-
with gr.Tab('
|
2190 |
eigvecs = gr.State(np.array([]))
|
2191 |
tsne3d_rgb = gr.State(np.array([]))
|
2192 |
with gr.Row():
|
@@ -2535,7 +2535,7 @@ with demo:
|
|
2535 |
right = F.normalize(right, p=2, dim=-1)
|
2536 |
similarity = left @ right.T
|
2537 |
similarity = similarity.max(dim=-1).values # B H W
|
2538 |
-
hot_map = matplotlib.
|
2539 |
heatmap = hot_map(similarity)[..., :3] # B H W 3
|
2540 |
heatmap_images = to_pil_images(torch.tensor(heatmap), target_size=256, force_size=True)
|
2541 |
# overlay input images on the heatmap
|
@@ -3976,7 +3976,7 @@ with demo:
|
|
3976 |
return heatmap
|
3977 |
# apply hot colormap and covert to PIL image 256x256
|
3978 |
heatmap = heatmap.cpu().numpy()
|
3979 |
-
hot_map = matplotlib.
|
3980 |
heatmap = hot_map(heatmap)
|
3981 |
pil_images = to_pil_images(torch.tensor(heatmap), target_size=256, force_size=True)
|
3982 |
if overlay_image:
|
@@ -4063,7 +4063,7 @@ with demo:
|
|
4063 |
# convert [-1, 1] to [0, 1]
|
4064 |
heatmap = (heatmap + 1) / 2
|
4065 |
heatmap = heatmap.cpu().numpy()
|
4066 |
-
cm = matplotlib.
|
4067 |
heatmap = cm(heatmap)
|
4068 |
# bwr with contrast
|
4069 |
pil_images1 = to_pil_images(torch.tensor(heatmap), resize=256)
|
@@ -4119,7 +4119,7 @@ with demo:
|
|
4119 |
outputs=[n_eig, current_idx, parent_plot, current_plot, *child_plots, child_idx],
|
4120 |
)
|
4121 |
|
4122 |
-
with gr.Tab('PlayGround', visible=True) as test_playground_tab2:
|
4123 |
eigvecs = gr.State(np.array([]))
|
4124 |
with gr.Row():
|
4125 |
with gr.Column(scale=5, min_width=200):
|
@@ -4247,7 +4247,7 @@ with demo:
|
|
4247 |
# apply hot colormap and covert to PIL image 256x256
|
4248 |
# gr.Info(f"heatmap vmin: {heatmap.min()}, vmax: {heatmap.max()}, mean: {heatmap.mean()}")
|
4249 |
heatmap = heatmap.cpu().numpy()
|
4250 |
-
hot_map = matplotlib.
|
4251 |
heatmap = hot_map(heatmap)
|
4252 |
pil_images = to_pil_images(torch.tensor(heatmap), target_size=256, force_size=True)
|
4253 |
if overlay_image:
|
|
|
2186 |
)
|
2187 |
with demo:
|
2188 |
|
2189 |
+
with gr.Tab('PlayGround'):
|
2190 |
eigvecs = gr.State(np.array([]))
|
2191 |
tsne3d_rgb = gr.State(np.array([]))
|
2192 |
with gr.Row():
|
|
|
2535 |
right = F.normalize(right, p=2, dim=-1)
|
2536 |
similarity = left @ right.T
|
2537 |
similarity = similarity.max(dim=-1).values # B H W
|
2538 |
+
hot_map = matplotlib.colormaps['hot']
|
2539 |
heatmap = hot_map(similarity)[..., :3] # B H W 3
|
2540 |
heatmap_images = to_pil_images(torch.tensor(heatmap), target_size=256, force_size=True)
|
2541 |
# overlay input images on the heatmap
|
|
|
3976 |
return heatmap
|
3977 |
# apply hot colormap and covert to PIL image 256x256
|
3978 |
heatmap = heatmap.cpu().numpy()
|
3979 |
+
hot_map = matplotlib.colormaps['hot']
|
3980 |
heatmap = hot_map(heatmap)
|
3981 |
pil_images = to_pil_images(torch.tensor(heatmap), target_size=256, force_size=True)
|
3982 |
if overlay_image:
|
|
|
4063 |
# convert [-1, 1] to [0, 1]
|
4064 |
heatmap = (heatmap + 1) / 2
|
4065 |
heatmap = heatmap.cpu().numpy()
|
4066 |
+
cm = matplotlib.colormaps['bwr']
|
4067 |
heatmap = cm(heatmap)
|
4068 |
# bwr with contrast
|
4069 |
pil_images1 = to_pil_images(torch.tensor(heatmap), resize=256)
|
|
|
4119 |
outputs=[n_eig, current_idx, parent_plot, current_plot, *child_plots, child_idx],
|
4120 |
)
|
4121 |
|
4122 |
+
with gr.Tab('PlayGround (eig)', visible=True) as test_playground_tab2:
|
4123 |
eigvecs = gr.State(np.array([]))
|
4124 |
with gr.Row():
|
4125 |
with gr.Column(scale=5, min_width=200):
|
|
|
4247 |
# apply hot colormap and covert to PIL image 256x256
|
4248 |
# gr.Info(f"heatmap vmin: {heatmap.min()}, vmax: {heatmap.max()}, mean: {heatmap.mean()}")
|
4249 |
heatmap = heatmap.cpu().numpy()
|
4250 |
+
hot_map = matplotlib.colormaps['hot']
|
4251 |
heatmap = hot_map(heatmap)
|
4252 |
pil_images = to_pil_images(torch.tensor(heatmap), target_size=256, force_size=True)
|
4253 |
if overlay_image:
|