karthi311 commited on
Commit
f01d828
·
verified ·
1 Parent(s): d3a7daa

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -71
app.py DELETED
@@ -1,71 +0,0 @@
1
- import streamlit as st
2
- from transformers import pipeline
3
-
4
- # Initialize the summarization pipeline
5
- summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
6
-
7
- # Streamlit UI setup
8
- st.title("📝 Text Summarization App")
9
-
10
- # User input box (allows large input text)
11
- user_input = st.text_area("Enter text to summarize:", "", height=300)
12
-
13
- # Custom CSS to position the slider in the top-right corner
14
- st.markdown("""
15
- <style>
16
- .slider-container {
17
- position: fixed;
18
- top: 10px;
19
- right: 10px;
20
- z-index: 1000;
21
- }
22
- </style>
23
- """, unsafe_allow_html=True)
24
-
25
- # Slider for adjusting summary length in the top-right corner
26
- with st.container():
27
- st.markdown('<div class="slider-container">', unsafe_allow_html=True)
28
- summary_length = st.slider(
29
- "Adjust Summary Length",
30
- min_value=1,
31
- max_value=3,
32
- value=2,
33
- step=1,
34
- format="Summary Length: %d"
35
- )
36
- st.markdown('</div>', unsafe_allow_html=True)
37
-
38
- # Set min and max summary length based on the selected slider value
39
- if summary_length == 1: # Short
40
- min_len = 10
41
- max_len = 50
42
- elif summary_length == 2: # Medium
43
- min_len = 50
44
- max_len = 150
45
- else: # Long
46
- min_len = 150
47
- max_len = 300
48
-
49
- # Display the selected range for feedback
50
- st.write(f"Selected Summary Length: {'Short' if summary_length == 1 else 'Medium' if summary_length == 2 else 'Long'}")
51
-
52
- # Button to trigger summarization
53
- if st.button("Summarize"):
54
- if user_input.strip(): # Ensure there's input before summarizing
55
- try:
56
- # Generate summary using the model with custom min and max length
57
- summarized_text = summarizer(user_input,
58
- max_length=max_len,
59
- min_length=min_len,
60
- length_penalty=2.0,
61
- num_beams=4,
62
- early_stopping=True)[0]['summary_text']
63
-
64
- # Display the generated summary
65
- st.subheader("Summarized Text:")
66
- st.write(summarized_text)
67
-
68
- except Exception as e:
69
- st.error(f"An error occurred while summarizing: {e}")
70
- else:
71
- st.warning("Please enter some text to summarize.")