Spaces:
Sleeping
Sleeping
Commit Β·
92751a2
1
Parent(s): bbfd282
Fix pipeline task error: switch to summarization task
Browse files
app.py
CHANGED
|
@@ -11,7 +11,7 @@ st.write("Summarize text, images, or PDFs with AI")
|
|
| 11 |
|
| 12 |
@st.cache_resource
|
| 13 |
def load_model():
|
| 14 |
-
return pipeline("
|
| 15 |
|
| 16 |
summarizer = load_model()
|
| 17 |
|
|
@@ -33,9 +33,9 @@ def summarize_text(text):
|
|
| 33 |
"""Summarize the given text"""
|
| 34 |
if not text.strip():
|
| 35 |
return None
|
| 36 |
-
input_text = "summarize: " + text[:4000]
|
| 37 |
-
result = summarizer(
|
| 38 |
-
return result[0]["
|
| 39 |
|
| 40 |
tab1, tab2, tab3 = st.tabs(["π Text", "πΌοΈ Image", "π PDF"])
|
| 41 |
|
|
|
|
| 11 |
|
| 12 |
@st.cache_resource
|
| 13 |
def load_model():
|
| 14 |
+
return pipeline("summarization", model="t5-small")
|
| 15 |
|
| 16 |
summarizer = load_model()
|
| 17 |
|
|
|
|
| 33 |
"""Summarize the given text"""
|
| 34 |
if not text.strip():
|
| 35 |
return None
|
| 36 |
+
# input_text = "summarize: " + text[:4000]
|
| 37 |
+
result = summarizer(text[:4000], max_length=150, min_length=40, do_sample=False)
|
| 38 |
+
return result[0]["summary_text"]
|
| 39 |
|
| 40 |
tab1, tab2, tab3 = st.tabs(["π Text", "πΌοΈ Image", "π PDF"])
|
| 41 |
|