Update app.py
Browse files
app.py
CHANGED
@@ -199,6 +199,7 @@ def hook_backward(module, grad_in, grad_out):
|
|
199 |
gradients['value'] = grad_out[0]
|
200 |
|
201 |
def cam_inference(target_tag, threshold):
|
|
|
202 |
global input_image, sorted_tag_score, target_tag_index, gradients, activations
|
203 |
img = input_image
|
204 |
tensor = transform(img).unsqueeze(0)
|
@@ -260,9 +261,7 @@ def create_cam_visualization_pil(cam, alpha=0.6, vis_threshold=0.2):
|
|
260 |
Returns:
|
261 |
PIL.Image.Image with overlay
|
262 |
"""
|
263 |
-
|
264 |
-
print("CAM is None, skipping visualization.")
|
265 |
-
return image_pil
|
266 |
global input_image
|
267 |
# Convert to RGB (in case RGBA or others)
|
268 |
image_pil = input_image
|
@@ -336,7 +335,7 @@ with gr.Blocks(css=".output-class { display: none; }") as demo:
|
|
336 |
|
337 |
label_box.select(
|
338 |
fn=cam_inference,
|
339 |
-
inputs=[threshold_slider],
|
340 |
outputs=[image_input]
|
341 |
)
|
342 |
|
|
|
199 |
gradients['value'] = grad_out[0]
|
200 |
|
201 |
def cam_inference(target_tag, threshold):
|
202 |
+
print(f"target_tag: {target_tag}")
|
203 |
global input_image, sorted_tag_score, target_tag_index, gradients, activations
|
204 |
img = input_image
|
205 |
tensor = transform(img).unsqueeze(0)
|
|
|
261 |
Returns:
|
262 |
PIL.Image.Image with overlay
|
263 |
"""
|
264 |
+
|
|
|
|
|
265 |
global input_image
|
266 |
# Convert to RGB (in case RGBA or others)
|
267 |
image_pil = input_image
|
|
|
335 |
|
336 |
label_box.select(
|
337 |
fn=cam_inference,
|
338 |
+
inputs=[label_box, threshold_slider],
|
339 |
outputs=[image_input]
|
340 |
)
|
341 |
|