VNImageRequestHandler with multiple requests

Hi,


I've been using CoreML and Vision to do some basic detection/recognition on my images.

Now, making a more complex framework, and allowing users (developers) to easily append multiple models and get results, I've stumbled upon a rather annoying problem:

A Vision request handler, VNImageRequestHandler, returns wrong results when the perform function contains multiple model request (VNCoreMLRequest).


To simplify, let's say that I am trying to get gender, age and emotion of a face in an image. I create one Vision handler and dispatch its perform function in a queue as follow:

DispatchQueue.global(qos: .userInteractive).async { do {
    try handler.perform([self.ageClassificationRequest, self.genderClassificationRequest, self.emotionsClassificationRequest])
      catch { print(error)}}}


Each of the xxxClassificationRequests is a VNCoreMLRequest with a completion handler that checks the observation results (VNClassificationObservation).

This code fails because the observations are exactly the same as the very first (in this case, Age is the first in the array, so Gender and Emotions' observation results will be a duplicate of Age's ones)


Doing this on the other hand solves the problem:

DispatchQueue.global(qos: .userInteractive).async { do {
    try handler.perform([self.ageClassificationRequest])
    } catch { print(error) } }
DispatchQueue.global(qos: .userInteractive).async { do {
   try handler.perform([self.genderClassificationRequest])
    } catch { print(error) } }
DispatchQueue.global(qos: .userInteractive).async { do {
   try handler.perform([self.emotionsClassificationRequest])
    } catch { print(error) } }


In other words, dispatching multiple times with the same handler allows the results to be correct.


Now, the question is, why is this behavior acceptable or is it just a bug? Is there a way to ensure correct results, especially that each completion handler is correctly called.


Thank you.

Answered by EinharchAltPlus in 294125022

Tested on iOS 11.3.b2 and it seems fixed.

Didn't try on other OSes supporting Vision though, hopefully it's fine.

Can confirm the same thing happens for me in a similar situation. Why would iOS recommend passing in an array of requests if it can only return the results from one of them?


Performing a single request from a handler works fine, but all observations when performing multiple requests are duplicated.

Hi,


Just for the update, I filled this a while ago under rdar #36431689.

It has been market as a duplicate of #35014427 that is now closed.

So maybe some hope.

Does this problem reproduce on the latest seeds?

Accepted Answer

Tested on iOS 11.3.b2 and it seems fixed.

Didn't try on other OSes supporting Vision though, hopefully it's fine.

Hello I have access to your website that is for dvelopers i would like to get in touch with someone to make them aware that the site has been placed on computer in order to control the devoces that we own please reply

thank you

stephen herin

Sorry???


I don't understand what you're talking about, can you clarify?

VNImageRequestHandler with multiple requests
 
 
Q