text_summarize / app.py
37Rohan's picture
Upload app.py
23c44f3
raw history blame
No virus
2.22 kB
# -*- coding: utf-8 -*-
"""app
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/102X117iwYLnyujM4T3HnbSWZNcWRl3On
"""
# For installing packages to use
#pip install gradio
#pip install transformers
"""1. GRADIO is very handy and easy to make GUIs<br>
2. Transformers provides APIs to easily download and train state-of-the-art pretrained models.
"""
import gradio as gr
from transformers import pipeline
from gradio.outputs import Label
Name = "Summarizer" #Name of the model i've choose as Summarizer
about = "Please drop an article or any phrase you want to summarize" # Description about model
sample = [
"""
The craze for Cricket in India is huge, and we consider cricketers as our role models. Many cricket fans in India spend hours in front of the television to watch a cricket match. Cricket matches in India are like grand feasts to the eyes and mind. Indians cannot separate themselves from Cricket.
Cricket is a fantastic sport that required the use of a bat and ball. Cricket is played between two teams, and each team has 11 players. The major aim of Cricket is to score the highest number of runs. Cricket is played on a pitch in a field. Cricket does not have only one format, but various ones and each format have its own set of rules and duration.
There are majorly three formats of Cricket that are played at the international level. Test matches are played for five days, One-Day Internationals are a one day match and Twenty20 Internationals. These matches are played under the strict rules and regulations approved by the International Cricket Council.
"""
] # A sample example is provided for using model
model = gr.Interface.load("huggingface/facebook/bart-large-cnn") # gr.Interface.load is used for calling repo with the specifying the path
UI = gr.Interface(fn=model,inputs=gr.inputs.Textbox(lines=10,placeholder="Write your Summary text....",label="Text"),outputs="text",title=Name,description=about,examples=sample)
# Interface() is used for constructing GUI
# for making a textbox we use inputs.Textbox
UI.launch() #.launch() is for launching interface