File size: 425 Bytes
d133ad9
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import gradio as gr
from transformers import pipeline

clf = pipeline("text-classification", model="Desklib/ai-text-detector-v1.01")

def detect(text):
    if not text.strip():
        return "No input"
    result = clf(text)[0]
    label = result['label']
    score = round(result['score'] * 100, 2)
    return f"{label} ({score}%)"

gr.Interface(fn=detect, inputs="text", outputs="text", title="AI Detector Test").launch()