ErnestBeckham commited on
Commit
43f7f5d
·
1 Parent(s): 03e7919
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -3,14 +3,14 @@ import tensorflow as tf
3
  import cv2
4
  import numpy as np
5
  from huggingface_hub import from_pretrained_keras
6
- from lime import lime_image
7
- from skimage.segmentation import mark_boundaries
8
  import matplotlib.pyplot as plt
9
 
10
 
11
 
12
  model = from_pretrained_keras('ErnestBeckham/BreastResViT')
13
- explainer = lime_image.LimeImageExplainer()
14
 
15
  hp = {}
16
  hp['class_names'] = ["breast_benign", "breast_malignant"]
@@ -64,7 +64,7 @@ def predict_single_image(image, model, hp):
64
  return class_name
65
 
66
 
67
- def xai_result(image):
68
  path = "lime_explanation.png"
69
  tem = cv2.resize(image, [512,512])
70
  gray_img = cv2.cvtColor(tem, cv2.COLOR_BGR2GRAY)
@@ -73,7 +73,7 @@ def xai_result(image):
73
  top_labels=1000, hide_color=0, num_samples=1000)
74
  temp, mask = explanation.get_image_and_mask(explanation.top_labels[0], positive_only=True, num_features=5, hide_rest=True)
75
  plt.imshow(mark_boundaries(temp / 2 + 0.5, mask), interpolation='nearest')
76
- plt.savefig(path)
77
 
78
 
79
  if __name__ == "__main__":
 
3
  import cv2
4
  import numpy as np
5
  from huggingface_hub import from_pretrained_keras
6
+ #from lime import lime_image
7
+ #from skimage.segmentation import mark_boundaries
8
  import matplotlib.pyplot as plt
9
 
10
 
11
 
12
  model = from_pretrained_keras('ErnestBeckham/BreastResViT')
13
+ #explainer = lime_image.LimeImageExplainer()
14
 
15
  hp = {}
16
  hp['class_names'] = ["breast_benign", "breast_malignant"]
 
64
  return class_name
65
 
66
 
67
+ """def xai_result(image):
68
  path = "lime_explanation.png"
69
  tem = cv2.resize(image, [512,512])
70
  gray_img = cv2.cvtColor(tem, cv2.COLOR_BGR2GRAY)
 
73
  top_labels=1000, hide_color=0, num_samples=1000)
74
  temp, mask = explanation.get_image_and_mask(explanation.top_labels[0], positive_only=True, num_features=5, hide_rest=True)
75
  plt.imshow(mark_boundaries(temp / 2 + 0.5, mask), interpolation='nearest')
76
+ plt.savefig(path)"""
77
 
78
 
79
  if __name__ == "__main__":