Skip to content

Commit 6cb0ea7

Browse files
committed
yolov3_coco.h5 + YOLOv3 model
1 parent cc3c78b commit 6cb0ea7

File tree

5 files changed

+15
-10
lines changed

5 files changed

+15
-10
lines changed

configs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
DIR_TEST = DIR_DATA + "test/"
3535
PATH_CLASSES = DIR_TRAIN + "_classes.txt"
3636
PATH_ANCHORS = "data/yolo_anchors.txt"
37-
PATH_WEIGHT = "data/yolov3_weights.h5"
37+
PATH_WEIGHT = "data/yolov3_coco.h5"
3838
PATH_DARKNET_WEIGHT = "data/yolov3.weights"
3939

4040
# TRAIN options

convert2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
# https://machinelearningmastery.com/how-to-perform-object-detection-with-yolov3-in-keras/
3434
# https://github.com/experiencor/keras-yolo3/blob/master/yolo3_one_file_to_detect_them_all.py
3535
# Input: yolov3 keras model, yolov3.weights
36-
# Output: yolov3_weights.h5
36+
# Output: yolov3_coco.h5
3737
# ===================================================================
3838
class WeightReader:
3939
def __init__(self, weight_file):
@@ -131,5 +131,5 @@ def _main(args):
131131

132132
if __name__ == '__main__':
133133
# run following command (as per current folder structure) on terminal
134-
# python convert2.py data/yolov3.weights data/yolov3_weights.h5
134+
# python convert2.py data/yolov3.weights data/yolov3_coco.h5
135135
_main(parser.parse_args())

loss/loss_functional.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,13 @@ def loop_body(idx, ignore_mask):
127127

128128
# =========================================================
129129
# calculate xy loss using binary_crossentropy
130-
# K.sigmoid calculation additionally added in this repository compared to original source
131130
# =========================================================
132-
xy_loss = object_mask * box_loss_scale * K.binary_crossentropy(raw_true_xy, K.sigmoid(raw_pred[..., 0:2]),
131+
# Adding K.sigmoid calculation additionally (which is not in original repo) shifted the final prediction
132+
# TODO: need to investigate
133+
# =========================================================
134+
# xy_loss = object_mask * box_loss_scale * K.binary_crossentropy(raw_true_xy, K.sigmoid(raw_pred[..., 0:2]),
135+
# from_logits=True)
136+
xy_loss = object_mask * box_loss_scale * K.binary_crossentropy(raw_true_xy, raw_pred[..., 0:2],
133137
from_logits=True)
134138

135139
# =========================================================

predict.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ def draw_boxes(image, boxes, labels, obj_thresh):
216216

217217
def _main(args):
218218
image_path = args.image_path if args.image_path is not None else "data/apple.jpg"
219-
weight_path = "data/yolov3_weights.h5"
219+
weight_path = "data/yolov3.h5"
220220

221221
# set some parameters
222222
net_h, net_w = 416, 416
@@ -238,9 +238,9 @@ def _main(args):
238238
# anchors = [[116, 90, 156, 198, 373, 326], [30, 61, 62, 45, 59, 119], [10, 13, 16, 30, 33, 23]]
239239

240240
# make the yolov3 model to predict 80 classes on COCO
241-
yolov3 = YOLOv3((None, None, 3), num_classes)
241+
# yolov3 = YOLOv3((None, None, 3), num_classes)
242242
# yolov3 = make_yolov3_model((None, None, 3))
243-
# yolov3 = yolo_body((None, None, 3), anchors_mask, num_classes)
243+
yolov3 = yolo_body((None, None, 3), anchors_mask, num_classes)
244244

245245
# run model summary
246246
# yolov3.summary()

predict2.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def __init__(self, args):
5656
# If the shape does not match, pay attention to the modification of the model_path
5757
# and classes_path parameters during training
5858
# =====================================================================
59-
self.weight_path = args.weight_path if args.weight_path is not None else 'data/yolov3_weights.h5'
59+
self.weight_path = args.weight_path if args.weight_path is not None else 'data/yolov3_coco.h5'
6060
self.classes_path = args.classes_path if args.classes_path is not None else 'data/coco_classes.txt'
6161

6262
# =====================================================================
@@ -448,6 +448,7 @@ def _main(args):
448448
if __name__ == '__main__':
449449
# run following command (as per current folder structure) on terminal
450450
# python predict2.py [-i] <image_path>
451-
# python predict2.py -w data/yolov3_weights_license.h5 -c data/license_classes.txt -i data/florida_license.jpg
451+
# python predict2.py -w data/yolov3_license.h5 -c data/license_classes.txt -i data/florida_license.jpg
452+
# python predict2.py -w data/yolov3_fruits.h5 -c data/fruits/train/_classes.txt -i data/apple.jpg
452453
_main(parser.parse_args())
453454

0 commit comments

Comments
 (0)