ultralytics / ultralytics

NEW - YOLOv8 🚀 in PyTorch > ONNX > OpenVINO > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
23.75k stars 4.74k forks source link

Training with uint16 #11675

Open christianayala10 opened 1 week ago

christianayala10 commented 1 week ago

Search before asking

Question

I am training YOLOv8 with satellite images, which are usually in the uint16 data format and comprise several bands. However, YOLO only supports training with images of 3 channels in the uint8 format. This limitation hinders our model from fully utilizing the information contained in these images.

I have successfully modified the source code to allow input of images with an arbitrary number of channels. However, I am struggling to switch from uint8 to uint16. I have looked into previous issues, and while some ask about training with other data types, none of them provide a solution.

I have managed to modify the source code to read uint16 TIFF files. However, I have encountered an issue where the ultralytics library clips my data to the range [0, 255]. Can anyone provide guidance on which specific files I should modify to address this?

Additional

No response

github-actions[bot] commented 1 week ago

👋 Hello @christianayala10, 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):

Status

Ultralytics CI

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.

glenn-jocher commented 1 week ago

Hi there! 🚀 It's great to hear about your efforts to adapt YOLOv8 for satellite imagery with more channels and uint16 data types.

Regarding the issue with the data being clipped to [0, 255], you would likely need to adjust the normalization and possibly the image loading functions within the YOLOv8 codebase. Specifically, check the part of your modified code where images are loaded into the model. Make sure the datatype is preserved and not forcefully scaled or converted to uint8.

A common place to look would be in the image pre-processing step, especially where you handle or adjust incoming image arrays before they enter the model's network layers. You might also need to check how tensors are formed from image data and see if there's an explicit conversion to uint8 that mandates the [0, 255] range.

Keep an eye on ensuring your modifications align with how the network expects data, not just in format but in range and scaling too. If you still face issues, consider sharing a bit of the code snippet you have modified for a more detailed look!

Hope this helps, and looking forward to seeing your success with it!