Nuclio 모델배포 : custom model 

Published by onesixx on

모델배포 : custom model – mmdetection

0. inference demo 확인

https://onesixx.com/inference-demo/

main.py의 handler작성을 위해 inference demo확인 ( init_detector, inference_detector, [show_result_pyplot])

https://onesixx.com/mmdet-inference/

demo/image_demo.py —[copy]—>demo_img.py

Shell
  • Config파일 만들기 (work_dirs/faster_rcnn/faster_rcnn.py)
  • CheckPoint파일 확인 (work_dirs/faster_rcnn/lastest.pth)

1. MakeConfig

Shell

https://onesixx.com/mmdet-train/ 참고

Dataset 수집/구성/> Model 선정/checkpoint > config 수정 > Training

2. dockerfile

Shell
Shell
YAML/YML
/dockerfile

function.yaml

YAML/YML
function.yaml

외부에서 해당 모델을 통해 접근을 위한 설정

nuclio function의 포트번호와 cvat network를 지정

spec.triggers.myHttpTrigger.attributes에 특정 port를 추가하고, 
spec.platform.attributes 에 도커 컴포즈를 실행했을 때 생성된 도커 네트워크(cvat_cvat)를 추가.

YAML/YML
function.yaml

Nuclio에 적용

2. 로컬에서 DL모델을 실행하기 위한 소스코드를 Nuclio 플랫폼에 적용

2-1 모델을 메모리에 로딩 (init_context(context)함수를 사용하여)

https://nuclio.io/docs/latest/concepts/best-practices-and-common-pitfalls/#use-init_context-instead-of-global-variable-declarations-or-function-calls

Python
init_context

main.py

from inference demo

Python
/demo_img.py 수정

2-2 아래 프로세스를 위해 handler에 entry point를 정의하고, main.py에 넣는다.

  • accept incoming HTTP requests
  • run inference
  • reply with detection results

main.py

Python
main.py
Python
main.py
Python
main.py

3. deploy

새로운 serverless 함수를 사용하기 위해서는
(위 Builtin model에서 했던것처럼) nuctl 명령어로 deploy를 해야한다.

  • function.yaml
  • main.py
  • model_handler.py

방법1)

Shell

방법2)

Shell
Shell

Issue

https://github.com/opencv/cvat/issues/3457 : Steps for custom model deployment

http://How to upload DL which built by myself? : How to upload DL which built by myself?

https://github.com/opencv/cvat/issues/5551 : Mmdetection MaskRCNN serverless support for semi-automatic annotation

https://github.com/opencv/cvat/issues/4909: Load my own Yolov5 model on cvat by nuclio

mmdetection 모델변환

https://mmdetection.readthedocs.io/en/latest/useful_tools.html#model-conversion

Exporting MMDetection models to ONNX format
https://medium.com/axinc-ai/exporting-mmdetection-models-to-onnx-format-3ec839c38ff

openvino : https://da2so.tistory.com/63

Serving pre-trained ML/DL models
https://docs.mlrun.org/en/stable/tutorial/03-model-serving.html#serving-pre-trained-ml-dl-models

docker 정리

더 이상 컨테이너에 연결되지 않고, 태그가 없어진 이미지를 Dangling image

https://sarc.io/index.php/aws/1921-docker

HTML
HTML

Categories: vision

onesixx

Blog Owner

guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x