File size: 576 Bytes
77b3501
b8f917c
 
 
 
77b3501
b8f917c
21cdd54
67013df
21cdd54
67013df
 
b8f917c
67013df
77b3501
b8f917c
 
 
77b3501
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import os
import io 
from dotenv import load_dotenv, find_dotenv
import requests, json
from transformers import pipeline
import gradio as gr
from transformers import pipeline

load_dotenv()

# Access the Hugging Face API key and endpoint URL
hf_api_key = os.getenv('HF_API_KEY')
#Summarization endpoint
get_completion = pipeline("summarization", model="shleifer/distilbart-cnn-12-6", token=hf_api_key)

def summarize(input):
    output = get_completion(input)
    return output[0]['summary_text']

demo = gr.Interface(fn=summarize, inputs="text", outputs="text")
demo.launch()