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

Stitched image detection #738

Closed
1 task done
ZBC0de opened this issue Jun 20, 2024 · 5 comments
Closed
1 task done

Stitched image detection #738

ZBC0de opened this issue Jun 20, 2024 · 5 comments
Labels
question A HUB question that does not involve a bug Stale

Comments

@ZBC0de
Copy link

ZBC0de commented Jun 20, 2024

Search before asking

Question

Hey there, I am looking to detect features on a single image that contains 6 images that are stitched together horizontally. The width of the base images will be over 10000px and the height will be set at 1224. How can I train on an image of this size? As I need to maintain the aspect ratio when training.

Additional

N/a

@ZBC0de ZBC0de added the question A HUB question that does not involve a bug label Jun 20, 2024
Copy link

👋 Hello @ZBC0de, thank you for raising an issue about Ultralytics HUB 🚀! Please visit our HUB Docs to learn more:

  • Quickstart. Start training and deploying YOLO models with HUB in seconds.
  • Datasets: Preparing and Uploading. Learn how to prepare and upload your datasets to HUB in YOLO format.
  • Projects: Creating and Managing. Group your models into projects for improved organization.
  • Models: Training and Exporting. Train YOLOv5 and YOLOv8 models on your custom datasets and export them to various formats for deployment.
  • Integrations. Explore different integration options for your trained models, such as TensorFlow, ONNX, OpenVINO, CoreML, and PaddlePaddle.
  • Ultralytics HUB App. Learn about the Ultralytics App for iOS and Android, which allows you to run models directly on your mobile device.
    • iOS. Learn about YOLO CoreML models accelerated on Apple's Neural Engine on iPhones and iPads.
    • Android. Explore TFLite acceleration on mobile devices.
  • Inference API. Understand how to use the Inference API for running your trained models in the cloud to generate predictions.

If this is a 🐛 Bug Report, please provide screenshots and steps to reproduce your problem to help us get started working on a fix.

If this is a ❓ Question, please provide as much information as possible, including dataset, model, environment details etc. so that we might provide the most helpful response.

We try to respond to all issues as promptly as possible. Thank you for your patience!

@pderrenger
Copy link
Member

@ZBC0de hello,

Thank you for reaching out with your question about detecting features on a stitched image. To assist you effectively, could you please provide a minimum reproducible code example? This will help us understand your setup and reproduce the issue on our end. You can find guidelines on how to create a minimum reproducible example here. It's crucial for us to replicate the problem to investigate and provide a solution.

Additionally, please ensure that you are using the latest versions of torch, ultralytics, and hub-sdk. If you haven't updated recently, please upgrade your packages and try again to see if the issue persists.

Regarding your specific question about training on large images while maintaining the aspect ratio, here are a few suggestions:

  1. Image Resizing: You can resize your images to a manageable size while maintaining the aspect ratio. For example, you can use the cv2.resize function in OpenCV to resize your images before feeding them into the model.

    import cv2
    
    image = cv2.imread('path_to_your_image.jpg')
    resized_image = cv2.resize(image, (desired_width, desired_height))
  2. Image Patching: Another approach is to divide your large image into smaller patches and train the model on these patches. This way, you can handle high-resolution images without running into memory issues.

    def split_image(image, patch_size):
        patches = []
        for y in range(0, image.shape[0], patch_size[1]):
            for x in range(0, image.shape[1], patch_size[0]):
                patch = image[y:y + patch_size[1], x:x + patch_size[0]]
                patches.append(patch)
        return patches
    
    patches = split_image(image, (desired_width, desired_height))
  3. Custom DataLoader: You can create a custom DataLoader that handles large images by either resizing or patching them on-the-fly during training.

If you provide more details or a code example, we can offer more specific guidance. Thank you for your cooperation, and we look forward to helping you resolve this issue!

@ZBC0de
Copy link
Author

ZBC0de commented Jun 21, 2024

It's not so much an issue as it is a quest about how to go about it. I currently have 6x 8MP images that I am horizontally stitching together. I want to use your API to do detections on the stitched image. When training on an image this large through the ultralytics hub, will the aspect ratio always remain the same?

@pderrenger
Copy link
Member

Hello @ZBC0de,

Thank you for your question and for providing context about your project! It's great to hear that you're exploring the use of our API for detecting features on stitched images.

To address your query about maintaining the aspect ratio when training on large images through the Ultralytics HUB, here are a few key points:

  1. Aspect Ratio Maintenance: When you upload and train images using the Ultralytics HUB, the aspect ratio of your images is typically preserved. However, it's important to ensure that your images are within a manageable size for the model to handle efficiently. Extremely large images can pose challenges in terms of memory and processing power.

  2. Image Resizing: If your stitched image is exceptionally large (e.g., over 10000px in width), you might consider resizing it while maintaining the aspect ratio. This can be done using image processing libraries like OpenCV. Here's a quick example:

    import cv2
    
    image = cv2.imread('path_to_your_image.jpg')
    resized_image = cv2.resize(image, (desired_width, desired_height))
  3. Image Patching: Another effective approach is to divide your large stitched image into smaller patches. This allows you to process high-resolution images without running into memory issues. You can then train the model on these patches and aggregate the results. Here's a sample function to split an image into patches:

    def split_image(image, patch_size):
        patches = []
        for y in range(0, image.shape[0], patch_size[1]):
            for x in range(0, image.shape[1], patch_size[0]):
                patch = image[y:y + patch_size[1], x:x + patch_size[0]]
                patches.append(patch)
        return patches
    
    patches = split_image(image, (desired_width, desired_height))
  4. Custom DataLoader: You can also create a custom DataLoader that handles large images by resizing or patching them on-the-fly during training.

If you encounter any specific issues or have further questions, please provide a minimum reproducible code example. This will help us understand your setup better and offer more precise guidance. You can find guidelines on creating a minimum reproducible example here.

Additionally, please ensure you are using the latest versions of torch, ultralytics, and hub-sdk. If you haven't updated recently, please upgrade your packages and try again to see if the issue persists.

We appreciate your engagement with the YOLO community and the Ultralytics team. We're here to help you succeed with your project!

Copy link

👋 Hello there! We wanted to give you a friendly reminder that this issue has not had any recent activity and may be closed soon, but don't worry - you can always reopen it if needed. If you still have any questions or concerns, please feel free to let us know how we can help.

For additional resources and information, please see the links below:

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

@github-actions github-actions bot added the Stale label Jul 22, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question A HUB question that does not involve a bug Stale
Projects
None yet
Development

No branches or pull requests

2 participants