abdulllah01 commited on
Commit
19e8e74
·
verified ·
1 Parent(s): 63816dc

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
3
+
4
+ # Load the tokenizer and model from the Hugging Face Model Hub
5
+ model_path = 'abdulllah01/Bert-Finetuned'
6
+ tokenizer = AutoTokenizer.from_pretrained(model_path)
7
+ model = AutoModelForSeq2SeqLM.from_pretrained(model_path)
8
+
9
+ # Streamlit app
10
+ st.title("Summarization App")
11
+ st.write("Summarize Your Dialogues with the Fine Tuned Bart!")
12
+
13
+ # User input
14
+ user_input = st.text_area("Enter text to summarize", "")
15
+
16
+ if st.button("Summarize"):
17
+ if user_input:
18
+ inputs = tokenizer.encode("summarize: " + user_input, return_tensors="pt", max_length=512, truncation=True)
19
+ summary_ids = model.generate(inputs, max_length=150, min_length=40, length_penalty=2.0, num_beams=4, early_stopping=True)
20
+ summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
21
+ st.write("Summary:")
22
+ st.write(summary)
23
+ else:
24
+ st.write("Please enter some text to summarize")