Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
# Define the examples
|
4 |
examples = [
|
@@ -6,15 +7,16 @@ examples = [
|
|
6 |
["я купил iphone 10X за 14990 руб без 3-x часов полдень и т.д."]
|
7 |
]
|
8 |
|
9 |
-
# Load the model
|
10 |
-
model =
|
11 |
-
|
12 |
-
|
13 |
-
|
|
|
14 |
|
15 |
# Create the Gradio interface
|
16 |
interface = gr.Interface(
|
17 |
-
fn=
|
18 |
inputs=gr.inputs.Textbox(lines=2, placeholder="Enter text here..."), # Input type
|
19 |
outputs="text", # Output type
|
20 |
examples=examples # Examples to display
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
|
4 |
# Define the examples
|
5 |
examples = [
|
|
|
7 |
["я купил iphone 10X за 14990 руб без 3-x часов полдень и т.д."]
|
8 |
]
|
9 |
|
10 |
+
# Load the model using Hugging Face pipeline
|
11 |
+
model = pipeline("text2text-generation", model="alexue4/text-normalization-ru-new")
|
12 |
+
|
13 |
+
# Define the function to normalize text with max_length parameter
|
14 |
+
def normalize_text(input_text):
|
15 |
+
return model(input_text, max_length=512)[0]['generated_text']
|
16 |
|
17 |
# Create the Gradio interface
|
18 |
interface = gr.Interface(
|
19 |
+
fn=normalize_text, # The function to call
|
20 |
inputs=gr.inputs.Textbox(lines=2, placeholder="Enter text here..."), # Input type
|
21 |
outputs="text", # Output type
|
22 |
examples=examples # Examples to display
|