File size: 860 Bytes
932274f
a88bc6c
932274f
d653395
5e13b07
 
3b8a11a
5e13b07
 
a88bc6c
 
 
 
 
 
1c903eb
d653395
 
a88bc6c
e7f75fd
 
d653395
 
1c903eb
d653395
 
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
26
27
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()