BhumikaMak commited on
Commit
afe9924
·
1 Parent(s): eb18a04

Debug: yolov8 target lyr

Browse files
Files changed (1) hide show
  1. yolov8.py +1 -4
yolov8.py CHANGED
@@ -47,11 +47,8 @@ def xai_yolov8(image):
47
  # Convert image to PyTorch tensor for Grad-CAM
48
  image_tensor = torch.tensor(np.array(image)).permute(2, 0, 1).unsqueeze(0).float() / 255.0
49
  image_tensor = image_tensor.to('cpu')
50
-
51
- # Inspect the model and print layer structure
52
  print(model.model) # Output model layers to find the target layer
53
-
54
- # Find the correct target layer
55
  target_layer = model.model.model[-1] # Target the last detection layer
56
 
57
  # Initialize Grad-CAM with the target layer
 
47
  # Convert image to PyTorch tensor for Grad-CAM
48
  image_tensor = torch.tensor(np.array(image)).permute(2, 0, 1).unsqueeze(0).float() / 255.0
49
  image_tensor = image_tensor.to('cpu')
50
+ model(image_tensor) # Forward pass
 
51
  print(model.model) # Output model layers to find the target layer
 
 
52
  target_layer = model.model.model[-1] # Target the last detection layer
53
 
54
  # Initialize Grad-CAM with the target layer