alexue4's picture
Update app.py
a88bc6c verified
raw
history blame
861 Bytes
import gradio as gr
from transformers import pipeline
# Define the examples
examples = [
["в 2006-2010 гг. Вася учился в МГУ"],
["я купил iphone 10X за 14990 руб без 3-x часов полдень и т.д."]
]
# Load the model using Hugging Face pipeline
model = pipeline("text2text-generation", model="alexue4/text-normalization-ru-new")
# Define the function to normalize text with max_length parameter
def normalize_text(input_text):
return model(input_text, max_length=512)[0]['generated_text']
# Create the Gradio interface
interface = gr.Interface(
fn=normalize_text, # The function to call
inputs=gr.inputs.Textbox(lines=2, placeholder="Enter text here..."), # Input type
outputs="text", # Output type
examples=examples # Examples to display
)
# Launch the interface
interface.launch()