Spaces:
Runtime error
Runtime error
autonomous019
commited on
Commit
•
8090b75
1
Parent(s):
90d39d4
more updates
Browse files
app.py
CHANGED
@@ -1,4 +1,8 @@
|
|
1 |
from transformers import ViTConfig, ViTForImageClassification
|
|
|
|
|
|
|
|
|
2 |
|
3 |
# option 1: load with randomly initialized weights (train from scratch)
|
4 |
|
@@ -7,16 +11,11 @@ model = ViTForImageClassification(config)
|
|
7 |
|
8 |
print(config)
|
9 |
|
10 |
-
from transformers import ViTFeatureExtractor
|
11 |
-
|
12 |
feature_extractor = ViTFeatureExtractor()
|
13 |
|
14 |
# or, to load one that corresponds to a checkpoint on the hub:
|
15 |
feature_extractor = ViTFeatureExtractor.from_pretrained("google/vit-base-patch16-224")
|
16 |
|
17 |
-
from PIL import Image
|
18 |
-
import requests
|
19 |
-
|
20 |
url = 'http://images.cocodataset.org/val2017/000000039769.jpg'
|
21 |
image = Image.open(requests.get(url, stream=True).raw)
|
22 |
image.save("cats.png")
|
|
|
1 |
from transformers import ViTConfig, ViTForImageClassification
|
2 |
+
from transformers import ViTFeatureExtractor
|
3 |
+
from PIL import Image
|
4 |
+
import requests
|
5 |
+
|
6 |
|
7 |
# option 1: load with randomly initialized weights (train from scratch)
|
8 |
|
|
|
11 |
|
12 |
print(config)
|
13 |
|
|
|
|
|
14 |
feature_extractor = ViTFeatureExtractor()
|
15 |
|
16 |
# or, to load one that corresponds to a checkpoint on the hub:
|
17 |
feature_extractor = ViTFeatureExtractor.from_pretrained("google/vit-base-patch16-224")
|
18 |
|
|
|
|
|
|
|
19 |
url = 'http://images.cocodataset.org/val2017/000000039769.jpg'
|
20 |
image = Image.open(requests.get(url, stream=True).raw)
|
21 |
image.save("cats.png")
|