updated
Browse files
app.py
CHANGED
@@ -60,17 +60,19 @@ def main():
|
|
60 |
image_class = predict_single_image(image, model, hp)
|
61 |
#gradCam.save_and_display_gradcam()
|
62 |
st.write(f"Image Class: {image_class}")
|
|
|
|
|
63 |
explanation = explainer.explain_instance(
|
64 |
gray_img.astype('double'),
|
65 |
model.predict,
|
66 |
-
top_labels=
|
67 |
hide_color=0,
|
68 |
-
num_samples=
|
69 |
)
|
70 |
temp, mask = explanation.get_image_and_mask(
|
71 |
explanation.top_labels[0],
|
72 |
positive_only=True,
|
73 |
-
num_features=
|
74 |
hide_rest=True
|
75 |
)
|
76 |
|
@@ -80,7 +82,7 @@ def main():
|
|
80 |
# Save and display LIME explanation
|
81 |
lime_explanation_path = 'lime_explanation.png'
|
82 |
cv2.imwrite(lime_explanation_path, (xai * 255).astype(np.uint8))
|
83 |
-
st.image(
|
84 |
|
85 |
|
86 |
def convert_to_opencv(uploaded_file):
|
|
|
60 |
image_class = predict_single_image(image, model, hp)
|
61 |
#gradCam.save_and_display_gradcam()
|
62 |
st.write(f"Image Class: {image_class}")
|
63 |
+
|
64 |
+
|
65 |
explanation = explainer.explain_instance(
|
66 |
gray_img.astype('double'),
|
67 |
model.predict,
|
68 |
+
top_labels=2,
|
69 |
hide_color=0,
|
70 |
+
num_samples=100
|
71 |
)
|
72 |
temp, mask = explanation.get_image_and_mask(
|
73 |
explanation.top_labels[0],
|
74 |
positive_only=True,
|
75 |
+
num_features=5,
|
76 |
hide_rest=True
|
77 |
)
|
78 |
|
|
|
82 |
# Save and display LIME explanation
|
83 |
lime_explanation_path = 'lime_explanation.png'
|
84 |
cv2.imwrite(lime_explanation_path, (xai * 255).astype(np.uint8))
|
85 |
+
st.image((xai * 255).astype(np.uint8), caption="LIME Explanation", use_column_width=True)
|
86 |
|
87 |
|
88 |
def convert_to_opencv(uploaded_file):
|