VoltIC commited on
Commit
d16f3ca
Β·
verified Β·
1 Parent(s): f29f0cb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -16
app.py CHANGED
@@ -1,29 +1,33 @@
1
  import streamlit as st
2
  from transformers import pipeline
3
 
 
4
  MODEL_ID = "VoltIC/Automated-Text-Summarizer"
5
 
6
  @st.cache_resource
7
  def load_summarizer():
8
- # Notice: 'subfolder' is GONE. This is much more stable.
9
- return pipeline("summarization", model=MODEL_ID, framework="pt")
 
 
 
 
 
10
 
11
- st.set_page_config(page_title="AI Summarizer", page_icon="πŸ“")
12
  st.title("πŸ“ Automated Text Summarizer")
13
 
14
- try:
15
- # This will now find the files instantly at the root
16
- summarizer = load_summarizer()
17
- st.success("Model Loaded Successfully!")
18
- except Exception as e:
19
- st.error("The model is still initializing. Please wait 2 minutes.")
20
- st.stop()
21
 
22
- input_text = st.text_area("Paste text here:", height=300)
23
 
24
  if st.button("Summarize"):
25
- if input_text.strip():
26
- with st.spinner("Processing..."):
27
- summary = summarizer(input_text, max_length=100, min_length=30)
28
- st.write("### Summary:")
29
- st.write(summary[0]['summary_text'])
 
 
 
 
1
  import streamlit as st
2
  from transformers import pipeline
3
 
4
+ # Your verified Model ID
5
  MODEL_ID = "VoltIC/Automated-Text-Summarizer"
6
 
7
  @st.cache_resource
8
  def load_summarizer():
9
+ # This worked in your logs!
10
+ return pipeline(
11
+ "summarization",
12
+ model=MODEL_ID,
13
+ subfolder="summarizer_model",
14
+ framework="pt"
15
+ )
16
 
17
+ st.set_page_config(page_title="AI TL;DR", page_icon="πŸ“")
18
  st.title("πŸ“ Automated Text Summarizer")
19
 
20
+ # Load the model (The logs prove this is working now!)
21
+ summarizer = load_summarizer()
 
 
 
 
 
22
 
23
+ text_input = st.text_area("Paste long text here:", height=300)
24
 
25
  if st.button("Summarize"):
26
+ if text_input.strip():
27
+ with st.spinner("AI is thinking..."):
28
+ # length_penalty=2.0 helps keep it to 2-3 sentences
29
+ summary = summarizer(text_input, max_length=100, min_length=30, length_penalty=2.0)
30
+ st.success("Summary Generated!")
31
+ st.markdown(f"### Result:\n{summary[0]['summary_text']}")
32
+ else:
33
+ st.warning("Please enter text first.")