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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -9
app.py CHANGED
@@ -1,26 +1,30 @@
1
  import gradio as gr
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
 
1
  import gradio as gr
 
2
  from span_marker import SpanMarkerModel
3
 
4
  # Define the function
5
+ def function(text):
6
  # Load the pre-trained model from Hugging Face
7
  model = SpanMarkerModel.from_pretrained("tomaarsen/span-marker-bert-base-acronyms")
8
 
9
  # Ensure the input is valid
10
+ if text:
11
+ # Run inference on the input text
12
+ out = model.predict([text]) # Wrap the text in a list as the model expects a list of strings
13
  return out
14
  else:
15
  return "Please provide valid text input."
16
 
17
  # Set up the Gradio interface
18
+ demo = gr.Interface(
19
  fn=function,
20
+ inputs=gr.Textbox(lines=5, placeholder="Enter your text here...", label="Input Text"),
21
+ outputs="json",
22
+ title="Abbreviation Detector",
23
+ examples=[
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