Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from gradio.mix import Parallel, Series
|
| 3 |
+
|
| 4 |
+
from transformers import pipeline
|
| 5 |
+
|
| 6 |
+
summariser = pipeline("text2text-generation", model="balaramas/mbart-enhiriser")
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
def summarise(inp, direction):
|
| 10 |
+
if direction == 'en->vi':
|
| 11 |
+
text = "en: " + inp
|
| 12 |
+
else:
|
| 13 |
+
text = "vi: " + inp
|
| 14 |
+
|
| 15 |
+
res = summariser(
|
| 16 |
+
text,
|
| 17 |
+
max_length=512,
|
| 18 |
+
early_stopping=True,
|
| 19 |
+
)[0]['translation_text'][3:]
|
| 20 |
+
return res
|
| 21 |
+
|
| 22 |
+
description = """
|
| 23 |
+
<p>
|
| 24 |
+
<center>
|
| 25 |
+
Multi-domain Summarisation Between English and Hindi
|
| 26 |
+
</center>
|
| 27 |
+
</p>
|
| 28 |
+
"""
|
| 29 |
+
examples = [
|
| 30 |
+
[" I remember when I first arrived in the United States. Even before the plane landed, the little windows in the airplane revealed snow and ice-covered houses and buildings. As I walked off the plane, cold air crept through the corrugated ramp that led to the airport terminal. Some people inside the airport were wearing big coats and hats, which I had seen on television, but never up close. I felt a little dizzy and needed to sit down, and then my cell phone rang. It was my Aunt Sophia. She was waiting for me outside in the passenger pick-up area, so I walked quickly to the exit, forgetting all about my luggage. When the sliding glass door opened to the outside, there was my aunt–a woman I hadn’t seen in over ten years–wearing a parka and waving her arms frantically in my direction.", "en->hi"]
|
| 31 |
+
]
|
| 32 |
+
iface = gr.Interface(
|
| 33 |
+
fn=summarise,
|
| 34 |
+
|
| 35 |
+
title="🌸English to Hindi Summariser🌸",
|
| 36 |
+
description=description,
|
| 37 |
+
article=article,
|
| 38 |
+
examples=examples,
|
| 39 |
+
inputs=[
|
| 40 |
+
gr.inputs.Textbox(lines=5, placeholder="Enter paragraph (maximum 20 lines)", label="Input"),
|
| 41 |
+
gr.inputs.Radio(
|
| 42 |
+
choices=[
|
| 43 |
+
'en->hi'],
|
| 44 |
+
default='en->hi',
|
| 45 |
+
label='Direction'),
|
| 46 |
+
],
|
| 47 |
+
outputs="text")
|
| 48 |
+
|
| 49 |
+
iface.launch(enable_queue=True)
|