You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have put print function many times in my code to understand the code and I have also mentioned the output in comments wherever the print function is present.
My code is
predicted_dir_path = '/content/drive/MyDrive/Okutama/mAP/predicted'
ground_truth_dir_path = '/content/drive/MyDrive/Okutama/mAP/ground-truth'
INPUT_SIZE = 416
NUM_CLASS = 13
CLASSES = ['"None"\n', '"Handshaking"\n', '"Hugging"\n', '"Reading"\n', '"Drinking"\n', '"Pushing/Pulling"\n', '"Carrying"\n', '"Calling"\n', '"Running"\n', '"Walking"\n', '"Lying"\n', '"Sitting"\n', '"Standing"\n']
feature_maps = YOLOv4(input_layer)
bbox_tensors = []
for i, fm in enumerate(feature_maps):
if i == 0:
bbox_tensor = decode_train(fm, 52, 13, 8, ANCHORS = anchors, i = i, XYSCALE = xyscale)
elif i == 1:
bbox_tensor = decode_train(fm, 26, 13, 16, ANCHORS = anchors, i = i, XYSCALE = xyscale)
else:
bbox_tensor = decode_train(fm, 13, 13, 32, ANCHORS = anchors, i = i, XYSCALE = xyscale)
bbox_tensors.append(fm)
bbox_tensors.append(bbox_tensor)
model = tf.keras.Model(input_layer, bbox_tensors)
model.load_weights("/content/drive/MyDrive/Okutama/YoloV4_2.h5")
detetction_path = '/content/drive/MyDrive/Okutama/detection'
IOU_THRESHOLD = 0.45
SCORE_THRESHOLD = 0.3
for num in range(len(x_test)):
image = cv2.imread(x_test[num])
boxes = load_annotation_test(filename=y_test[num], frame=frame_no_test[num])
# boxes = load_annotation(filename=y_test[i%len(y_test)], frame=frame_no_test[i%len(frame_no_test)])
# bbox_data_gt = np.array([list(map(int, box.split(','))) for box in boxes])
bbox_data_gt = np.array(boxes)
if len(bbox_data_gt) == 0:
bboxes_gt=[]
classes_gt=[]
else:
bboxes_gt, classes_gt = bbox_data_gt[:, :4], bbox_data_gt[:, 4]
ground_truth_path = os.path.join(ground_truth_dir_path, str(num) + '.txt')
image_path = x_test[0]
image_name = image_path.split('/')[-1]
print('=> ground truth of %s:' % image_name)
num_bbox_gt = len(bboxes_gt)
with open(ground_truth_path, 'w') as f:
for i in range(num_bbox_gt):
class_name = CLASSES[int(classes_gt[i])]
xmin, ymin, xmax, ymax = list(map(str, bboxes_gt[i]))
bbox_mess = ' '.join([class_name, xmin, ymin, xmax, ymax]) + '\n'
f.write(bbox_mess)
print('\t' + str(bbox_mess).strip())
print('=> predict result of %s:' % image_name)
predict_result_path = os.path.join(predicted_dir_path, str(num) + '.txt')
# Predict Process.
print(image.shape) # (720, 1280, 3)
image_size = image.shape[:2]
print(image_size) # (720, 1280)
image_data = image_preporcess(np.copy(image), [INPUT_SIZE, INPUT_SIZE])
print(image_data.shape) #(416, 416, 3)
image_data = image_data[np.newaxis, ...].astype(np.float32)
print(image_data.shape) #(1, 416, 416, 3)
pred_bbox = model.predict(image_data)
pred_bbox = [tf.reshape(x, (-1, tf.shape(x)[-1])) for x in pred_bbox]
# X = np.array(pred_bbox, dtype="object")
# print(X.shape)
pred_bbox = tf.concat(pred_bbox, axis=0)
bboxes = postprocess_boxes(pred_bbox, image_size, INPUT_SIZE, SCORE_THRESHOLD)
bboxes = nms(bboxes, IOU_THRESHOLD , method='nms')
The text was updated successfully, but these errors were encountered:
I have changed the test file according to my use in colab.
I am getting the following error:
I have put print function many times in my code to understand the code and I have also mentioned the output in comments wherever the print function is present.
My code is
The text was updated successfully, but these errors were encountered: