Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,57 +3,71 @@ import spaces
|
|
| 3 |
from transformers import pipeline
|
| 4 |
|
| 5 |
# -------------------------------
|
| 6 |
-
# Load Text AI
|
| 7 |
# -------------------------------
|
| 8 |
text_detector = pipeline("text-classification", model="roberta-base-openai-detector")
|
| 9 |
|
| 10 |
# -------------------------------
|
| 11 |
-
#
|
| 12 |
# -------------------------------
|
| 13 |
@spaces.GPU
|
| 14 |
-
def
|
| 15 |
-
if not user_text.strip():
|
| 16 |
return "🧞 Please provide some text for the Oracle to examine."
|
|
|
|
| 17 |
result = text_detector(user_text)
|
| 18 |
label = result[0]['label']
|
| 19 |
score = round(result[0]['score'] * 100, 2)
|
|
|
|
| 20 |
if label.lower() == "fake":
|
| 21 |
-
|
| 22 |
else:
|
| 23 |
-
|
|
|
|
|
|
|
| 24 |
|
| 25 |
# -------------------------------
|
| 26 |
# Gradio UI
|
| 27 |
# -------------------------------
|
| 28 |
with gr.Blocks(css="""
|
| 29 |
-
body {
|
| 30 |
-
background: linear-gradient(135deg, #0f2027, #
|
| 31 |
-
font-family: Trebuchet MS, sans-serif;
|
| 32 |
color: white;
|
| 33 |
}
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
""") as demo:
|
| 36 |
|
| 37 |
-
|
|
|
|
|
|
|
|
|
|
| 38 |
gr.Markdown("""
|
| 39 |
-
Welcome
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
or conjured by **
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
["Once upon a time in a galaxy far away…"],
|
| 54 |
-
["In this paper, we analyze the performance of Transformer models on natural language inference tasks."]
|
| 55 |
-
],
|
| 56 |
-
inputs=txt_in
|
| 57 |
-
)
|
| 58 |
-
|
| 59 |
-
demo.launch()
|
|
|
|
| 3 |
from transformers import pipeline
|
| 4 |
|
| 5 |
# -------------------------------
|
| 6 |
+
# Load Text AI Detector
|
| 7 |
# -------------------------------
|
| 8 |
text_detector = pipeline("text-classification", model="roberta-base-openai-detector")
|
| 9 |
|
| 10 |
# -------------------------------
|
| 11 |
+
# Oracle Function
|
| 12 |
# -------------------------------
|
| 13 |
@spaces.GPU
|
| 14 |
+
def oracle_text(user_text: str):
|
| 15 |
+
if not user_text or not user_text.strip():
|
| 16 |
return "🧞 Please provide some text for the Oracle to examine."
|
| 17 |
+
|
| 18 |
result = text_detector(user_text)
|
| 19 |
label = result[0]['label']
|
| 20 |
score = round(result[0]['score'] * 100, 2)
|
| 21 |
+
|
| 22 |
if label.lower() == "fake":
|
| 23 |
+
verdict = f"🌌 **Prophecy:** {score}% chance this was **conjured by AI sorcery** 🤖✨"
|
| 24 |
else:
|
| 25 |
+
verdict = f"☀️ **Prophecy:** {score}% chance this was **crafted by a mortal hand** 🧑💻"
|
| 26 |
+
|
| 27 |
+
return verdict
|
| 28 |
|
| 29 |
# -------------------------------
|
| 30 |
# Gradio UI
|
| 31 |
# -------------------------------
|
| 32 |
with gr.Blocks(css="""
|
| 33 |
+
body {
|
| 34 |
+
background: linear-gradient(135deg, #0f2027, #2c5364);
|
| 35 |
+
font-family: 'Trebuchet MS', sans-serif;
|
| 36 |
color: white;
|
| 37 |
}
|
| 38 |
+
#title {
|
| 39 |
+
text-align: center;
|
| 40 |
+
font-size: 2.5em;
|
| 41 |
+
color: #FFD700;
|
| 42 |
+
padding: 20px;
|
| 43 |
+
}
|
| 44 |
+
#subtitle {
|
| 45 |
+
text-align: center;
|
| 46 |
+
font-size: 1.3em;
|
| 47 |
+
color: #E0FFFF;
|
| 48 |
+
margin-bottom: 30px;
|
| 49 |
+
}
|
| 50 |
+
textarea, input, .gr-textbox {
|
| 51 |
+
font-size: 1.1em !important;
|
| 52 |
+
}
|
| 53 |
""") as demo:
|
| 54 |
|
| 55 |
+
# Title and intro
|
| 56 |
+
gr.HTML("<div id='title'>🔮 Oracle of Truth 🔮</div>")
|
| 57 |
+
gr.HTML("<div id='subtitle'>Enter the Chamber of Truth ✨</div>")
|
| 58 |
+
|
| 59 |
gr.Markdown("""
|
| 60 |
+
Welcome, traveler 🌌
|
| 61 |
+
|
| 62 |
+
This chamber is home to the **Oracle of Truth**, an ancient AI seer that discerns whether words were born of **mortal minds** 🧑💻
|
| 63 |
+
or conjured by the **forges of artificial sorcery** 🤖✨
|
| 64 |
+
|
| 65 |
+
### 📖 **How to use this Space**
|
| 66 |
+
- Paste **any text**: essays, blogs, social posts, code comments, even AI prompts.
|
| 67 |
+
- Press **“Reveal Truth”** and await the Oracle’s prophecy.
|
| 68 |
+
- The Oracle will divine the **likelihood** that your offering was human‑written or AI‑generated.
|
| 69 |
+
|
| 70 |
+
### 🌟 Pro Tips
|
| 71 |
+
- Try both short and long texts.
|
| 72 |
+
- Compare a paragraph you wrote vs one generated by ChatGPT or another AI.
|
| 73 |
+
- Share the Oracle’s flame‑lit
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|