Spaces:
Runtime error
Runtime error
aus10powell
commited on
Commit
•
59b85d3
1
Parent(s):
07768ac
Upload summarization.py
Browse files- scripts/summarization.py +19 -0
scripts/summarization.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
|
3 |
+
def bert_summarization(inputs):
|
4 |
+
# import requests
|
5 |
+
|
6 |
+
# API_URL = (
|
7 |
+
# "https://api-inference.huggingface.co/models/philschmid/bart-large-cnn-samsum"
|
8 |
+
# )
|
9 |
+
# headers = {"Authorization": "Bearer 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"}
|
10 |
+
|
11 |
+
# def query(payload):
|
12 |
+
# response = requests.post(API_URL, headers=headers, json=payload)
|
13 |
+
# return response.json()
|
14 |
+
|
15 |
+
# return query({"inputs": inputs})
|
16 |
+
|
17 |
+
|
18 |
+
summarizer = pipeline("summarization", model="philschmid/bart-large-cnn-samsum")
|
19 |
+
return summarizer(inputs)[0]["summary_text"]
|