Spaces:
Sleeping
Sleeping
File size: 645 Bytes
6eda4a9 dfb0362 6eda4a9 dfb0362 6eda4a9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
import gradio as gr
from transformers import pipeline
# Load a pre-trained AI text detector model
detector = pipeline("text-classification", model="roberta-base-openai-detector")
def detect_text(text):
result = detector(text)[0]
label = result['label']
score = round(result['score'] * 100, 2)
return f"Prediction: {label} ({score}%)"
# Gradio UI
interface = gr.Interface(
fn=detect_text,
inputs=gr.Textbox(lines=7, label="Enter your text"),
outputs=gr.Textbox(label="Result"),
title="Text AI Detector",
description="This model predicts if the text is AI-generated or human-written."
)
interface.launch()
|