Update README.md
Browse files
README.md
CHANGED
|
@@ -43,6 +43,7 @@ Preprocessing: Images are resized to 224x224 pixels and normalized across RGB ch
|
|
| 43 |
Training: Pretraining was conducted on TPUv3 hardware with a batch size of 4096 and learning rate warmup. Gradient clipping was applied during training to enhance stability.
|
| 44 |
```python
|
| 45 |
from transformers import ViTImageProcessor, ViTForImageClassification
|
|
|
|
| 46 |
from PIL import Image
|
| 47 |
import requests
|
| 48 |
import torch
|
|
@@ -51,9 +52,9 @@ def predict_image_from_url(url):
|
|
| 51 |
# Load image from URL
|
| 52 |
image = Image.open(requests.get(url, stream=True).raw)
|
| 53 |
|
| 54 |
-
# Initialize processor and model
|
| 55 |
-
processor =
|
| 56 |
-
model =
|
| 57 |
|
| 58 |
# Preprocess image and make predictions
|
| 59 |
inputs = processor(images=image, return_tensors="pt")
|
|
@@ -71,6 +72,7 @@ if __name__ == "__main__":
|
|
| 71 |
url = 'http://images.cocodataset.org/val2017/000000039769.jpg'
|
| 72 |
predicted_class = predict_image_from_url(url)
|
| 73 |
print(f"Predicted class: {predicted_class}")
|
|
|
|
| 74 |
```
|
| 75 |
|
| 76 |
For more code examples, we refer to the [documentation](https://huggingface.co/transformers/model_doc/vit.html#).
|
|
|
|
| 43 |
Training: Pretraining was conducted on TPUv3 hardware with a batch size of 4096 and learning rate warmup. Gradient clipping was applied during training to enhance stability.
|
| 44 |
```python
|
| 45 |
from transformers import ViTImageProcessor, ViTForImageClassification
|
| 46 |
+
from transformers import AutoImageProcessor, AutoModelForImageClassification
|
| 47 |
from PIL import Image
|
| 48 |
import requests
|
| 49 |
import torch
|
|
|
|
| 52 |
# Load image from URL
|
| 53 |
image = Image.open(requests.get(url, stream=True).raw)
|
| 54 |
|
| 55 |
+
# Initialize Sreekanth's processor and model
|
| 56 |
+
processor = AutoImageProcessor.from_pretrained("Sreekanth3096/vit-coco-image-classification")
|
| 57 |
+
model = AutoModelForImageClassification.from_pretrained("Sreekanth3096/vit-coco-image-classification")
|
| 58 |
|
| 59 |
# Preprocess image and make predictions
|
| 60 |
inputs = processor(images=image, return_tensors="pt")
|
|
|
|
| 72 |
url = 'http://images.cocodataset.org/val2017/000000039769.jpg'
|
| 73 |
predicted_class = predict_image_from_url(url)
|
| 74 |
print(f"Predicted class: {predicted_class}")
|
| 75 |
+
|
| 76 |
```
|
| 77 |
|
| 78 |
For more code examples, we refer to the [documentation](https://huggingface.co/transformers/model_doc/vit.html#).
|