import gradio as gr from span_marker import SpanMarkerModel # Download the model from the Hugging Face Hub model = SpanMarkerModel.from_pretrained("tomaarsen/span-marker-bert-base-acronyms") # Define the function for prediction def predict_acronyms(text): if text: output = model.predict(text) return output return {"error": "Please provide valid text"} # Create the Gradio interface interface = gr.Interface( fn=predict_acronyms, inputs=gr.Textbox(label="Enter some text:", lines=5, placeholder="Type here..."), outputs=gr.JSON(label="Predicted Output"), title="Acronym Detection with Span Marker", description="This application detects acronyms in the given text using the SpanMarker model." ) # Launch the Gradio app if __name__ == "__main__": interface.launch()