Plots a single modality. Function name has a typo because of legacy reasons. Args: dec_dict (dict): Dictionary of decoded modalities key (str): Key of the modality to plot ax (matplotlib.axes.Axes): Matplotlib axis to plot on figscale (float): Scaling factor
(dec_dict, key, ax, figscale=4.0)
| 1167 | |
| 1168 | |
| 1169 | def plot_modality(dec_dict, key, ax, figscale=4.0): |
| 1170 | """ |
| 1171 | Plots a single modality. Function name has a typo because of legacy reasons. |
| 1172 | |
| 1173 | Args: |
| 1174 | dec_dict (dict): Dictionary of decoded modalities |
| 1175 | key (str): Key of the modality to plot |
| 1176 | ax (matplotlib.axes.Axes): Matplotlib axis to plot on |
| 1177 | figscale (float): Scaling factor for the figure (used to scale the caption box) |
| 1178 | """ |
| 1179 | modality = dec_dict[key] |
| 1180 | k = get_transform_key(key) |
| 1181 | |
| 1182 | if 'tok' in k or k == 'rgb' or k == 'human_poses' or k == 'color_palette': |
| 1183 | ax.imshow(modality.clip(0,1)) |
| 1184 | elif k == 'caption': |
| 1185 | plot_text_in_square(ax, modality, wrap_width=max(1,int(7*figscale))) # 7*figscale turns out to make caption box fit nicely |
| 1186 | elif k == 't5_caption': |
| 1187 | plot_text_in_square(ax, modality, wrap_width=max(1,int(7*figscale))) # 7*figscale turns out to make caption box fit nicely |
| 1188 | elif k == 'metadata': |
| 1189 | modality = ',\n'.join([f'{k}: {v:.2f}' if isinstance(v, float) else f'{k}: {v}' for k, v in modality.items()]) |
| 1190 | plot_text_in_square(ax, modality, wrap_width=max(1,int(7*figscale)), fontsize=11) |
| 1191 | elif k == 'det': |
| 1192 | bbox_img = visualize_bboxes(np.ones((224,224,3)), modality, thickness=2) |
| 1193 | ax.imshow(bbox_img.clip(0,1)) |
| 1194 | |
| 1195 | def plot_conds_and_targets(cond_domains, target_domains, dec_dicts, save_path=None, fs_titles=15, figscale=4.0, dpi=100): |
| 1196 | """ |
no test coverage detected