Spaces:
Running
Running
Commit
Β·
5b36832
1
Parent(s):
18e11fc
UI - theme
Browse files
app.py
CHANGED
|
@@ -32,13 +32,13 @@ def classify_text(text):
|
|
| 32 |
outputs = model(**inputs)
|
| 33 |
probabilities = torch.softmax(outputs.logits, dim=1)[0]
|
| 34 |
predicted_class = torch.argmax(probabilities).item()
|
| 35 |
-
confidence = probabilities[predicted_class].item() * 100
|
| 36 |
|
| 37 |
if predicted_class == 24:
|
| 38 |
-
prediction_label = f"β
The text is **{confidence:.2f}%** likely
|
| 39 |
-
model_info = ""
|
| 40 |
else:
|
| 41 |
-
prediction_label = f"π€ The text is **{confidence:.2f}%** likely **AI generated**."
|
| 42 |
model_info = f"**Identified AI Model:** {label_mapping[predicted_class]}"
|
| 43 |
|
| 44 |
result_message = f"**Result:**\n\n{prediction_label}"
|
|
@@ -47,7 +47,7 @@ def classify_text(text):
|
|
| 47 |
|
| 48 |
return result_message
|
| 49 |
|
| 50 |
-
title = "AI
|
| 51 |
description = """
|
| 52 |
**AI detection tool by SzegedAI**
|
| 53 |
|
|
@@ -57,6 +57,8 @@ Detect AI-generated texts with precision using the new **ModernBERT** model, fin
|
|
| 57 |
- **β
Human Verification**: Marks confidently human-written text with a green checkmark.
|
| 58 |
|
| 59 |
**Press the button below to classify your text!**
|
|
|
|
|
|
|
| 60 |
"""
|
| 61 |
|
| 62 |
iface = gr.Interface(
|
|
@@ -67,7 +69,7 @@ iface = gr.Interface(
|
|
| 67 |
lines=5,
|
| 68 |
elem_id="text_input_box"
|
| 69 |
),
|
| 70 |
-
outputs=gr.Markdown(),
|
| 71 |
title=title,
|
| 72 |
description=description,
|
| 73 |
allow_flagging="never",
|
|
@@ -77,6 +79,15 @@ iface = gr.Interface(
|
|
| 77 |
border-radius: 10px;
|
| 78 |
border: 2px solid #4CAF50;
|
| 79 |
font-size: 18px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
}
|
| 81 |
body {
|
| 82 |
background: #1E1E2F;
|
|
@@ -87,13 +98,14 @@ iface = gr.Interface(
|
|
| 87 |
.gradio-container {
|
| 88 |
border: 2px solid #4CAF50;
|
| 89 |
border-radius: 15px;
|
| 90 |
-
padding:
|
| 91 |
box-shadow: 0px 0px 20px rgba(0,255,0,0.6);
|
| 92 |
}
|
| 93 |
h1, h2 {
|
| 94 |
text-align: center;
|
| 95 |
font-size: 32px;
|
| 96 |
font-weight: bold;
|
|
|
|
| 97 |
}
|
| 98 |
"""
|
| 99 |
)
|
|
|
|
| 32 |
outputs = model(**inputs)
|
| 33 |
probabilities = torch.softmax(outputs.logits, dim=1)[0]
|
| 34 |
predicted_class = torch.argmax(probabilities).item()
|
| 35 |
+
confidence = probabilities[predicted_class].item() * 100 # Confidence as %
|
| 36 |
|
| 37 |
if predicted_class == 24:
|
| 38 |
+
prediction_label = f"β
- The text is **{confidence:.2f}%** likely **Human written**."
|
| 39 |
+
model_info = ""
|
| 40 |
else:
|
| 41 |
+
prediction_label = f"π€ - The text is **{confidence:.2f}%** likely **AI generated**."
|
| 42 |
model_info = f"**Identified AI Model:** {label_mapping[predicted_class]}"
|
| 43 |
|
| 44 |
result_message = f"**Result:**\n\n{prediction_label}"
|
|
|
|
| 47 |
|
| 48 |
return result_message
|
| 49 |
|
| 50 |
+
title = "AI Text Detector"
|
| 51 |
description = """
|
| 52 |
**AI detection tool by SzegedAI**
|
| 53 |
|
|
|
|
| 57 |
- **β
Human Verification**: Marks confidently human-written text with a green checkmark.
|
| 58 |
|
| 59 |
**Press the button below to classify your text!**
|
| 60 |
+
|
| 61 |
+
|
| 62 |
"""
|
| 63 |
|
| 64 |
iface = gr.Interface(
|
|
|
|
| 69 |
lines=5,
|
| 70 |
elem_id="text_input_box"
|
| 71 |
),
|
| 72 |
+
outputs=gr.Markdown(elem_id="result_output_box"),
|
| 73 |
title=title,
|
| 74 |
description=description,
|
| 75 |
allow_flagging="never",
|
|
|
|
| 79 |
border-radius: 10px;
|
| 80 |
border: 2px solid #4CAF50;
|
| 81 |
font-size: 18px;
|
| 82 |
+
padding: 10px;
|
| 83 |
+
}
|
| 84 |
+
#result_output_box {
|
| 85 |
+
border-radius: 10px;
|
| 86 |
+
border: 2px solid #4CAF50;
|
| 87 |
+
font-size: 18px;
|
| 88 |
+
padding: 15px;
|
| 89 |
+
background-color: #2E2E3F;
|
| 90 |
+
margin-top: 20px;
|
| 91 |
}
|
| 92 |
body {
|
| 93 |
background: #1E1E2F;
|
|
|
|
| 98 |
.gradio-container {
|
| 99 |
border: 2px solid #4CAF50;
|
| 100 |
border-radius: 15px;
|
| 101 |
+
padding: 25px;
|
| 102 |
box-shadow: 0px 0px 20px rgba(0,255,0,0.6);
|
| 103 |
}
|
| 104 |
h1, h2 {
|
| 105 |
text-align: center;
|
| 106 |
font-size: 32px;
|
| 107 |
font-weight: bold;
|
| 108 |
+
margin-bottom: 20px;
|
| 109 |
}
|
| 110 |
"""
|
| 111 |
)
|