Spaces:
Sleeping
Sleeping
import gradio | |
from transformers import pipeline | |
summarizer = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6") | |
def summarize_function(texts): | |
return summarizer(texts)[0]["summary_text"].strip() # type: ignore | |
gradio_interface = gradio.Interface( | |
fn=summarize_function, | |
inputs="text", | |
outputs="text", | |
title="Simple REST API with Gradio and Huggingface Spaces for text summarization.", | |
description="This API uses 'sshleifer/distilbart-cnn-12-6' model from Huggingface to summarize text.", | |
article="© Naufal Suryanto, 2023." | |
) | |
gradio_interface.launch() | |