Spaces:
Running
Running
made the interface
Browse files
app.py
CHANGED
@@ -1,7 +1,37 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
|
4 |
+
# Load your models
|
5 |
+
# Adjust these lines according to how your models are set up
|
6 |
+
roberta_base_detector = pipeline("text-classification", model="Models/fine_tuned/roberta-base-openai-detector-model", tokenizer="Models/fine_tuned/roberta-base-openai-detector-tokenizer")
|
7 |
+
chatgpt_lli_hc3_detector = pipeline("text-classification", model="Models/fine_tuned/chatgpt-detector-lli-hc3-model", tokenizer="Models/fine_tuned/chatgpt-detector-lli-hc3-tokenizer")
|
8 |
+
chatgpt_roberta_detector = pipeline("text-classification", model="Models/fine_tuned/chatgpt-detector-roberta-model", tokenizer="Models/fine_tuned/chatgpt-detector-roberta-tokenizer")
|
9 |
|
10 |
+
def classify_text(text):
|
11 |
+
# Get predictions from each model
|
12 |
+
roberta_base_pred = roberta_base_detector(text)[0]['label']
|
13 |
+
chatgpt_lli_hc3_pred = chatgpt_lli_hc3_detector(text)[0]['label']
|
14 |
+
chatgpt_roberta_pred = chatgpt_roberta_detector(text)[0]['label']
|
15 |
+
|
16 |
+
# Count the votes for AI and Human
|
17 |
+
votes = {"AI": 0, "Human": 0}
|
18 |
+
for pred in [roberta_base_pred, chatgpt_lli_hc3_pred, chatgpt_roberta_pred]:
|
19 |
+
if pred == "AI":
|
20 |
+
votes["AI"] += 1
|
21 |
+
else:
|
22 |
+
votes["Human"] += 1
|
23 |
+
|
24 |
+
# Determine final decision based on majority
|
25 |
+
if votes["AI"] > votes["Human"]:
|
26 |
+
return "AI"
|
27 |
+
else:
|
28 |
+
return "Human"
|
29 |
+
|
30 |
+
# Create Gradio Interface
|
31 |
+
iface = gr.Interface(
|
32 |
+
fn=classify_text,
|
33 |
+
inputs=gr.inputs.Textbox(lines=2, placeholder="Enter a sentence to classify..."),
|
34 |
+
outputs="text"
|
35 |
+
)
|
36 |
+
|
37 |
+
iface.launch()
|