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

# Load the tokenizer and model from the Hugging Face Model Hub
model_path = 'abdulllah01/Bert-Finetuned'
tokenizer = AutoTokenizer.from_pretrained(model_path)
model = AutoModelForSeq2SeqLM.from_pretrained(model_path)

# Streamlit app
st.title("Summarization App")
st.write("Summarize Your Dialogues with the Fine Tuned Bart!")

# User input
user_input = st.text_area("Enter text to summarize", "")

if st.button("Summarize"):
    if user_input:
        inputs = tokenizer.encode("summarize: " + user_input, 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)
    else:
        st.write("Please enter some text to summarize")