Training on rectangular pictures

I need to train on rectangular pictures w=480, h=128

!python --imgsz [480,128] --batch 16 --epochs 300
--data …detect_480x120/data.yaml
--cfg ./models/yolov5x.yaml
--name v5x_res

I get the error: error: argument --imgsz/–img/–img-size: invalid int value: ‘[480,128]’

Hey @ai1archivizer

It looks like you are using the YOLOv5 model. According to this issue from the YOLOv5 GitHub, the following should do what you are looking for:

python --img 512 --rect

See this issue: Train on Non-Square Images · Issue #4116 · ultralytics/yolov5 · GitHub

1 Like

Hey leo
Thank you for your attention.
There’s no solution

Although it should take the size as a list → utils/

def check_img_size(imgsz, s=32, floor=0):
    # Verify image size is a multiple of stride s in each dimension
    if isinstance(imgsz, int):  # integer i.e. img_size=640
        new_size = max(make_divisible(imgsz, int(s)), floor)
    else:  # list i.e. img_size=[640, 480]
        imgsz = list(imgsz)  # convert to list if tuple
        new_size = [max(make_divisible(x, int(s)), floor) for x in imgsz]
    if new_size != imgsz:
        LOGGER.warning(f'WARNING ⚠️ --img-size {imgsz} must be multiple of max stride {s}, updating to {new_size}')
    return new_size

Hi @ai1archivizer

The solution I highlighted is from the YOLOv5 GitHub repo and we (Roboflow) don’t maintain that. For any issues that relate directly to YOLOv5, I suggest following up in that issue or creating a new issue there. Of course, for any Roboflow related issues or questions, please let us know here.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.