Spaces:
Configuration error
Configuration error
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +4 -8
src/streamlit_app.py
CHANGED
|
@@ -9,20 +9,18 @@ MODEL_NAME = "AbdullahAlnemr1/flan-t5-summarizer"
|
|
| 9 |
tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
|
| 10 |
model = AutoModelForSeq2SeqLM.from_pretrained(MODEL_NAME)
|
| 11 |
|
| 12 |
-
st.title("Text Summarizer
|
| 13 |
|
| 14 |
-
input_text = st.text_area("Enter text summarize:", height=200)
|
| 15 |
|
| 16 |
-
|
| 17 |
-
max_new_tokens = 100 # You can adjust this number
|
| 18 |
|
| 19 |
if st.button("Generate Summary"):
|
| 20 |
if input_text.strip() == "":
|
| 21 |
-
st.warning("
|
| 22 |
else:
|
| 23 |
# Tokenize input
|
| 24 |
inputs = tokenizer(input_text, return_tensors="pt", truncation=True)
|
| 25 |
-
|
| 26 |
# Generate summary
|
| 27 |
outputs = model.generate(
|
| 28 |
inputs["input_ids"],
|
|
@@ -30,8 +28,6 @@ if st.button("Generate Summary"):
|
|
| 30 |
num_beams=4,
|
| 31 |
early_stopping=True
|
| 32 |
)
|
| 33 |
-
|
| 34 |
summary = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 35 |
-
|
| 36 |
st.subheader("Summary:")
|
| 37 |
st.write(summary)
|
|
|
|
| 9 |
tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
|
| 10 |
model = AutoModelForSeq2SeqLM.from_pretrained(MODEL_NAME)
|
| 11 |
|
| 12 |
+
st.title("Text Summarizer(Encoder-Decoder)")
|
| 13 |
|
| 14 |
+
input_text = st.text_area("Enter text to summarize:", height=200)
|
| 15 |
|
| 16 |
+
max_new_tokens = st.slider("Max summary length", min_value=20, max_value=200, value=100)
|
|
|
|
| 17 |
|
| 18 |
if st.button("Generate Summary"):
|
| 19 |
if input_text.strip() == "":
|
| 20 |
+
st.warning("Please enter some text to summarize.")
|
| 21 |
else:
|
| 22 |
# Tokenize input
|
| 23 |
inputs = tokenizer(input_text, return_tensors="pt", truncation=True)
|
|
|
|
| 24 |
# Generate summary
|
| 25 |
outputs = model.generate(
|
| 26 |
inputs["input_ids"],
|
|
|
|
| 28 |
num_beams=4,
|
| 29 |
early_stopping=True
|
| 30 |
)
|
|
|
|
| 31 |
summary = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
|
|
|
| 32 |
st.subheader("Summary:")
|
| 33 |
st.write(summary)
|