hassoudi commited on
Commit
f33c0ca
·
verified ·
1 Parent(s): 9d5574c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +53 -21
app.py CHANGED
@@ -1,32 +1,64 @@
1
  import gradio as gr
 
 
2
 
3
- def load_disclaimer():
4
- return """
5
- ⚠️ EDUCATIONAL VERSION
6
- This demo implements the exact model you'll build in Chapter [6]
7
- of the book "Natural Language Processing on Oracle Cloud Infrastructure: Building Transformer-Based NLP Solutions Using Oracle AI and Hugging Face".
8
- For production solutions, contact us.
9
- """
 
 
 
 
 
 
 
 
10
 
11
  demo = gr.Interface(
12
  fn=process_text,
13
  inputs=gr.Textbox(
14
- label="Try French Healthcare NER (Educational Version)",
15
- placeholder="En cas d'infection bactérienne, le médecin recommande une antibiothérapie."
 
16
  ),
17
- outputs=gr.HTML(label="Entities Found"),
18
- title="Educational French Healthcare NER | From the book 'Natural Language Processing on Oracle Cloud Infrastructure: Building Transformer-Based NLP Solutions Using Oracle AI and Hugging Face'",
19
  description="""
20
- 🎓 Educational Implementation
21
- - Follows Chapters 4, 5 and 6 of the book"
22
- - Perfect for learning NLP concepts
23
- - Not for production use
24
 
25
- Want to build this yourself?
26
- Get the book: https://a.co/d/2soeB3b
 
27
 
28
- Need a production solution?
29
- Schedule a call: https://typica.ai/
30
  """,
31
- article=load_disclaimer()
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")