Update app.py
Browse files
app.py
CHANGED
@@ -356,7 +356,7 @@ def process_image_with_xception_gradcam(image, model, device, pred_class):
|
|
356 |
_, _, _, _, face_box, _ = dataset[0]
|
357 |
|
358 |
return raw_cam, overlay, comparison, face_box
|
359 |
-
|
360 |
st.error("Failed to generate GradCAM visualization")
|
361 |
return None, None, None, None
|
362 |
|
@@ -435,18 +435,18 @@ def generate_gradcam_caption(image, processor, model, max_length=60):
|
|
435 |
# Try to parse the caption based on different possible formats
|
436 |
try:
|
437 |
# Original format with "high activation:" etc.
|
438 |
-
|
439 |
if "high activation :" in caption:
|
440 |
high_match = caption.split("high activation :")[1].split("moderate")[0]
|
441 |
-
|
442 |
|
443 |
if "moderate activation :" in caption:
|
444 |
moderate_match = caption.split("moderate activation :")[1].split("low")[0]
|
445 |
-
|
446 |
|
447 |
if "low activation :" in caption:
|
448 |
low_match = caption.split("low activation :")[1]
|
449 |
-
|
450 |
|
451 |
# If nothing was extracted using the original format, try alternative formats
|
452 |
if not formatted_text.strip():
|
|
|
356 |
_, _, _, _, face_box, _ = dataset[0]
|
357 |
|
358 |
return raw_cam, overlay, comparison, face_box
|
359 |
+
else:
|
360 |
st.error("Failed to generate GradCAM visualization")
|
361 |
return None, None, None, None
|
362 |
|
|
|
435 |
# Try to parse the caption based on different possible formats
|
436 |
try:
|
437 |
# Original format with "high activation:" etc.
|
438 |
+
formatted_text = ""
|
439 |
if "high activation :" in caption:
|
440 |
high_match = caption.split("high activation :")[1].split("moderate")[0]
|
441 |
+
formatted_text += f"**High activation**:\n{high_match.strip()}\n\n"
|
442 |
|
443 |
if "moderate activation :" in caption:
|
444 |
moderate_match = caption.split("moderate activation :")[1].split("low")[0]
|
445 |
+
formatted_text += f"**Moderate activation**:\n{moderate_match.strip()}\n\n"
|
446 |
|
447 |
if "low activation :" in caption:
|
448 |
low_match = caption.split("low activation :")[1]
|
449 |
+
formatted_text += f"**Low activation**:\n{low_match.strip()}"
|
450 |
|
451 |
# If nothing was extracted using the original format, try alternative formats
|
452 |
if not formatted_text.strip():
|