Summarizing Text with Transformers and deploying it as Gradio App

We are in the 21st Century where everyone is busy in their small world. We don’t have time to read Large articles, texts, posts, or news. That is why we are always looking for something which can be understood at a glance while commuting, having coffee, or walking. Due to the time limitation apps like Inshorts, Google News is offering a summarised view of the article which can be easily glanced at. That summarised view is nothing but a summary of the whole article and the tech used in it is called Text Summarisation.

Text Summarisation can be achieved in two ways:

  • Abstractive Methods: Using LSTM (Long Short Term Memory) networks and other deep learning principles. Using this method creates a completely new summary of the article that includes sentences that aren’t even part of the original text.

We will be using Abstractive Methods for Text Summarisation.

Image Source:

In Today’s blog, we will create a Pipeline that not only Summarizes Text but also give Sentiment Analysis for that text.

We are going to create this pipeline with Transformers.

Let’s begin

Importing Libraries

import gradio as grfrom articles import * # this is a local module, you can find in code repofrom transformers import pipeline

Creating our Pipeline

Here, we are creating our summarise pipeline which first summarises the text and then runs the sentiment Analysis.
In this pipeline, Summarisation can be done with 3 models here:

  • Distil BART
  • Google’s Pegasus XSum

Building Gradio App

We are going to create our Gradio App and run it on port 8080

Test Drive

Running our App

Voila! it runs, Now we will work on deploying this.


We are going to use TrueFoundry for our deployment

Logging into TrueFoundry

Heading to Deployment Section

1) Creating a new deployment

2) Select the Service option and Workspace name

3) Fill out properties and submit

4) Deploying

5) Successful Deployment

6) Final Thoughts

After the deployment is done, you will be able to use the Gradio App.

The app is deployed here:



The above code is also present in my Repository


  1. TrueFoundry:
  2. TrueFoundry App:
  3. TrueFoundry Docs:
  4. Code:




Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store