alexue4 commited on
Commit
5e13b07
·
verified ·
1 Parent(s): 932274f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -1
app.py CHANGED
@@ -1,3 +1,29 @@
1
  import gradio as gr
2
 
3
- gr.load("models/alexue4/text-normalization-ru-new").launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
 
3
+ # Load the pre-built interface
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
+ # Customize the examples
18
+ examples = [
19
+ ["в 2006-2010 гг. Вася учился в МГУ"],
20
+ ["я купил iphone 10X за 14990 руб без 3-x часов полдень и т.д."]
21
+ ]
22
+
23
+ # Define the new Gradio interface with custom function and examples
24
+ gr.Interface(
25
+ fn=custom_function,
26
+ inputs="text",
27
+ outputs="text",
28
+ examples=examples
29
+ ).launch()