TOG icon indicating copy to clipboard operation
TOG copied to clipboard

How do I solve the IndexError: list index out of range error when using tensorflow-gpu==2.5.0 for execute the demo_patch.ipynb program

Open s5377689 opened this issue 1 year ago • 1 comments

from attack_utils.patch_utils import extract_roi, evaluate_vanishing_patch, evaluate_mislabeling_patch from dataset_utils.preprocessing import letterbox_image_padded from models.yolov3 import YOLOv3_Darknet53 from misc_utils.visualization import visualize_detections from tensorflow.keras import backend as K from tqdm import tqdm from PIL import Image import numpy as np import datetime import os K.clear_session()

weights = 'model_weights/YOLOv3_Darknet53.h5' # TODO: Change this path to the victim model's weights #weights = '/research/projects/robust-object-detection/model_weights/YOLOv3_VOC0712_Darknet53.h5' # TODO: Change this path to the victim model's weights

detector = YOLOv3_Darknet53(weights=weights)


WARNING:tensorflow: The following Variables were used a Lambda layer's call (tf.nn.convolution), but are not present in its tracked objects: <tf.Variable 'conv2d/kernel:0' shape=(3, 3, 3, 32) dtype=float32> It is possible that this is intended behavior, but it is more likely an omission. This is a strong indication that this layer should be formulated as a subclassed Layer rather than a Lambda layer. WARNING:tensorflow: The following Variables were used a Lambda layer's call (tf.compat.v1.nn.fused_batch_norm), but are not present in its tracked objects: <tf.Variable 'batch_normalization/gamma:0' shape=(32,) dtype=float32> <tf.Variable 'batch_normalization/beta:0' shape=(32,) dtype=float32> It is possible that this is intended behavior, but it is more likely an omission. This is a strong indication that this layer should be formulated as a subclassed Layer rather than a Lambda layer. WARNING:tensorflow: The following Variables were used a Lambda layer's call (tf.nn.convolution_1), but are not present in its tracked objects: <tf.Variable 'conv2d_1/kernel:0' shape=(3, 3, 32, 64) dtype=float32> It is possible that this is intended behavior, but it is more likely an omission. This is a strong indication that this layer should be formulated as a subclassed Layer rather than a Lambda layer. WARNING:tensorflow: The following Variables were used a Lambda layer's call (tf.compat.v1.nn.fused_batch_norm_1), but are not present in its tracked objects: ... <tf.Variable 'batch_normalization_58/beta:0' shape=(256,) dtype=float32> It is possible that this is intended behavior, but it is more likely an omission. This is a strong indication that this layer should be formulated as a subclassed Layer rather than a Lambda layer. Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings...

IndexError Traceback (most recent call last) C:\TEMP\ipykernel_9648\2429568344.py in 2 #weights = '/research/projects/robust-object-detection/model_weights/YOLOv3_VOC0712_Darknet53.h5' # TODO: Change this path to the victim model's weights 3 ----> 4 detector = YOLOv3_Darknet53(weights=weights)

c:\Users\User\Desktop\TOG\models\yolov3.py in init(self, weights, model_img_size, confidence_thresh_default, confidence_thresh_eval) 241 def init(self, weights, model_img_size=(416, 416), confidence_thresh_default=0.20, confidence_thresh_eval=0.01): 242 super().init(weights, yolo_darknet53, --> 243 model_img_size, confidence_thresh_default, confidence_thresh_eval) 244 245

c:\Users\User\Desktop\TOG\models\yolov3.py in init(self, weights, backbone, model_img_size, confidence_thresh_default, confidence_thresh_eval) 18 self.num_anchors = len(self.anchors) 19 ---> 20 self.model = backbone(Input(shape=(None, None, 3)), self.num_anchors // 3, self.num_classes) 21 self.model.load_weights(weights) 22

c:\Users\User\Desktop\TOG\yolov3_utils\model.py in yolo_darknet53(inputs, num_anchors, num_classes) 69 70 x = compose(DarknetConv2D_BN_Leaky(256, (1, 1)), UpSampling2D(2))(x) ---> 71 x = Concatenate()([x, darknet.layers[152].output]) 72 x, y2 = make_last_layers(x, 256, num_anchors * (num_classes + 5)) 73 y2 = Reshape((tf.shape(y2)[1], tf.shape(y2)[2], num_anchors, num_classes + 5))(y2)

IndexError: list index out of range

TOG_yolov3_utils_model.txt

s5377689 avatar Jul 26 '23 12:07 s5377689