안드로이드 Kotlin을 이용한 Tensorflow-lite 추론기

안드로이드를 이용해서 텐서플로우, 즉 케라스를 통해 만든 MobileNet 모델을 가지고 추론하는 방식. 모델의 용량은 약 8메가. 모바일넷 훈련은, 케라스에서 진행했으며, 최대한 용량을 줄여야 어플리케이션의 크기가 줄어들기 때문에 (직접 앱내에서 다운로드 할것이 아니라면) 파라미터 크기를 최대한 줄여야 한다. 코드 내 log함수는 그냥 toString()을 찍는 함수이다. 입력은 512 X 512 X 3채널 이미지이며, 출력은 성별과 나이가 출력 2개로 나온다. 훈련 파이선 코드는 이곳을 참조한다.

To inference, mobilenet model was pre built (8mb appox.). This will run on Android Kotlin. This model was trained with tensorflow and keras. MobileNet Model should be concise and small enough to be in mobile devices. log() method is just executing toString(), nothing special. Input tensor size is 512 x 512 x 3, and output is 2, age(0~1) and gender(0~1). training code is written in Python, which is here.

답글 남기기