Spaces:
Running
Running
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
model_path = '/content/drive/My Drive/Bart_samsum'
|
2 |
+
|
3 |
+
from transformers import pipeline
|
4 |
+
|
5 |
+
# Load the tokenizer and model from the specified path
|
6 |
+
tokenizer = AutoTokenizer.from_pretrained(model_path)
|
7 |
+
model = AutoModelForSeq2SeqLM.from_pretrained(model_path)
|
8 |
+
|
9 |
+
# Create a pipeline for text summarization
|
10 |
+
summarizer = pipeline("summarization", model=model, tokenizer=tokenizer)
|
11 |
+
|
12 |
+
# Example input for inference
|
13 |
+
|
14 |
+
# Perform inference
|
15 |
+
summary = summarizer(dialogue, max_length=500, min_length=300, do_sample=False)
|
16 |
+
|
17 |
+
# Print the summary
|
18 |
+
print("Summary:", summary[0]['summary_text'])
|