Comments (3)
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.
@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:
-
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.
-
Package Versions: Verify that you are using the latest versions of both
torch
andultralytics
. 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.
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)
- Why when I put Pretrained = False, yolov8 still transfer and freeze weights HOT 4
- YOLOv8 is jointly trained with other models HOT 2
- Optimizer='auto' problem HOT 2
- Docker run yolov8 report error:Killed, OOM HOT 4
- Is there any other way to get faster YOLOv8n results without using GPU HOT 2
- Default training parameters for yolov8n? HOT 6
- Exporting a YOLO model fails when current directory is in a different filesystem HOT 6
- YOLOv8 resizes input images differently when training for classification? HOT 3
- FedAvg with YOLO HOT 6
- YOLOv8, v10, RT-DETR albumentation do not apply HOT 5
- How can i train better my project ? YOLOV8 HOT 14
- Codebase for running YoloV10 with ONNX HOT 8
- xywh returns wrong result while xyxy returns right result HOT 1
- Support distributed evaluation during training process HOT 1
- Is there an example of yolov8n-segn Android split HOT 2
- @glenn-jocher tracker is not working for custom trained models,
- multi input video to YOLOv8 and using bytetrack.yaml return same ID to different object and keep increasing HOT 2
- The engine model RTX3060 exported by RTX4070 cannot be inferred HOT 3
- YOLO(model_yaml).load(model.pt) not work. HOT 5
- Exporting after training on YoloV10 raise a ValueError with MultiGPU HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ultralytics.