From 9d73e8969b209f29c36ef3ee087aeba1631bbc00 Mon Sep 17 00:00:00 2001 From: Kakaluoto <1052176873@qq.com> Date: Tue, 7 Mar 2023 11:30:16 +0800 Subject: [PATCH 1/2] Fix syntax errors --- pytorch_object_detection/yolov3_spp/build_utils/datasets.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pytorch_object_detection/yolov3_spp/build_utils/datasets.py b/pytorch_object_detection/yolov3_spp/build_utils/datasets.py index d09ce0b59..245534610 100644 --- a/pytorch_object_detection/yolov3_spp/build_utils/datasets.py +++ b/pytorch_object_detection/yolov3_spp/build_utils/datasets.py @@ -236,11 +236,11 @@ def __init__(self, # 放大裁剪目标的宽高 b[2:] = b[2:] * 1.3 + 30 # pad # 将坐标格式从 x,y,w,h -> xmin,ymin,xmax,ymax - b = xywh2xyxy(b.reshape(-1, 4)).revel().astype(np.int) + b = xywh2xyxy(b.reshape(-1, 4)).ravel().astype(np.int) # 裁剪bbox坐标到图片内 - b[[0, 2]] = np.clip[b[[0, 2]], 0, w] - b[[1, 3]] = np.clip[b[[1, 3]], 0, h] + b[[0, 2]] = np.clip(b[[0, 2]], 0, w) + b[[1, 3]] = np.clip(b[[1, 3]], 0, h) assert cv2.imwrite(f, img[b[1]:b[3], b[0]:b[2]]), "Failure extracting classifier boxes" else: ne += 1 # file empty From 6ae87030b84f4eb80c44131ac8201260390bb7be Mon Sep 17 00:00:00 2001 From: Kakaluoto <1052176873@qq.com> Date: Thu, 9 Mar 2023 15:29:53 +0800 Subject: [PATCH 2/2] fixed some bugs --- pytorch_object_detection/yolov3_spp/predict_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pytorch_object_detection/yolov3_spp/predict_test.py b/pytorch_object_detection/yolov3_spp/predict_test.py index bbd2d87b4..8b4d7fe00 100644 --- a/pytorch_object_detection/yolov3_spp/predict_test.py +++ b/pytorch_object_detection/yolov3_spp/predict_test.py @@ -20,14 +20,14 @@ def main(): json_path = "./data/pascal_voc_classes.json" # json标签文件 img_path = "test.jpg" assert os.path.exists(cfg), "cfg file {} dose not exist.".format(cfg) - assert os.path.exists(weights), "weights file {} dose not exist.".format(weights) + assert os.path.exists(weights_path), "weights file {} dose not exist.".format(weights_path) assert os.path.exists(json_path), "json file {} dose not exist.".format(json_path) assert os.path.exists(img_path), "image file {} dose not exist.".format(img_path) with open(json_path, 'r') as f: class_dict = json.load(f) - category_index = {str(v): str(k) for k, v in class_dict.items()} + category_index = {str(k): str(v) for k, v in class_dict.items()} input_size = (img_size, img_size)