Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,12 @@
|
|
1 |
import streamlit as st
|
2 |
-
from transformers import T5Tokenizer,
|
3 |
import zipfile
|
4 |
import os
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
# Define the path to the saved model zip file
|
7 |
zip_model_path = 'T5_samsum-20240723T171755Z-001.zip'
|
@@ -22,7 +27,7 @@ if not os.path.exists(model_path):
|
|
22 |
else:
|
23 |
# Load the tokenizer and model
|
24 |
tokenizer = T5Tokenizer.from_pretrained(model_path)
|
25 |
-
model =
|
26 |
|
27 |
# Create a summarization pipeline
|
28 |
summarizer = pipeline("summarization", model=model, tokenizer=tokenizer)
|
|
|
1 |
import streamlit as st
|
2 |
+
from transformers import T5Tokenizer, AutoModelForSeq2SeqLM, pipeline
|
3 |
import zipfile
|
4 |
import os
|
5 |
+
import nltk
|
6 |
+
|
7 |
+
# Download NLTK data
|
8 |
+
nltk.download('punkt')
|
9 |
+
from nltk.tokenize import sent_tokenize
|
10 |
|
11 |
# Define the path to the saved model zip file
|
12 |
zip_model_path = 'T5_samsum-20240723T171755Z-001.zip'
|
|
|
27 |
else:
|
28 |
# Load the tokenizer and model
|
29 |
tokenizer = T5Tokenizer.from_pretrained(model_path)
|
30 |
+
model = AutoModelForSeq2SeqLM.from_pretrained(model_path)
|
31 |
|
32 |
# Create a summarization pipeline
|
33 |
summarizer = pipeline("summarization", model=model, tokenizer=tokenizer)
|