Spaces:
Sleeping
Sleeping
Download utils.py from XAI/PCNN-StanfordDogs-HumanStudy: direct link, hf CLI and curl.
- Browser
- Download file 553 Bytes
-
https://huggingface.co/spaces/XAI/PCNN-StanfordDogs-HumanStudy/resolve/refs%2Fpr%2F1/utils.py
- Command line
-
hf download hf://spaces/XAI/PCNN-StanfordDogs-HumanStudy@refs/pr/1/utils.py
-
curl -L -o utils.py https://huggingface.co/spaces/XAI/PCNN-StanfordDogs-HumanStudy/resolve/refs%2Fpr%2F1/utils.py
553 Bytes
| import matplotlib.pyplot as plt | |
| import numpy as np | |
| def string_to_image(text): | |
| text = text.replace("_", " ").lower().replace(", ", "\n") | |
| # Create a blank white square image | |
| img = np.ones((220, 75, 3)) | |
| fig, ax = plt.subplots(figsize=(6, 2.25)) | |
| ax.imshow(img, extent=[0, 1, 0, 1]) | |
| ax.text(0.5, 0.75, text, fontsize=18, ha="center", va="center") | |
| ax.set_xticks([]) | |
| ax.set_yticks([]) | |
| ax.set_xticklabels([]) | |
| ax.set_yticklabels([]) | |
| for spine in ax.spines.values(): | |
| spine.set_visible(False) | |
| return fig | |