-
-
Notifications
You must be signed in to change notification settings - Fork 15
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
Why does the API return different results than the Preview functionality or testing the pytorch model itself using a python application? #1039
Comments
👋 Hello @florinmititica, thank you for raising an issue about Ultralytics HUB 🚀! Please visit our HUB Docs to learn more:
If this is a 🐛 Bug Report, could you please provide a minimum reproducible example (MRE), including:
If this is a ❓ Question, additional information about your model, dataset, environment, and how you're comparing the results would greatly facilitate troubleshooting 🕵️♂️. We try to respond to all issues as promptly as possible. Thank you for your patience! An Ultralytics engineer will review and assist you shortly 😊. |
@florinmititica thanks for your question! Differences between HUB Preview, local PyTorch inference, and API results typically stem from three main factors:
Troubleshooting Steps: # Compare API vs local results with identical parameters
from ultralytics import YOLO
# Local inference
model = YOLO("yolov8n.pt") # Replace with your model
local_results = model.predict("image.jpg", imgsz=640, conf=0.25, iou=0.45)
# API request (ensure parameters match)
import requests
response = requests.post(
"https://predict.ultralytics.com",
headers={"x-api-key": "API_KEY"},
files={"file": open("image.jpg", "rb")},
data={"model": "MODEL_ID", "imgsz":640, "conf":0.25, "iou":0.45}
)
print("API:", response.json())
print("Local:", local_results[0].tojson()) If discrepancies persist after verifying these factors, please share:
We'll investigate further! For more details, see the Inference API documentation. |
Hey @pderrenger thank you for getting back to me and sharing all these details. I'm actually already using the same parameters and I'm not processing the image at all. Take a look at another test I've run using your troubleshooting code: |
👋 Thanks for sharing the comparison! From your screenshot, it looks like the API is returning empty results while local PyTorch inference works. Let's dig deeper with these steps:
If the shapes differ significantly, there might be a letterbox/stretch resizing mismatch. For critical cases, you can force identical preprocessing by adding If this still doesn't resolve it, please share:
We'll escalate this to our engineering team for deeper investigation. You can also create a new issue with these details for public tracking. 🛠️ |
Search before asking
Question
I trained a model and then tested it using the preview functionality in the Ultralytics HUB. I was happy with the results but then when I tested the API with the same picture I received no results. Doing more tests, I managed to get some results on some images but in most of the cases I get no results using the API compared to getting accurate detection using the preview functionality in the HUB or using a python application that uses the pytorch model.
Additional
No response
The text was updated successfully, but these errors were encountered: