Image Classification
Transformers
Safetensors
English
vit
vision
biology
ecology
phenology
plants
plant-phenology
leaf-phenology
iNaturalist
Eval Results (legacy)
Instructions to use phenobase/phenovisionL with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use phenobase/phenovisionL with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-classification", model="phenobase/phenovisionL") pipe("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/parrots.png")# Load model directly from transformers import AutoImageProcessor, AutoModelForImageClassification processor = AutoImageProcessor.from_pretrained("phenobase/phenovisionL") model = AutoModelForImageClassification.from_pretrained("phenobase/phenovisionL", device_map="auto") - Notebooks
- Google Colab
- Kaggle
How-to-Use: use AutoImageProcessor; note torchvision requirement
Browse files
README.md
CHANGED
|
@@ -83,14 +83,17 @@ PhenoVisionL is initialized from the trained PhenoVision reproductive structures
|
|
| 83 |
|
| 84 |
## How to Use
|
| 85 |
|
|
|
|
|
|
|
|
|
|
| 86 |
```python
|
| 87 |
-
from transformers import
|
| 88 |
from PIL import Image
|
| 89 |
import torch
|
| 90 |
|
| 91 |
# Load model and processor
|
| 92 |
-
processor =
|
| 93 |
-
model =
|
| 94 |
model.eval()
|
| 95 |
|
| 96 |
# Run inference
|
|
@@ -101,9 +104,10 @@ with torch.no_grad():
|
|
| 101 |
outputs = model(**inputs)
|
| 102 |
probs = torch.sigmoid(outputs.logits)[0]
|
| 103 |
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
|
|
|
| 107 |
|
| 108 |
print(f"Green leaves: {green_prob:.3f}")
|
| 109 |
print(f"Colored leaves: {colored_prob:.3f}")
|
|
|
|
| 83 |
|
| 84 |
## How to Use
|
| 85 |
|
| 86 |
+
Requires `transformers`, `torch`, and `torchvision` (torchvision is needed by the
|
| 87 |
+
image processor in `transformers` v5+).
|
| 88 |
+
|
| 89 |
```python
|
| 90 |
+
from transformers import AutoModelForImageClassification, AutoImageProcessor
|
| 91 |
from PIL import Image
|
| 92 |
import torch
|
| 93 |
|
| 94 |
# Load model and processor
|
| 95 |
+
processor = AutoImageProcessor.from_pretrained("phenobase/phenovisionL")
|
| 96 |
+
model = AutoModelForImageClassification.from_pretrained("phenobase/phenovisionL")
|
| 97 |
model.eval()
|
| 98 |
|
| 99 |
# Run inference
|
|
|
|
| 104 |
outputs = model(**inputs)
|
| 105 |
probs = torch.sigmoid(outputs.logits)[0]
|
| 106 |
|
| 107 |
+
# Output order is [green, colored, breaking_buds].
|
| 108 |
+
green_prob = probs[0].item() # index 0 = green leaves
|
| 109 |
+
colored_prob = probs[1].item() # index 1 = colored leaves
|
| 110 |
+
breaking_buds_prob = probs[2].item() # index 2 = breaking leaf buds
|
| 111 |
|
| 112 |
print(f"Green leaves: {green_prob:.3f}")
|
| 113 |
print(f"Colored leaves: {colored_prob:.3f}")
|