mansoorhamidzadeh commited on
Commit
cfe783b
·
verified ·
1 Parent(s): af3d487

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -9
app.py CHANGED
@@ -1,12 +1,23 @@
1
- import os
 
 
 
2
  import gradio as gr
3
 
4
- hf_token = os.getenv("HF_TOKEN")
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
- with gr.Blocks() as demo:
7
- demo_block = gr.Blocks.load(
8
- "models/ViravirastSHZ/Hafez-NER",
9
- src="models",
10
- hf_token=hf_token
11
- )
12
- demo.launch()
 
1
+
2
+
3
+ from transformers import pipeline
4
+
5
  import gradio as gr
6
 
7
+ ner_pipeline = pipeline("ner", model="models/ViravirastSHZ/Hafez-NER")
8
+
9
+ examples = [
10
+ "روسیه به آمریکا و کشورهای «غیردوست» دعوت‌نامه‌هایی برای شرکت در سیزدهمین دوره مجمع بین‌المللی امنیتی مسکو ارسال کرده است. این رویداد از ۲۷ تا ۲۹ مه ۲۰۲۵ در مسکو برگزار خواهد شد.",
11
+ ]
12
+
13
+ def ner(text):
14
+ output = ner_pipeline(text)
15
+ return {"text": text, "entities": output}
16
+
17
+ demo = gr.Interface(ner,
18
+ gr.Textbox(placeholder="Enter sentence here..."),
19
+ gr.HighlightedText(),
20
+ examples=examples)
21
 
22
+ if __name__ == "__main__":
23
+ demo.launch()