GIRI45's picture
Update app.py
494c05d verified
Raw
History Blame Contribute Delete
1 kB
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()