Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Code 4 - Let's create an UI using Gradio
|
| 2 |
+
import gradio as gr
|
| 3 |
+
|
| 4 |
+
# Code 5 - define a function to summarize text
|
| 5 |
+
def nlp(input_text):
|
| 6 |
+
summary = summarizer(
|
| 7 |
+
input_text,
|
| 8 |
+
repetition_penalty=5.0, # Increase this to discourage repetition
|
| 9 |
+
length_penalty=0.3, # Decrease this to generate longer summaries
|
| 10 |
+
min_length=20, max_length=100
|
| 11 |
+
)
|
| 12 |
+
return summary[0]["summary_text"]
|
| 13 |
+
# Code 6 - UI object
|
| 14 |
+
ui = gr.Interface(nlp,
|
| 15 |
+
inputs=gr.Textbox(label="Input Text"),
|
| 16 |
+
outputs=gr.Textbox(label="Summary"),
|
| 17 |
+
title="Text Summarizer",
|
| 18 |
+
description="Summarize your text using the BART model.")
|
| 19 |
+
# Code 7 - launch UI
|
| 20 |
+
ui.launch(share=True)
|