Spaces:
Sleeping
Sleeping
Add summarizer gradio and additional files
Browse files- README.md +4 -3
- app.py +20 -0
- requirements.txt +1 -0
README.md
CHANGED
|
@@ -2,11 +2,12 @@
|
|
| 2 |
title: Simple Text Summarizer
|
| 3 |
emoji: 🐠
|
| 4 |
colorFrom: blue
|
| 5 |
-
colorTo:
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version: 3.
|
|
|
|
| 8 |
app_file: app.py
|
| 9 |
-
pinned:
|
| 10 |
license: openrail
|
| 11 |
---
|
| 12 |
|
|
|
|
| 2 |
title: Simple Text Summarizer
|
| 3 |
emoji: 🐠
|
| 4 |
colorFrom: blue
|
| 5 |
+
colorTo: green
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 3.12.0
|
| 8 |
+
python_version: 3.9.13
|
| 9 |
app_file: app.py
|
| 10 |
+
pinned: true
|
| 11 |
license: openrail
|
| 12 |
---
|
| 13 |
|
app.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
summarizer = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6")
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
def summarize_function(texts):
|
| 9 |
+
return summarizer(texts)[0]["summary_text"] # type: ignore
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
gradio_interface = gradio.Interface(
|
| 13 |
+
fn=summarize_function,
|
| 14 |
+
inputs="text",
|
| 15 |
+
outputs="text",
|
| 16 |
+
title="Simple REST API with Gradio and Huggingface Spaces for text summarization.",
|
| 17 |
+
description="This API uses 'sshleifer/distilbart-cnn-12-6' model from Huggingface to summarize text.",
|
| 18 |
+
article="© Naufal Suryanto, 2023."
|
| 19 |
+
)
|
| 20 |
+
gradio_interface.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
transformers
|