ibrahimgiki commited on
Commit
02f0188
·
verified ·
1 Parent(s): 7562d6c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -13
app.py CHANGED
@@ -1,19 +1,21 @@
 
1
  from transformers import pipeline
2
 
 
 
 
3
  # Load the model and tokenizer from Hugging Face
4
- summarizer = pipeline("summarization", model="ibrahimgiki/facebook_bart_base")
5
 
6
- # Define a function to summarize text
7
- def summarize_text(text, max_length=130, min_length=30, do_sample=False):
8
- summary = summarizer(text, max_length=max_length, min_length=min_length, do_sample=do_sample)
9
- return summary[0]['summary_text']
10
 
11
- # Example usage
12
- text = """
13
- Your text here. This text should be a long paragraph that you want to summarize.
14
- The pipeline will take this text and generate a shorter version of it.
15
- """
16
 
17
- summary = summarize_text(text)
18
- print("Original Text:", text)
19
- print("Summary:", summary)
 
 
 
 
1
+ import streamlit as st
2
  from transformers import pipeline
3
 
4
+ # Replace with your actual model URL
5
+ model_url = "your_hf_username/your_model_name"
6
+
7
  # Load the model and tokenizer from Hugging Face
8
+ summarizer = pipeline("summarization", model=model_url)
9
 
10
+ # Streamlit application
11
+ st.title("Text Summarization with BART")
 
 
12
 
13
+ # Text input from the user
14
+ user_input = st.text_area("Enter the text to summarize:")
 
 
 
15
 
16
+ # If user input is provided, summarize the text
17
+ if user_input:
18
+ with st.spinner("Summarizing..."):
19
+ summary = summarizer(user_input, max_length=130, min_length=30, do_sample=False)
20
+ summarized_text = summary[0]['summary_text']
21
+ st.text_area("Summary:", summarized_text, height=200)