Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| import torch | |
| from transformers import AutoTokenizer, AutoModelForSequenceClassification | |
| tokenizer = AutoTokenizer.from_pretrained("GeorgeDrayson/modernbert-ai-detection-raid-mage") | |
| model = AutoModelForSequenceClassification.from_pretrained("GeorgeDrayson/modernbert-ai-detection-raid-mage") | |
| def predict(text): | |
| inputs = tokenizer(text, return_tensors="pt") | |
| outputs = model(**inputs) | |
| logits = outputs.logits / 1.3 # temp | |
| probs = torch.nn.functional.softmax(logits, dim=-1) | |
| return probs[0][1].item() | |
| def run(text): | |
| score = predict(text) | |
| print(score, 1.0-score) | |
| return {"ai": score, "human": 1.0-score} | |
| demo = gr.Interface(fn=run, inputs="text", outputs="label") | |
| demo.launch() | |