import gradio as gr from transformers import pipeline # Define the examples examples = [ ["в 2006-2010 гг. Вася учился в МГУ"], ["я купил iphone 10X за 14990 руб без 3х часов полдень и т.д."] ] # 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.Textbox(lines=2, placeholder="Enter text here..."), # Input type outputs=gr.Textbox(), # Output type examples=examples # Examples to display ) # Launch the interface interface.launch()