Instructions to use jlee-larr/dynaflip-base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use jlee-larr/dynaflip-base with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("zero-shot-image-classification", model="jlee-larr/dynaflip-base", 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 AutoModel model = AutoModel.from_pretrained("jlee-larr/dynaflip-base", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files
README.md
CHANGED
|
@@ -14,11 +14,21 @@ The model is compatible with Transformers:
|
|
| 14 |
|
| 15 |
```python
|
| 16 |
from transformers import AutoModel, AutoProcessor
|
|
|
|
|
|
|
| 17 |
|
| 18 |
-
|
|
|
|
|
|
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
```
|
| 23 |
|
| 24 |
## Citation
|
|
|
|
| 14 |
|
| 15 |
```python
|
| 16 |
from transformers import AutoModel, AutoProcessor
|
| 17 |
+
from PIL import Image
|
| 18 |
+
import torch
|
| 19 |
|
| 20 |
+
REPO = "jlee-larr/dynaflip-base"
|
| 21 |
+
dynaflip = AutoModel.from_pretrained(REPO, trust_remote_code=True).eval()
|
| 22 |
+
processor = AutoProcessor.from_pretrained(REPO, trust_remote_code=True)
|
| 23 |
|
| 24 |
+
image = Image.open("example.png").convert("RGB")
|
| 25 |
+
inputs = processor(images=image, return_tensors="pt")
|
| 26 |
+
|
| 27 |
+
with torch.no_grad():
|
| 28 |
+
v = dynaflip.vision_outputs(inputs["pixel_values"])
|
| 29 |
+
|
| 30 |
+
# v.last_hidden_state -> (B, num_patches, 768) patch tokens
|
| 31 |
+
# v.pooler_output -> (B, 1536) CLS + mean(patches)
|
| 32 |
```
|
| 33 |
|
| 34 |
## Citation
|