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