Kalbe-x-Bangkit
commited on
Commit
•
204cc82
1
Parent(s):
24201d7
Update app.py
Browse files
app.py
CHANGED
@@ -232,7 +232,7 @@ def grad_cam(input_model, img_array, cls, layer_name):
|
|
232 |
|
233 |
|
234 |
# Compute Grad-CAM
|
235 |
-
def compute_gradcam(
|
236 |
# base_model = keras.applications.DenseNet121(weights = './densenet.hdf5', include_top = False)
|
237 |
# x = base_model.output
|
238 |
# x = keras.layers.GlobalAveragePooling2D()(x)
|
@@ -255,7 +255,7 @@ def compute_gradcam(model, img_path, layer_name='bn'):
|
|
255 |
|
256 |
for i in range(len(labels)):
|
257 |
st.write(f"Generating gradcam for class {labels[i]}")
|
258 |
-
gradcam = grad_cam(
|
259 |
gradcam = (gradcam * 255).astype(np.uint8)
|
260 |
gradcam = cv2.applyColorMap(gradcam, cv2.COLORMAP_JET)
|
261 |
gradcam = cv2.addWeighted(gradcam, 0.5, original_image.squeeze().astype(np.uint8), 0.5, 0)
|
|
|
232 |
|
233 |
|
234 |
# Compute Grad-CAM
|
235 |
+
def compute_gradcam(model_gradcam, img_path, layer_name='bn'):
|
236 |
# base_model = keras.applications.DenseNet121(weights = './densenet.hdf5', include_top = False)
|
237 |
# x = base_model.output
|
238 |
# x = keras.layers.GlobalAveragePooling2D()(x)
|
|
|
255 |
|
256 |
for i in range(len(labels)):
|
257 |
st.write(f"Generating gradcam for class {labels[i]}")
|
258 |
+
gradcam = grad_cam(model_gradcam, preprocessed_input, i, layer_name)
|
259 |
gradcam = (gradcam * 255).astype(np.uint8)
|
260 |
gradcam = cv2.applyColorMap(gradcam, cv2.COLORMAP_JET)
|
261 |
gradcam = cv2.addWeighted(gradcam, 0.5, original_image.squeeze().astype(np.uint8), 0.5, 0)
|