Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 #26

Open
s5377689 opened this issue Jul 26, 2023 · 1 comment

Comments

@s5377689
Copy link

s5377689 commented Jul 26, 2023

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 s5377689 changed the title How do I solve the IndexError: list index out of range error when using tensorflow-gpu==2.5.0 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 Jul 26, 2023
@s5377689
Copy link
Author

從attack_utils.patch_utils導入extract_roi,evaluate_vanishing_patch,evaluate_mislabeling_patch 從dataset_utils.preprocessing導入letterbox_image_padded 從models.yolov3導入YOLOv3_Darknet53 從misc_utils.visualization導入visible_detections 從tensorflow.keras導入後端作為K 從tqdm導入tqdm 從PIL導入圖像 導入numpy作為np 導入日期時間 導入 os K.clear_session()

weights = 'model_weights/YOLOv3_Darknet53.h5' # TODO:將此路徑更改為受害者模型的權重 #weights = '/research/projects/robust-object-detection/model_weights/YOLOv3_VOC0712_Darknet53.h5' # TODO:將此路徑更改為受害者模型的權重

檢測器= YOLOv3_Darknet53(權重=權重)

警告:tensorflow:

以下變量用於 Lambda 層的調用 (tf.nn.volving),但
不存在於其跟踪對像中:
<tf.Variable 'conv2d/kernel:0' shape=(3, 3, 3, 32) dtype=float32>
這可能是有意的行為,但更可能是
遺漏。這強烈表明該層應被
制定為子類層而不是 Lambda 層。
警告:tensorflow:
以下變量用於 Lambda 層的調用 (tf.compat.v1.nn.fused_batch_norm),但
不存在於其跟踪對像中:
<tf.Variable 'batch_normalization/gamma:0' shape=(32, ) dtype=float32>
<tf.Variable 'batch_normalization/beta:0' shape=(32,
這可能是有意的行為,但更有可能是
疏忽。這強烈表明該層應被
制定為子類層而不是 Lambda 層。
警告:tensorflow:
以下變量用於 Lambda 層的調用 (tf.nn.convolution_1),但
不存在於其跟踪對像中:
<tf.Variable 'conv2d_1/kernel:0' shape=(3, 3, 32, 64) dtype=float32>
這可能是有意的行為,但更可能是
遺漏。這強烈表明該層應被
制定為子類層而不是 Lambda 層。
警告:張量流:
以下變量用於 Lambda 層的調用 (tf.compat.v1.nn.fused_batch_norm_1),但
不存在於其跟踪對像中:
...
<tf.Variable 'batch_normalization_58/beta:0' shape=(256,) dtype=float32>
這可能是有意的行為,但更可能是
疏忽。這強烈表明該層應被
制定為子類層而不是 Lambda 層。
輸出被截斷。作為可滾動元素查看或在文本編輯器中打開。調整單元格輸出設置...
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:列表索引超出範圍

TOG_yolov3_utils_model.txt

@s5377689 s5377689 reopened this Jul 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant