Muhammad Abdiel Al Hafiz commited on
Commit
910566d
·
1 Parent(s): 41fecdd

adjust output for disease explanation

Browse files
Files changed (1) hide show
  1. app.py +11 -6
app.py CHANGED
@@ -40,10 +40,10 @@ def predict_image(image):
40
 
41
  formatted_explanation = (
42
  f"**Diagnosis:** {top_label}\n\n"
43
- f"**What is it?**\n{explanation.split('What causes it?')[0].strip()}\n\n"
44
- f"**What causes it?**\n{explanation.split('What causes it?')[1].split('Suggestion')[0].strip()}\n\n"
45
- f"**Suggestion**\n{explanation.split('Suggestion')[1].split('Reminder')[0].strip()}\n\n"
46
- f"**Reminder:** Always seek professional help, such as a doctor."
47
  )
48
 
49
  return {top_label: top_probability}, formatted_explanation
@@ -62,10 +62,15 @@ example_images = [
62
  interface = gr.Interface(
63
  fn=predict_image,
64
  inputs=gr.Image(type="pil"),
65
- outputs=[gr.Label(num_top_classes=1, label="Prediction"), gr.Textbox(label="Explanation")],
 
 
66
  examples=example_images,
67
  title="Eye Diseases Classifier",
68
- description="Upload an image of an eye fundus, and the model will predict it.\n\n**Disclaimer:** This model is intended as a form of learning process in the field of health-related machine learning and was trained with a limited amount and variety of data with a total of about 4000 data, so the prediction results may not always be correct. There is still a lot of room for improvisation on this model in the future.",
 
 
 
69
  allow_flagging="never"
70
  )
71
 
 
40
 
41
  formatted_explanation = (
42
  f"**Diagnosis:** {top_label}\n\n"
43
+ f"**What is it?** {explanation.split('What causes it?')[0].split('Suggestions')[0].strip()}\n\n"
44
+ f"**What causes it?** {explanation.split('What causes it?')[1].split('Suggestions')[0].strip()}\n\n"
45
+ f"**Suggestions:** {explanation.split('Suggestions')[1].split('Reminder')[0].strip()}\n\n"
46
+ f"**Reminder:** Always seek professional help, such as a doctor."
47
  )
48
 
49
  return {top_label: top_probability}, formatted_explanation
 
62
  interface = gr.Interface(
63
  fn=predict_image,
64
  inputs=gr.Image(type="pil"),
65
+ outputs=[
66
+ gr.Label(num_top_classes=1, label="Prediction"),
67
+ gr.Textbox(label="Explanation")],
68
  examples=example_images,
69
  title="Eye Diseases Classifier",
70
+ description=(
71
+ "Upload an image of an eye fundus, and the model will predict it.\n\n"
72
+ "**Disclaimer:** This model is intended as a form of learning process in the field of health-related machine learning and was trained with a limited amount and variety of data with a total of about 4000 data, so the prediction results may not always be correct. There is still a lot of room for improvisation on this model in the future."
73
+ ),
74
  allow_flagging="never"
75
  )
76