File size: 1,373 Bytes
3723b18
 
 
 
 
 
 
 
 
 
174f0a6
 
3723b18
174f0a6
 
3723b18
174f0a6
 
 
3723b18
174f0a6
 
3723b18
174f0a6
3723b18
174f0a6
 
 
 
 
3723b18
174f0a6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# app.py
!pip install transformers
!pip install streamlit

import streamlit as st
from transformers import pipeline
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
import torch
import gdown

import streamlit as st
from transformers import pipeline, AutoTokenizer, AutoModelForSeq2SeqLM

# Load the model and tokenizer
model_path = '.' 

tokenizer = AutoTokenizer.from_pretrained(model_path)
model = AutoModelForSeq2SeqLM.from_pretrained(model_path)
summarizer = pipeline('summarization', model=model, tokenizer=tokenizer)

st.title("Text Summarization with Fine-Tuned Model")
st.write("Enter text to generate a summary using the fine-tuned summarization model.")

text = st.text_area("Input Text", height=200)
if st.button("Summarize"):
    if text:
        with st.spinner("Summarizing..."):
            summary = summarizer(text, max_length=150, min_length=30, do_sample=False)
            st.success("Summary Generated")
            st.write(summary[0]['summary_text'])
    else:
        st.warning("Please enter some text to summarize.")

if __name__ == "__main__":
    st.set_option('deprecation.showfileUploaderEncoding', False)
    st.markdown(
        """
        <style>
        .reportview-container {
            flex-direction: row;
            justify-content: center;
        }
        </style>
        """,
        unsafe_allow_html=True
    )