Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
import gradio as gr
|
| 3 |
+
from transformers import pipeline
|
| 4 |
+
|
| 5 |
+
# Load the summarization pipeline using a pre-trained model from Hugging Face
|
| 6 |
+
text_summary = pipeline("summarization", model="sshleifer/distilbart-xsum-12-6")
|
| 7 |
+
|
| 8 |
+
# Input text for summarization
|
| 9 |
+
# text = """
|
| 10 |
+
# The India vs England cricket series in early 2025 was a comprehensive display of India's dominance in both T20I and ODI formats,
|
| 11 |
+
# culminating in a 4-1 T20I series win and a 3-0 ODI whitewash. The T20I series began with India asserting their supremacy, notably in
|
| 12 |
+
# the first match where Abhishek Sharma's explosive 79 off 36 balls led India to a swift chase of England's 132, setting the tone for the
|
| 13 |
+
# series. England managed to pull one back in the third T20I, securing a 26-run victory in Rajkot, with Ben Duckett scoring a half-century
|
| 14 |
+
# and their bowlers, including Jofra Archer and Brydon Carse, sharing seven wickets to halt India's winning streak. However, India's
|
| 15 |
+
# resilience shone through in the fourth T20I, where a controversial concussion substitution saw Harshit Rana replace Shivam Dube
|
| 16 |
+
# and claim three crucial wickets, aiding India in clinching the series with a 15-run win. The final T20I was a spectacle,
|
| 17 |
+
# with Abhishek Sharma delivering a record-breaking 135 off 54 balls, propelling India to a massive total of 247/9.
|
| 18 |
+
# England's response was lackluster, collapsing to 97 all out, handing India a resounding 150-run victory and a 4-1
|
| 19 |
+
# series triumph. Transitioning to the ODIs, India continued their dominance. In the first ODI, Shubman Gill's 87
|
| 20 |
+
# anchored India's chase of 249, securing a four-wicket win. The second ODI saw Rohit Sharma's commanding 119 off 76 balls
|
| 21 |
+
# lead India to a successful chase of England's 304, despite a brief floodlight malfunction. The final ODI was a testament
|
| 22 |
+
# to India's batting prowess, with Shubman Gill scoring 112, supported by Virat Kohli and Shreyas Iyer, setting a formidable
|
| 23 |
+
# total of 356. England's batting faltered, managing only 214, as India's bowlers, including Axar Patel and Harshit Rana,
|
| 24 |
+
# dismantled their lineup, sealing a 142-run victory and a 3-0 series sweep. Throughout the series, India's blend of
|
| 25 |
+
# experienced players and emerging talents showcased their depth and adaptability, while England struggled to find consistency,
|
| 26 |
+
# highlighting the challenges they face in adapting to subcontinental conditions.
|
| 27 |
+
|
| 28 |
+
# """
|
| 29 |
+
|
| 30 |
+
# # summary
|
| 31 |
+
# print(text_summary(text))
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
def summary(input):
|
| 35 |
+
output = text_summary(input)
|
| 36 |
+
return output[0]['summary_text']
|
| 37 |
+
|
| 38 |
+
gr.close_all()
|
| 39 |
+
|
| 40 |
+
demo = gr.Interface(
|
| 41 |
+
fn=summary,
|
| 42 |
+
inputs=gr.Textbox(label="Input text to summarize", lines=6),
|
| 43 |
+
outputs=gr.Textbox(label="Summarized text", lines=4),
|
| 44 |
+
title="@GenAILearniverse Project 1: Text Summarizer",
|
| 45 |
+
description="THIS APPLICATION WILL BE USED TO SUMMARIZE THE TEXT"
|
| 46 |
+
)
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
demo.launch()
|
| 50 |
+
|
| 51 |
+
|