Mykes commited on
Commit
5eeab19
·
verified ·
1 Parent(s): 3f8c048

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -0
app.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Initialize the pipeline
5
+ pipe = pipeline(task="ner",
6
+ model='Mykes/rubert_ner_SDDCS',
7
+ tokenizer='Mykes/rubert_ner_SDDCS',
8
+ aggregation_strategy='max')
9
+
10
+ def process_text(text):
11
+ # Convert input to lowercase as in your example
12
+ results = pipe(text.lower())
13
+
14
+ # Format the output
15
+ output = []
16
+ for entity in results:
17
+ formatted_result = f"Type: {entity['entity_group']}\nWord: {entity['word']}\nScore: {entity['score']:.4f}\n"
18
+ output.append(formatted_result)
19
+
20
+ return "\n".join(output)
21
+
22
+ # Create Gradio interface
23
+ iface = gr.Interface(
24
+ fn=process_text,
25
+ inputs=gr.Textbox(lines=3, placeholder="Enter your text here..."),
26
+ outputs=gr.Textbox(lines=10),
27
+ title="Medical NER for Russian Text",
28
+ description="This model identifies medical entities (diseases, symptoms, drugs, etc.) in Russian text.",
29
+ examples=[
30
+ ["У ребенка треога и норушения сна, потеря сознания, раньше ставили паническое расстройство. по назначению психиатра принимал атаракс без эффекта."],
31
+ ]
32
+ )
33
+
34
+ # Launch the interface
35
+ iface.launch()