Comments (6)
π Hello @Rbrq03, thank you for your interest in Ultralytics YOLOv8 π! We recommend a visit to the Docs for new users where you can find many Python and CLI usage examples and where many of the most common questions may already be answered.
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.
Join the vibrant Ultralytics Discord π§ community for real-time conversations and collaborations. This platform offers a perfect space to inquire, showcase your work, and connect with fellow Ultralytics users.
Install
Pip install the ultralytics
package including all requirements in a Python>=3.8 environment with PyTorch>=1.8.
pip install ultralytics
Environments
YOLOv8 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):
- Notebooks with free GPU:
- Google Cloud Deep Learning VM. See GCP Quickstart Guide
- Amazon Deep Learning AMI. See AWS Quickstart Guide
- Docker Image. See Docker Quickstart Guide
Status
If this badge is green, all Ultralytics CI tests are currently passing. CI tests verify correct operation of all YOLOv8 Modes and Tasks on macOS, Windows, and Ubuntu every 24 hours and on every commit.
from ultralytics.
Additional log are shown below:
engine/trainer: task=detect, mode=train, model=yolov10n.yaml, data=coco.yaml, epochs=100, time=None, patience=100,
batch=256, imgsz=512, save=True, save_period=-1, val_period=1, cache=False, device=[0, 1, 2, 3, 4, 5, 6, 7], workers=8,
project=None, name=train35, exist_ok=False, pretrained=True, optimizer=SGD, verbose=True, seed=0, deterministic=False,
single_cls=False, rect=False, cos_lr=False, close_mosaic=10, resume=False, amp=True, fraction=1.0, profile=False,
freeze=None, multi_scale=False, overlap_mask=True, mask_ratio=4, dropout=0.0, val=True, split=val, save_json=False,
save_hybrid=False, conf=None, iou=0.7, max_det=300, half=False, dnn=False, plots=True, source=None, vid_stride=1,
stream_buffer=False, visualize=False, augment=False, agnostic_nms=False, classes=None, retina_masks=False,
embed=None, show=False, save_frames=False, save_txt=False, save_conf=False, save_crop=False, show_labels=True,
show_conf=True, show_boxes=True, line_width=None, format=torchscript, keras=False, optimize=False, int8=False,
dynamic=False, simplify=False, opset=None, workspace=4, nms=False, lr0=0.01, lrf=0.0001, momentum=0.937,
weight_decay=0.0005, warmup_epochs=3.0, warmup_momentum=0.8, warmup_bias_lr=0.1, box=7.5, cls=0.5, dfl=1.5,
pose=12.0, kobj=1.0, label_smoothing=0.0, nbs=64, hsv_h=0.015, hsv_s=0.7, hsv_v=0.4, degrees=0.0, translate=0.1,
scale=0.5, shear=0.0, perspective=0.0, flipud=0.0, fliplr=0.5, bgr=0.0, mosaic=1.0, mixup=0.0, copy_paste=0.0,
auto_augment=randaugment, erasing=0.4, crop_fraction=1.0, cfg=None, tracker=botsort.yaml,
Freezing layer 'model.23.dfl.conv.weight'
AMP: running Automatic Mixed Precision (AMP) checks with YOLOv8n...
AMP: checks passed β
train: Scanning /opt/data/private/hjn/fna-detection/datasets/coco/labels/train2017.cache... 117266 images, 1021 backgrounds, 0 corrupt: 100%|ββββββββββ| 118287/118287 [00:00<?, ?it/s]
val: Scanning /opt/data/private/hjn/fna-detection/datasets/coco/labels/val2017.cache... 4952 images, 48 backgrounds, 0 corrupt: 100%|ββββββββββ| 5000/5000 [00:00<?, ?it/s]
Plotting labels to /opt/data/private/hjn/fna-detection/yolov10/runs/detect/train35/labels.jpg...
optimizer: SGD(lr=0.01, momentum=0.937) with parameter groups 95 weight(decay=0.0), 108 weight(decay=0.002), 107 bias(decay=0.0)
Image sizes 512 train, 512 val
Using 64 dataloader workers
Logging results to /opt/data/private/hjn/fna-detection/yolov10/runs/detect/train35
Starting training for 100 epochs...
Epoch GPU_mem box_om cls_om dfl_om box_oo cls_oo dfl_oo Instances Size
1/100 5.42G 3.562 5.044 3.487 3.284 6.018 3.206 30 512: 100%|ββββββββββ| 463/463 [01:27<00:00, 5.29it/s]
Class Images Instances Box(P R mAP50 mAP50-95): 0%| | 0/79 [00:00<?, ?it/s]torch.Size([64, 3, 288, 544])
from ultralytics.
@Rbrq03 hello!
Thank you for reaching out with your question regarding the imgsz
argument in validation.
The imgsz
argument is used to specify the target image size for both training and validation. When you set imgsz=512
, it indicates that the images should be resized to 512x512 pixels. However, in practice, the actual image dimensions may vary slightly due to the aspect ratio preservation and padding applied during preprocessing.
From your provided logs, it seems that the images are being resized to dimensions close to 512x512 but not exactly square, resulting in shapes like torch.Size([64, 3, 288, 544])
. This discrepancy is due to the rect
argument, which is set to False
by default. When rect
is False
, the images are resized while preserving their aspect ratios, and padding is added to match the target size.
To ensure that the images are resized to exactly 512x512
, you can set the rect
argument to True
. This will enforce rectangular training and validation, resizing the images to the specified dimensions without preserving the aspect ratio.
Hereβs how you can modify your training script to achieve this:
from ultralytics import YOLOv10
import torch
model = YOLOv10("yolov10n.yaml")
model.train(
data="coco.yaml",
epochs=100,
batch=256,
imgsz=512,
optimizer="SGD",
lr0=0.01,
lrf=0.0001,
plots=True,
fna=True,
device=[0, 1, 2, 3, 4, 5, 6, 7],
rect=True # Add this line to enforce rectangular resizing
)
By setting rect=True
, the images will be resized to exactly 512x512
during validation, ensuring consistent dimensions.
If you have any further questions or need additional assistance, feel free to ask. Happy training! π
from ultralytics.
Thanks @glenn-jocher! What I further concern is, the shape I print is excepted to be 512x512
as it will be feed into the model forward directly. So it should be the shape which is after padding? What cause this problem and how should i do?
from ultralytics.
Hello @Rbrq03,
Thank you for your follow-up question!
To ensure that your images are resized to exactly 512x512
before being fed into the model, you should set the rect
argument to True
in your training script. This will enforce rectangular resizing, ensuring that the images are resized to the specified dimensions without preserving the aspect ratio.
Hereβs how you can modify your training script:
from ultralytics import YOLOv10
import torch
model = YOLOv10("yolov10n.yaml")
model.train(
data="coco.yaml",
epochs=100,
batch=256,
imgsz=512,
optimizer="SGD",
lr0=0.01,
lrf=0.0001,
plots=True,
fna=True,
device=[0, 1, 2, 3, 4, 5, 6, 7],
rect=True # Add this line to enforce rectangular resizing
)
By setting rect=True
, the images will be resized to exactly 512x512
during validation, ensuring consistent dimensions that match your expectation.
If you continue to experience issues, please ensure you are using the latest versions of torch
and ultralytics
. If the problem persists, providing a minimum reproducible code example would be very helpful for us to investigate further. You can find more details on how to create one here: https://docs.ultralytics.com/help/minimum_reproducible_example.
Feel free to reach out if you have any more questions! π
from ultralytics.
Thanks @plashchynski ! it solves my problem.
from ultralytics.
Related Issues (20)
- Whether to support anchor-base HOT 3
- How can i plot the loss and mAP diagram after training yolov8 ? HOT 2
- YOLOv10 NCNN export HOT 2
- segmentation HOT 1
- unexpected freezed layer HOT 4
- KeyError When Customization to YOLOv8 Model: HOT 9
- YOLOv10 export: Setting simplify=True raise exception HOT 7
- TensorFlow & tflite Export Not Working HOT 6
- Different result between v8.1.2 and v8.2 on same dataset HOT 4
- RT-DETR load other pretrained weights HOT 2
- broken hub link HOT 1
- GFLOPs value not showing in summary HOT 6
- How to Optimize YOLOv8 Preprocessing and Postprocessing Time? HOT 3
- On the issue of adding a CBAM attention mechanism HOT 1
- On the issue of adding a CBAM attention mechanism HOT 1
- YOLOv8 Inference Time Increases from Stable 1ms to 15ms over Continuous Runs HOT 1
- Filter small objects when validating HOT 2
- Integration of SCINet with YOLOv8 for Low-Light Object Detection HOT 5
- YOLOV8 and ONNX Support HOT 1
- custom dataset trained model not able to be open in yolov8 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ultralytics.