andy-wyx commited on
Commit
eb27f59
·
1 Parent(s): 7b461d5

update xai preprocess

Browse files
Files changed (1) hide show
  1. explanations.py +4 -2
explanations.py CHANGED
@@ -98,7 +98,7 @@ def explain(model, input_image,explain_method,nb_samples,size=600, n_classes=171
98
  # #
99
  # ]
100
 
101
- cropped,repetitions = _clever_crop(input_image,(size,size))
102
  # size_repetitions = int(size//(repetitions.numpy()+1))
103
  # print(size)
104
  # print(type(input_image))
@@ -108,7 +108,9 @@ def explain(model, input_image,explain_method,nb_samples,size=600, n_classes=171
108
  # print(repetitions)
109
  # print(size_repetitions)
110
  # print(type(size_repetitions))
111
- X = preprocess(cropped,size=size)
 
 
112
  predictions = class_model.predict(np.array([X]))
113
  #Y = np.argmax(predictions)
114
  top_5_indices = np.argsort(predictions[0])[-5:][::-1]
 
98
  # #
99
  # ]
100
 
101
+ # cropped,repetitions = _clever_crop(input_image,(size,size))
102
  # size_repetitions = int(size//(repetitions.numpy()+1))
103
  # print(size)
104
  # print(type(input_image))
 
108
  # print(repetitions)
109
  # print(size_repetitions)
110
  # print(type(size_repetitions))
111
+ # X = preprocess(cropped,size=size)
112
+ X = tf.image.resize(input_image, (size, size))
113
+ X = tf.reshape(X, (size, size, 3))/255
114
  predictions = class_model.predict(np.array([X]))
115
  #Y = np.argmax(predictions)
116
  top_5_indices = np.argsort(predictions[0])[-5:][::-1]