VoltIC commited on
Commit
53034fc
Β·
verified Β·
1 Parent(s): 33602b7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -23
app.py CHANGED
@@ -1,12 +1,15 @@
1
  import streamlit as st
2
  from transformers import pipeline
 
 
 
 
3
 
4
- # 1. Configuration
5
  MODEL_ID = "VoltIC/Automated-Text-Summarizer"
6
 
7
  @st.cache_resource
8
  def load_summarizer():
9
- # Use subfolder because your files are in 'summarizer_model'
10
  return pipeline(
11
  "summarization",
12
  model=MODEL_ID,
@@ -14,35 +17,30 @@ def load_summarizer():
14
  framework="pt"
15
  )
16
 
17
- # 2. Page Config (MUST be the first Streamlit command)
18
  st.set_page_config(page_title="AI Summarizer", page_icon="πŸ“")
19
 
20
- # 3. App Title & UI
21
- st.title("πŸ“ Automated Text Summarizer")
22
- st.write("The model is loading. Please wait a moment...")
23
 
24
- # Load the model
 
25
  try:
26
- summarizer = load_summarizer()
27
- st.success("Model Ready!")
 
 
28
  except Exception as e:
29
- st.error(f"Waiting for model files... {e}")
30
  st.stop()
31
 
32
- # 4. Input and Logic
33
- text_input = st.text_area("Paste your article here:", height=300)
34
 
35
  if st.button("Summarize"):
36
- if text_input.strip():
37
- with st.spinner("Summarizing..."):
38
- # length_penalty helps keep the summary concise (2-3 sentences)
39
- result = summarizer(
40
- text_input,
41
- max_length=100,
42
- min_length=30,
43
- do_sample=False
44
- )
45
  st.subheader("Summary")
46
- st.write(result[0]['summary_text'])
47
  else:
48
- st.warning("Please enter some text.")
 
1
  import streamlit as st
2
  from transformers import pipeline
3
+ import os
4
+
5
+ # 1. Silencing TensorFlow & Streamlit startup "noise"
6
+ os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
7
 
 
8
  MODEL_ID = "VoltIC/Automated-Text-Summarizer"
9
 
10
  @st.cache_resource
11
  def load_summarizer():
12
+ # Adding subfolder ensures we target the right directory
13
  return pipeline(
14
  "summarization",
15
  model=MODEL_ID,
 
17
  framework="pt"
18
  )
19
 
20
+ # 2. Page Configuration
21
  st.set_page_config(page_title="AI Summarizer", page_icon="πŸ“")
22
 
23
+ st.title("πŸ“ AI Text Summarizer")
 
 
24
 
25
+ # 3. Handling the "Bare Mode" Startup
26
+ # This check ensures the UI only tries to render when the environment is ready
27
  try:
28
+ with st.status("πŸš€ Initializing AI Engine...", expanded=True) as status:
29
+ st.write("Downloading model weights (1.6GB)...")
30
+ summarizer = load_summarizer()
31
+ status.update(label="βœ… AI Engine Ready!", state="complete", expanded=False)
32
  except Exception as e:
33
+ st.info("The app is currently warming up. Please refresh in 1 minute.")
34
  st.stop()
35
 
36
+ # 4. Main App Interface
37
+ input_text = st.text_area("Paste your article or document below:", height=300)
38
 
39
  if st.button("Summarize"):
40
+ if input_text.strip():
41
+ with st.spinner("Processing..."):
42
+ summary = summarizer(input_text, max_length=100, min_length=30)
 
 
 
 
 
 
43
  st.subheader("Summary")
44
+ st.write(summary[0]['summary_text'])
45
  else:
46
+ st.warning("Please provide some text to summarize.")