Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,10 +1,14 @@
|
|
1 |
import streamlit as st
|
2 |
-
from transformers import pipeline, AutoModelForSeq2SeqLM, T5Tokenizer
|
3 |
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
8 |
summarizer = pipeline("summarization", model=model, tokenizer=tokenizer)
|
9 |
|
10 |
# Set the title for the Streamlit app
|
@@ -15,7 +19,7 @@ text = st.text_area("Enter your text: ")
|
|
15 |
|
16 |
def generate_summary(input_text):
|
17 |
# Perform summarization
|
18 |
-
summary = summarizer(input_text, max_length=
|
19 |
return summary[0]['summary_text']
|
20 |
|
21 |
if st.button("Generate"):
|
|
|
1 |
import streamlit as st
|
|
|
2 |
|
3 |
+
from transformers import T5Tokenizer, TFAutoModelForSeq2SeqLM, pipeline
|
4 |
+
|
5 |
+
# Define the path to the saved model
|
6 |
+
model_path = '/T5_samsum-20240723T171755Z-001.zip'
|
7 |
+
|
8 |
+
# Load the tokenizer and model
|
9 |
+
tokenizer = T5Tokenizer.from_pretrained(model_path)
|
10 |
+
model = TFAutoModelForSeq2SeqLM.from_pretrained(model_path)
|
11 |
+
|
12 |
summarizer = pipeline("summarization", model=model, tokenizer=tokenizer)
|
13 |
|
14 |
# Set the title for the Streamlit app
|
|
|
19 |
|
20 |
def generate_summary(input_text):
|
21 |
# Perform summarization
|
22 |
+
summary = summarizer(input_text, max_length=200, min_length=40, do_sample=False)
|
23 |
return summary[0]['summary_text']
|
24 |
|
25 |
if st.button("Generate"):
|