GithubHelp home page GithubHelp logo

Comments (3)

glenn-jocher avatar glenn-jocher commented on July 21, 2024 1

Hello @kadirnar,

Thank you for the update! I'm glad to hear that the manual resizing with torch.nn.functional.interpolate worked for you ❤️.

We understand the convenience of having the Ultralytics library handle the resizing internally, and we appreciate your feedback. This is something we can consider for future updates to improve user experience.

For now, your approach is a solid workaround. If you encounter any further issues or have additional suggestions, please feel free to share them. Your input is invaluable in helping us enhance the library.

Regarding the installation and running of the ComfyUI library, we appreciate your offer to assist. However, we aim to keep our support focused on the Ultralytics library itself. If you have any specific issues or questions related to Ultralytics, please don't hesitate to ask.

Thank you for your understanding and for contributing to the community!

from ultralytics.

glenn-jocher avatar glenn-jocher commented on July 21, 2024

@kadirnar hello,

Thank you for reaching out and providing detailed information about the issue you're encountering. It appears that the imgsz parameter isn't functioning as expected when you upload images in tensor format.

To better assist you, could you please ensure the following:

  1. Reproducible Code Example: The provided code snippet is helpful, but could you please share a minimal reproducible example that includes the model loading and any other relevant parts? This will help us replicate the issue on our end. You can refer to our minimum reproducible example guide for more details.

  2. Package Versions: Verify that you are using the latest versions of both torch and ultralytics. You can upgrade them using the following commands:

    pip install --upgrade torch ultralytics

Regarding your specific issue with the imgsz parameter, it seems that the resizing might not be applied correctly when the input is a tensor. Here’s a quick workaround you can try:

import torch
from ultralytics import YOLO

# Load the model
model = YOLO('yolov8n.pt')

def inference(model, image, conf=0.25, iou=0.7, imgsz=640, device="cuda:0", half=False, augment=False, agnostic_nms=False):
    # Resize the tensor manually
    yolo_image = torch.nn.functional.interpolate(image.permute(0, 3, 1, 2), size=(imgsz, imgsz), mode='bilinear', align_corners=False)
    results = model.predict(yolo_image, conf=conf, iou=iou, imgsz=imgsz, device=device, half=half, augment=augment, agnostic_nms=agnostic_nms)[0]

    boxes = results.boxes.xywh
    masks = results.masks

    return (results, image, boxes, masks)

# Example usage
image = torch.randn(1, 1024, 1024, 3)  # Dummy image tensor
results, image, boxes, masks = inference(model, image)

This code manually resizes the tensor before passing it to the model.predict function, which should ensure that the imgsz parameter is respected.

Please try this and let us know if it resolves the issue. If the problem persists, providing the additional details mentioned above will help us investigate further.

Thank you for your cooperation and understanding. We look forward to your response!

from ultralytics.

kadirnar avatar kadirnar commented on July 21, 2024

It worked when I added the torch.nn.function function ❤️ But I would love for it to do the Ultralytics library instead of adding it manually. Installing and running the ComfyUI library can be a bit complicated. I can tell you how to do it if you want. Or you can try uploading a tensor image and changing the image-size values.

logs:

0: 640x640 5 persons, 399.2ms
Speed: 4.1ms preprocess, 399.2ms inference, 115.4ms postprocess per image at shape (1, 3, 640, 640)
Prompt executed in 1.63 seconds
got prompt

0: 1024x1024 5 persons, 344.2ms
Speed: 2.1ms preprocess, 344.2ms inference, 6.5ms postprocess per image at shape (1, 3, 1024, 1024)
Prompt executed in 0.49 seconds
got prompt

0: 1280x1280 6 persons, 210.1ms
Speed: 3.5ms preprocess, 210.1ms inference, 9.3ms postprocess per image at shape (1, 3, 1280, 1280)
Prompt executed in 0.42 seconds

from ultralytics.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.