{"id":407395,"date":"2024-06-29T19:32:22","date_gmt":"2024-06-29T19:32:22","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=407395"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2024-06-29T19:32:22","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=407395","title":{"rendered":"<span>\u0420\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0435\u043c \u0430\u0432\u0442\u043e\u043c\u043e\u0431\u0438\u043b\u044c\u043d\u044b\u0435 \u043d\u043e\u043c\u0435\u0440\u0430 \u043d\u0430 TorchServe<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412\u043e\u043a\u0440\u0443\u0433 \u0442\u0430\u043a \u043c\u043d\u043e\u0433\u043e \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u0432 \u0434\u043b\u044f \u0438\u043d\u0444\u0435\u0440\u0435\u043d\u0441\u0430 \u043d\u0435\u0439\u0440\u043e\u043d\u043e\u043a, \u0447\u0442\u043e \u0433\u043b\u0430\u0437\u0430 \u0440\u0430\u0437\u0431\u0435\u0433\u0430\u044e\u0442\u0441\u044f. \u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u043c \u0446\u0438\u043a\u043b \u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0435\u0440\u0432\u0438\u043d\u0433\u0430 \u043e\u0434\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438, \u043d\u043e \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438. \u0412 \u043f\u0440\u043e\u0448\u043b\u044b\u0439 \u0440\u0430\u0437 <a href=\"https:\/\/habr.com\/ru\/post\/717890\/\" rel=\"noopener noreferrer nofollow\">\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/a> \u0431\u044b\u043b\u0430 \u043d\u0430 Nvidia Triton Inference Serve (\u0437\u0430 \u0430\u043d\u043e\u043d\u0441\u0430\u043c\u0438 \u043f\u0440\u043e\u0448\u0443 \u0432 \u043c\u043e\u0439 <a href=\"https:\/\/t.me\/yet_another_mle\" rel=\"noopener noreferrer nofollow\">\u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c \u043a\u0430\u043d\u0430\u043b<\/a>. \u041a\u043e\u0434 \u043a \u0441\u0442\u0430\u0442\u044c\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 <a href=\"https:\/\/github.com\/EgShes\/one_task_multiple_infras\" rel=\"noopener noreferrer nofollow\">\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438<\/a>.<\/p>\n<h2>\u0417\u0430\u0434\u0430\u0447\u0430<\/h2>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0432\u0437\u044f\u0442\u043e \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u0440\u043e\u0441\u0441\u0438\u0439\u0441\u043a\u0438\u0445 \u0430\u0432\u0442\u043e\u043c\u043e\u0431\u0438\u043b\u044c\u043d\u044b\u0445 \u043d\u043e\u043c\u0435\u0440\u043e\u0432. \u041c\u043e\u0434\u0435\u043b\u0438 \u0431\u044b\u043b\u0438 \u0432\u0437\u044f\u0442\u044b \u0438\u0437 \u044d\u0442\u043e\u0433\u043e <a href=\"https:\/\/github.com\/EtokonE\/License_Plate_Recognition\" rel=\"noopener noreferrer nofollow\">\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f<\/a>.<\/p>\n<p>\u041f\u0430\u0439\u043f\u043b\u0430\u0439\u043d \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439:<br \/> 1. \u0414\u0435\u0442\u0435\u043a\u0446\u0438\u044f \u043d\u043e\u043c\u0435\u0440\u043e\u0432 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Yolov5;<br \/> 2. \u0412\u044b\u0440\u0435\u0437\u0430\u043d\u043d\u044b\u0435 \u043d\u043e\u043c\u0435\u0440\u0430 \u043f\u0440\u043e\u0433\u043e\u043d\u044f\u044e\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 Spatial transformer (STN) \u0434\u043b\u044f \u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u044f;<br \/> 3. \u0422\u0435\u043a\u0441\u0442 \u043d\u043e\u043c\u0435\u0440\u0430 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0435\u0442\u0441\u044f \u0441 LPR-net.<\/p>\n<h2>\u0424\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a<\/h2>\n<p>\u0414\u043b\u044f \u0438\u043d\u0444\u0435\u0440\u0435\u043d\u0441\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f [TorchServe]. \u0414\u0430\u043d\u043d\u044b\u0439 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u044c\u044e \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u044b Pytorch. \u041e\u043d \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u0435\u0442\u0441\u044f.<\/p>\n<p>\u0412 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043e \u043d\u0435\u043c \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<blockquote>\n<p>TorchServe is a performant, flexible and easy to use tool for serving PyTorch eager mode and torschripted models.<\/p>\n<\/blockquote>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438:<\/p>\n<ul>\n<li>\n<p>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 <a href=\"https:\/\/github.com\/pytorch\/serve\/blob\/master\/docs\/performance_guide.md\" rel=\"noopener noreferrer nofollow\">\u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u0432<\/a> \u043c\u043e\u0434\u0435\u043b\u0435\u0439 (torchscript, onnx, ipex, tensorrt);<\/p>\n<\/li>\n<li>\n<p>\u041e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0432 \u043e\u0434\u0438\u043d <a href=\"https:\/\/github.com\/pytorch\/serve\/blob\/master\/examples\/Workflows\/README.md\" rel=\"noopener noreferrer nofollow\">\u0433\u0440\u0430\u0444\/workflow<\/a>;<\/p>\n<\/li>\n<li>\n<p>\u0418\u043d\u0444\u0435\u0440\u0435\u043d\u0441 <a href=\"https:\/\/github.com\/pytorch\/serve\/blob\/master\/docs\/inference_api.md\" rel=\"noopener noreferrer nofollow\">API<\/a> (REST \u0438 GRPC);<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/pytorch\/serve\/blob\/master\/docs\/management_api.md\" rel=\"noopener noreferrer nofollow\">API<\/a> \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u044f\u043c\u0438;<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/pytorch\/serve\/blob\/master\/docs\/metrics.md\" rel=\"noopener noreferrer nofollow\">\u041c\u0435\u0442\u0440\u0438\u043a\u0438<\/a> \u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438.<\/p>\n<\/li>\n<\/ul>\n<h2>\u041a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u0438<\/h2>\n<p>\u041a\u0430\u043a \u0438 Triton, TorchServe \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043f\u0435\u0440\u0435\u0432\u0435\u0441\u0442\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 \u0432 \u0441\u0432\u043e\u0439 \u0444\u043e\u0440\u043c\u0430\u0442. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0435\u0441\u0442\u044c \u0443\u0442\u0438\u043b\u0438\u0442\u044b <a href=\"https:\/\/github.com\/pytorch\/serve\/tree\/master\/model-archiver#torch-model-archiver-for-torchserve\" rel=\"noopener noreferrer nofollow\">torch-model-archiver<\/a> \u0438 <a href=\"https:\/\/github.com\/pytorch\/serve\/blob\/fd4e3e8b72bed67c1e83141265157eed975fec95\/workflow-archiver\/README.md\" rel=\"noopener noreferrer nofollow\">torch-workflow-archiver<\/a> \u0434\u043b\u044f \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0438 \u0433\u0440\u0430\u0444\u043e\u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e.<\/p>\n<p>\u0414\u043b\u044f \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e:<\/p>\n<ol>\n<li>\n<p>\u041c\u043e\u0434\u0435\u043b\u044c \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 TorchServe\/Onnx\/\u0434\u0440.;<\/p>\n<\/li>\n<li>\n<p>\u0421\u043a\u0440\u0438\u043f\u0442, \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d \u0440\u0430\u0431\u043e\u0442\u044b \u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<\/li>\n<\/ol>\n<p>\u0422\u0430\u043a\u043e\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f handler. \u0412 \u043d\u0435\u043c <a href=\"https:\/\/pytorch.org\/serve\/custom_service.html#custom-handler-with-class-level-entry-point\" rel=\"noopener noreferrer nofollow\">\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442\u0441\u044f<\/a> \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u044d\u0442\u0430\u043f\u044b \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430 \u043c\u043e\u0434\u0435\u043b\u0438 (\u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f, \u043f\u0440\u0435\u0434\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430, \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u0435, \u043f\u043e\u0441\u0442\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0438 \u0434\u0440.). \u0414\u043b\u044f \u0442\u0438\u043f\u043e\u0432\u044b\u0445 \u0437\u0430\u0434\u0430\u0447 \u043e\u043d\u0438 \u0443\u0436\u0435 <a href=\"https:\/\/pytorch.org\/serve\/#default-handlers\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u0435\u0434\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b<\/a>.<\/p>\n<p>\u041c\u043e\u0434\u0435\u043b\u0438 STN \u0438 LPR \u043b\u0435\u0433\u043a\u043e <a href=\"https:\/\/github.com\/EgShes\/one_task_multiple_infras\/blob\/master\/inference_torchserve\/inference_torchserve\/scripts\/README.md\" rel=\"noopener noreferrer nofollow\">\u043a\u043e\u043d\u0432\u0435\u0440\u0443\u044e\u0442\u0441\u044f<\/a> \u0432 TorchServe, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u0438\u0445 \u0445\u044d\u043d\u0434\u043b\u0435\u0440\u0430\u0445 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438. <a href=\"https:\/\/github.com\/EgShes\/one_task_multiple_infras\/blob\/master\/inference_torchserve\/inference_torchserve\/handlers\/stn.py\" rel=\"noopener noreferrer nofollow\">\u0418\u043c\u043f\u043e\u0440\u0442\u044b<\/a> \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"python\">import json import logging from abc import ABC import numpy as np import torch from ts.torch_handler.base_handler import BaseHandler <\/code><\/pre>\n<p>Yolo \u043d\u0435\u043b\u044c\u0437\u044f \u0431\u044b\u043b\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u0432\u0435\u0441\u0442\u0438 \u0432 TorchScript, \u0442\u0430\u043a \u043a\u0430\u043a \u0447\u0430\u0441\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0438 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043e\u0441\u0442\u0430\u0432\u0430\u043b\u0430\u0441\u044c \u0441\u043d\u0430\u0440\u0443\u0436\u0438 \u043c\u043e\u0434\u0435\u043b\u0438. \u0422\u0430\u043a \u043a\u0430\u043a \u043a\u043e\u043f\u0430\u0442\u044c\u0441\u044f \u0441 \u044d\u0442\u0438\u043c \u0436\u0435\u043b\u0430\u043d\u0438\u044f \u043d\u0435 \u0431\u044b\u043b\u043e, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0440\u0430\u0434\u0438 \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0438\u0431\u043b\u0438\u0436\u0435\u043d\u043d\u043e\u0433\u043e \u043a \u0436\u0438\u0437\u043d\u0438 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f, \u0432 \u0445\u044d\u043d\u0434\u043b\u0435\u0440\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 Yolo \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0438\u0437 <a href=\"https:\/\/github.com\/EgShes\/one_task_multiple_infras\/blob\/master\/inference_torchserve\/inference_torchserve\/handlers\/yolo.py\" rel=\"noopener noreferrer nofollow\">TorchHub<\/a>. \u0412 \u0438\u043c\u043f\u043e\u0440\u0442\u0430\u0445 \u043c\u044b \u0443\u0436\u0435 \u0432\u0438\u0434\u0438\u043c \u0438 \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0435 \u043c\u043e\u0434\u0443\u043b\u0438:<\/p>\n<pre><code class=\"python\">from inference_torchserve.data_models import PlatePrediction from nn.inference.predictor import prepare_detection_input, prepare_recognition_input from nn.models.yolo import load_yolo from nn.settings import settings <\/code><\/pre>\n<p>\u0427\u0442\u043e\u0431\u044b \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432 \u0434\u043e\u043a\u0435\u0440\u0444\u0430\u0439\u043b\u0435 <a href=\"https:\/\/github.com\/EgShes\/one_task_multiple_infras\/blob\/9c7ea4c92209ac67955cf956fe9e4209082b256b\/inference_torchserve\/docker\/dockerfiles\/DockerfileTorchServe#L53\" rel=\"noopener noreferrer nofollow\">\u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c<\/a> \u0432 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0432\u0430\u043c \u043f\u0430\u043a\u0435\u0442\u044b.<\/p>\n<p>\u0412 TorchServe \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0436\u0435\u0441\u0442\u043a\u043e \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u0442\u0438\u043f \u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u044c \u0432\u0445\u043e\u0434\u043e\u0432 \u0438 \u0432\u044b\u0445\u043e\u0434\u043e\u0432 \u043c\u043e\u0434\u0435\u043b\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0438\u043a\u0430\u043a\u0438\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0438 \u0434\u043b\u044f \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e. \u0421 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u044d\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u043e, \u0430 \u0441 \u0434\u0440\u0443\u0433\u043e\u0439 &#8212; \u043f\u043e\u0440\u043e\u0436\u0434\u0430\u0435\u0442 \u0445\u0430\u043e\u0441, \u0435\u0441\u043b\u0438 \u043d\u0435 \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a\u043e\u043c\u0443-\u0442\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u0444\u043e\u0440\u043c\u0430\u0442\u0443.<\/p>\n<p>\u041a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 zip \u0430\u0440\u0445\u0438\u0432 \u0441 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435\u043c <em>.mar<\/em>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043b\u0435\u0436\u0430\u0442 \u0432\u0441\u0435 \u0430\u0440\u0442\u0435\u0444\u0430\u043a\u0442\u044b (\u0441\u043b\u0443\u0436\u0435\u0431\u043d\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f, \u0432\u0435\u0441\u0430, \u0441\u043a\u0440\u0438\u043f\u0442\u044b \u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b).<\/p>\n<pre><code>. \u251c\u2500\u2500 MAR-INF \u2502\u00a0\u00a0 \u2514\u2500\u2500 MANIFEST.json \u251c\u2500\u2500 stn.pt \u2514\u2500\u2500 stn.py <\/code><\/pre>\n<p>\u041d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0441 \u0430\u0440\u0445\u0438\u0432\u043e\u043c \u043d\u0435\u0443\u0434\u043e\u0431\u043d\u043e \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438. \u041f\u043e\u0441\u043b\u0435 \u043b\u044e\u0431\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u043d\u043e\u0432\u043e \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c. \u0422\u0430\u043a\u0436\u0435 \u044f \u0438\u0441\u043f\u044b\u0442\u044b\u0432\u0430\u043b \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0432 \u043d\u0435\u043c \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0434\u0435\u0431\u0430\u0433\u0435\u0440\u0430.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b TorchServe \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u043b \u043c\u043e\u0434\u0435\u043b\u0438, \u0438\u0445 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u0432 \u043e\u0434\u043d\u0443 \u043f\u0430\u043f\u043a\u0443 &#8212; <code>model storage<\/code> \u0438 <a href=\"https:\/\/github.com\/EgShes\/one_task_multiple_infras\/blob\/9c7ea4c92209ac67955cf956fe9e4209082b256b\/inference_torchserve\/inference_torchserve\/config.properties#L1\" rel=\"noopener noreferrer nofollow\">\u0443\u043a\u0430\u0437\u0430\u0442\u044c<\/a> \u043f\u0443\u0442\u044c \u0434\u043e \u043d\u0435\u0435 \u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u0445. \u0427\u0442\u043e\u0431\u044b \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u043b\u0438\u0441\u044c \u0432\u0441\u0435 \u043c\u043e\u0434\u0435\u043b\u0438, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c <code>--models all<\/code>.<\/p>\n<h2>\u0414\u0435\u043b\u0430\u0435\u043c \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f<\/h2>\n<p>\u0412\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0439 \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u043d\u043e\u043c\u0435\u0440\u0430 \u0430\u0432\u0442\u043e\u043c\u043e\u0431\u0438\u043b\u044f \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u043c\u043e\u0434\u0435\u043b\u044f\u043c\u0438. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 TorchServe \u0435\u0441\u0442\u044c <a href=\"https:\/\/pytorch.org\/serve\/workflows.html\" rel=\"noopener noreferrer nofollow\">Workflow<\/a>. \u041e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0437\u0430\u0434\u0430\u0442\u044c \u043a\u0430\u043a \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439, \u0442\u0430\u043a \u0438 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0439 \u0433\u0440\u0430\u0444 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438:<\/p>\n<pre><code class=\"yaml\"># \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439  dag:   pre_processing : [m1]   m1 : [m2]   m2 : [postprocessing] <\/code><\/pre>\n<pre><code>input -> function1 -> model1 -> model2 -> function2 -> output <\/code><\/pre>\n<pre><code class=\"yaml\"># \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0439 \u0433\u0440\u0430\u0444 dag:   pre_processing: [model1, model2]   model1: [aggregate_func]   model2: [aggregate_func] <\/code><\/pre>\n<pre><code>                          model1                          \/       \\ input -> preprocessing ->         -> aggregate_func                          \\       \/                           model2 <\/code><\/pre>\n<p>\u0414\u043b\u044f \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 <a href=\"https:\/\/github.com\/EgShes\/one_task_multiple_infras\/tree\/master\/inference_torchserve\/inference_torchserve\/scripts#plate-recognition\" rel=\"noopener noreferrer nofollow\">\u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f<\/a> \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e-\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0439 <a href=\"https:\/\/github.com\/EgShes\/one_task_multiple_infras\/blob\/master\/inference_torchserve\/inference_torchserve\/workflow\/plate_recognition.yaml\" rel=\"noopener noreferrer nofollow\">\u0433\u0440\u0430\u0444<\/a>. \u0423\u0437\u0435\u043b aggregate \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0435\u0442 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043d\u043e\u043c\u0435\u0440\u043e\u0432 \u0441 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u043d\u043d\u044b\u043c\u0438 \u0442\u0435\u043a\u0441\u0442\u0430\u043c\u0438.<\/p>\n<pre><code>    \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2510     \u2502 YOLO \u251c\u2500\u2500\u2500\u2500\u2500\u2510     \u2514\u2500\u2500\u252c\u2500\u2500\u2500\u2518     \u2502        \u2502         v        \u2502      \u250c\u2500\u2500\u2500\u2500\u2500\u2510 plate  \u2502      \u2502 STN \u2502 coords \u2502      \u2514\u2500\u2500\u252c\u2500\u2500\u2518        \u2502         \u2502        \u2502         v        \u2502      \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2510        \u2502      \u2502LPRNET\u2502        \u2502      \u2514\u2500\u2500\u252c\u2500\u2500\u2500\u2518        v         \u2502    \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510   \u2502 plate    \u2502aggregate\u2502&lt;\u2500\u2500\u2518 texts    \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518 <\/code><\/pre>\n<p>\u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u0435\u0436\u0434\u0443 \u043c\u043e\u0434\u0435\u043b\u044f\u043c\u0438 <a href=\"https:\/\/github.com\/EgShes\/one_task_multiple_infras\/blob\/9c7ea4c92209ac67955cf956fe9e4209082b256b\/inference_torchserve\/inference_torchserve\/handlers\/stn.py#L37\" rel=\"noopener noreferrer nofollow\">\u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f<\/a> \u0432 \u0432\u0438\u0434\u0435 \u0441\u043b\u043e\u0432\u0430\u0440\u0435\u0439. \u0421\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0442\u0430\u043a\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 TorchServe \u0432\u0435\u0441\u044c\u043c\u0430 <a href=\"https:\/\/github.com\/pytorch\/serve\/blob\/d0510ba4fb6bd63a10eb1af1660155e7376ebcaf\/ts\/protocol\/otf_message_handler.py#L136\" rel=\"noopener noreferrer nofollow\">\u043d\u0435\u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u0430<\/a> (\u043f\u0435\u0440\u0435\u0432\u043e\u0434\u044f\u0442 \u0432 \u0441\u0442\u0440\u043e\u043a\u0443 \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u043e\u0432 \u0441\u0442\u0440\u043e\u043a), \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u0442\u0430\u0440\u0430\u0439\u0442\u0435\u0441\u044c \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u0445 \u043a\u0430\u043a \u0442\u0435\u043d\u0437\u043e\u0440\u044b \u0438\u043b\u0438 \u0431\u0430\u0439\u0442\u044b.<\/p>\n<p>\u0423\u0447\u0442\u0438\u0442\u0435, \u0447\u0442\u043e workflow \u043d\u0435\u043b\u044c\u0437\u044f \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u0430\u0442\u044c \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 &#8212; \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u044f\u0432\u043d\u043e \u043f\u043e\u0441\u043b\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u044d\u0442\u043e. \u0415\u0441\u043b\u0438 \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u0438 \u043f\u043e\u0434\u043d\u044f\u0442\u0438\u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u0442\u043e \u043c\u043e\u0436\u043d\u043e <a href=\"https:\/\/github.com\/EgShes\/one_task_multiple_infras\/blob\/9c7ea4c92209ac67955cf956fe9e4209082b256b\/inference_torchserve\/docker\/dockerfiles\/DockerfileTorchServe#L76\" rel=\"noopener noreferrer nofollow\">\u0442\u0430\u043a<\/a>.<\/p>\n<pre><code class=\"bash\">curl -X POST http:\/\/localhost:8081\/workflows?url=plate_recognition <\/code><\/pre>\n<h2>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0435\u0439<\/h2>\n<p>\u041c\u043e\u0434\u0435\u043b\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b. \u0421\u0435\u0440\u0432\u0435\u0440 \u0437\u0430\u043f\u0443\u0449\u0435\u043d.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u0443\u044e \u0440\u0430\u043d\u0435\u0435 \u043c\u043e\u0434\u0435\u043b\u044c \u0438\u043b\u0438 workflow \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0441\u043b\u0430\u0442\u044c \u0432 TorchServe \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 plate_recognition (\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f <a href=\"https:\/\/pytorch.org\/serve\/rest_api.html\" rel=\"noopener noreferrer nofollow\">REST<\/a>, \u043d\u043e \u0435\u0441\u0442\u044c \u0435\u0449\u0435 \u0438 <a href=\"https:\/\/pytorch.org\/serve\/grpc_api.html\" rel=\"noopener noreferrer nofollow\">GRPC<\/a>). \u0414\u043b\u044f \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u044d\u043d\u0434\u043f\u043e\u0438\u043d\u0442 <code>predictions<\/code>, \u0430 \u0434\u043b\u044f workflow <code>wfpredict<\/code>.<\/p>\n<pre><code class=\"python\">response = requests.post(     \"http:\/\/localhost:8080\/predictions\/yolo\", data=image.open(\"rb\").read() )  response = requests.post(     \"http:\/\/localhost:8080\/wfpredict\/plate_recognition\",      data=image.open(\"rb\").read() ) <\/code><\/pre>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u041d\u0443 \u0432\u043e\u0442 \u0438\u043d\u0444\u0435\u0440\u0435\u043d\u0441 \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d. \u0414\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0435 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439, \u0447\u0442\u043e\u0431\u044b \u0431\u044b\u0442\u044c \u0432 \u0446\u0435\u043b\u043e\u043c \u0431\u0435\u0441\u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c, \u043d\u043e \u0438 \u043d\u0435 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0441\u043b\u043e\u0436\u043d\u044b\u0439, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043a\u0440\u044b\u0442\u044c \u0432\u0441\u0435 \u0444\u0438\u0448\u043a\u0438 \u044d\u0442\u043e\u0433\u043e \u0444\u0440\u0435\u0439\u043c\u043e\u0432\u0440\u043a\u0430 \u0434\u043b\u044f \u0438\u043d\u0444\u0435\u0440\u0435\u043d\u0441\u0430.<\/p>\n<p>\u0412 \u044d\u0442\u043e\u043c \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0435 \u0431\u044b\u043b\u0438 \u0440\u0430\u0441\u043a\u0440\u044b\u0442\u044b \u043d\u0435 \u0432\u0441\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 TorchServe, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u043e\u0432\u0435\u0442\u0443\u044e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043f\u0440\u043e:<\/p>\n<ul>\n<li>\n<p>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 <a href=\"https:\/\/github.com\/pytorch\/serve\/blob\/master\/examples\/captum\/Captum_visualization_for_bert.ipynb\" rel=\"noopener noreferrer nofollow\">explanations<\/a>;<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/pytorch.org\/serve\/metrics.html\" rel=\"noopener noreferrer nofollow\">\u0421\u043d\u044f\u0442\u0438\u0435<\/a> \u043c\u0435\u0442\u0440\u0438\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0435\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430;<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/pytorch.org\/serve\/batch_inference_with_ts.html\" rel=\"noopener noreferrer nofollow\">\u0411\u0430\u0442\u0447\u0435\u0432\u0430\u043d\u0438\u0435<\/a>.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0439\u0442\u0435\u0441\u044c \u043d\u0430 \u043c\u043e\u0439 <a href=\"https:\/\/t.me\/yet_another_mle\" rel=\"noopener noreferrer nofollow\">\u043a\u0430\u043d\u0430\u043b<\/a> &#8212; \u0442\u0430\u043c \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u044e \u043f\u0440\u043e \u043d\u0435\u0439\u0440\u043e\u043d\u043a\u0438 \u0441 \u0443\u043f\u043e\u0440\u043e\u043c \u0432 \u0441\u0435\u0440\u0432\u0438\u043d\u0433.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/727484\/\"> https:\/\/habr.com\/ru\/articles\/727484\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412\u043e\u043a\u0440\u0443\u0433 \u0442\u0430\u043a \u043c\u043d\u043e\u0433\u043e \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u0432 \u0434\u043b\u044f \u0438\u043d\u0444\u0435\u0440\u0435\u043d\u0441\u0430 \u043d\u0435\u0439\u0440\u043e\u043d\u043e\u043a, \u0447\u0442\u043e \u0433\u043b\u0430\u0437\u0430 \u0440\u0430\u0437\u0431\u0435\u0433\u0430\u044e\u0442\u0441\u044f. \u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u043c \u0446\u0438\u043a\u043b \u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0435\u0440\u0432\u0438\u043d\u0433\u0430 \u043e\u0434\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438, \u043d\u043e \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438. \u0412 \u043f\u0440\u043e\u0448\u043b\u044b\u0439 \u0440\u0430\u0437 <a href=\"https:\/\/habr.com\/ru\/post\/717890\/\" rel=\"noopener noreferrer nofollow\">\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/a> \u0431\u044b\u043b\u0430 \u043d\u0430 Nvidia Triton Inference Serve (\u0437\u0430 \u0430\u043d\u043e\u043d\u0441\u0430\u043c\u0438 \u043f\u0440\u043e\u0448\u0443 \u0432 \u043c\u043e\u0439 <a href=\"https:\/\/t.me\/yet_another_mle\" rel=\"noopener noreferrer nofollow\">\u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c \u043a\u0430\u043d\u0430\u043b<\/a>. \u041a\u043e\u0434 \u043a \u0441\u0442\u0430\u0442\u044c\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 <a href=\"https:\/\/github.com\/EgShes\/one_task_multiple_infras\" rel=\"noopener noreferrer nofollow\">\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438<\/a>.<\/p>\n<h2>\u0417\u0430\u0434\u0430\u0447\u0430<\/h2>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0432\u0437\u044f\u0442\u043e \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u0440\u043e\u0441\u0441\u0438\u0439\u0441\u043a\u0438\u0445 \u0430\u0432\u0442\u043e\u043c\u043e\u0431\u0438\u043b\u044c\u043d\u044b\u0445 \u043d\u043e\u043c\u0435\u0440\u043e\u0432. \u041c\u043e\u0434\u0435\u043b\u0438 \u0431\u044b\u043b\u0438 \u0432\u0437\u044f\u0442\u044b \u0438\u0437 \u044d\u0442\u043e\u0433\u043e <a href=\"https:\/\/github.com\/EtokonE\/License_Plate_Recognition\" rel=\"noopener noreferrer nofollow\">\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f<\/a>.<\/p>\n<p>\u041f\u0430\u0439\u043f\u043b\u0430\u0439\u043d \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439:<br \/> 1. \u0414\u0435\u0442\u0435\u043a\u0446\u0438\u044f \u043d\u043e\u043c\u0435\u0440\u043e\u0432 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Yolov5;<br \/> 2. \u0412\u044b\u0440\u0435\u0437\u0430\u043d\u043d\u044b\u0435 \u043d\u043e\u043c\u0435\u0440\u0430 \u043f\u0440\u043e\u0433\u043e\u043d\u044f\u044e\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 Spatial transformer (STN) \u0434\u043b\u044f \u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u044f;<br \/> 3. \u0422\u0435\u043a\u0441\u0442 \u043d\u043e\u043c\u0435\u0440\u0430 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0435\u0442\u0441\u044f \u0441 LPR-net.<\/p>\n<h2>\u0424\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a<\/h2>\n<p>\u0414\u043b\u044f \u0438\u043d\u0444\u0435\u0440\u0435\u043d\u0441\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f [TorchServe]. \u0414\u0430\u043d\u043d\u044b\u0439 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u044c\u044e \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u044b Pytorch. \u041e\u043d \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u0435\u0442\u0441\u044f.<\/p>\n<p>\u0412 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043e \u043d\u0435\u043c \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<blockquote>\n<p>TorchServe is a performant, flexible and easy to use tool for serving PyTorch eager mode and torschripted models.<\/p>\n<\/blockquote>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438:<\/p>\n<ul>\n<li>\n<p>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 <a href=\"https:\/\/github.com\/pytorch\/serve\/blob\/master\/docs\/performance_guide.md\" rel=\"noopener noreferrer nofollow\">\u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u0432<\/a> \u043c\u043e\u0434\u0435\u043b\u0435\u0439 (torchscript, onnx, ipex, tensorrt);<\/p>\n<\/li>\n<li>\n<p>\u041e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0432 \u043e\u0434\u0438\u043d <a href=\"https:\/\/github.com\/pytorch\/serve\/blob\/master\/examples\/Workflows\/README.md\" rel=\"noopener noreferrer nofollow\">\u0433\u0440\u0430\u0444\/workflow<\/a>;<\/p>\n<\/li>\n<li>\n<p>\u0418\u043d\u0444\u0435\u0440\u0435\u043d\u0441 <a href=\"https:\/\/github.com\/pytorch\/serve\/blob\/master\/docs\/inference_api.md\" rel=\"noopener noreferrer nofollow\">API<\/a> (REST \u0438 GRPC);<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/pytorch\/serve\/blob\/master\/docs\/management_api.md\" rel=\"noopener noreferrer nofollow\">API<\/a> \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u044f\u043c\u0438;<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/pytorch\/serve\/blob\/master\/docs\/metrics.md\" rel=\"noopener noreferrer nofollow\">\u041c\u0435\u0442\u0440\u0438\u043a\u0438<\/a> \u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438.<\/p>\n<\/li>\n<\/ul>\n<h2>\u041a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u0438<\/h2>\n<p>\u041a\u0430\u043a \u0438 Triton, TorchServe \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043f\u0435\u0440\u0435\u0432\u0435\u0441\u0442\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 \u0432 \u0441\u0432\u043e\u0439 \u0444\u043e\u0440\u043c\u0430\u0442. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0435\u0441\u0442\u044c \u0443\u0442\u0438\u043b\u0438\u0442\u044b <a href=\"https:\/\/github.com\/pytorch\/serve\/tree\/master\/model-archiver#torch-model-archiver-for-torchserve\" rel=\"noopener noreferrer nofollow\">torch-model-archiver<\/a> \u0438 <a href=\"https:\/\/github.com\/pytorch\/serve\/blob\/fd4e3e8b72bed67c1e83141265157eed975fec95\/workflow-archiver\/README.md\" rel=\"noopener noreferrer nofollow\">torch-workflow-archiver<\/a> \u0434\u043b\u044f \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0438 \u0433\u0440\u0430\u0444\u043e\u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e.<\/p>\n<p>\u0414\u043b\u044f \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e:<\/p>\n<ol>\n<li>\n<p>\u041c\u043e\u0434\u0435\u043b\u044c \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 TorchServe\/Onnx\/\u0434\u0440.;<\/p>\n<\/li>\n<li>\n<p>\u0421\u043a\u0440\u0438\u043f\u0442, \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d \u0440\u0430\u0431\u043e\u0442\u044b \u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<\/li>\n<\/ol>\n<p>\u0422\u0430\u043a\u043e\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f handler. \u0412 \u043d\u0435\u043c <a href=\"https:\/\/pytorch.org\/serve\/custom_service.html#custom-handler-with-class-level-entry-point\" rel=\"noopener noreferrer nofollow\">\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442\u0441\u044f<\/a> \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u044d\u0442\u0430\u043f\u044b \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430 \u043c\u043e\u0434\u0435\u043b\u0438 (\u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f, \u043f\u0440\u0435\u0434\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430, \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u0435, \u043f\u043e\u0441\u0442\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0438 \u0434\u0440.). \u0414\u043b\u044f \u0442\u0438\u043f\u043e\u0432\u044b\u0445 \u0437\u0430\u0434\u0430\u0447 \u043e\u043d\u0438 \u0443\u0436\u0435 <a href=\"https:\/\/pytorch.org\/serve\/#default-handlers\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u0435\u0434\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b<\/a>.<\/p>\n<p>\u041c\u043e\u0434\u0435\u043b\u0438 STN \u0438 LPR \u043b\u0435\u0433\u043a\u043e <a href=\"https:\/\/github.com\/EgShes\/one_task_multiple_infras\/blob\/master\/inference_torchserve\/inference_torchserve\/scripts\/README.md\" rel=\"noopener noreferrer nofollow\">\u043a\u043e\u043d\u0432\u0435\u0440\u0443\u044e\u0442\u0441\u044f<\/a> \u0432 TorchServe, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u0438\u0445 \u0445\u044d\u043d\u0434\u043b\u0435\u0440\u0430\u0445 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438. <a href=\"https:\/\/github.com\/EgShes\/one_task_multiple_infras\/blob\/master\/inference_torchserve\/inference_torchserve\/handlers\/stn.py\" rel=\"noopener noreferrer nofollow\">\u0418\u043c\u043f\u043e\u0440\u0442\u044b<\/a> \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"python\">import json import logging from abc import ABC import numpy as np import torch from ts.torch_handler.base_handler import BaseHandler <\/code><\/pre>\n<p>Yolo \u043d\u0435\u043b\u044c\u0437\u044f \u0431\u044b\u043b\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u0432\u0435\u0441\u0442\u0438 \u0432 TorchScript, \u0442\u0430\u043a \u043a\u0430\u043a \u0447\u0430\u0441\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0438 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043e\u0441\u0442\u0430\u0432\u0430\u043b\u0430\u0441\u044c \u0441\u043d\u0430\u0440\u0443\u0436\u0438 \u043c\u043e\u0434\u0435\u043b\u0438. \u0422\u0430\u043a \u043a\u0430\u043a \u043a\u043e\u043f\u0430\u0442\u044c\u0441\u044f \u0441 \u044d\u0442\u0438\u043c \u0436\u0435\u043b\u0430\u043d\u0438\u044f \u043d\u0435 \u0431\u044b\u043b\u043e, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0440\u0430\u0434\u0438 \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0438\u0431\u043b\u0438\u0436\u0435\u043d\u043d\u043e\u0433\u043e \u043a \u0436\u0438\u0437\u043d\u0438 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f, \u0432 \u0445\u044d\u043d\u0434\u043b\u0435\u0440\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 Yolo \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0438\u0437 <a href=\"https:\/\/github.com\/EgShes\/one_task_multiple_infras\/blob\/master\/inference_torchserve\/inference_torchserve\/handlers\/yolo.py\" rel=\"noopener noreferrer nofollow\">TorchHub<\/a>. \u0412 \u0438\u043c\u043f\u043e\u0440\u0442\u0430\u0445 \u043c\u044b \u0443\u0436\u0435 \u0432\u0438\u0434\u0438\u043c \u0438 \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0435 \u043c\u043e\u0434\u0443\u043b\u0438:<\/p>\n<pre><code class=\"python\">from inference_torchserve.data_models import PlatePrediction from nn.inference.predictor import prepare_detection_input, prepare_recognition_input from nn.models.yolo import load_yolo from nn.settings import settings <\/code><\/pre>\n<p>\u0427\u0442\u043e\u0431\u044b \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432 \u0434\u043e\u043a\u0435\u0440\u0444\u0430\u0439\u043b\u0435 <a href=\"https:\/\/github.com\/EgShes\/one_task_multiple_infras\/blob\/9c7ea4c92209ac67955cf956fe9e4209082b256b\/inference_torchserve\/docker\/dockerfiles\/DockerfileTorchServe#L53\" rel=\"noopener noreferrer nofollow\">\u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c<\/a> \u0432 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0432\u0430\u043c \u043f\u0430\u043a\u0435\u0442\u044b.<\/p>\n<p>\u0412 TorchServe \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0436\u0435\u0441\u0442\u043a\u043e \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u0442\u0438\u043f \u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u044c \u0432\u0445\u043e\u0434\u043e\u0432 \u0438 \u0432\u044b\u0445\u043e\u0434\u043e\u0432 \u043c\u043e\u0434\u0435\u043b\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0438\u043a\u0430\u043a\u0438\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0438 \u0434\u043b\u044f \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e. \u0421 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u044d\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u043e, \u0430 \u0441 \u0434\u0440\u0443\u0433\u043e\u0439 &#8212; \u043f\u043e\u0440\u043e\u0436\u0434\u0430\u0435\u0442 \u0445\u0430\u043e\u0441, \u0435\u0441\u043b\u0438 \u043d\u0435 \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a\u043e\u043c\u0443-\u0442\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u0444\u043e\u0440\u043c\u0430\u0442\u0443.<\/p>\n<p>\u041a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 zip \u0430\u0440\u0445\u0438\u0432 \u0441 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435\u043c <em>.mar<\/em>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043b\u0435\u0436\u0430\u0442 \u0432\u0441\u0435 \u0430\u0440\u0442\u0435\u0444\u0430\u043a\u0442\u044b (\u0441\u043b\u0443\u0436\u0435\u0431\u043d\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f, \u0432\u0435\u0441\u0430, \u0441\u043a\u0440\u0438\u043f\u0442\u044b \u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b).<\/p>\n<pre><code>. \u251c\u2500\u2500 MAR-INF \u2502\u00a0\u00a0 \u2514\u2500\u2500 MANIFEST.json \u251c\u2500\u2500 stn.pt \u2514\u2500\u2500 stn.py <\/code><\/pre>\n<p>\u041d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0441 \u0430\u0440\u0445\u0438\u0432\u043e\u043c \u043d\u0435\u0443\u0434\u043e\u0431\u043d\u043e \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438. \u041f\u043e\u0441\u043b\u0435 \u043b\u044e\u0431\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u043d\u043e\u0432\u043e \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c. \u0422\u0430\u043a\u0436\u0435 \u044f \u0438\u0441\u043f\u044b\u0442\u044b\u0432\u0430\u043b \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0432 \u043d\u0435\u043c \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0434\u0435\u0431\u0430\u0433\u0435\u0440\u0430.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b TorchServe \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u043b \u043c\u043e\u0434\u0435\u043b\u0438, \u0438\u0445 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u0432 \u043e\u0434\u043d\u0443 \u043f\u0430\u043f\u043a\u0443 &#8212; <code>model storage<\/code> \u0438 <a href=\"https:\/\/github.com\/EgShes\/one_task_multiple_infras\/blob\/9c7ea4c92209ac67955cf956fe9e4209082b256b\/inference_torchserve\/inference_torchserve\/config.properties#L1\" rel=\"noopener noreferrer nofollow\">\u0443\u043a\u0430\u0437\u0430\u0442\u044c<\/a> \u043f\u0443\u0442\u044c \u0434\u043e \u043d\u0435\u0435 \u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u0445. \u0427\u0442\u043e\u0431\u044b \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u043b\u0438\u0441\u044c \u0432\u0441\u0435 \u043c\u043e\u0434\u0435\u043b\u0438, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c <code>--models all<\/code>.<\/p>\n<h2>\u0414\u0435\u043b\u0430\u0435\u043c \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f<\/h2>\n<p>\u0412\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0439 \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u043d\u043e\u043c\u0435\u0440\u0430 \u0430\u0432\u0442\u043e\u043c\u043e\u0431\u0438\u043b\u044f \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u043c\u043e\u0434\u0435\u043b\u044f\u043c\u0438. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 TorchServe \u0435\u0441\u0442\u044c <a href=\"https:\/\/pytorch.org\/serve\/workflows.html\" rel=\"noopener noreferrer nofollow\">Workflow<\/a>. \u041e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0437\u0430\u0434\u0430\u0442\u044c \u043a\u0430\u043a \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439, \u0442\u0430\u043a \u0438 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0439 \u0433\u0440\u0430\u0444 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438:<\/p>\n<pre><code class=\"yaml\"># \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439  dag:   pre_processing : [m1]   m1 : [m2]   m2 : [postprocessing] <\/code><\/pre>\n<pre><code>input -> function1 -> model1 -> model2 -> function2 -> output <\/code><\/pre>\n<pre><code class=\"yaml\"># \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0439 \u0433\u0440\u0430\u0444 dag:   pre_processing: [model1, model2]   model1: [aggregate_func]   model2: [aggregate_func] <\/code><\/pre>\n<pre><code>                          model1                          \/       \\ input -> preprocessing ->         -> aggregate_func                          \\       \/                           model2 <\/code><\/pre>\n<p>\u0414\u043b\u044f \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 <a href=\"https:\/\/github.com\/EgShes\/one_task_multiple_infras\/tree\/master\/inference_torchserve\/inference_torchserve\/scripts#plate-recognition\" rel=\"noopener noreferrer nofollow\">\u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f<\/a> \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e-\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0439 <a href=\"https:\/\/github.com\/EgShes\/one_task_multiple_infras\/blob\/master\/inference_torchserve\/inference_torchserve\/workflow\/plate_recognition.yaml\" rel=\"noopener noreferrer nofollow\">\u0433\u0440\u0430\u0444<\/a>. \u0423\u0437\u0435\u043b aggregate \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0435\u0442 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043d\u043e\u043c\u0435\u0440\u043e\u0432 \u0441 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u043d\u043d\u044b\u043c\u0438 \u0442\u0435\u043a\u0441\u0442\u0430\u043c\u0438.<\/p>\n<pre><code>    \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2510     \u2502 YOLO \u251c\u2500\u2500\u2500\u2500\u2500\u2510     \u2514\u2500\u2500\u252c\u2500\u2500\u2500\u2518     \u2502        \u2502         v        \u2502      \u250c\u2500\u2500\u2500\u2500\u2500\u2510 plate  \u2502      \u2502 STN \u2502 coords \u2502      \u2514\u2500\u2500\u252c\u2500\u2500\u2518        \u2502         \u2502        \u2502         v        \u2502      \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2510        \u2502      \u2502LPRNET\u2502        \u2502      \u2514\u2500\u2500\u252c\u2500\u2500\u2500\u2518        v         \u2502    \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510   \u2502 plate    \u2502aggregate\u2502&lt;\u2500\u2500\u2518 texts    \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518 <\/code><\/pre>\n<p>\u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u0435\u0436\u0434\u0443 \u043c\u043e\u0434\u0435\u043b\u044f\u043c\u0438 <a href=\"https:\/\/github.com\/EgShes\/one_task_multiple_infras\/blob\/9c7ea4c92209ac67955cf956fe9e4209082b256b\/inference_torchserve\/inference_torchserve\/handlers\/stn.py#L37\" rel=\"noopener noreferrer nofollow\">\u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f<\/a> \u0432 \u0432\u0438\u0434\u0435 \u0441\u043b\u043e\u0432\u0430\u0440\u0435\u0439. \u0421\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0442\u0430\u043a\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 TorchServe \u0432\u0435\u0441\u044c\u043c\u0430 <a href=\"https:\/\/github.com\/pytorch\/serve\/blob\/d0510ba4fb6bd63a10eb1af1660155e7376ebcaf\/ts\/protocol\/otf_message_handler.py#L136\" rel=\"noopener noreferrer nofollow\">\u043d\u0435\u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u0430<\/a> (\u043f\u0435\u0440\u0435\u0432\u043e\u0434\u044f\u0442 \u0432 \u0441\u0442\u0440\u043e\u043a\u0443 \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u043e\u0432 \u0441\u0442\u0440\u043e\u043a), \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u0442\u0430\u0440\u0430\u0439\u0442\u0435\u0441\u044c \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u0445 \u043a\u0430\u043a \u0442\u0435\u043d\u0437\u043e\u0440\u044b \u0438\u043b\u0438 \u0431\u0430\u0439\u0442\u044b.<\/p>\n<p>\u0423\u0447\u0442\u0438\u0442\u0435, \u0447\u0442\u043e workflow \u043d\u0435\u043b\u044c\u0437\u044f \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u0430\u0442\u044c \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 &#8212; \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u044f\u0432\u043d\u043e \u043f\u043e\u0441\u043b\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u044d\u0442\u043e. \u0415\u0441\u043b\u0438 \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u0438 \u043f\u043e\u0434\u043d\u044f\u0442\u0438\u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u0442\u043e \u043c\u043e\u0436\u043d\u043e <a href=\"https:\/\/github.com\/EgShes\/one_task_multiple_infras\/blob\/9c7ea4c92209ac67955cf956fe9e4209082b256b\/inference_torchserve\/docker\/dockerfiles\/DockerfileTorchServe#L76\" rel=\"noopener noreferrer nofollow\">\u0442\u0430\u043a<\/a>.<\/p>\n<pre><code class=\"bash\">curl -X POST http:\/\/localhost:8081\/workflows?url=plate_recognition <\/code><\/pre>\n<h2>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0435\u0439<\/h2>\n<p>\u041c\u043e\u0434\u0435\u043b\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b. \u0421\u0435\u0440\u0432\u0435\u0440 \u0437\u0430\u043f\u0443\u0449\u0435\u043d.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u0443\u044e \u0440\u0430\u043d\u0435\u0435 \u043c\u043e\u0434\u0435\u043b\u044c \u0438\u043b\u0438 workflow \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0441\u043b\u0430\u0442\u044c \u0432 TorchServe \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 plate_recognition (\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f <a href=\"https:\/\/pytorch.org\/serve\/rest_api.html\" rel=\"noopener noreferrer nofollow\">REST<\/a>, \u043d\u043e \u0435\u0441\u0442\u044c \u0435\u0449\u0435 \u0438 <a href=\"https:\/\/pytorch.org\/serve\/grpc_api.html\" rel=\"noopener noreferrer nofollow\">GRPC<\/a>). \u0414\u043b\u044f \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u044d\u043d\u0434\u043f\u043e\u0438\u043d\u0442 <code>predictions<\/code>, \u0430 \u0434\u043b\u044f workflow <code>wfpredict<\/code>.<\/p>\n<pre><code class=\"python\">response = requests.post(     \"http:\/\/localhost:8080\/predictions\/yolo\", data=image.open(\"rb\").read() )  response = requests.post(     \"http:\/\/localhost:8080\/wfpredict\/plate_recognition\",      data=image.open(\"rb\").read() ) <\/code><\/pre>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u041d\u0443 \u0432\u043e\u0442 \u0438\u043d\u0444\u0435\u0440\u0435\u043d\u0441 \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d. \u0414\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0435 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439, \u0447\u0442\u043e\u0431\u044b \u0431\u044b\u0442\u044c \u0432 \u0446\u0435\u043b\u043e\u043c \u0431\u0435\u0441\u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c, \u043d\u043e \u0438 \u043d\u0435 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0441\u043b\u043e\u0436\u043d\u044b\u0439, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043a\u0440\u044b\u0442\u044c \u0432\u0441\u0435 \u0444\u0438\u0448\u043a\u0438 \u044d\u0442\u043e\u0433\u043e \u0444\u0440\u0435\u0439\u043c\u043e\u0432\u0440\u043a\u0430 \u0434\u043b\u044f \u0438\u043d\u0444\u0435\u0440\u0435\u043d\u0441\u0430.<\/p>\n<p>\u0412 \u044d\u0442\u043e\u043c \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0435 \u0431\u044b\u043b\u0438 \u0440\u0430\u0441\u043a\u0440\u044b\u0442\u044b \u043d\u0435 \u0432\u0441\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 TorchServe, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u043e\u0432\u0435\u0442\u0443\u044e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043f\u0440\u043e:<\/p>\n<ul>\n<li>\n<p>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 <a href=\"https:\/\/github.com\/pytorch\/serve\/blob\/master\/examples\/captum\/Captum_visualization_for_bert.ipynb\" rel=\"noopener noreferrer nofollow\">explanations<\/a>;<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/pytorch.org\/serve\/metrics.html\" rel=\"noopener noreferrer nofollow\">\u0421\u043d\u044f\u0442\u0438\u0435<\/a> \u043c\u0435\u0442\u0440\u0438\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0435\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430;<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/pytorch.org\/serve\/batch_inference_with_ts.html\" rel=\"noopener noreferrer nofollow\">\u0411\u0430\u0442\u0447\u0435\u0432\u0430\u043d\u0438\u0435<\/a>.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0439\u0442\u0435\u0441\u044c \u043d\u0430 \u043c\u043e\u0439 <a href=\"https:\/\/t.me\/yet_another_mle\" rel=\"noopener noreferrer nofollow\">\u043a\u0430\u043d\u0430\u043b<\/a> &#8212; \u0442\u0430\u043c \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u044e \u043f\u0440\u043e \u043d\u0435\u0439\u0440\u043e\u043d\u043a\u0438 \u0441 \u0443\u043f\u043e\u0440\u043e\u043c \u0432 \u0441\u0435\u0440\u0432\u0438\u043d\u0433.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/727484\/\"> https:\/\/habr.com\/ru\/articles\/727484\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-407395","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/407395","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=407395"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/407395\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=407395"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=407395"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=407395"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}