peal.visualization.visualize_counterfactual_gradients.create_label_image¶
- peal.visualization.visualize_counterfactual_gradients.create_label_image(text, image_size, font_size=50)[source]¶
Render a text caption as an image tensor of a given size.
The text is drawn centred in black on a white canvas (RGB when
C == 3, greyscale otherwise) witharial.ttfif available, else PIL’s default font.- Parameters:
- Returns:
Tensor of shape
(1, C, H, W)with values in[0, 1].- Return type: