Zero-Shot Image Classification
Transformers
Safetensors
tipsv2
feature-extraction
vision
image-text
contrastive-learning
zero-shot
custom_code
Instructions to use google/tipsv2-b14 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use google/tipsv2-b14 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("zero-shot-image-classification", model="google/tipsv2-b14", trust_remote_code=True) pipe( "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/parrots.png", candidate_labels=["animals", "humans", "landscape"], )# Load model directly from transformers import AutoProcessor, AutoModel processor = AutoProcessor.from_pretrained("google/tipsv2-b14", trust_remote_code=True) model = AutoModel.from_pretrained("google/tipsv2-b14", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Gabriele commited on
Commit ·
d075dda
1
Parent(s): d0e7527
PCA visualization: add whitening and sigmoid
Browse files
README.md
CHANGED
|
@@ -96,7 +96,8 @@ from sklearn.decomposition import PCA
|
|
| 96 |
|
| 97 |
spatial = out.patch_tokens.reshape(1, 32, 32, 768)
|
| 98 |
feat = spatial[0].detach().numpy().reshape(-1, 768)
|
| 99 |
-
rgb = PCA(n_components=3).fit_transform(feat).reshape(32, 32, 3)
|
|
|
|
| 100 |
print(rgb.shape) # (32, 32, 3) — PCA of patch features as RGB
|
| 101 |
```
|
| 102 |
|
|
|
|
| 96 |
|
| 97 |
spatial = out.patch_tokens.reshape(1, 32, 32, 768)
|
| 98 |
feat = spatial[0].detach().numpy().reshape(-1, 768)
|
| 99 |
+
rgb = PCA(n_components=3, whiten=True).fit_transform(feat).reshape(32, 32, 3)
|
| 100 |
+
rgb = 1 / (1 + np.exp(-2.0 * rgb)) # sigmoid for [0, 1] range with good contrast
|
| 101 |
print(rgb.shape) # (32, 32, 3) — PCA of patch features as RGB
|
| 102 |
```
|
| 103 |
|