muneebashraf commited on
Commit
77d1721
·
1 Parent(s): dc23258

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -5
app.py CHANGED
@@ -1,7 +1,19 @@
 
 
 
1
 
2
- unmasker = pipeline('fill-mask', model='bert-large-uncased')
3
- user_input = input("Enter a sentence with a masked word: ")
4
- results = unmasker(user_input)
 
 
 
 
 
 
 
 
 
 
 
5
 
6
- for result in results:
7
- print(result['sequence'])
 
1
+ from transformers import AutoImageProcessor, AutoModelForImageClassification
2
+ import torch
3
+ from datasets import load_dataset
4
 
5
+ dataset = load_dataset("competitions/aiornot")
6
+ image = dataset["test"][0]["image"]
7
+
8
+ processor = AutoImageProcessor.from_pretrained("microsoft/resnet-50")
9
+ model = AutoModelForImageClassification.from_pretrained("arnolfokam/ai-generated-image-detector", trust_remote_code=True)
10
+
11
+ inputs = processor(image, return_tensors="pt")
12
+
13
+ with torch.no_grad():
14
+ logits = model(**inputs).logits
15
+
16
+ # model predicts one of the 2 classes
17
+ predicted_label = logits.argmax(-1).item()
18
+ print(model.config.id2label[predicted_label])
19