Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -20,11 +20,9 @@ def oracle_text(user_text: str):
|
|
| 20 |
result = text_detector(user_text)
|
| 21 |
label = result[0]['label']
|
| 22 |
score = round(result[0]['score'] * 100, 2)
|
| 23 |
-
|
| 24 |
-
f"
|
| 25 |
-
|
| 26 |
-
else f"<div class='prophecy ai'>🌌 Prophecy: {score}% AI‑generated 🤖✨</div>"
|
| 27 |
-
)
|
| 28 |
|
| 29 |
@spaces.GPU
|
| 30 |
def oracle_image(user_img):
|
|
@@ -33,7 +31,7 @@ def oracle_image(user_img):
|
|
| 33 |
result = image_analyzer(user_img)
|
| 34 |
label = result[0]['label']
|
| 35 |
score = round(result[0]['score'] * 100, 2)
|
| 36 |
-
return f"
|
| 37 |
|
| 38 |
@spaces.GPU
|
| 39 |
def oracle_audio(audio_file):
|
|
@@ -43,12 +41,9 @@ def oracle_audio(audio_file):
|
|
| 43 |
result = text_detector(transcript)
|
| 44 |
label = result[0]['label']
|
| 45 |
score = round(result[0]['score'] * 100, 2)
|
| 46 |
-
|
| 47 |
-
f"
|
| 48 |
-
|
| 49 |
-
else f"<div class='prophecy human'>🔊 Transcript: <i>{transcript}</i><br><br>☀️ Prophecy: {score}% Human‑written 🧑💻</div>"
|
| 50 |
-
)
|
| 51 |
-
return verdict
|
| 52 |
|
| 53 |
@spaces.GPU
|
| 54 |
def oracle_pdf(pdf_file):
|
|
@@ -61,83 +56,69 @@ def oracle_pdf(pdf_file):
|
|
| 61 |
result = text_detector(text[:800])
|
| 62 |
label = result[0]['label']
|
| 63 |
score = round(result[0]['score'] * 100, 2)
|
| 64 |
-
|
| 65 |
-
f"
|
| 66 |
-
|
| 67 |
-
else f"<div class='prophecy human'>📑 PDF Prophecy: {score}% Human‑authored 🧑💻</div>"
|
| 68 |
-
)
|
| 69 |
|
| 70 |
# -------------------------------
|
| 71 |
-
# UI
|
| 72 |
# -------------------------------
|
| 73 |
with gr.Blocks(css="""
|
| 74 |
body {
|
| 75 |
-
|
| 76 |
-
|
|
|
|
|
|
|
| 77 |
}
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
padding: 15px;
|
| 83 |
-
text-shadow: 3px 3px 10px #000;
|
| 84 |
}
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
color: #00FFFF;
|
| 89 |
-
margin-bottom: 25px;
|
| 90 |
}
|
| 91 |
-
.
|
| 92 |
-
|
| 93 |
-
padding: 25px;
|
| 94 |
-
font-size: 1.6em;
|
| 95 |
-
margin-top: 15px;
|
| 96 |
-
text-align: center;
|
| 97 |
-
font-weight: bold;
|
| 98 |
}
|
| 99 |
-
.
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
.
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
}
|
| 109 |
-
.prophecy.image {
|
| 110 |
-
background: rgba(0,0,0,0.6);
|
| 111 |
-
color: #FFD700;
|
| 112 |
-
box-shadow: 0 0 15px #FFF176;
|
| 113 |
}
|
| 114 |
""") as demo:
|
| 115 |
|
| 116 |
-
gr.
|
| 117 |
-
gr.
|
| 118 |
|
| 119 |
with gr.Tab("📜 Text Divination"):
|
| 120 |
-
txt_in = gr.Textbox(lines=8, label="Enter
|
| 121 |
btn_txt = gr.Button("✨ Reveal Prophecy")
|
| 122 |
-
txt_out = gr.
|
| 123 |
btn_txt.click(oracle_text, inputs=txt_in, outputs=txt_out)
|
| 124 |
|
| 125 |
with gr.Tab("🖼️ Image Prophecy"):
|
| 126 |
-
img_in = gr.Image(type="filepath", label="Upload Image")
|
| 127 |
btn_img = gr.Button("✨ Reveal Prophecy")
|
| 128 |
-
img_out = gr.
|
| 129 |
btn_img.click(oracle_image, inputs=img_in, outputs=img_out)
|
| 130 |
|
| 131 |
with gr.Tab("🔊 Voice Revelation"):
|
| 132 |
-
aud_in = gr.Audio(sources=["microphone"], type="filepath", label="Speak
|
| 133 |
btn_aud = gr.Button("✨ Reveal Prophecy")
|
| 134 |
-
aud_out = gr.
|
| 135 |
btn_aud.click(oracle_audio, inputs=aud_in, outputs=aud_out)
|
| 136 |
|
| 137 |
with gr.Tab("📑 PDF Prophecy"):
|
| 138 |
-
pdf_in = gr.File(file_types=[".pdf"]
|
| 139 |
btn_pdf = gr.Button("✨ Reveal Prophecy")
|
| 140 |
-
pdf_out = gr.
|
| 141 |
btn_pdf.click(oracle_pdf, inputs=pdf_in, outputs=pdf_out)
|
| 142 |
|
| 143 |
demo.launch()
|
|
|
|
| 20 |
result = text_detector(user_text)
|
| 21 |
label = result[0]['label']
|
| 22 |
score = round(result[0]['score'] * 100, 2)
|
| 23 |
+
if label.lower() == "fake":
|
| 24 |
+
return f"🌌 **Prophecy:** {score}% AI‑generated 🤖✨"
|
| 25 |
+
return f"☀️ **Prophecy:** {score}% Human‑written 🧑💻"
|
|
|
|
|
|
|
| 26 |
|
| 27 |
@spaces.GPU
|
| 28 |
def oracle_image(user_img):
|
|
|
|
| 31 |
result = image_analyzer(user_img)
|
| 32 |
label = result[0]['label']
|
| 33 |
score = round(result[0]['score'] * 100, 2)
|
| 34 |
+
return f"🖼️ Oracle’s Sight: {score}% resemblance to **{label}**"
|
| 35 |
|
| 36 |
@spaces.GPU
|
| 37 |
def oracle_audio(audio_file):
|
|
|
|
| 41 |
result = text_detector(transcript)
|
| 42 |
label = result[0]['label']
|
| 43 |
score = round(result[0]['score'] * 100, 2)
|
| 44 |
+
if label.lower() == "fake":
|
| 45 |
+
return f"🔊 Transcript: *{transcript}*\n\n🌌 Prophecy: {score}% AI‑generated 🤖"
|
| 46 |
+
return f"🔊 Transcript: *{transcript}*\n\n☀️ Prophecy: {score}% Human‑written 🧑💻"
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
@spaces.GPU
|
| 49 |
def oracle_pdf(pdf_file):
|
|
|
|
| 56 |
result = text_detector(text[:800])
|
| 57 |
label = result[0]['label']
|
| 58 |
score = round(result[0]['score'] * 100, 2)
|
| 59 |
+
if label.lower() == "fake":
|
| 60 |
+
return f"📑 PDF Prophecy: {score}% AI‑generated 🤖"
|
| 61 |
+
return f"📑 PDF Prophecy: {score}% Human‑authored 🧑💻"
|
|
|
|
|
|
|
| 62 |
|
| 63 |
# -------------------------------
|
| 64 |
+
# UI (copied styling from awesome-pet-talk)
|
| 65 |
# -------------------------------
|
| 66 |
with gr.Blocks(css="""
|
| 67 |
body {
|
| 68 |
+
background: linear-gradient(135deg, #fbc2eb, #a6c1ee);
|
| 69 |
+
font-family: 'Trebuchet MS', sans-serif;
|
| 70 |
+
color: #2c003e;
|
| 71 |
+
text-align: center;
|
| 72 |
}
|
| 73 |
+
h1 {
|
| 74 |
+
font-size: 3em !important;
|
| 75 |
+
color: #ff0080;
|
| 76 |
+
text-shadow: 2px 2px 8px #00000055;
|
|
|
|
|
|
|
| 77 |
}
|
| 78 |
+
h2, h3, label {
|
| 79 |
+
font-size: 1.4em !important;
|
| 80 |
+
color: #4b0082;
|
|
|
|
|
|
|
| 81 |
}
|
| 82 |
+
textarea, input, .gr-textbox {
|
| 83 |
+
font-size: 1.2em !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
}
|
| 85 |
+
.result-box {
|
| 86 |
+
background: rgba(255,255,255,0.9);
|
| 87 |
+
border-radius: 20px;
|
| 88 |
+
padding: 20px;
|
| 89 |
+
margin-top: 20px;
|
| 90 |
+
font-size: 1.4em;
|
| 91 |
+
color: #222;
|
| 92 |
+
box-shadow: 0px 4px 15px rgba(0,0,0,0.3);
|
| 93 |
+
text-align: left;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
}
|
| 95 |
""") as demo:
|
| 96 |
|
| 97 |
+
gr.Markdown("# 🔮 Oracle of Truth 🔮")
|
| 98 |
+
gr.Markdown("### ✨ Multi‑Sight Divination: **Text · Image · Voice · PDF** ✨")
|
| 99 |
|
| 100 |
with gr.Tab("📜 Text Divination"):
|
| 101 |
+
txt_in = gr.Textbox(lines=8, label="✍️ Enter Text", placeholder="Paste your essay, blog, or snippet…")
|
| 102 |
btn_txt = gr.Button("✨ Reveal Prophecy")
|
| 103 |
+
txt_out = gr.Markdown(elem_classes="result-box")
|
| 104 |
btn_txt.click(oracle_text, inputs=txt_in, outputs=txt_out)
|
| 105 |
|
| 106 |
with gr.Tab("🖼️ Image Prophecy"):
|
| 107 |
+
img_in = gr.Image(type="filepath", label="Upload Image 🖼️")
|
| 108 |
btn_img = gr.Button("✨ Reveal Prophecy")
|
| 109 |
+
img_out = gr.Markdown(elem_classes="result-box")
|
| 110 |
btn_img.click(oracle_image, inputs=img_in, outputs=img_out)
|
| 111 |
|
| 112 |
with gr.Tab("🔊 Voice Revelation"):
|
| 113 |
+
aud_in = gr.Audio(sources=["microphone"], type="filepath", label="🎤 Speak")
|
| 114 |
btn_aud = gr.Button("✨ Reveal Prophecy")
|
| 115 |
+
aud_out = gr.Markdown(elem_classes="result-box")
|
| 116 |
btn_aud.click(oracle_audio, inputs=aud_in, outputs=aud_out)
|
| 117 |
|
| 118 |
with gr.Tab("📑 PDF Prophecy"):
|
| 119 |
+
pdf_in = gr.File(label="📄 Upload PDF", file_types=[".pdf"])
|
| 120 |
btn_pdf = gr.Button("✨ Reveal Prophecy")
|
| 121 |
+
pdf_out = gr.Markdown(elem_classes="result-box")
|
| 122 |
btn_pdf.click(oracle_pdf, inputs=pdf_in, outputs=pdf_out)
|
| 123 |
|
| 124 |
demo.launch()
|