var client = new RestClient("https://predict-6ab663062f703b3a47ad0790-dproatj77a-km.a.run.app");
var request = new RestRequest("", Method.Post);
request.AddHeader("Accept", "application/json");
request.AddHeader("Content-Type", "multipart/form-data");
request.AddHeader("authorization", "################");
request.AddHeader("Content-Type", "multipart/form-data");
request.AddFile("file", FileName, "image/png");
request.AddParameter("conf", "0.15");
request.AddParameter("iou", "0.70");
request.AddParameter("imgsz", "640");
var response = await client.ExecuteAsync(request);
GetPrediction1 myDeserializedClass = JsonConvert.DeserializeObject<GetPrediction1>(response.Content);
As I am new to Yolo, I have a question please.
With regards to the parameter ‘imgsz’ does the actual image that I supply to the Endpoint have to be 640, or does the Endpoint resize it?
This is because I have found a difference in the confidence values when I submit the image via the endpoint vs when I “drop the image” on the endpoint.
Maybe, when I “drop” the image on the endpoint, the image is first resized?
But, this does not explain when I get a positive prediction, but the monitoring page of the endpoint shows the image without a prediction found.
Thanks for the code, Steve. Your image does not have to be 640 × 640.imgsz=640 sets the inference input size; the model’s preprocessing handles images of other dimensions. There is one important difference between your two tests: the deployment’s browser Predict tab resizes an image before uploading it, while your C# request uploads the original file. That can change confidence scores, particularly for a detection near your conf=0.15 threshold. The Platform inference documentation describes that browser-side resize. For a closer comparison, send the exact same resized image through both routes to the same deployment with the same settings, then compare their raw JSON responses.
The Monitoring gallery is not a record of every response: it captures examples on a best-effort basis, at most one per second. So a gallery image with no overlay does not, by itself, establish that it corresponds to the request that returned a positive result. If you can match a particular monitored example to a particular API response and they disagree, that warrants investigation. The Monitoring documentation explains the capture limits.
One thing to check in your snippet: the documented endpoint path ends in /predict, whereas the URL shown does not. Please confirm the actual URL being called, remove the duplicate Content-Type header and let RestSharp set the multipart boundary, and log the HTTP status and rawresponse.Content before deserializing it. If the discrepancy persists, please share a reproducible image, both raw responses, the request times, and the Ultralytics version reported in the responses—with your API key removed—after checking on the latest available version.