Matching plugin for Python Matcher Proxy#
Using the matching plugin, the Python Matcher Proxy service can redirect matching requests from the API service to either the Python Matcher service or the Indexed Matcher service. The principle of operation of the plugin and the description of the choice of the service in which the matching will be performed are described below.
The matching plugin is already integrated into the Python Matcher Proxy Docker container, you just need to enable it (see the installation manual).
Matching plugin description#
Each matching request is presented in the form of all possible combinations of candidates and references, then each such combination is processed as a separate sub-request as follows (further sub-request means combination of reference and candidates):
-
Get the sub-request matching cost (see "Matching cost").
-
Choose the way for the sub-request processing using the lowest estimated matching cost: matching plugin or Python Matcher service.
-
If in the previous step Python Matcher service was selected, it will process sub-request, returns the response to the Python Matcher Proxy service.
-
If in the previous step matching plugin was selected, it will process sub-request. If sub-request was successfully processed, the response returns to the Python Matcher Proxy service. If a sub-request was not successfully processed, it will try to process by Python Matcher service.
-
-
If the request was successfully processed by matching plugin and plugin does not have access to all matching targets which specified in sub-request, then Python Matcher Proxy service will enrich data before next step, see matching targets for details.
-
The Python Matcher Proxy service collects results from all sub-requests, sorts them in the right order, and replies to the user.
Matching cost#
Matching cost is a float numeric expression of matching request process complexity using a plugin. Matching cost is necessary to choose the best way to process a matching request: Python Matcher service or one or more plugins.
The matching cost value for the Python Matcher service is infinity. If there are several plugins, then the matching cost value will be calculated for each plugin. If the matching label is loaded in the Redis database, then a certain query complexity will be calculated and the matching plugin will be used. If the label is not loaded, then the Python Matcher service will be used.
Matching targets#
The Python Matcher service has access to all data of matching entities, so it can process matching requests with all targets. Matching plugins may not have access to data, which is specified in request targets. In this case, Python Matcher Proxy service will enrich response of plugin with missing targets data, e.g.:
-
matching response contains next targets: face_id, user_data and similarity and the chosen matching plugin does not have access to user_data field:
-
matching plugin match reference with specified face_ids and return the matching response to the Python Matcher Proxy, which contains only pairs of face_id and similarity;
-
for every match candidate in result, Python Matcher Proxy service will get user_data from the main database by face_id and merge face_id and similarity with user_data;
-
return enriched response with specified targets to the user.
-
-
matching response contains next targets: age, gender (all candidates are events’ faces) and the chosen matching plugin have access only to event_id, descriptor, and age fields:
-
matching plugin match reference and return the matching response to the Python Matcher Proxy, which contains only pairs of event_id, age and similarity;
-
for every match candidate in result, Python Matcher Proxy service will get gender from the main database by event_id and merge event_id with gender, also after that it drops non-required event_id and similarity from the response
-
return a prepared response with specified targets to the user.
-
Several matching plugins can be used in LUNA PLATFORM. See the "Matching plugins" section of the LUNA PLATFORM administrator manuals for details.