Spaces:
Runtime error
Runtime error
Commit
·
0cf0380
1
Parent(s):
a9e0f17
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,19 +1,9 @@
|
|
| 1 |
-
|
| 2 |
-
import
|
| 3 |
-
from datasets import load_dataset
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 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 |
|
|
|
|
|
|
|
|
|
| 1 |
+
import transformers
|
| 2 |
+
from transformers import pipeline
|
|
|
|
| 3 |
|
| 4 |
+
unmasker = pipeline('fill-mask', model='bert-large-uncased')
|
| 5 |
+
user_input = input("Enter a sentence with a masked word: ")
|
| 6 |
+
results = unmasker(user_input)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
+
for result in results:
|
| 9 |
+
print(result['sequence'])
|