lyangas commited on
Commit
73b8367
·
1 Parent(s): d577848

return json-format

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -17,20 +17,20 @@ def classify_code(text):
17
  embed = model._texts2vecs([text])
18
  probs = model.classifier_code.predict_proba(embed)
19
  best_n = np.flip(np.argsort(probs, axis=1,)[0,-3:])
20
- preds = [f"{model.classifier_code.classes_[i]} - {probs[0][i]*100:.1f}%" for i in best_n]
21
- output_text = '\n'.join(preds)
22
- return output_text
23
 
24
  def classify_group(text):
25
  embed = model._texts2vecs([text])
26
  probs = model.classifier_group.predict_proba(embed)
27
  best_n = np.flip(np.argsort(probs, axis=1,)[0,-3:])
28
- preds = [f"{model.classifier_group.classes_[i]} - {probs[0][i]*100:.1f}%" for i in best_n]
29
- output_text = '\n'.join(preds)
30
- return output_text
31
 
32
  def classify(text):
33
- return f"Diagnostic code:\n{classify_code(text)}\n\nDiagnostic group:\n{classify_group(text)}"
34
 
35
  print('INFO: starting gradio interface')
36
  default_input_text = """Microscopic Evaluation: The specimen is excised into the reticular dermis and demonstrates skin with prominent papillomatosis and hyperkeratosis. The keratinocytes show reactive changes with nuclear enlargement and increased amounts of cytoplasm but no dysplasia is identified. Lymphocytic inflammation is distributed through the base of the lesion. Some pigmentation is present. The lesion approximates the edges of the specimen but appears to be predominantly excised. (GMW/jc) Gross Description: Shave removal and destruction erythematous tender papule with hyperkeratotic scale SCC vs BCC D.. Right medial temple. Final Diagnosis: Pigmented seborrheic keratosis inflamed."""
@@ -40,6 +40,6 @@ iface = gr.Interface(
40
  description="",
41
  fn=classify,
42
  inputs=[gr.Textbox(label="Input text", value=default_input_text)],
43
- outputs=gr.outputs.Textbox(label="Result class"),
44
  )
45
  iface.launch()
 
17
  embed = model._texts2vecs([text])
18
  probs = model.classifier_code.predict_proba(embed)
19
  best_n = np.flip(np.argsort(probs, axis=1,)[0,-3:])
20
+ preds = [{model.classifier_code.classes_[i]: f"{probs[0][i]*100:.1f}"} for i in best_n]
21
+ #output_text = '\n'.join(preds)
22
+ return preds
23
 
24
  def classify_group(text):
25
  embed = model._texts2vecs([text])
26
  probs = model.classifier_group.predict_proba(embed)
27
  best_n = np.flip(np.argsort(probs, axis=1,)[0,-3:])
28
+ preds = [{model.classifier_group.classes_[i]: f"{probs[0][i]*100:.1f}"} for i in best_n]
29
+ # output_text = '\n'.join(preds)
30
+ return preds
31
 
32
  def classify(text):
33
+ return classify_code(text), classify_group(text)
34
 
35
  print('INFO: starting gradio interface')
36
  default_input_text = """Microscopic Evaluation: The specimen is excised into the reticular dermis and demonstrates skin with prominent papillomatosis and hyperkeratosis. The keratinocytes show reactive changes with nuclear enlargement and increased amounts of cytoplasm but no dysplasia is identified. Lymphocytic inflammation is distributed through the base of the lesion. Some pigmentation is present. The lesion approximates the edges of the specimen but appears to be predominantly excised. (GMW/jc) Gross Description: Shave removal and destruction erythematous tender papule with hyperkeratotic scale SCC vs BCC D.. Right medial temple. Final Diagnosis: Pigmented seborrheic keratosis inflamed."""
 
40
  description="",
41
  fn=classify,
42
  inputs=[gr.Textbox(label="Input text", value=default_input_text)],
43
+ outputs=[gr.outputs.Textbox(label="Result class"), gr.outputs.Textbox(label="Result group")],
44
  )
45
  iface.launch()