Spaces:
Runtime error
Runtime error
Jason Surya commited on
Commit ·
867afc2
1
Parent(s): 87fbbad
first commit
Browse files- app.py +31 -0
- requirements.txt +2 -0
app.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# def summarizeText(summarizer, txt):
|
| 5 |
+
# summarized_text = summarizer(txt)[0]["summary_text"]
|
| 6 |
+
# return summarized_text
|
| 7 |
+
@st.cache(ttl=120)
|
| 8 |
+
def load_summarizer():
|
| 9 |
+
return pipeline("summarization", model = "jasonsurya0/BART_TWELVE")
|
| 10 |
+
|
| 11 |
+
def main():
|
| 12 |
+
st.set_page_config(page_title="Automatic Text Summarizer With BART")
|
| 13 |
+
# BART MODEL DEVELOPED
|
| 14 |
+
summarizer = load_summarizer()
|
| 15 |
+
# ----HEADER
|
| 16 |
+
st.subheader("Text Summarizer Built With BART")
|
| 17 |
+
|
| 18 |
+
#-----Text Area
|
| 19 |
+
txt = st.text_area('Input Text to Summarize', '''
|
| 20 |
+
Amanda: I baked cookies. Do you want some?
|
| 21 |
+
Jerry: Sure!
|
| 22 |
+
Amanda: I'll bring you tomorrow :-)
|
| 23 |
+
''', height = 180)
|
| 24 |
+
|
| 25 |
+
if st.button('Summarize'):
|
| 26 |
+
st.write("TEST")
|
| 27 |
+
#st.write(summarizeText(summarizer, txt))
|
| 28 |
+
#st.text_area('Summarized Text', summarizeText(summarizer, txt), height = 140)
|
| 29 |
+
|
| 30 |
+
if __name__=="__main__":
|
| 31 |
+
main()
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
transformers==4.28.1
|
| 2 |
+
torch
|