File size: 1,002 Bytes
494c05d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import gradio as gr
from transformers import pipeline

# Load the text simplification model from Hugging Face
simplifier = pipeline("text2text-generation", model="t5-base", tokenizer="t5-base")

# Function to simplify the text
def simplify_text(input_text):
    # Prepend the task-specific instruction for T5
    task_instruction = "simplify: "
    text_to_simplify = task_instruction + input_text
    simplified_text = simplifier(text_to_simplify, max_length=400)[0]['generated_text']
    return simplified_text

# Create the Gradio interface
iface = gr.Interface(fn=simplify_text, 
                     inputs=gr.Textbox(label="Input Text", placeholder="Enter complex text here..."), 
                     outputs="text", 
                     live=True,
                     title="Text Simplification",
                     description="Simplify complex text by entering it into the input box. The model will provide an easier-to-understand version.")

# Launch the Gradio interface
iface.launch()