Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,33 +1,38 @@
|
|
1 |
import gradio as gr
|
2 |
-
from
|
3 |
|
4 |
-
# Инициализация
|
5 |
-
|
|
|
|
|
|
|
|
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
# Форматируем результат
|
16 |
-
if label == 'POSITIVE':
|
17 |
-
interpretation = "Текст похож на сгенерированный ИИ"
|
18 |
-
else:
|
19 |
-
interpretation = "Текст похож на человеческий"
|
20 |
-
|
21 |
-
return f"Результат: {interpretation}\nВероятность: {score:.2%}"
|
22 |
|
23 |
-
#
|
24 |
interface = gr.Interface(
|
25 |
-
fn=
|
26 |
-
inputs=gr.Textbox(
|
27 |
-
|
28 |
-
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
)
|
31 |
|
32 |
-
#
|
33 |
-
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from generated_text_detector.utils.text_detector import GeneratedTextDetector
|
3 |
|
4 |
+
# Инициализация детектора
|
5 |
+
detector = GeneratedTextDetector(
|
6 |
+
"SuperAnnotate/ai-detector",
|
7 |
+
device="cuda",
|
8 |
+
preprocessing=True
|
9 |
+
)
|
10 |
|
11 |
+
# Функция для предсказания
|
12 |
+
def detect_generated_text(input_text):
|
13 |
+
try:
|
14 |
+
result = detector.detect_report(input_text)
|
15 |
+
return f"Detection Result:\n\n{result}"
|
16 |
+
except Exception as e:
|
17 |
+
return f"Error: {str(e)}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
+
# Создание интерфейса Gradio
|
20 |
interface = gr.Interface(
|
21 |
+
fn=detect_generated_text,
|
22 |
+
inputs=gr.Textbox(
|
23 |
+
lines=5,
|
24 |
+
placeholder="Enter text here to check if it's AI-generated...",
|
25 |
+
label="Input Text"
|
26 |
+
),
|
27 |
+
outputs=gr.Textbox(label="Detection Result"),
|
28 |
+
title="AI-Generated Text Detector",
|
29 |
+
description="Enter any text to determine if it was generated by AI. Powered by SuperAnnotate/ai-detector model.",
|
30 |
+
examples=[
|
31 |
+
["It's not uncommon for people to develop allergies or intolerances to certain foods as they get older."],
|
32 |
+
["The quick brown fox jumps over the lazy dog near the river bank on a sunny afternoon."]
|
33 |
+
]
|
34 |
)
|
35 |
|
36 |
+
# Запуск интерфейса
|
37 |
+
if __name__ == "__main__":
|
38 |
+
interface.launch()
|