Felix Marty commited on
Commit
77501cd
·
1 Parent(s): 8ed47c1

add readme

Browse files
Files changed (1) hide show
  1. README.md +24 -0
README.md CHANGED
@@ -1,3 +1,27 @@
1
  ---
2
  license: apache-2.0
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: apache-2.0
3
  ---
4
+
5
+ Use at your own risk:
6
+
7
+ ```python
8
+ from transformers import AutoFeatureExtractor, AutoModelForImageClassification
9
+ from datasets import load_dataset
10
+ import torch
11
+
12
+ feature_extractor = AutoFeatureExtractor.from_pretrained("fxmarty/tiny-testing-remote-code")
13
+
14
+ model = AutoModelForImageClassification.from_pretrained("fxmarty/tiny-testing-remote-code", trust_remote_code=True)
15
+
16
+ dataset = load_dataset("huggingface/cats-image")
17
+ image = dataset["test"]["image"][0]
18
+
19
+ inputs = feature_extractor(image, return_tensors="pt")
20
+
21
+ with torch.no_grad():
22
+ logits = model(**inputs).logits
23
+
24
+ # model predicts one of the 1000 ImageNet classes
25
+ predicted_label = logits.argmax(-1).item()
26
+ print(model.config.id2label[predicted_label])
27
+ ```