Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2,17 +2,27 @@ import gradio as gr
|
|
2 |
from transformers import pipeline
|
3 |
from span_marker import SpanMarkerModel
|
4 |
|
5 |
-
|
6 |
def function(messages):
|
7 |
-
#
|
8 |
model = SpanMarkerModel.from_pretrained("tomaarsen/span-marker-bert-base-acronyms")
|
9 |
-
# Run inference
|
10 |
-
# text = st.text_area('enter some text:')
|
11 |
|
12 |
-
|
|
|
|
|
13 |
out = model.predict(messages)
|
14 |
-
|
15 |
-
|
|
|
16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
-
|
|
|
|
|
|
2 |
from transformers import pipeline
|
3 |
from span_marker import SpanMarkerModel
|
4 |
|
5 |
+
# Define the function
|
6 |
def function(messages):
|
7 |
+
# Load the pre-trained model from Hugging Face
|
8 |
model = SpanMarkerModel.from_pretrained("tomaarsen/span-marker-bert-base-acronyms")
|
|
|
|
|
9 |
|
10 |
+
# Ensure the input is valid
|
11 |
+
if messages:
|
12 |
+
# Run inference on the input messages
|
13 |
out = model.predict(messages)
|
14 |
+
return out
|
15 |
+
else:
|
16 |
+
return "Please provide valid text input."
|
17 |
|
18 |
+
# Set up the Gradio interface
|
19 |
+
demo = gr.ChatInterface(
|
20 |
+
fn=function,
|
21 |
+
type="messages",
|
22 |
+
examples=["Hello, I'm curious about abbreviations like NASA.", "Hola, ¿qué significa AI?", "Merhaba, kısaltmalar hakkında bilgi verir misiniz?"],
|
23 |
+
title="Abbreviation Detector"
|
24 |
+
)
|
25 |
|
26 |
+
# Launch the app
|
27 |
+
if __name__ == "__main__":
|
28 |
+
demo.launch()
|