tensorflow 2.x object detection api & snpe ] dlc 변환
▼ snapdrgon 기기에서 머신러닝을 지원하는 snpe sdk
Snapdragon Neural Processing Engine SDK: Main Page
Snapdragon Neural Processing Engine SDK Reference Guide
developer.qualcomm.com
▼ tensorflow의 saved-model을 바로 dlc로 변환할 수 있다.
Snapdragon Neural Processing Engine SDK: Tools
This chapter describes the various SDK tools and features. snpe-net-run snpe-net-run loads a DLC file, loads the data for the input tensor(s), and executes the network on the specified runtime. DESCRIPTION: ------------ Example application demonstrating ho
developer.qualcomm.com
▼ 지원하는 레이어들
Snapdragon Neural Processing Engine SDK: Supported Network Layers
Supported Network Layers SNPE supports the network layer types listed in the table below. See Limitations for details on the limitations and constraints for the supported runtimes and individual layer types. All of supported layers in GPU runtime are valid
developer.qualcomm.com
상사분이 예전에 tf 1.x 버전의 ssd mobilenet v1을 변환해본 적이 있다고 하셔서
tf 2.x의 ssd mobilenet v2를 변환해보았는데 ( saved-model -> dlc )
dlc로 변환할때 대부분의 레이어를 변환할 수 없다며 불완전하게 작업이 종료된다.
하소연)
위의 지원하는 레이어들 목록에 없는 relu6 같은 없음직하다 싶은 레이어들 외에도 일반적인 convolution 까지도 변환이 안되어서
saved-model -> onnx -> dlc를 시도해보니 이번에는 convolution의 padding이 비대칭이라고 안된다.
[0, 0, 1, 1] 이런 식이면 안되고 [0, 1, 0, 1] 등등 앞의 둘 뒤의 둘이 대칭이어야 했던 듯
onnx를 수정하여 conv 노드에서 패딩을 하지 않도록 하고 conv 노드 앞에 pad 노드를 추가하여 해결하였으나
nms 레이어를 지원하지 않으니 불완전하게 raw_detection_scores, raw_detection_boxes를 가져다가
tensorflow의 nms를 사용해야 결과를 얻을 수 있었다.
아무튼 saved-model -> dlc 과정에서 convolution까지 변환을 못하는것이 이상해서 검색해보니
tf od api의 특정 커밋 이후부터 saved-model을 다른 포맷으로 변환할때 문제가 생긴다고 한다.
exporter_main_v2.py on official TF2 OD checkpoints produces saved_model.pb different than official saved_model.pb · Issue #1012
Please make sure that this is a bug. As per our GitHub Policy, we only address code/doc bugs, performance issues, feature requests and build/installation issues on GitHub. tag:bug_template System i...
github.com
위의 페이지의 답글들을 따라 특정 커밋시점 이전의 코드를 통해 saved-model을 생성하면
ssd mobilenet v2 saved-model -> dlc 변환이 잘 된다.
git clone https://github.com/tensorflow/models.git
cd models/research
git checkout --detach 420a725
protoc object_detection/protos/*.proto --python_out=.
python -m pip install --use-feature=2020-resolver .