Skip to content
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

How to train 16bit grayscale images? #8481

Closed
1 task done
pourmand1376 opened this issue Jul 5, 2022 · 6 comments
Closed
1 task done

How to train 16bit grayscale images? #8481

pourmand1376 opened this issue Jul 5, 2022 · 6 comments
Labels
question Further information is requested

Comments

@pourmand1376
Copy link
Contributor

Search before asking

Question

Issues I've read:

I have 16-bit grayscale images. Until now, I've converted all images to grayscale png with 16-bit depth. YOLOv5 works but it doesn't give good results. One of my assumptions is that since a lot of information is lost, training results is not good. The images were original dcm format and I converted them to png to be able to read it.

I read source code and I understood that YOLO convert png image to 8bit. To be specific, whenever I see cv2.imread it is like this:

cv2.imread(path_to_file)
# it should be like this to read 16bit depth (as is)
cv2.imread(path_to_file, -1)

I changed every imread function and also changed every scaling from 255 to 65535, but I am not able to get any results. I get some weird error which I can not trace back.

libpng error: PNG input buffer is incomplete

There is also a stackoverflow post about this but it doesn't help.

I try to get my image to work with YOLOv5, but it appears hopeless. Could you please give me a starting point?

Additional

No response

@pourmand1376 pourmand1376 added the question Further information is requested label Jul 5, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Jul 5, 2022

👋 Hello @pourmand1376, 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 screenshots and minimum viable code to reproduce your issue, otherwise we can not help you.

If this is a custom training ❓ Question, please provide as much information as possible, including dataset images, training logs, screenshots, and a public link to online W&B logging if available.

For business inquiries or professional support requests please visit https://ultralytics.com or email support@ultralytics.com.

Requirements

Python>=3.7.0 with all requirements.txt installed including PyTorch>=1.7. To get started:

git clone https://github.com/ultralytics/yolov5  # clone
cd yolov5
pip install -r requirements.txt  # install

Environments

YOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):

Status

CI CPU testing

If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training (train.py), validation (val.py), inference (detect.py) and export (export.py) on macOS, Windows, and Ubuntu every 24 hours and on every commit.

@glenn-jocher
Copy link
Member

@pourmand1376 I don't think you want to try using 16 bit imagery. uint8 is the standard across all ML, and the 255 value is hard coded in multiple places throughout the repository, as well as the assumption built into many functions, not to mention your model will be unable to deploy using any standard workflows.

If you have greyscale imagery I would simply convert these to normal greyscale PNGs like you did and let YOLO train on them directly without any modifications. You might disable HSV augmentation or visit the Tips for Best Training Tutorial for training best practices.

@pourmand1376
Copy link
Contributor Author

pourmand1376 commented Jul 6, 2022

Thank you.

As each patient in my case has 200 images and they are totally related, do you recommend creating a 16 channel image (each image is gray-scale) which consists 16 random samples from the same patient and make model learn that thing? (Something like #1741)

Currently it seems that I am not using all information which a patient has, I am just using a 1% of information.

@glenn-jocher
Copy link
Member

@pourmand1376 oh I see. Well if you have 200 channels you could just submit all 200.

But you are confusing topics. 8 bits or 16 bits is just the color depth of a channel. 3ch vs 1ch is about RGB vs greyscale. You can have RGB images at 8, 16, 32, 64 bits and they still only have 3 channels.

@pourmand1376
Copy link
Contributor Author

Well.Thanks for explanation.

I should have created another issue for this one. Mixing issues is not a good idea.

My question is resolved so I think it is best to close this issue.

Thank you again🙏

@glenn-jocher
Copy link
Member

@pourmand1376 you're welcome! 🙏 I'm glad I could help clarify things for you. If you have any more questions in the future, please feel free to open a new issue. Have a great day!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants