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

Corrupt JPEG data: 130816 extraneous bytes before marker 0xdb #9178

Closed
1 of 2 tasks
realgump opened this issue Aug 27, 2022 · 4 comments
Closed
1 of 2 tasks

Corrupt JPEG data: 130816 extraneous bytes before marker 0xdb #9178

realgump opened this issue Aug 27, 2022 · 4 comments
Labels
bug Something isn't working Stale Stale and schedule for closing soon

Comments

@realgump
Copy link

Search before asking

  • I have searched the YOLOv5 issues and found no similar bug report.

YOLOv5 Component

No response

Bug

When training, there is some error occurs:
Corrupt JPEG data: 130816 extraneous bytes before marker 0xdb.

Environment

No response

Minimal Reproducible Example

No response

Additional

There has been a commit to fix that in #4548. However, the errors are raised by opencv-python while the auto-fix is writen by pillow. I found my jpg images pass the pillow verification but still cannot be read by opencv-python, the verify code does nothing but increases time consumption and raise lots of unneccessary warnings. Why not use both opencv-python or pillow in the auto-fix period and the training period?

Are you willing to submit a PR?

  • Yes I'd like to help by submitting a PR!
@realgump realgump added the bug Something isn't working label Aug 27, 2022
@glenn-jocher
Copy link
Member

glenn-jocher commented Aug 29, 2022

@realgump hi, thank you for your feature suggestion on how to improve YOLOv5 🚀!

The fastest and easiest way to incorporate your ideas into the official codebase is to submit a Pull Request (PR) implementing your idea, and if applicable providing before and after profiling/inference/training results to help us understand the improvement your feature provides. This allows us to directly see the changes in the code and to understand how they affect workflows and performance.

Please see our ✅ Contributing Guide to get started.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 28, 2022

👋 Hello, this issue has been automatically marked as stale because it has not had recent activity. Please note it will be closed if no further activity occurs.

Access additional YOLOv5 🚀 resources:

Access additional Ultralytics ⚡ resources:

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 YOLOv5 🚀 and Vision AI ⭐!

@github-actions github-actions bot added the Stale Stale and schedule for closing soon label Sep 28, 2022
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 9, 2022
@halqadasi
Copy link

We read each JPEG image in the specified folder using OpenCV and overwrite it by re-saving with a quality setting of 95. This re-encoding process fixes any corruption issues by standardizing the image data format.

for filename in tqdm(image_files, desc="Re-encoding images"):

    image_path = os.path.join(folder_path, filename)
    img = cv2.imread(image_path)

    if img is not None:
       # Re-encode and overwrite the image
       cv2.imwrite(image_path, img, [int(cv2.IMWRITE_JPEG_QUALITY), 95])
    else:
        print(f"Failed to read image data: {image_path}")

This solution fixed my problem after long time of debugging.

@pderrenger
Copy link
Member

@halqadasi thank you for sharing your solution! Re-encoding images using OpenCV is indeed an effective method to resolve JPEG corruption issues, as it standardizes the format and removes extraneous data. This approach is especially helpful when working with OpenCV for image processing. Your contribution could assist other users facing similar problems—thank you for supporting the YOLO community!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Stale Stale and schedule for closing soon
Projects
None yet
Development

No branches or pull requests

4 participants