Spaces:
Running
Running
import gradio as gr | |
from transformers import pipeline | |
clf = pipeline("text-classification", model="MayZhou/e5-small-lora-ai-generated-detector") | |
# π this enables the /run/predict route! | |
def detect_ai(text: str): | |
result = clf(text)[0] | |
label = result['label'] | |
score = round(result['score'] * 100, 2) | |
return f"{label} ({score}%)" | |
demo = gr.Interface(fn=detect_ai, inputs="textbox", outputs="text", title="AI Text Detector") | |
demo.launch() | |
# Load the model | |
clf = pipeline("text-classification", model="MayZhou/e5-small-lora-ai-generated-detector") | |
# Define detection function | |
def detect_ai(text): | |
result = clf(text)[0] | |
label = result['label'] | |
score = round(result['score'] * 100, 2) | |
return f"{label} ({score}%)" | |
# Build the interface | |
demo = gr.Interface( | |
fn=detect_ai, | |
inputs="textbox", | |
outputs="text", | |
title="AI Text Detector" | |
) | |
# Launch the app | |
demo.launch() | |