thak123 commited on
Commit
a99e8a0
·
verified ·
1 Parent(s): 28759da

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -0
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+
4
+ from typing import List
5
+
6
+ from punctuators.models import SBDModelONNX
7
+
8
+ # Instantiate this model
9
+ # This will download the ONNX and SPE models. To clean up, delete this model from your HF cache directory.
10
+ m = SBDModelONNX.from_pretrained("sbd_multi_lang")
11
+
12
+ def sentence_boundary_detection(name):
13
+ # Run inference
14
+ results: List[List[str]] = m.infer(input_texts)
15
+ return "\n".join(results), len(results)
16
+
17
+
18
+ # Gradio interface
19
+ iface = gr.Interface(
20
+ fn=sentence_boundary_detection,
21
+ inputs=gr.Textbox(label="Input Text", lines=10, maximum_lines = 200, placeholder="Enter text here..."),
22
+ outputs=[
23
+ gr.Textbox(label="Sentences", lines=10, maximum_lines = 200, placeholder="Sentences will appear here..."),
24
+ gr.Number(label="Number of Sentences")
25
+ ],
26
+ title="Sentence Boundary Detection",
27
+ description="Enter text to detect sentence boundaries and count the number of sentences."
28
+ )
29
+
30
+ # Launch the Gradio app
31
+ iface.launch()