Spaces:
Sleeping
Sleeping
import gradio as gr | |
from transformers import pipeline | |
clf = pipeline("text-classification", model="MayZhou/e5-small-lora-ai-generated-detector") | |
def detect_ai(text): | |
if not text.strip(): | |
return "No text provided." | |
try: | |
result = clf(text)[0] | |
label = result['label'] | |
score = round(result['score'] * 100, 2) | |
return f"{label} ({score}%)" | |
except Exception as e: | |
return f"Error: {str(e)}" | |
# Launch the app with a basic Gradio Interface (exposes /predict endpoint) | |
demo = gr.Interface( | |
fn=detect_ai, | |
inputs=gr.Textbox(lines=4, label="Enter text"), | |
outputs="text", | |
title="AI Text Detector", | |
) | |
demo.launch() | |