VoltIC commited on
Commit
f29f0cb
ยท
verified ยท
1 Parent(s): 29d500e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -20
app.py CHANGED
@@ -1,34 +1,29 @@
1
  import streamlit as st
2
  from transformers import pipeline
3
 
4
- # 1. Config
5
  MODEL_ID = "VoltIC/Automated-Text-Summarizer"
6
 
7
- # 2. Page Config (Must be first)
8
- st.set_page_config(page_title="AI Summarizer", layout="wide")
9
-
10
- # 3. Cached Loader
11
  @st.cache_resource
12
- def load_model():
13
- # We use the subfolder since that's where your files are
14
- return pipeline("summarization", model=MODEL_ID, subfolder="summarizer_model", framework="pt")
15
 
 
16
  st.title("๐Ÿ“ Automated Text Summarizer")
17
 
18
- # 4. Error-Resistant Loading
19
  try:
20
- with st.spinner("Downloading AI Model (1.6GB)... This may take 3-5 minutes on first run."):
21
- summarizer = load_model()
22
- st.success("AI Model Loaded!")
23
  except Exception as e:
24
- st.warning("The model is still downloading in the background. Please wait 2 minutes and refresh.")
25
  st.stop()
26
 
27
- # 5. UI
28
- input_text = st.text_area("Paste text here:", height=250)
29
  if st.button("Summarize"):
30
- if input_text:
31
- with st.spinner("Summarizing..."):
32
- output = summarizer(input_text, max_length=100, min_length=30, do_sample=False)
33
- st.subheader("Summary")
34
- st.write(output[0]['summary_text'])
 
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'])