File size: 796 Bytes
f3c0ca7
6d092e6
ce48cd3
 
 
6791153
 
446e2f7
6d092e6
66564a6
 
 
 
 
6d092e6
f3c0ca7
ce48cd3
6791153
ce48cd3
6d092e6
f1f86da
 
 
f3c0ca7
 
6d092e6
 
 
f1f86da
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# Imports
import gradio as gr
from transformers import AutoModel, AutoProcessor
import torch
import requests
from PIL import Image
from io import BytesIO
from transformers import pipeline

# Import a specific model
model_name = "facebook/bart-large-cnn"

# Create a summarization pipeline with Facebook Bart
summarizer = pipeline("summarization", model=model_name)

# Define a function that takes input and returns summary
def summarize(input_text):
  summary = summarizer(input_text, max_length=100, min_length=10, do_sample=False)
  return summary[0]["summary_text"]

# Create a Gradio interface
interface = gr.Interface(
  fn=summarize, # the function to wrap
  inputs=gr.Textbox(lines=10, label="Input Text"),
  outputs=gr.Textbox(label="Summary")
)

# Launch the interface
interface.launch()