jomarie04 commited on
Commit
3e658cb
·
verified ·
1 Parent(s): 7ef71d0

Create files.py

Browse files
Files changed (1) hide show
  1. files.py +32 -0
files.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import ViTImageProcessor, ViTForImageClassification
2
+
3
+ model_name = "google/vit-base-patch16-224"
4
+
5
+ processor = ViTImageProcessor.from_pretrained(model_name)
6
+ model = ViTForImageClassification.from_pretrained(
7
+ model_name,
8
+ num_labels=8,
9
+ id2label={
10
+ 0: "Mercury",
11
+ 1: "Venus",
12
+ 2: "Earth",
13
+ 3: "Mars",
14
+ 4: "Jupiter",
15
+ 5: "Saturn",
16
+ 6: "Uranus",
17
+ 7: "Neptune"
18
+ },
19
+ label2id={
20
+ "Mercury": 0,
21
+ "Venus": 1,
22
+ "Earth": 2,
23
+ "Mars": 3,
24
+ "Jupiter": 4,
25
+ "Saturn": 5,
26
+ "Uranus": 6,
27
+ "Neptune": 7
28
+ }
29
+ )
30
+
31
+ model.save_pretrained("planet-image-classifier")
32
+ processor.save_pretrained("planet-image-classifier")