Spaces:
Sleeping
Sleeping
File size: 982 Bytes
71c5e75 45f1ced 9d67ccc 45f1ced 71c5e75 45f1ced 9d67ccc 45f1ced 71c5e75 45f1ced 9d67ccc 45f1ced 9d67ccc 45f1ced 71c5e75 45f1ced |
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 span_marker import SpanMarkerModel
# Define the function
def function(text):
# Load the pre-trained model from Hugging Face
model = SpanMarkerModel.from_pretrained("tomaarsen/span-marker-bert-base-acronyms")
# Ensure the input is valid
if text:
# Run inference on the input text
out = model.predict([text]) # Wrap the text in a list as the model expects a list of strings
return out
else:
return "Please provide valid text input."
# Set up the Gradio interface
demo = gr.Interface(
fn=function,
inputs=gr.Textbox(lines=5, placeholder="Enter your text here...", label="Input Text"),
outputs="json",
title="Abbreviation Detector",
examples=[
"NASA is an abbreviation for National Aeronautics and Space Administration.",
"AI stands for Artificial Intelligence.",
"What does HTTP mean?"
]
)
# Launch the app
if __name__ == "__main__":
demo.launch() |