Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -25,7 +25,7 @@ def summarize_text(text):
|
|
| 25 |
if not text or len(text.split()) < 10:
|
| 26 |
return "⚠️ Teks terlalu pendek (minimal 10 kata)."
|
| 27 |
|
| 28 |
-
text = clean_text()
|
| 29 |
|
| 30 |
inputs = tokenizer(
|
| 31 |
"ringkas: " + text,
|
|
@@ -45,12 +45,12 @@ def summarize_text(text):
|
|
| 45 |
return tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 46 |
|
| 47 |
# =========================
|
| 48 |
-
# CUSTOM CSS
|
| 49 |
# =========================
|
| 50 |
custom_css = """
|
| 51 |
body {
|
| 52 |
background: radial-gradient(circle at top, #141a33, #0b0f1a);
|
| 53 |
-
font-family:
|
| 54 |
}
|
| 55 |
|
| 56 |
.gradio-container {
|
|
@@ -66,22 +66,12 @@ body {
|
|
| 66 |
box-shadow: 0 10px 30px rgba(0,0,0,0.25);
|
| 67 |
}
|
| 68 |
|
| 69 |
-
h1 {
|
| 70 |
-
font-size: 2.4rem;
|
| 71 |
-
font-weight: 700;
|
| 72 |
-
text-align: center;
|
| 73 |
-
}
|
| 74 |
-
|
| 75 |
.subtitle {
|
| 76 |
text-align: center;
|
| 77 |
opacity: 0.85;
|
| 78 |
margin-bottom: 2rem;
|
| 79 |
}
|
| 80 |
|
| 81 |
-
label {
|
| 82 |
-
font-weight: 600;
|
| 83 |
-
}
|
| 84 |
-
|
| 85 |
button {
|
| 86 |
background: linear-gradient(135deg, #8b5cf6, #10b981) !important;
|
| 87 |
color: white !important;
|
|
@@ -100,38 +90,34 @@ button {
|
|
| 100 |
# =========================
|
| 101 |
# UI
|
| 102 |
# =========================
|
| 103 |
-
with gr.Blocks(
|
| 104 |
|
| 105 |
-
# HERO
|
| 106 |
gr.Markdown("""
|
| 107 |
-
<h1>AI Text Summarization</h1>
|
| 108 |
<div class="subtitle">
|
| 109 |
Research-grade automatic summarization for Indonesian text
|
| 110 |
</div>
|
| 111 |
""")
|
| 112 |
|
| 113 |
-
|
| 114 |
-
gr.Markdown('<div class="section-card">', unsafe_allow_html=True)
|
| 115 |
gr.Markdown("### 📝 Input Artikel")
|
| 116 |
input_text = gr.Textbox(
|
| 117 |
lines=12,
|
| 118 |
placeholder="Tempelkan artikel, berita, atau teks panjang di sini..."
|
| 119 |
)
|
| 120 |
gr.Markdown(
|
| 121 |
-
'<div class="helper">Minimal 10 kata. Maksimal ±500 kata.</div>'
|
| 122 |
-
unsafe_allow_html=True
|
| 123 |
)
|
| 124 |
btn = gr.Button("Generate Summary")
|
| 125 |
-
gr.Markdown('</div>'
|
| 126 |
|
| 127 |
-
|
| 128 |
-
gr.Markdown('<div class="section-card">', unsafe_allow_html=True)
|
| 129 |
gr.Markdown("### ✨ Ringkasan")
|
| 130 |
output_text = gr.Textbox(
|
| 131 |
lines=10,
|
| 132 |
placeholder="Hasil ringkasan akan muncul di sini..."
|
| 133 |
)
|
| 134 |
-
gr.Markdown('</div>'
|
| 135 |
|
| 136 |
btn.click(
|
| 137 |
fn=summarize_text,
|
|
@@ -139,11 +125,13 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Base()) as demo:
|
|
| 139 |
outputs=output_text
|
| 140 |
)
|
| 141 |
|
| 142 |
-
# FOOTER
|
| 143 |
gr.Markdown("""
|
| 144 |
<center style="opacity:0.6; font-size:0.85rem; margin-top:1rem;">
|
| 145 |
© 2025 — AI Summarization System • Built with Gradio & Transformers
|
| 146 |
</center>
|
| 147 |
""")
|
| 148 |
|
| 149 |
-
demo.launch(
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
if not text or len(text.split()) < 10:
|
| 26 |
return "⚠️ Teks terlalu pendek (minimal 10 kata)."
|
| 27 |
|
| 28 |
+
text = clean_text(text)
|
| 29 |
|
| 30 |
inputs = tokenizer(
|
| 31 |
"ringkas: " + text,
|
|
|
|
| 45 |
return tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 46 |
|
| 47 |
# =========================
|
| 48 |
+
# CUSTOM CSS
|
| 49 |
# =========================
|
| 50 |
custom_css = """
|
| 51 |
body {
|
| 52 |
background: radial-gradient(circle at top, #141a33, #0b0f1a);
|
| 53 |
+
font-family: Inter, system-ui, sans-serif;
|
| 54 |
}
|
| 55 |
|
| 56 |
.gradio-container {
|
|
|
|
| 66 |
box-shadow: 0 10px 30px rgba(0,0,0,0.25);
|
| 67 |
}
|
| 68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
.subtitle {
|
| 70 |
text-align: center;
|
| 71 |
opacity: 0.85;
|
| 72 |
margin-bottom: 2rem;
|
| 73 |
}
|
| 74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
button {
|
| 76 |
background: linear-gradient(135deg, #8b5cf6, #10b981) !important;
|
| 77 |
color: white !important;
|
|
|
|
| 90 |
# =========================
|
| 91 |
# UI
|
| 92 |
# =========================
|
| 93 |
+
with gr.Blocks() as demo:
|
| 94 |
|
|
|
|
| 95 |
gr.Markdown("""
|
| 96 |
+
<h1 style="text-align:center;">AI Text Summarization</h1>
|
| 97 |
<div class="subtitle">
|
| 98 |
Research-grade automatic summarization for Indonesian text
|
| 99 |
</div>
|
| 100 |
""")
|
| 101 |
|
| 102 |
+
gr.Markdown('<div class="section-card">')
|
|
|
|
| 103 |
gr.Markdown("### 📝 Input Artikel")
|
| 104 |
input_text = gr.Textbox(
|
| 105 |
lines=12,
|
| 106 |
placeholder="Tempelkan artikel, berita, atau teks panjang di sini..."
|
| 107 |
)
|
| 108 |
gr.Markdown(
|
| 109 |
+
'<div class="helper">Minimal 10 kata. Maksimal ±500 kata.</div>'
|
|
|
|
| 110 |
)
|
| 111 |
btn = gr.Button("Generate Summary")
|
| 112 |
+
gr.Markdown('</div>')
|
| 113 |
|
| 114 |
+
gr.Markdown('<div class="section-card">')
|
|
|
|
| 115 |
gr.Markdown("### ✨ Ringkasan")
|
| 116 |
output_text = gr.Textbox(
|
| 117 |
lines=10,
|
| 118 |
placeholder="Hasil ringkasan akan muncul di sini..."
|
| 119 |
)
|
| 120 |
+
gr.Markdown('</div>')
|
| 121 |
|
| 122 |
btn.click(
|
| 123 |
fn=summarize_text,
|
|
|
|
| 125 |
outputs=output_text
|
| 126 |
)
|
| 127 |
|
|
|
|
| 128 |
gr.Markdown("""
|
| 129 |
<center style="opacity:0.6; font-size:0.85rem; margin-top:1rem;">
|
| 130 |
© 2025 — AI Summarization System • Built with Gradio & Transformers
|
| 131 |
</center>
|
| 132 |
""")
|
| 133 |
|
| 134 |
+
demo.launch(
|
| 135 |
+
css=custom_css,
|
| 136 |
+
theme=gr.themes.Base()
|
| 137 |
+
)
|