Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pytorch_object_detection/yolov3_spp/build_utils/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions pytorch_object_detection/yolov3_spp/predict_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down