orangeorang commited on
Commit
8be2de0
·
verified ·
1 Parent(s): 39020ae

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -1
app.py CHANGED
@@ -1,6 +1,18 @@
1
  import gradio as gr
 
2
 
3
- # Load model dari Hugging Face Inference API
 
 
 
 
 
 
 
 
 
 
 
4
  model = gr.load("models/mistralai/Mistral-7B-Instruct-v0.3", provider="hf-inference")
5
 
6
  # Bungkus dengan Gradio Interface agar bisa dikustomisasi
@@ -20,4 +32,14 @@ with gr.Blocks(css="""
20
  with gr.Column():
21
  model.render()
22
 
 
 
 
 
 
 
 
 
 
 
23
  demo.launch()
 
1
  import gradio as gr
2
+ from transformers import pipeline
3
 
4
+ # Load model NER
5
+ ner_pipeline = pipeline("ner", model="d4data/biomedical-ner-all")
6
+
7
+ def extract_entities(text):
8
+ """Fungsi untuk mengekstrak entitas medis dari teks input."""
9
+ entities = ner_pipeline(text)
10
+ results = []
11
+ for ent in entities:
12
+ results.append(f"{ent['word']} ({ent['entity']}) - Score: {ent['score']:.2f}")
13
+ return "\n".join(results) if results else "Tidak ada entitas medis yang terdeteksi."
14
+
15
+ # Load model chatbot dari Hugging Face Inference API
16
  model = gr.load("models/mistralai/Mistral-7B-Instruct-v0.3", provider="hf-inference")
17
 
18
  # Bungkus dengan Gradio Interface agar bisa dikustomisasi
 
32
  with gr.Column():
33
  model.render()
34
 
35
+ gr.Markdown("## 🏥 Biomedical NER (Named Entity Recognition)")
36
+ gr.Markdown("🔍 Ekstrak entitas medis dari teks yang dimasukkan.")
37
+
38
+ with gr.Row():
39
+ input_text = gr.Textbox(label="Masukkan teks medis", placeholder="Ketik teks medis di sini...")
40
+ ner_output = gr.Textbox(label="Hasil NER", interactive=False)
41
+
42
+ extract_button = gr.Button("Ekstrak Entitas Medis")
43
+ extract_button.click(extract_entities, inputs=[input_text], outputs=[ner_output])
44
+
45
  demo.launch()