Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
import gradio as gr
|
2 |
import nltk
|
3 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
4 |
|
@@ -59,3 +59,39 @@ iface = gr.Interface(
|
|
59 |
)
|
60 |
|
61 |
iface.launch(share=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""import gradio as gr
|
2 |
import nltk
|
3 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
4 |
|
|
|
59 |
)
|
60 |
|
61 |
iface.launch(share=True)
|
62 |
+
"""
|
63 |
+
import gradio as gr
|
64 |
+
import nltk
|
65 |
+
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
66 |
+
|
67 |
+
nltk.download('punkt')
|
68 |
+
|
69 |
+
def fragment_text(text, tokenizer):
|
70 |
+
# Your existing code for text fragmentation
|
71 |
+
|
72 |
+
def summarize_text(text, tokenizer, model):
|
73 |
+
# Your existing code for text summarization
|
74 |
+
|
75 |
+
checkpoint = "tclopess/bart_samsum"
|
76 |
+
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
|
77 |
+
model = AutoModelForSeq2SeqLM.from_pretrained(checkpoint)
|
78 |
+
|
79 |
+
def summarize_with_button(text):
|
80 |
+
return summarize_text(text, tokenizer, model)
|
81 |
+
|
82 |
+
iface = gr.Interface(
|
83 |
+
fn=summarize_with_button,
|
84 |
+
inputs=gr.Textbox(label="Enter text to summarize:"),
|
85 |
+
outputs=gr.Textbox(label="Summary:"),
|
86 |
+
title="Text Summarizer with Button",
|
87 |
+
)
|
88 |
+
|
89 |
+
def summarize_text_button():
|
90 |
+
iface.launch(share=True)
|
91 |
+
|
92 |
+
gr.Interface(
|
93 |
+
summarize_text_button,
|
94 |
+
inputs=None,
|
95 |
+
outputs=None,
|
96 |
+
title="Click to Summarize"
|
97 |
+
).launch()
|