Spaces:
Sleeping
Sleeping
Dan Pro
commited on
Commit
·
5012e27
1
Parent(s):
63001f3
Add simpler API endpoint
Browse files
app.py
CHANGED
|
@@ -25,17 +25,19 @@ def detect_ai_text(text):
|
|
| 25 |
ai_prob = probs[0][1].item()
|
| 26 |
|
| 27 |
return {
|
| 28 |
-
"
|
| 29 |
-
"
|
|
|
|
| 30 |
}
|
| 31 |
|
| 32 |
-
# Create Gradio interface
|
| 33 |
iface = gr.Interface(
|
| 34 |
fn=detect_ai_text,
|
| 35 |
inputs=gr.Textbox(lines=10, placeholder="Enter text to analyze..."),
|
| 36 |
outputs=gr.JSON(label="Detection Results"),
|
| 37 |
title="AI Text Detector",
|
| 38 |
-
description="Detects whether text was written by a human or generated by AI"
|
|
|
|
| 39 |
)
|
| 40 |
|
| 41 |
if __name__ == "__main__":
|
|
|
|
| 25 |
ai_prob = probs[0][1].item()
|
| 26 |
|
| 27 |
return {
|
| 28 |
+
"human_probability": round(human_prob * 100, 2),
|
| 29 |
+
"ai_probability": round(ai_prob * 100, 2),
|
| 30 |
+
"prediction": "AI Generated" if ai_prob > 0.5 else "Human Written"
|
| 31 |
}
|
| 32 |
|
| 33 |
+
# Create Gradio interface with API endpoint
|
| 34 |
iface = gr.Interface(
|
| 35 |
fn=detect_ai_text,
|
| 36 |
inputs=gr.Textbox(lines=10, placeholder="Enter text to analyze..."),
|
| 37 |
outputs=gr.JSON(label="Detection Results"),
|
| 38 |
title="AI Text Detector",
|
| 39 |
+
description="Detects whether text was written by a human or generated by AI",
|
| 40 |
+
api_name="detect"
|
| 41 |
)
|
| 42 |
|
| 43 |
if __name__ == "__main__":
|