mansoorhamidzadeh commited on
Commit
d45058a
·
verified ·
1 Parent(s): fe9105d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -8
app.py CHANGED
@@ -1,10 +1,21 @@
1
- import os
 
2
  import gradio as gr
3
 
4
- hf_token = os.getenv("HF_TOKEN") # or your actual token
5
- app = gr.load(
6
- "mansoorhamidzadeh/Named-entity-recognition",
7
- src="models", # explicitly load via the Inference API
8
- hf_token=hf_token # or token=hf_token
9
- )
10
- app.launch()
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+
3
  import gradio as gr
4
 
5
+ ner_pipeline = pipeline("ner", model="ViravirastSHZ/Hafez-NER")
6
+
7
+ examples = [
8
+ "Does Chicago have any stores and does Joe live here?",
9
+ ]
10
+
11
+ def ner(text):
12
+ output = ner_pipeline(text)
13
+ return {"text": text, "entities": output}
14
+
15
+ demo = gr.Interface(ner,
16
+ gr.Textbox(placeholder="Enter sentence here..."),
17
+ gr.HighlightedText(),
18
+ examples=examples)
19
+
20
+ if __name__ == "__main__":
21
+ demo.launch()