drone resolutions for input yolov5
Search before asking
- [x] I have searched the YOLOv5 issues and discussions and found no similar questions.
Question
halo
I am using a drone and trying to detect rice fields using yolov5. after successfully detecting the segmentation, I used the Ground Sampling Distance method to calculate the area of the rice field segmentation based on the number of pixels. my problem now is that the drone image input is about 20MP, but I have tried yolov5 and resized it automatically to 3008 x 2272 pixels. is there any suggestion for yolo to maintain the number of 20 mp pixels?
please ask for the answer from the professionals, thank you good health always
Additional
No response
👋 Hello @pepsodent72, 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 or implementation ❓ Question, such as your scenario involving drone imagery and high-resolution input, please provide as much detail as possible, including:
- Example drone images or data (if shareable)
- Any specific YOLOv5 configuration or preprocessing steps you are using
- Logs or output details during your tests
- How resizing is being handled or any relevant code snippets
Additionally, it is worth noting that YOLOv5 automatically resizes inputs to the model's default training resolution. To work with high-resolution images (like 20MP), you may need to experiment with custom input sizes by modifying the --img parameter during training or inference. This could have implications on memory usage and performance, so adjustments may be necessary.
Requirements
Python>=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
Environments
YOLOv5 can be run in various environments, including:
- 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 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.
This is an automated response to help guide you. An Ultralytics engineer will assist you further as soon as possible. Let us know if you have additional details to share in the meantime! 😊
@pepsodent72 for drone imagery at native 20MP resolution, we recommend:
- Tile Inference: Split large images into smaller tiles (e.g., 640x640) using sliding window detection. This maintains original resolution while accommodating YOLOv5's default input size. Example:
model = torch.hub.load('ultralytics/yolov5', 'yolov5s')
results = model('large_image.jpg', tile=512) # tile size 512
- Adjust Input Size: Train with higher resolution using
--imgargument (requires retraining):
python train.py --img 1280 # maximum size depends on GPU memory
- Verify GSD Calibration: Ensure your Ground Sampling Distance calculations account for drone altitude and sensor specs, as demonstrated in our AI in agriculture solutions.
For commercial deployments requiring high-res processing, consider an Ultralytics Enterprise License for optimized large-scale implementations.
@pepsodent72 for drone imagery at native 20MP resolution, we recommend:
- Tile Inference: Split large images into smaller tiles (e.g., 640x640) using sliding window detection. This maintains original resolution while accommodating YOLOv5's default input size. Example:
model = torch.hub.load('ultralytics/yolov5', 'yolov5s') results = model('large_image.jpg', tile=512) # tile size 512 2. Adjust Input Size: Train with higher resolution using
--imgargument (requires retraining):python train.py --img 1280 # maximum size depends on GPU memory 3. Verify GSD Calibration: Ensure your Ground Sampling Distance calculations account for drone altitude and sensor specs, as demonstrated in our AI in agriculture solutions.
For commercial deployments requiring high-res processing, consider an Ultralytics Enterprise License for optimized large-scale implementations.
are methods sliding window and SAHI is different?
👋 Hello @pepsodent72, 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 or implementation ❓ Question, such as your scenario involving drone imagery and high-resolution input, please provide as much detail as possible, including:
- Example drone images or data (if shareable)
- Any specific YOLOv5 configuration or preprocessing steps you are using
- Logs or output details during your tests
- How resizing is being handled or any relevant code snippets
Additionally, it is worth noting that YOLOv5 automatically resizes inputs to the model's default training resolution. To work with high-resolution images (like 20MP), you may need to experiment with custom input sizes by modifying the
--imgparameter during training or inference. This could have implications on memory usage and performance, so adjustments may be necessary.Requirements
Python>=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
Environments
YOLOv5 can be run in various environments, including:
- 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 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.
This is an automated response to help guide you. An Ultralytics engineer will assist you further as soon as possible. Let us know if you have additional details to share in the meantime! 😊
for implementation
👋 Hi @pepsodent72, great question! While both methods address high-resolution inference, YOLOv5's native sliding window (tile parameter) and SAHI differ in implementation:
- YOLOv5 Sliding Window: Built-in tile processing with automatic stitching (
model(..., tile=512)). Simple integration but no overlapping slices. - SAHI: Third-party library with advanced features like overlapping slices and adjustable overlap ratios to reduce edge-effect errors.
Example SAHI+YOLOv5 integration:
from sahi import AutoDetectionModel
from sahi.predict import get_sliced_prediction
detection_model = AutoDetectionModel.from_pretrained(model_type='yolov5', model_path='yolov5s.pt')
results = get_sliced_prediction(..., detection_model=detection_model, slice_height=640, slice_width=640)
For agricultural use cases like your rice field analysis, SAHI's overlap feature often improves edge detection for dense fields. We've seen similar techniques applied successfully in our AI in agriculture solutions. 😊
Can SAHI be integrated into the yolov5 segmentation model?
Yes, SAHI can be integrated with YOLOv5 segmentation models. While YOLOv5 has native tiling support via the tile parameter, SAHI offers enhanced capabilities for segmentation tasks with adjustable overlap ratios to improve edge detection. Here's a minimal integration example:
from sahi import AutoDetectionModel
from sahi.predict import get_sliced_prediction
# Load YOLOv5-seg model
detection_model = AutoDetectionModel.from_pretrained(
model_type='yolov5',
model_path='yolov5s-seg.pt', # segmentation model
confidence_threshold=0.3
)
results = get_sliced_prediction(
'drone_image.jpg',
detection_model=detection_model,
slice_height=640,
slice_width=640,
overlap_height_ratio=0.2 # 20% vertical overlap
)
For agricultural use cases like rice field segmentation, SAHI's overlap feature can help maintain field boundary continuity. The Ultralytics team has seen similar techniques applied successfully in our AI agriculture solutions.
for yolov5 with the aim of detecting rice field objects that are not small, sometimes they can be large. is it more suitable to use SAHI or sliding window?
For rice field detection with varying object sizes in YOLOv5, SAHI is generally preferred over native sliding window for large objects due to its adjustable overlap ratios (20-30% recommended), which help maintain object continuity across tiles. Example SAHI integration:
from sahi import AutoDetectionModel
from sahi.predict import get_sliced_prediction
results = get_sliced_prediction(..., overlap_height_ratio=0.2)
For field-scale applications, our AI in agriculture solutions demonstrate optimal practices. 😊
👋 Hello there! We wanted to give you a friendly reminder that this issue has not had any recent activity and may be closed soon, but don't worry - you can always reopen it if needed. If you still have any questions or concerns, please feel free to let us know how we can help.
For additional resources and information, please see the links below:
- Docs: https://docs.ultralytics.com
- HUB: https://hub.ultralytics.com
- Community: https://community.ultralytics.com
Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed!
Thank you for your contributions to YOLO 🚀 and Vision AI ⭐