File size: 2,123 Bytes
c9e6271
 
 
603d5ea
00bb000
c9e6271
603d5ea
c9e6271
00bb000
 
 
 
 
 
 
 
c9e6271
00bb000
c9e6271
 
603d5ea
 
eccaa24
00bb000
c9e6271
603d5ea
90d8b57
 
 
603d5ea
 
90d8b57
 
eccaa24
603d5ea
79bffd7
603d5ea
 
c9e6271
603d5ea
 
 
 
c9e6271
 
603d5ea
 
 
 
 
 
 
 
 
 
00bb000
603d5ea
 
 
 
 
 
 
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import streamlit as st
from transformers import pipeline

# 🧠 Set up the page
st.set_page_config(page_title="Text Summarizer", layout="wide")

# πŸ”„ Load summarizer model
@st.cache_resource
#def load_model():
    #return pipeline(
        #"summarization",
        #model="knkarthick/MEETING_SUMMARY",
        #tokenizer="knkarthick/MEETING_SUMMARY",
        #truncation=True
    #)

def load_model():
    return pipeline("summarization", model="facebook/bart-large-cnn")

summarizer = load_model()

# 🎨 Title and Subtitle
st.markdown("<h1 style='text-align: center;'>LLM- Powered Text Summarizer</h1>", unsafe_allow_html=True)
#st.markdown("<p style='text-align: center; color: gray;'>This app summarizes large texts efficiently using a lightweight model suited for Hugging Face CPU Spaces.</p>", unsafe_allow_html=True)

# πŸ”² Two-column layout
col1, col2 = st.columns(2)

with col1:
    st.markdown("### Enter Text here...")
    text = st.text_area("Enter your long text here...", height=400, label_visibility="collapsed")

with col2:
    st.markdown("### Summary:")
    summary_output = st.empty()

# πŸ›‘ Prevent crash from large input
text = " ".join(text.split()[:700])  # ~500–700 words safe for token limits

# ▢️ Generate summary
if st.button("πŸ” Summarize Now"):
    if text.strip() == "":
        st.warning("Please enter some text to summarize.")
    else:
        with st.spinner("Generating summary..."):
            try:
                output = summarizer(
                    text,
                    max_length=120,
                    min_length=40,
                    do_sample=False
                )
                result = output[0]['summary_text']
                summary_output.text_area("Summary Result", value=result, height=400, label_visibility="collapsed")
            except Exception as e:
                st.error(f"Error generating summary: {e}")

# πŸ‘£ Footer
#st.markdown("""
  #  <hr style="margin-top: 2em;">
  #  <p style='text-align: center; color: gray;'>Made with ❀️ by Komal Dahiya | Powered by Hugging Face & Streamlit</p>
#""", unsafe_allow_html=True)