Comments (4)
π Hello @agNihit928, 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.
@agNihit928 hi there,
Thank you for your detailed report and for checking existing issues before posting. Itβs great to see your thorough investigation into the matter.
The warning you encountered is indeed expected behavior. Currently, YOLOv8's training process assumes square dimensions for images (imgsz
as an integer) due to the way various augmentations and transformations are implemented. This is why you see the warning and why the evaluation metrics remain consistent regardless of the rectangular dimensions you attempted to set.
To address your specific points:
-
Training with Rectangular Images: As you correctly identified, the current implementation does not support non-square dimensions directly in the training pipeline. The
imgsz
parameter is expected to be an integer, representing square dimensions. This is a design choice to ensure compatibility and stability across various augmentation and preprocessing steps. -
Documentation Clarification: The documentation might indeed seem misleading regarding the flexibility of
imgsz
. Whilepredict
andexport
modes support rectangular dimensions,train
andval
modes do not. We appreciate your feedback and will work on clarifying this in our documentation to prevent future confusion. -
Possible Workaround: If you need to work with rectangular images, you might consider resizing your images to the nearest square dimension (e.g., padding or cropping) before feeding them into the training pipeline. This ensures compatibility with the current implementation while allowing you to work with your desired aspect ratio.
Hereβs a small snippet to help you resize your images to square dimensions using padding:
import cv2
import numpy as np
def resize_to_square(image, size=640):
h, w = image.shape[:2]
scale = size / max(h, w)
new_h, new_w = int(h * scale), int(w * scale)
resized_image = cv2.resize(image, (new_w, new_h))
delta_w = size - new_w
delta_h = size - new_h
top, bottom = delta_h // 2, delta_h - (delta_h // 2)
left, right = delta_w // 2, delta_w - (delta_w // 2)
color = [0, 0, 0]
new_image = cv2.copyMakeBorder(resized_image, top, bottom, left, right, cv2.BORDER_CONSTANT, value=color)
return new_image
# Example usage
image = cv2.imread('path/to/your/image.jpg')
square_image = resize_to_square(image, size=640)
cv2.imwrite('path/to/save/square_image.jpg', square_image)
This approach ensures that your images maintain their aspect ratio while fitting into the required square dimensions.
If you have any further questions or need additional assistance, feel free to ask. Weβre here to help!
from ultralytics.
Thanks a lot for the confirmation @glenn-jocher .
Also, thank you the reference code, this is gonna make my work easier in the preprocessing step.
from ultralytics.
@agNihit928 you're welcome! π I'm glad the reference code will help streamline your preprocessing step.
If you encounter any further issues or have additional questions, feel free to reach out. We're here to assist!
Happy coding! π
from ultralytics.
Related Issues (20)
- YOLOv9 HOT 1
- training parameters HOT 2
- How to use YOLOv8 model trained on my custom dataset? HOT 4
- Validity of Results When Using Different YOLO Model Versions (YOLOv8 and YOLOv10) with YOLOv5-Formatted Dataset HOT 2
- How to package the train of yolov8 to an exe? HOT 1
- yolov10-nmsfree out of memory HOT 2
- During inference, conf too low produces nan in boxes HOT 2
- How to package the train of yolov8 to an exe? HOT 1
- YoloV8-OBB Onnx-Simplifier Error HOT 8
- Getting Accuracy from validation results for CLASSIFICATION HOT 1
- YOLOv8 - Unexpected Behavior When Training with Custom Dataset HOT 4
- A question about Face antispoofing with Yolo HOT 2
- how to use yolov8 metric HOT 1
- OpenVINO model is dynamic even it was converted with dynamic=False HOT 2
- NOT WORK for "label_smoothing" parameter HOT 2
- Is there possibility to train YOLO model over multiple datasets? HOT 3
- Is there possibility to integrate custom augmentations into training pipeline? HOT 1
- Generate Confusion matrix from a list of ground truth labels and predicted labels in yolo format HOT 2
- YOLO dissection HOT 4
- WHY AM I FACING THIS ISSUE? 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.