alicelouis commited on
Commit
4d32508
1 Parent(s): bb62ef1

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +18 -1
README.md CHANGED
@@ -5,11 +5,28 @@ metrics:
5
  ---
6
 
7
  from transformers import AutoImageProcessor, SwinForImageClassification
 
8
  from PIL import Image
 
9
  import requests
10
 
11
  url = "http://images.cocodataset.org/val2017/000000039769.jpg"
 
12
  image = Image.open(requests.get(url, stream=True).raw)
13
 
 
14
  processor = AutoImageProcessor.from_pretrained("alicelouis/Swin2e-4Lion")
15
- model = SwinForImageClassification.from_pretrained("alicelouis/Swin2e-4Lion")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  ---
6
 
7
  from transformers import AutoImageProcessor, SwinForImageClassification
8
+
9
  from PIL import Image
10
+
11
  import requests
12
 
13
  url = "http://images.cocodataset.org/val2017/000000039769.jpg"
14
+
15
  image = Image.open(requests.get(url, stream=True).raw)
16
 
17
+
18
  processor = AutoImageProcessor.from_pretrained("alicelouis/Swin2e-4Lion")
19
+
20
+ model = SwinForImageClassification.from_pretrained("alicelouis/Swin2e-4Lion")
21
+
22
+ inputs = processor(images=image, return_tensors="pt")
23
+
24
+ outputs = model(**inputs)
25
+
26
+ logits = outputs.logits
27
+
28
+ # model predicts one of the 1000 ImageNet classes
29
+
30
+ predicted_class_idx = logits.argmax(-1).item()
31
+
32
+ print("Predicted class:", model.config.id2label[predicted_class_idx])