yuvarajareddy001 commited on
Commit
bc702c6
·
verified ·
1 Parent(s): 5dd759f

Upload 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
+ import spacy
3
+ import spacy.displacy
4
+
5
+ # Define model name as installed package
6
+ MODEL_NAME = "en_pipeline"
7
+
8
+ try:
9
+ # Load the installed model
10
+ nlp = spacy.load(MODEL_NAME)
11
+ except OSError:
12
+ raise ValueError(f"Could not load spaCy model '{MODEL_NAME}'. Verify installation and package name.")
13
+
14
+ # Function to process input text and display named entities
15
+ def extract_entities(text):
16
+ doc = nlp(text)
17
+ return spacy.displacy.render(doc, style="ent", jupyter=False)
18
+
19
+ # Gradio UI for Medical NER Model
20
+ iface = gr.Interface(
21
+ fn=extract_entities,
22
+ inputs=gr.Textbox(lines=5, placeholder="Enter medical text here..."),
23
+ outputs="html",
24
+ title="🩺 Medical Named Entity Recognition (NER) Model",
25
+ description="Enter medical text to extract entities such as **medical conditions, medications, and pathogens**.",
26
+ examples=[
27
+ ["John Doe, a 45-year-old man, visited the hospital after experiencing severe acute respiratory syndrome symptoms..."],
28
+ ["A recent outbreak of rabies virus has caused concerns in the rural community..."]
29
+ ],
30
+ theme="default",
31
+ )
32
+
33
+ # Launch the Gradio app
34
+ if __name__ == "__main__":
35
+ iface.launch()