File size: 392 Bytes
5e2b57d
513571d
 
 
 
0f27267
 
 
 
 
 
 
5e2b57d
f7d8953
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="MayZhou/e5-small-lora-ai-generated-detector")

with gr.Blocks() as demo:
    @gr.api()
    def detect_ai(text: str):
        result = clf(text)[0]
        label = result['label']
        score = round(result['score'] * 100, 2)
        return f"{label} ({score}%)"

demo.launch(show_api=True)