Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,15 +1,14 @@
|
|
1 |
import os
|
|
|
|
|
2 |
import streamlit as st
|
3 |
from transformers import PegasusTokenizer, PegasusForConditionalGeneration
|
4 |
|
5 |
-
# Install necessary packages (only needed if not already installed)
|
6 |
-
os.system('pip install streamlit transformers torch')
|
7 |
-
|
8 |
# Load the model and tokenizer
|
9 |
-
|
10 |
|
11 |
-
tokenizer = PegasusTokenizer.from_pretrained(
|
12 |
-
model = PegasusForConditionalGeneration.from_pretrained(
|
13 |
|
14 |
def summarize_text(text):
|
15 |
inputs = tokenizer(text, return_tensors="pt", truncation=True, padding="longest")
|
@@ -37,7 +36,7 @@ if __name__ == "__main__":
|
|
37 |
<style>
|
38 |
.reportview-container {
|
39 |
flex-direction: row;
|
40 |
-
justify-content: center
|
41 |
}
|
42 |
</style>
|
43 |
""",
|
|
|
1 |
import os
|
2 |
+
os.system('pip install streamlit transformers torch sentencepiece')
|
3 |
+
|
4 |
import streamlit as st
|
5 |
from transformers import PegasusTokenizer, PegasusForConditionalGeneration
|
6 |
|
|
|
|
|
|
|
7 |
# Load the model and tokenizer
|
8 |
+
model_name = "google/pegasus-xsum" # Using a different Pegasus model
|
9 |
|
10 |
+
tokenizer = PegasusTokenizer.from_pretrained(model_name)
|
11 |
+
model = PegasusForConditionalGeneration.from_pretrained(model_name)
|
12 |
|
13 |
def summarize_text(text):
|
14 |
inputs = tokenizer(text, return_tensors="pt", truncation=True, padding="longest")
|
|
|
36 |
<style>
|
37 |
.reportview-container {
|
38 |
flex-direction: row;
|
39 |
+
justify-content: center.
|
40 |
}
|
41 |
</style>
|
42 |
""",
|