Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,18 @@
|
|
1 |
-
|
2 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
# Load the model
|
5 |
clf = pipeline("text-classification", model="MayZhou/e5-small-lora-ai-generated-detector")
|
|
|
1 |
+
|
2 |
import gradio as gr
|
3 |
+
from transformers import pipeline
|
4 |
+
|
5 |
+
clf = pipeline("text-classification", model="MayZhou/e5-small-lora-ai-generated-detector")
|
6 |
+
|
7 |
+
@gr.api() # 👈 this enables the /run/predict route!
|
8 |
+
def detect_ai(text: str):
|
9 |
+
result = clf(text)[0]
|
10 |
+
label = result['label']
|
11 |
+
score = round(result['score'] * 100, 2)
|
12 |
+
return f"{label} ({score}%)"
|
13 |
+
|
14 |
+
demo = gr.Interface(fn=detect_ai, inputs="textbox", outputs="text", title="AI Text Detector")
|
15 |
+
demo.launch()
|
16 |
|
17 |
# Load the model
|
18 |
clf = pipeline("text-classification", model="MayZhou/e5-small-lora-ai-generated-detector")
|