Spaces:
Running
Running
jschwaller
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -25,10 +25,11 @@ pred = transformers.pipeline("text-classification", model=model,
|
|
25 |
|
26 |
explainer = shap.Explainer(pred)
|
27 |
|
28 |
-
ner_tokenizer = AutoTokenizer.from_pretrained("
|
29 |
-
ner_model = AutoModelForTokenClassification.from_pretrained("
|
30 |
|
31 |
ner_pipe = pipeline("ner", model=ner_model, tokenizer=ner_tokenizer, aggregation_strategy="simple") # pass device=0 if using gpu
|
|
|
32 |
|
33 |
def adr_predict(x):
|
34 |
encoded_input = tokenizer(x, return_tensors='pt')
|
@@ -41,14 +42,14 @@ def adr_predict(x):
|
|
41 |
|
42 |
res = ner_pipe(x)
|
43 |
entity_colors = {
|
44 |
-
'Severity': '
|
45 |
-
'Sign_symptom': '
|
46 |
-
'Medication': '
|
47 |
-
'Age': '
|
48 |
-
'Sex': '
|
49 |
-
'Diagnostic_procedure': '
|
50 |
-
'Biological_structure': '
|
51 |
-
|
52 |
|
53 |
htext = ""
|
54 |
prev_end = 0
|
|
|
25 |
|
26 |
explainer = shap.Explainer(pred)
|
27 |
|
28 |
+
ner_tokenizer = AutoTokenizer.from_pretrained("d4data/biomedical-ner-all")
|
29 |
+
ner_model = AutoModelForTokenClassification.from_pretrained("d4data/biomedical-ner-all")
|
30 |
|
31 |
ner_pipe = pipeline("ner", model=ner_model, tokenizer=ner_tokenizer, aggregation_strategy="simple") # pass device=0 if using gpu
|
32 |
+
#
|
33 |
|
34 |
def adr_predict(x):
|
35 |
encoded_input = tokenizer(x, return_tensors='pt')
|
|
|
42 |
|
43 |
res = ner_pipe(x)
|
44 |
entity_colors = {
|
45 |
+
'Severity': '#E63946', # a vivid red
|
46 |
+
'Sign_symptom': '#2A9D8F', # a deep teal
|
47 |
+
'Medication': '#457B9D', # a dusky blue
|
48 |
+
'Age': '#F4A261', # a sandy orange
|
49 |
+
'Sex': '#F4A261', # same sandy orange for consistency with 'Age'
|
50 |
+
'Diagnostic_procedure': '#9C6644', # a brown
|
51 |
+
'Biological_structure': '#BDB2FF', # a light pastel purple
|
52 |
+
}
|
53 |
|
54 |
htext = ""
|
55 |
prev_end = 0
|