imelia13 commited on
Commit
759c6b8
·
verified ·
1 Parent(s): 13e1f7b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +62 -37
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(text)
29
 
30
  inputs = tokenizer(
31
  "ringkas: " + text,
@@ -38,48 +38,62 @@ def summarize_text(text):
38
  outputs = model.generate(
39
  **inputs,
40
  max_length=128,
41
- num_beams=2
 
42
  )
43
 
44
  return tokenizer.decode(outputs[0], skip_special_tokens=True)
45
 
46
  # =========================
47
- # CUSTOM CSS (FORCE SIDE BY SIDE)
48
  # =========================
49
  custom_css = """
50
  body {
51
  background: radial-gradient(circle at top, #141a33, #0b0f1a);
52
- font-family: 'Space Grotesk', sans-serif;
53
  }
54
 
55
  .gradio-container {
56
- max-width: 1200px !important;
57
  margin: auto !important;
58
  }
59
 
60
- /* Paksa kiri-kanan di desktop */
61
- .gr-row {
62
- flex-wrap: nowrap !important;
63
- }
64
-
65
- /* Responsive: mobile tetap atas-bawah */
66
- @media (max-width: 900px) {
67
- .gr-row {
68
- flex-wrap: wrap !important;
69
- }
70
  }
71
 
72
  h1 {
73
- font-size: 2.6rem;
74
  font-weight: 700;
75
  text-align: center;
76
  }
77
 
 
 
 
 
 
 
 
 
 
 
78
  button {
79
  background: linear-gradient(135deg, #8b5cf6, #10b981) !important;
80
  color: white !important;
81
  font-weight: 600;
82
  border-radius: 14px !important;
 
 
 
 
 
 
 
83
  }
84
  """
85
 
@@ -88,28 +102,36 @@ button {
88
  # =========================
89
  with gr.Blocks(css=custom_css, theme=gr.themes.Base()) as demo:
90
 
 
91
  gr.Markdown("""
92
- <div style="text-align:center; margin-bottom: 2rem;">
93
- <h1>AI Text Summarization</h1>
94
- <p>Research-grade automatic summarization for Indonesian text</p>
95
  </div>
96
  """)
97
 
98
- with gr.Row():
99
- with gr.Column(scale=1, min_width=420):
100
- gr.Markdown("### Input Artikel")
101
- input_text = gr.Textbox(
102
- lines=16,
103
- placeholder="Masukkan teks artikel panjang di sini..."
104
- )
105
- btn = gr.Button("Generate Summary")
106
-
107
- with gr.Column(scale=1, min_width=420):
108
- gr.Markdown("### Ringkasan")
109
- output_text = gr.Textbox(
110
- lines=16,
111
- placeholder="Hasil ringkasan akan muncul di sini..."
112
- )
 
 
 
 
 
 
 
113
 
114
  btn.click(
115
  fn=summarize_text,
@@ -117,8 +139,11 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Base()) as demo:
117
  outputs=output_text
118
  )
119
 
120
- gr.Markdown(
121
- "<center><small>© 2025 — AI Summarization System</small></center>"
122
- )
 
 
 
123
 
124
  demo.launch()
 
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,
 
38
  outputs = model.generate(
39
  **inputs,
40
  max_length=128,
41
+ num_beams=4,
42
+ early_stopping=True
43
  )
44
 
45
  return tokenizer.decode(outputs[0], skip_special_tokens=True)
46
 
47
  # =========================
48
+ # CUSTOM CSS (PROFESSIONAL)
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 {
57
+ max-width: 860px !important;
58
  margin: auto !important;
59
  }
60
 
61
+ .section-card {
62
+ background: rgba(255,255,255,0.04);
63
+ border-radius: 20px;
64
+ padding: 1.5rem;
65
+ margin-bottom: 1.5rem;
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;
88
  font-weight: 600;
89
  border-radius: 14px !important;
90
+ height: 48px;
91
+ }
92
+
93
+ .helper {
94
+ font-size: 0.85rem;
95
+ opacity: 0.7;
96
+ margin-top: 0.5rem;
97
  }
98
  """
99
 
 
102
  # =========================
103
  with gr.Blocks(css=custom_css, theme=gr.themes.Base()) as demo:
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
+ # INPUT CARD
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>', unsafe_allow_html=True)
126
+
127
+ # OUTPUT CARD
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>', unsafe_allow_html=True)
135
 
136
  btn.click(
137
  fn=summarize_text,
 
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()