Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,32 +1,64 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
2 |
|
3 |
-
def
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
demo = gr.Interface(
|
12 |
fn=process_text,
|
13 |
inputs=gr.Textbox(
|
14 |
-
label="
|
15 |
-
placeholder="
|
|
|
16 |
),
|
17 |
-
outputs=gr.HTML(label="Entities
|
18 |
-
title="
|
19 |
description="""
|
20 |
-
|
21 |
-
- Follows Chapters 4, 5 and 6 of the book"
|
22 |
-
- Perfect for learning NLP concepts
|
23 |
-
- Not for production use
|
24 |
|
25 |
-
|
26 |
-
|
|
|
27 |
|
28 |
-
|
29 |
-
Schedule a call: https://typica.ai/
|
30 |
""",
|
31 |
-
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from huggingface_hub import login
|
3 |
+
import os
|
4 |
|
5 |
+
def load_healthcare_ner():
|
6 |
+
login(token=os.environ["HF_TOKEN"])
|
7 |
+
model = AutoModelForTokenClassification.from_pretrained(
|
8 |
+
"TypicaAI/HealthcareNER-Fr",
|
9 |
+
token=os.environ["HF_TOKEN"]
|
10 |
+
)
|
11 |
+
return model
|
12 |
+
|
13 |
+
def process_text(text):
|
14 |
+
entities = model(text)
|
15 |
+
# Format results with highlighting
|
16 |
+
html_output = highlight_entities(text, entities)
|
17 |
+
# Track usage for marketing insights
|
18 |
+
log_demo_usage(text, len(entities))
|
19 |
+
return html_output
|
20 |
|
21 |
demo = gr.Interface(
|
22 |
fn=process_text,
|
23 |
inputs=gr.Textbox(
|
24 |
+
label="Paste French medical text",
|
25 |
+
placeholder="Le patient présente une hypertension artérielle...",
|
26 |
+
lines=5
|
27 |
),
|
28 |
+
outputs=gr.HTML(label="Identified Medical Entities"),
|
29 |
+
title="French Healthcare NER Demo | As featured in 'NLP on OCI'",
|
30 |
description="""
|
31 |
+
🔬 Live demo of the French Healthcare NER model built in Chapter 5 of 'NLP on OCI'
|
|
|
|
|
|
|
32 |
|
33 |
+
📚 Follow along with the book to build this exact model step-by-step
|
34 |
+
🏥 Perfect for medical text analysis, clinical studies, and healthcare compliance
|
35 |
+
⚡ Powered by Oracle Cloud Infrastructure
|
36 |
|
37 |
+
By [Hicham Assoudi] - Oracle Consultant & AI Researcher
|
|
|
38 |
""",
|
39 |
+
examples=[
|
40 |
+
["Le patient souffre d'hypertension et diabète de type 2. Traitement: Metformine 500mg."],
|
41 |
+
["Antécédents: infarctus du myocarde en 2019. Allergie à la pénicilline."]
|
42 |
+
]
|
43 |
+
)
|
44 |
+
|
45 |
+
# Add conversion elements
|
46 |
+
with gr.Blocks() as marketing_elements:
|
47 |
+
gr.Markdown("""
|
48 |
+
### 📖 Get the Complete Guide
|
49 |
+
|
50 |
+
Learn how to build and deploy this exact model in 'NLP on OCI'
|
51 |
+
- ✓ Step-by-step implementation
|
52 |
+
- ✓ Performance optimization
|
53 |
+
- ✓ Enterprise deployment patterns
|
54 |
+
- ✓ Complete source code
|
55 |
+
|
56 |
+
[Get the Book](your-book-link) | Use code `NERSPACE` for 15% off
|
57 |
+
""")
|
58 |
+
|
59 |
+
with gr.Row():
|
60 |
+
email_input = gr.Textbox(
|
61 |
+
label="Get the French Healthcare NER Dataset",
|
62 |
+
placeholder="Enter your business email"
|
63 |
+
)
|
64 |
+
submit_btn = gr.Button("Access Dataset")
|