samyak152002 commited on
Commit
45f1ced
·
verified ·
1 Parent(s): bccf783

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -8
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
- # Download from the 🤗 Hub
8
  model = SpanMarkerModel.from_pretrained("tomaarsen/span-marker-bert-base-acronyms")
9
- # Run inference
10
- # text = st.text_area('enter some text:')
11
 
12
- if text:
 
 
13
  out = model.predict(messages)
14
-
15
- return st.json(out)
 
16
 
 
 
 
 
 
 
 
17
 
18
- demo = gr.ChatInterface(fn=function, type="messages", examples=["hello", "hola", "merhaba"], title="Abbreviation-Detector")
 
 
 
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()