AhsanShahid commited on
Commit
fd1d999
·
verified ·
1 Parent(s): d6471c1

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -0
app.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # Assuming 'model_path' is the path to your saved model
3
+ model_path = '/content/drive/My Drive/T5_samsum'
4
+
5
+ # Load the fine-tuned model and tokenizer
6
+ model = AutoModelForSeq2SeqLM.from_pretrained(model_path)
7
+ tokenizer = AutoTokenizer.from_pretrained(model_path)
8
+
9
+ summarizer = pipeline("summarization", model=model, tokenizer=tokenizer)
10
+
11
+ # Input text for summarization
12
+ input_text = """
13
+ Your long text that you want to summarize goes here.
14
+ It can be a document or any lengthy content you need to condense.
15
+ """
16
+
17
+ # Perform summarization
18
+ summary = summarizer(input_text, max_length=150, min_length=50, length_penalty=2.0)
19
+
20
+ # Print the generated summary
21
+ print("Summary:", summary[0]['summary_text'])