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 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)