alexue4 commited on
Commit
a88bc6c
1 Parent(s): c4bf6fa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -6
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 with arguments including max_length
10
- model = gr.load("models/alexue4/text-normalization-ru-new",
11
- src="https://huggingface.co/alexue4/text-normalization-ru-new",
12
- description="A model for text normalization in Russian",
13
- max_length=512)
 
14
 
15
  # Create the Gradio interface
16
  interface = gr.Interface(
17
- fn=model, # The model function to call
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