Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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
|
| 13 |
-
#
|
| 14 |
-
return pipeline("summarization", model=MODEL_ID,
|
| 15 |
|
|
|
|
| 16 |
st.title("๐ Automated Text Summarizer")
|
| 17 |
|
| 18 |
-
# 4. Error-Resistant Loading
|
| 19 |
try:
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
st.success("
|
| 23 |
except Exception as e:
|
| 24 |
-
st.
|
| 25 |
st.stop()
|
| 26 |
|
| 27 |
-
|
| 28 |
-
|
| 29 |
if st.button("Summarize"):
|
| 30 |
-
if input_text:
|
| 31 |
-
with st.spinner("
|
| 32 |
-
|
| 33 |
-
st.
|
| 34 |
-
st.write(
|
|
|
|
| 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'])
|