Skip to content

Commit 81f81d3

Browse files
imyhxyglenn-jocher
andauthored
Fixed randrange warnings in Python>=3.10 (ultralytics#11161)
Co-authored-by: Glenn Jocher <[email protected]>
1 parent 6dd1751 commit 81f81d3

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

segment/train.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ def train(hyp, opt, device, callbacks): # hyp is path/to/hyp.yaml or hyp dictio
299299

300300
# Multi-scale
301301
if opt.multi_scale:
302-
sz = random.randrange(imgsz * 0.5, imgsz * 1.5 + gs) // gs * gs # size
302+
sz = random.randrange(int(imgsz * 0.5), int(imgsz * 1.5) + gs) // gs * gs # size
303303
sf = sz / max(imgs.shape[2:]) # scale factor
304304
if sf != 1:
305305
ns = [math.ceil(x * sf / gs) * gs for x in imgs.shape[2:]] # new shape (stretched to gs-multiple)

train.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ def train(hyp, opt, device, callbacks): # hyp is path/to/hyp.yaml or hyp dictio
299299

300300
# Multi-scale
301301
if opt.multi_scale:
302-
sz = random.randrange(imgsz * 0.5, imgsz * 1.5 + gs) // gs * gs # size
302+
sz = random.randrange(int(imgsz * 0.5), int(imgsz * 1.5) + gs) // gs * gs # size
303303
sf = sz / max(imgs.shape[2:]) # scale factor
304304
if sf != 1:
305305
ns = [math.ceil(x * sf / gs) * gs for x in imgs.shape[2:]] # new shape (stretched to gs-multiple)

0 commit comments

Comments
 (0)