From f7a517d72c5351a905dd08510473fcc9b30d4e08 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Thu, 30 May 2019 01:40:35 +0200 Subject: [PATCH] updates --- models.py | 6 +++--- utils/gcp.sh | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/models.py b/models.py index ee0559be..61f7c79d 100755 --- a/models.py +++ b/models.py @@ -146,7 +146,7 @@ class YOLOLayer(nn.Module): xy = torch.sigmoid(p[..., 0:2]) + grid_xy # x, y wh = torch.exp(p[..., 2:4]) * anchor_wh # width, height p_conf = torch.sigmoid(p[..., 4:5]) # Conf - p_cls = p[..., 5:85] + p_cls = p[..., 5:5 + self.nc] # Broadcasting only supported on first dimension in CoreML. See onnx-coreml/_operators.py # p_cls = F.softmax(p_cls, 2) * p_conf # SSD-like conf p_cls = torch.exp(p_cls).permute((2, 1, 0)) @@ -212,8 +212,8 @@ class Darknet(nn.Module): return output elif ONNX_EXPORT: output = torch.cat(output, 1) # cat 3 layers 85 x (507, 2028, 8112) to 85 x 10647 - print(output.shape) - return output[5:85].t(), output[:4].t() # ONNX scores, boxes + nc = self.module_list[self.yolo_layers[0]][0].nc # number of classes + return output[5:5 + nc].t(), output[:4].t() # ONNX scores, boxes else: io, p = list(zip(*output)) # inference output, training output return torch.cat(io, 1), p diff --git a/utils/gcp.sh b/utils/gcp.sh index 16181a41..bbd2a112 100755 --- a/utils/gcp.sh +++ b/utils/gcp.sh @@ -69,7 +69,10 @@ python3 train.py --data data/coco_1img.data --epochs 5 --nosave # train 5 epoch # AlexyAB Darknet gsutil cp -r gs://sm4/supermarket2 . # dataset from bucket rm -rf darknet && git clone https://github.com/AlexeyAB/darknet && cd darknet && wget -c https://pjreddie.com/media/files/darknet53.conv.74 # sudo apt install libopencv-dev && make -./darknet detector train ../supermarket2/supermarket2.data ../yolov3-spp-sm2-1cls.cfg darknet53.conv.74 -map -dont_show # train spp +./darknet detector calc_anchors data/coco_img64.data -num_of_clusters 9 -width 320 -height 320 # kmeans anchor calculation +./darknet detector train ../supermarket2/supermarket2.data ../yolov3-spp-sm2-1cls-kmeans.cfg darknet53.conv.74 -map -dont_show # train spp +./darknet detector train ../yolov3/data/coco.data ../yolov3-spp.cfg darknet53.conv.74 -map -dont_show # train spp coco + ./darknet detector train ../supermarket2/supermarket2.data ../yolov3-tiny-sm2-1cls.cfg yolov3-tiny.conv.15 -map -dont_show # train tiny ./darknet detector train ../supermarket2/supermarket2.data cfg/yolov3-spp-sm2-1cls.cfg backup/yolov3-spp-sm2-1cls_last.weights # resume python3 train.py --data ../supermarket2/supermarket2.data --cfg cfg/yolov3-spp-sm2-1cls.cfg --epochs 100 --num-workers 8 --img-size 320 --evolve # train ultralytics