Spaces:
Sleeping
Sleeping
samyak152002
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,32 +1,25 @@
|
|
1 |
import gradio as gr
|
2 |
from span_marker import SpanMarkerModel
|
3 |
|
4 |
-
#
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
# Ensure the input is valid
|
10 |
if text:
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
else:
|
15 |
-
return "Please provide valid text input."
|
16 |
|
17 |
-
#
|
18 |
-
|
19 |
-
fn=
|
20 |
-
inputs=gr.Textbox(
|
21 |
-
outputs="
|
22 |
-
title="
|
23 |
-
|
24 |
-
"NASA is an abbreviation for National Aeronautics and Space Administration.",
|
25 |
-
"AI stands for Artificial Intelligence.",
|
26 |
-
"What does HTTP mean?"
|
27 |
-
]
|
28 |
)
|
29 |
|
30 |
-
# Launch the app
|
31 |
if __name__ == "__main__":
|
32 |
-
|
|
|
1 |
import gradio as gr
|
2 |
from span_marker import SpanMarkerModel
|
3 |
|
4 |
+
# Download the model from the Hugging Face Hub
|
5 |
+
model = SpanMarkerModel.from_pretrained("tomaarsen/span-marker-bert-base-acronyms")
|
6 |
+
|
7 |
+
# Define the function for prediction
|
8 |
+
def predict_acronyms(text):
|
|
|
9 |
if text:
|
10 |
+
output = model.predict(text)
|
11 |
+
return output
|
12 |
+
return {"error": "Please provide valid text"}
|
|
|
|
|
13 |
|
14 |
+
# Create the Gradio interface
|
15 |
+
interface = gr.Interface(
|
16 |
+
fn=predict_acronyms,
|
17 |
+
inputs=gr.Textbox(label="Enter some text:", lines=5, placeholder="Type here..."),
|
18 |
+
outputs=gr.JSON(label="Predicted Output"),
|
19 |
+
title="Acronym Detection with Span Marker",
|
20 |
+
description="This application detects acronyms in the given text using the SpanMarker model."
|
|
|
|
|
|
|
|
|
21 |
)
|
22 |
|
23 |
+
# Launch the Gradio app
|
24 |
if __name__ == "__main__":
|
25 |
+
interface.launch()
|