GIRI45 commited on
Commit
494c05d
·
verified ·
1 Parent(s): 9b52d27

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py CHANGED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load the text simplification model from Hugging Face
5
+ simplifier = pipeline("text2text-generation", model="t5-base", tokenizer="t5-base")
6
+
7
+ # Function to simplify the text
8
+ def simplify_text(input_text):
9
+ # Prepend the task-specific instruction for T5
10
+ task_instruction = "simplify: "
11
+ text_to_simplify = task_instruction + input_text
12
+ simplified_text = simplifier(text_to_simplify, max_length=400)[0]['generated_text']
13
+ return simplified_text
14
+
15
+ # Create the Gradio interface
16
+ iface = gr.Interface(fn=simplify_text,
17
+ inputs=gr.Textbox(label="Input Text", placeholder="Enter complex text here..."),
18
+ outputs="text",
19
+ live=True,
20
+ title="Text Simplification",
21
+ description="Simplify complex text by entering it into the input box. The model will provide an easier-to-understand version.")
22
+
23
+ # Launch the Gradio interface
24
+ iface.launch()