Naveen0312's picture
Update app.py
dfb0362 verified
raw
history blame
645 Bytes
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()