Update app.py
Browse files
app.py
CHANGED
@@ -1,29 +1,24 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
#
|
4 |
-
interface = gr.load("models/alexue4/text-normalization-ru-new")
|
5 |
-
|
6 |
-
# Function to modify the behavior (example: limiting max tokens and setting examples)
|
7 |
-
def custom_function(input_text):
|
8 |
-
# Custom processing here (e.g., limit max tokens)
|
9 |
-
max_tokens = 250 # Set your desired max token limit
|
10 |
-
if len(input_text.split()) > max_tokens:
|
11 |
-
input_text = ' '.join(input_text.split()[:max_tokens])
|
12 |
-
|
13 |
-
# Call the original function from the interface
|
14 |
-
original_output = interface.predict(input_text)
|
15 |
-
return original_output
|
16 |
-
|
17 |
examples = [
|
18 |
["в 2006-2010 гг. Вася учился в МГУ"],
|
19 |
["я купил iphone 10X за 14990 руб без 3-x часов полдень и т.д."]
|
20 |
]
|
21 |
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
).launch()
|
28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
# Define the examples
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
examples = [
|
5 |
["в 2006-2010 гг. Вася учился в МГУ"],
|
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
|
21 |
+
)
|
22 |
|
23 |
+
# Launch the interface
|
24 |
+
interface.launch()
|