Update README.md
Browse files
README.md
CHANGED
|
@@ -79,19 +79,21 @@ The following hyperparameters were used during training:
|
|
| 79 |
|
| 80 |
### Code to Run
|
| 81 |
|
| 82 |
-
from transformers import ViTFeatureExtractor
|
| 83 |
-
from transformers import ViTForImageClassification
|
| 84 |
-
import torch
|
| 85 |
-
|
| 86 |
-
vit = ViTForImageClassification.from_pretrained("oschamp/vit-artworkclassifier")
|
| 87 |
-
vit.eval()
|
| 88 |
-
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
| 89 |
-
vit.to(device)
|
| 90 |
-
|
| 91 |
-
model_name_or_path = 'google/vit-base-patch16-224-in21k'
|
| 92 |
-
feature_extractor = ViTFeatureExtractor.from_pretrained(model_name_or_path)
|
| 93 |
-
|
| 94 |
def vit_classify(image):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
encoding = feature_extractor(images=image, return_tensors="pt")
|
| 96 |
encoding.keys()
|
| 97 |
|
|
|
|
| 79 |
|
| 80 |
### Code to Run
|
| 81 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
def vit_classify(image):
|
| 83 |
+
from transformers import ViTFeatureExtractor
|
| 84 |
+
from transformers import ViTForImageClassification
|
| 85 |
+
import torch
|
| 86 |
+
|
| 87 |
+
vit = ViTForImageClassification.from_pretrained("oschamp/vit-artworkclassifier")
|
| 88 |
+
vit.eval()
|
| 89 |
+
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
| 90 |
+
vit.to(device)
|
| 91 |
+
|
| 92 |
+
model_name_or_path = 'google/vit-base-patch16-224-in21k'
|
| 93 |
+
feature_extractor = ViTFeatureExtractor.from_pretrained(model_name_or_path)
|
| 94 |
+
|
| 95 |
+
#LOAD IMAGE
|
| 96 |
+
|
| 97 |
encoding = feature_extractor(images=image, return_tensors="pt")
|
| 98 |
encoding.keys()
|
| 99 |
|