Spaces:
Sleeping
Sleeping
app python file
Browse files
app.py
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# Load Hugging Face summarization model
|
5 |
+
@st.cache_resource
|
6 |
+
def load_summarization_model():
|
7 |
+
summarizer = pipeline("summarization", model="Ramji/bart-cn-large-medical-summary") # You can replace with another model
|
8 |
+
return summarizer
|
9 |
+
|
10 |
+
summarizer = load_summarization_model()
|
11 |
+
|
12 |
+
# Streamlit UI
|
13 |
+
st.title("Text Summarization with Hugging Face")
|
14 |
+
|
15 |
+
st.write("This app uses a Finetuned Bart model to summarize long text inputs.")
|
16 |
+
|
17 |
+
# Input text area for the user
|
18 |
+
user_input = st.text_area("Enter text to summarize:", height=300)
|
19 |
+
|
20 |
+
# Set summary parameters (optional)
|
21 |
+
max_length = st.slider("Maximum Summary Length", 30, 500, 150)
|
22 |
+
min_length = st.slider("Minimum Summary Length", 10, 100, 30)
|
23 |
+
|
24 |
+
# Summarize when the button is clicked
|
25 |
+
if st.button("Summarize"):
|
26 |
+
if user_input:
|
27 |
+
# Get the summary
|
28 |
+
summary = summarizer(user_input, max_length=max_length, min_length=min_length, do_sample=False)
|
29 |
+
# Display the result
|
30 |
+
st.subheader("Summary")
|
31 |
+
st.write(summary[0]['summary_text'])
|
32 |
+
else:
|
33 |
+
st.write("Please enter some text to summarize.")
|