blazingbunny
commited on
Commit
·
bcb57ec
1
Parent(s):
00ded95
Update app.py
Browse files
app.py
CHANGED
@@ -12,12 +12,14 @@ model = st.sidebar.selectbox("Choose a model", models)
|
|
12 |
|
13 |
uploaded_file = st.file_uploader("Choose a .txt file", type="txt")
|
14 |
|
15 |
-
# Add sliders to the sidebar
|
16 |
-
min_length = st.sidebar.slider('Minimum Length', min_value=10, max_value=100, value=30)
|
17 |
-
length_decrease = st.sidebar.slider('Length % decrease', min_value=10, max_value=90, value=10)
|
18 |
-
|
19 |
if uploaded_file is not None:
|
20 |
user_input = uploaded_file.read().decode('utf-8')
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
if st.button('Summarize'):
|
23 |
summarizer = pipeline('summarization', model=model)
|
@@ -28,8 +30,8 @@ if uploaded_file is not None:
|
|
28 |
|
29 |
# Summarize each chunk
|
30 |
for chunk in chunks:
|
31 |
-
|
32 |
-
max_length =
|
33 |
summarized = summarizer(chunk, max_length=max_length, min_length=min_length, do_sample=False)
|
34 |
summarized_text += summarized[0]['summary_text'] + " "
|
35 |
|
|
|
12 |
|
13 |
uploaded_file = st.file_uploader("Choose a .txt file", type="txt")
|
14 |
|
|
|
|
|
|
|
|
|
15 |
if uploaded_file is not None:
|
16 |
user_input = uploaded_file.read().decode('utf-8')
|
17 |
+
total_length = len(user_input.split())
|
18 |
+
|
19 |
+
# Add sliders to the sidebar
|
20 |
+
min_length_percentage = st.sidebar.slider('Minimum Length %', min_value=10, max_value=50, value=30)
|
21 |
+
max_length_percentage = min_length_percentage + 10
|
22 |
+
st.sidebar.text(f'Maximum Length %: {max_length_percentage}')
|
23 |
|
24 |
if st.button('Summarize'):
|
25 |
summarizer = pipeline('summarization', model=model)
|
|
|
30 |
|
31 |
# Summarize each chunk
|
32 |
for chunk in chunks:
|
33 |
+
min_length = max(int(total_length * min_length_percentage / 100), 1) # Calculate min_length based on the percentage of the total length
|
34 |
+
max_length = int(total_length * max_length_percentage / 100) # Calculate max_length based on the percentage of the total length
|
35 |
summarized = summarizer(chunk, max_length=max_length, min_length=min_length, do_sample=False)
|
36 |
summarized_text += summarized[0]['summary_text'] + " "
|
37 |
|