Skip to content

drone resolutions for input yolov5 #13529

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

Open
1 task done
pepsodent72 opened this issue Mar 10, 2025 · 9 comments
Open
1 task done

drone resolutions for input yolov5 #13529

pepsodent72 opened this issue Mar 10, 2025 · 9 comments
Labels
detect Object Detection issues, PR's question Further information is requested

Comments

@pepsodent72
Copy link

Search before asking

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

@pepsodent72 pepsodent72 added the question Further information is requested label Mar 10, 2025
@UltralyticsAssistant UltralyticsAssistant added the detect Object Detection issues, PR's label Mar 10, 2025
@UltralyticsAssistant
Copy link
Member

👋 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:

Status

YOLOv5 CI

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! 😊

@pderrenger
Copy link
Member

@pepsodent72 for drone imagery at native 20MP resolution, we recommend:

  1. 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
  1. Adjust Input Size: Train with higher resolution using --img argument (requires retraining):
python train.py --img 1280  # maximum size depends on GPU memory
  1. 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
Copy link
Author

@pepsodent72 for drone imagery at native 20MP resolution, we recommend:

  1. 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 --img argument (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?

@pepsodent72
Copy link
Author

👋 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:

Status

YOLOv5 CI

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

@pderrenger
Copy link
Member

👋 Hi @pepsodent72, great question! While both methods address high-resolution inference, YOLOv5's native sliding window (tile parameter) and SAHI differ in implementation:

  1. YOLOv5 Sliding Window: Built-in tile processing with automatic stitching (model(..., tile=512)). Simple integration but no overlapping slices.
  2. 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. 😊

@pepsodent72
Copy link
Author

Can SAHI be integrated into the yolov5 segmentation model?

@pderrenger
Copy link
Member

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.

@pepsodent72
Copy link
Author

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?

@pderrenger
Copy link
Member

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. 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
detect Object Detection issues, PR's question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants