New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to change training input image size? #12966
Comments
👋 Hello @EXGHLI, thank you for your interest in YOLOv5 🚀! Please visit our ⭐️ Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution. If this is a 🐛 Bug Report, please provide a minimum reproducible example to help us debug it. If this is a custom training ❓ Question, please provide as much information as possible, including dataset image examples and training logs, and verify you are following our Tips for Best Training Results. RequirementsPython>=3.8.0 with all requirements.txt installed including PyTorch>=1.8. To get started: git clone https://github.com/ultralytics/yolov5 # clone
cd yolov5
pip install -r requirements.txt # install EnvironmentsYOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):
StatusIf this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training, validation, inference, export and benchmarks on macOS, Windows, and Ubuntu every 24 hours and on every commit. Introducing YOLOv8 🚀We're excited to announce the launch of our latest state-of-the-art (SOTA) object detection model for 2023 - YOLOv8 🚀! Designed to be fast, accurate, and easy to use, YOLOv8 is an ideal choice for a wide range of object detection, image segmentation and image classification tasks. With YOLOv8, you'll be able to quickly and accurately detect objects in real-time, streamline your workflows, and achieve new levels of accuracy in your projects. Check out our YOLOv8 Docs for details and get started with: pip install ultralytics |
Hello! It looks like you’re trying to adjust the input image size for training in YOLOv5 🚀. The way to do this is through the command line rather than modifying To specify a custom image size, you can use the python train.py --imgsz '1248 384' --rect This tells YOLOv5 to use an input resolution of 1248x384 pixels for both training and validation. The Remember, adjusting the input size can affect the model's performance and computational requirements, so it's good to experiment to find the best size for your particular application. Happy training! 🌟 |
Thank you for your reply. |
你好!如果您想通過代码而非命令行参数调整图像尺寸,您需要留意的是 然而,您可以通过命令行传递单一尺寸的方法适应该需求,将图像调整到一个尺寸,然后使用 python train.py --imgsz 640 --rect 如果您坚持要通过代码更改(不推荐这样做,因为命令行更灵活),您需要在数据加载时自己处理图像尺寸的调整,这意味着您可能需要深入 祝您训练愉快!如果有其他问题,欢迎继续提问。 |
Sorry, I'm still confused. python train.py --imgsz 1248 --rect |
你好!对不起让你感到困惑了。我来澄清一下。 当你使用 例如,如果原始图像是1248x384,使用 希望这次解释能帮助您更好地理解!🌟 |
Thank you very much for your teaching! |
You're very welcome! I'm glad to have been able to help clarify things for you. If you have any more questions or need further assistance down the line, please don't hesitate to reach out. Happy training with YOLOv5! 🌟 |
Search before asking
Question
How to change the training input image size from the default 640640 to 1248384?
I have tried changing the imgsz parameter default value of 640 in train.py to default=(1248, 384), as shown below
parser.add_argument("--imgsz", "--img", "--img-size", type=int, default=(1248, 384), help="train, val image size (pixels)")
But the following problems occurred
Traceback (most recent call last):
File "D:\PycharmProjects\yolov5_attention\train.py", line 849, in
main(opt)
File "D:\PycharmProjects\yolov5_attention\train.py", line 624, in main
train(opt.hyp, opt, device, callbacks)
File "D:\PycharmProjects\yolov5_attention\train.py", line 254, in train
train_loader, dataset = create_dataloader(
File "D:\PycharmProjects\yolov5_attention\utils\dataloaders.py", line 181, in create_dataloader
dataset = LoadImagesAndLabels(
File "D:\PycharmProjects\yolov5_attention\utils\dataloaders.py", line 561, in init
self.mosaic_border = [-img_size // 2, -img_size // 2]
TypeError: bad operand type for unary -: 'list'
I also tried another method
python train.py --imgsz 1248 384 --rect
But the following problems occurred
usage: train.py [-h] [--weights WEIGHTS] [--cfg CFG] [--data DATA] [--hyp HYP] [--epochs EPOCHS] [--batch-size BATCH_SIZE] [--imgsz IMGSZ] [--rect] [--resume [RESUME]] [--nosave]
[--noval] [--noautoanchor] [--noplots] [--evolve [EVOLVE]] [--evolve_population EVOLVE_POPULATION] [--resume_evolve RESUME_EVOLVE] [--bucket BUCKET]
[--cache [CACHE]] [--image-weights] [--device DEVICE] [--multi-scale] [--single-cls] [--optimizer {SGD,Adam,AdamW}] [--sync-bn] [--workers WORKERS]
[--project PROJECT] [--name NAME] [--exist-ok] [--quad] [--cos-lr] [--label-smoothing LABEL_SMOOTHING] [--patience PATIENCE] [--freeze FREEZE [FREEZE ...]]
[--save-period SAVE_PERIOD] [--seed SEED] [--local_rank LOCAL_RANK] [--entity ENTITY] [--upload_dataset [UPLOAD_DATASET]] [--bbox_interval BBOX_INTERVAL]
[--artifact_alias ARTIFACT_ALIAS] [--ndjson-console] [--ndjson-file]
train.py: error: unrecognized arguments: 384
Additional
No response
The text was updated successfully, but these errors were encountered: