Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,71 +1,39 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import random
|
| 3 |
|
| 4 |
-
# Dummy
|
| 5 |
-
def
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
def refine_text(text, tone, translate):
|
| 10 |
-
# Simulated tone conversion
|
| 11 |
-
if tone == "Academic":
|
| 12 |
-
refined = f"In academic tone: {text}"
|
| 13 |
-
elif tone == "Professional":
|
| 14 |
-
refined = f"As a professional: {text}"
|
| 15 |
-
elif tone == "Conversational":
|
| 16 |
-
refined = f"Hey! So here it is: {text}"
|
| 17 |
-
else:
|
| 18 |
-
refined = text
|
| 19 |
-
|
| 20 |
-
# Simulated translation
|
| 21 |
-
if translate == "Bahasa Malaysia":
|
| 22 |
-
translated = f"(BM Translation) {refined}"
|
| 23 |
-
elif translate == "Chinese":
|
| 24 |
-
translated = f"(中文翻译) {refined}"
|
| 25 |
-
else:
|
| 26 |
-
translated = ""
|
| 27 |
|
| 28 |
-
# AI-likeness
|
| 29 |
-
|
|
|
|
| 30 |
|
| 31 |
-
return refined,
|
| 32 |
|
| 33 |
-
# Gradio
|
| 34 |
with gr.Blocks() as demo:
|
| 35 |
gr.Markdown(
|
| 36 |
"""
|
| 37 |
-
# 🕌
|
| 38 |
-
|
| 39 |
-
Transforms input into refined **Academic**, **Professional**, or **Conversational** tone.
|
| 40 |
-
Also detects **AI-likeness** and can translate to **Bahasa Malaysia** or **Chinese**.
|
| 41 |
|
| 42 |
---
|
| 43 |
"""
|
| 44 |
)
|
| 45 |
|
| 46 |
-
|
| 47 |
-
with gr.Column(scale=1):
|
| 48 |
-
input_text = gr.Textbox(lines=6, label="✍️Enter your text", placeholder="Paste your content here...")
|
| 49 |
|
| 50 |
-
|
| 51 |
|
| 52 |
-
|
|
|
|
| 53 |
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
with gr.Column(scale=1):
|
| 59 |
-
output_box = gr.Textbox(label=" Refined Output", lines=5)
|
| 60 |
-
ai_score_box = gr.Textbox(label=" AI Detection Result")
|
| 61 |
-
translated_box = gr.Textbox(label=" Translated Output", lines=5)
|
| 62 |
-
|
| 63 |
-
# Button logic
|
| 64 |
-
submit_btn.click(fn=refine_text,
|
| 65 |
-
inputs=[input_text, tone, translate_to],
|
| 66 |
-
outputs=[output_box, ai_score_box, translated_box])
|
| 67 |
-
|
| 68 |
-
clear_btn.click(lambda: ("", "", ""), outputs=[output_box, ai_score_box, translated_box])
|
| 69 |
|
| 70 |
demo.queue().launch()
|
| 71 |
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import random
|
| 3 |
|
| 4 |
+
# Dummy logic (replace with your model later)
|
| 5 |
+
def humanize_and_detect(text):
|
| 6 |
+
# Simulated refined output
|
| 7 |
+
refined = f"This is the humanized version of your text:\n\n{text}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
+
# Simulated AI-likeness score
|
| 10 |
+
score = random.uniform(0.3, 0.95)
|
| 11 |
+
ai_score = f"AI-likeness score: {score:.2f} ({'Likely Human' if score < 0.5 else 'Likely AI'})"
|
| 12 |
|
| 13 |
+
return refined, ai_score
|
| 14 |
|
| 15 |
+
# Minimal Gradio interface
|
| 16 |
with gr.Blocks() as demo:
|
| 17 |
gr.Markdown(
|
| 18 |
"""
|
| 19 |
+
# 🕌 Zawiyah AI Collective – Humanizer AI
|
| 20 |
+
Refine your writing & detect AI-likeness. Simple, clean, effective.
|
|
|
|
|
|
|
| 21 |
|
| 22 |
---
|
| 23 |
"""
|
| 24 |
)
|
| 25 |
|
| 26 |
+
input_text = gr.Textbox(label="✍️ Paste Your Text Here", placeholder="Enter text...", lines=6)
|
|
|
|
|
|
|
| 27 |
|
| 28 |
+
submit_btn = gr.Button("🚀 Refine & Detect")
|
| 29 |
|
| 30 |
+
output_refined = gr.Textbox(label="🧠 Humanized Output", lines=6)
|
| 31 |
+
ai_score = gr.Textbox(label="🤖 AI Detection Result")
|
| 32 |
|
| 33 |
+
submit_btn.click(fn=humanize_and_detect,
|
| 34 |
+
inputs=input_text,
|
| 35 |
+
outputs=[output_refined, ai_score])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
demo.queue().launch()
|
| 38 |
|
| 39 |
+
|