This commit is contained in:
Glenn Jocher 2019-05-30 01:40:35 +02:00
parent cc043f60fb
commit f7a517d72c
2 changed files with 7 additions and 4 deletions

View File

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

View File

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