File size: 897 Bytes
07c9b4a
7565aef
07c9b4a
7565aef
 
 
 
07c9b4a
7565aef
 
 
07c9b4a
7565aef
 
07c9b4a
7565aef
07c9b4a
7565aef
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import streamlit as st
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM

# Load the model and tokenizer from Hugging Face Model Hub
model_name = "ASaboor/Saboors_Bart_samsum"  # Ensure this is correct
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSeq2SeqLM.from_pretrained(model_name)

# Streamlit App
st.title("Summarization App")
st.write("This app uses a fine-tuned model to summarize text.")

# Text input
text = st.text_area("Enter text to summarize")

# Summarize button
if st.button("Summarize"):
    inputs = tokenizer.encode("summarize: " + text, return_tensors="pt", max_length=512, truncation=True)
    summary_ids = model.generate(inputs, max_length=150, min_length=40, length_penalty=2.0, num_beams=4, early_stopping=True)
    summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
    st.write("Summary:")
    st.write(summary)