Spaces:
Sleeping
Sleeping
Download explain.py from WwYc/explain-ViT: direct link, hf CLI and curl.
- Browser
- Download file 491 Bytes
-
https://huggingface.co/spaces/WwYc/explain-ViT/resolve/main/explain.py
- Command line
-
hf download hf://spaces/WwYc/explain-ViT/explain.py
-
curl -L -o explain.py https://huggingface.co/spaces/WwYc/explain-ViT/resolve/main/explain.py
491 Bytes
| import matplotlib.pyplot as plt | |
| from visualization import generate_visualization, print_top_classes | |
| def do_explain(transform, image, class_index=None): | |
| fig, axs = plt.subplots(1, 2) | |
| axs[0].imshow(image) | |
| axs[0].axis("off") | |
| transformed_image = transform(image) | |
| viz = generate_visualization( | |
| transformed_image, class_index=class_index | |
| ) | |
| predict = print_top_classes(transformed_image) | |
| axs[1].imshow(viz) | |
| axs[1].axis("off") | |
| return fig, predict | |