jschwaller commited on
Commit
16a2843
·
verified ·
1 Parent(s): f0b4ad9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -9
app.py CHANGED
@@ -31,6 +31,16 @@ ner_model = AutoModelForTokenClassification.from_pretrained("d4data/biomedical-n
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')
36
  output = model(**encoded_input)
@@ -41,15 +51,6 @@ def adr_predict(x):
41
  local_plot = shap.plots.text(shap_values[0], display=False)
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
@@ -65,6 +66,7 @@ def adr_predict(x):
65
 
66
  return {"Severe Reaction": float(scores.numpy()[1]), "Non-severe Reaction": float(scores.numpy()[0])}, local_plot, htext
67
 
 
68
  def main(prob1):
69
  text = str(prob1).lower()
70
  obj = adr_predict(text)
 
31
  ner_pipe = pipeline("ner", model=ner_model, tokenizer=ner_tokenizer, aggregation_strategy="simple") # pass device=0 if using gpu
32
  #
33
 
34
+ entity_colors = {
35
+ 'Severity': '#E63946', # a vivid red
36
+ 'Sign_symptom': '#2A9D8F', # a deep teal
37
+ 'Medication': '#457B9D', # a dusky blue
38
+ 'Age': '#F4A261', # a sandy orange
39
+ 'Sex': '#F4A261', # same sandy orange for consistency with 'Age'
40
+ 'Diagnostic_procedure': '#9C6644', # a brown
41
+ 'Biological_structure': '#BDB2FF', # a light pastel purple
42
+ }
43
+
44
  def adr_predict(x):
45
  encoded_input = tokenizer(x, return_tensors='pt')
46
  output = model(**encoded_input)
 
51
  local_plot = shap.plots.text(shap_values[0], display=False)
52
 
53
  res = ner_pipe(x)
 
 
 
 
 
 
 
 
 
54
 
55
  htext = ""
56
  prev_end = 0
 
66
 
67
  return {"Severe Reaction": float(scores.numpy()[1]), "Non-severe Reaction": float(scores.numpy()[0])}, local_plot, htext
68
 
69
+
70
  def main(prob1):
71
  text = str(prob1).lower()
72
  obj = adr_predict(text)