ultralytics / yolov5

YOLOv5 🚀 in PyTorch > ONNX > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
51.22k stars 16.44k forks source link

Is there any difference if I use PNG image instead of JPG image? #1747

Closed Frank1126lin closed 3 years ago

Frank1126lin commented 3 years ago

❔Question:

Recently I realized that the different format image has different way of encode. So what if I use PNG format images to train or detect? or using jpg to train and use png to detect? The instructions recommend jpg format, right?

Additional context

https://github.com/ultralytics/yolov5/wiki/Train-Custom-Data

github-actions[bot] commented 3 years ago

Hello @Frank1126lin, 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://www.ultralytics.com or email Glenn Jocher at glenn.jocher@ultralytics.com.

Requirements

Python 3.8 or later with all requirements.txt dependencies installed, including torch>=1.7. To install run:

$ pip install -r requirements.txt

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), testing (test.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu every 24 hours and on every commit.

glenn-jocher commented 3 years ago

@Frank1126lin format is largely irrelevant. Supported image formats are shown in datasets.py https://github.com/ultralytics/yolov5/blob/394d1c89f33f29b2039c54f4a81e561a0b140b3a/utils/datasets.py#L25-L28

For best results compression ratios of train, val and deployed inputs should be similar.

Frank1126lin commented 3 years ago

@glenn-jocher Thanks a lot, I got you.

abuelgasimsaadeldin commented 3 years ago

Hi @glenn-jocher, just wondering so does this apply to any object detector where format is largely irrelevant and almost any image format is acceptable ['bmp', 'jpg', 'jpeg', 'png', 'tif', 'tiff', 'dng']?

I could not find a list like this for the YOLOv4 model, could you confirm if it is the same?

Thanks!

As a matter of fact I saw somewhere it was mentioned "script has support for images with “.jpg” format, so other formats such as “.png” or even “.jpeg” won’t be recognized." so I just want to confirm.

Source: https://medium.com/analytics-vidhya/train-a-custom-yolov4-object-detector-using-google-colab-61a659d4868

And from another source that "The darknet support images: jpeg jpg" so I'm assuming the supported image formats is to do with the Framework used? Is it safe to say that PyTorch in general supports all the above image formats mentioned ['bmp', 'jpg', 'jpeg', 'png', 'tif', 'tiff', 'dng'] while darknet only support jpg and jpeg?

source: https://github.com/pjreddie/darknet/pull/14/files/ba0678ab56c996c482f8fcc09ca6af118ff407ad

glenn-jocher commented 3 years ago

@abuelgasimsaadeldin as I mentioned above supported image formats are shown in datasets.py https://github.com/ultralytics/yolov5/blob/394d1c89f33f29b2039c54f4a81e561a0b140b3a/utils/datasets.py#L25-L28

abuelgasimsaadeldin commented 3 years ago

@glenn-jocher, thanks I was actually wondering if the image formats acceptable were the same for other object detectors as well (specifically Yolov4 on Darknet framework) But I think it will be better to ask the question there. Thanks anyways!

glenn-jocher commented 3 years ago

@abuelgasimsaadeldin I would recommend you raise questions directly on the relevant repositories if you have questions regarding them, as they're outside of the scope of this work.

Niranjan123se commented 1 year ago

I have data set the label in XML. pix size 512*512 How can I use the data set in Yolo v5? What kind of conversion do I have to do?

glenn-jocher commented 1 year ago

@Niranjan123se to use your dataset with YOLOv5, you will need to convert the XML labels to the YOLO format. YOLOv5 requires the label files to be in a specific format, which consists of a text file per image with each object's label and bounding box coordinates.

There are several ways to do this conversion. One option is to use a script or tool that can convert your XML annotations to the YOLO format. You can find such tools available online or within the YOLO community. Another option is to write your own script to parse the XML files and convert them to the YOLO format.

Once you have converted the labels, you can use the YOLOv5 training scripts to train your model with the dataset. Make sure to follow the instructions in the YOLOv5 documentation for training custom data.

If you face any specific issues during the conversion or training process, please feel free to ask for further assistance.

codingxperience commented 1 month ago

Hello Everyone,

I have a question regarding the image formats in my training set. I noticed that it contains both PNG and JPG image formats. Will having mixed formats affect the model's performance or the training process in any way?

I appreciate your assistance. Thank you!

pderrenger commented 1 month ago

Mixing PNG and JPG formats in your training set won't affect the model's performance. Just ensure the image quality and compression are consistent across your dataset.

codingxperience commented 1 month ago

Mixing PNG and JPG formats in your training set won't affect the model's performance. Just ensure the image quality and compression are consistent across your dataset.

Thanks for the clarification!

pderrenger commented 1 month ago

You're welcome! If you have any more questions, feel free to ask.