hyp['anchors'] evolution update
This commit is contained in:
1 parent
ffe9eb4238
commit
44cdcc7e0b
2 files changed
+7
-6
No files matched your search
@@ -68,8 +68,8 @@ def train(hyp, opt, device, tb_writer=None):
|
|||||||
with torch_distributed_zero_first(rank):
|
with torch_distributed_zero_first(rank):
|
||||||
attempt_download(weights) # download if not found locally
|
attempt_download(weights) # download if not found locally
|
||||||
ckpt = torch.load(weights, map_location=device) # load checkpoint
|
ckpt = torch.load(weights, map_location=device) # load checkpoint
|
||||||
# if hyp['anchors']:
|
if 'anchors' in hyp and hyp['anchors']:
|
||||||
# ckpt['model'].yaml['anchors'] = round(hyp['anchors']) # force autoanchor
|
ckpt['model'].yaml['anchors'] = round(hyp['anchors']) # force autoanchor
|
||||||
model = Model(opt.cfg or ckpt['model'].yaml, ch=3, nc=nc).to(device) # create
|
model = Model(opt.cfg or ckpt['model'].yaml, ch=3, nc=nc).to(device) # create
|
||||||
exclude = ['anchor'] if opt.cfg else [] # exclude keys
|
exclude = ['anchor'] if opt.cfg else [] # exclude keys
|
||||||
state_dict = ckpt['model'].float().state_dict() # to FP32
|
state_dict = ckpt['model'].float().state_dict() # to FP32
|
||||||
@@ -472,7 +472,7 @@ if __name__ == '__main__':
|
|||||||
'obj_pw': (1, 0.5, 2.0), # obj BCELoss positive_weight
|
'obj_pw': (1, 0.5, 2.0), # obj BCELoss positive_weight
|
||||||
'iou_t': (0, 0.1, 0.7), # IoU training threshold
|
'iou_t': (0, 0.1, 0.7), # IoU training threshold
|
||||||
'anchor_t': (1, 2.0, 8.0), # anchor-multiple threshold
|
'anchor_t': (1, 2.0, 8.0), # anchor-multiple threshold
|
||||||
# 'anchors': (1, 2.0, 10.0), # anchors per output grid (0 to ignore)
|
'anchors': (1, 2.0, 10.0), # anchors per output grid (0 to ignore)
|
||||||
'fl_gamma': (0, 0.0, 2.0), # focal loss gamma (efficientDet default gamma=1.5)
|
'fl_gamma': (0, 0.0, 2.0), # focal loss gamma (efficientDet default gamma=1.5)
|
||||||
'hsv_h': (1, 0.0, 0.1), # image HSV-Hue augmentation (fraction)
|
'hsv_h': (1, 0.0, 0.1), # image HSV-Hue augmentation (fraction)
|
||||||
'hsv_s': (1, 0.0, 0.9), # image HSV-Saturation augmentation (fraction)
|
'hsv_s': (1, 0.0, 0.9), # image HSV-Saturation augmentation (fraction)
|
||||||
@@ -493,7 +493,7 @@ if __name__ == '__main__':
|
|||||||
if opt.bucket:
|
if opt.bucket:
|
||||||
os.system('gsutil cp gs://%s/evolve.txt .' % opt.bucket) # download evolve.txt if exists
|
os.system('gsutil cp gs://%s/evolve.txt .' % opt.bucket) # download evolve.txt if exists
|
||||||
|
|
||||||
for _ in range(100): # generations to evolve
|
for _ in range(1): # generations to evolve
|
||||||
if os.path.exists('evolve.txt'): # if evolve.txt exists: select best hyps and mutate
|
if os.path.exists('evolve.txt'): # if evolve.txt exists: select best hyps and mutate
|
||||||
# Select parent(s)
|
# Select parent(s)
|
||||||
parent = 'single' # parent selection method: 'single' or 'weighted'
|
parent = 'single' # parent selection method: 'single' or 'weighted'
|
||||||
|
|||||||
+3
-2
@@ -4,11 +4,12 @@
|
|||||||
|
|
||||||
# Start on 4-GPU machine
|
# Start on 4-GPU machine
|
||||||
#for i in 0 1 2 3; do
|
#for i in 0 1 2 3; do
|
||||||
# t=ultralytics/yolov5:test && sudo docker pull $t && sudo docker run -d --ipc=host --gpus all -v "$(pwd)"/VOC:/usr/src/VOC $t bash utils/evolve.sh $i
|
# t=ultralytics/yolov5:evolve && sudo docker pull $t && sudo docker run -d --ipc=host --gpus all -v "$(pwd)"/VOC:/usr/src/VOC $t bash utils/evolve.sh $i
|
||||||
# sleep 60 # avoid simultaneous evolve.txt read/write
|
# sleep 60 # avoid simultaneous evolve.txt read/write
|
||||||
#done
|
#done
|
||||||
|
|
||||||
# Hyperparameter evolution commands
|
# Hyperparameter evolution commands
|
||||||
while true; do
|
while true; do
|
||||||
python train.py --batch 64 --weights yolov5m.pt --data voc.yaml --img 512 --epochs 50 --evolve --bucket ult/voc --device $1
|
# python train.py --batch 64 --weights yolov5m.pt --data voc.yaml --img 512 --epochs 50 --evolve --bucket ult/evolve/voc --device $1
|
||||||
|
python train.py --batch 40 --weights yolov5m.pt --data coco.yaml --img 640 --epochs 30 --evolve --bucket ult/evolve/coco --device $1
|
||||||
done
|
done
|
||||||
Reference in new issue
Block a user