Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix : "cannot convert between a tensorflow lite buffer with 602112 bytes and a bytebuffer with 150528 bytes" #6

Open
jeongiin opened this issue Nov 11, 2020 · 0 comments

Comments

@jeongiin
Copy link
Owner

jeongiin commented Nov 11, 2020

오류 수정
위 깃헙을 많이 참고하여 오류를 수정했다.

오류 원인 result 배열과 이미지 bitmap 변환 시 float 배열을 사용하지 않았기 때문이었다.

1. convertBitmapToByteBuffer

imgData.putFloat(((value shr 16 and 0xFF)- IMAGE_MEAN )/ IMAGE_STD)
                imgData.putFloat(((value shr 8 and 0xFF) - IMAGE_MEAN)/ IMAGE_STD)
                imgData.putFloat(((value and 0xFF)- IMAGE_MEAN)/ IMAGE_STD)

2. Initialize

private var labelProb: Array<FloatArray>

3. SetKey.kt

const val IMAGE_MEAN: Int = 128 //0
const val IMAGE_STD: Float = 128.0f //0.toFloat

위 세 부분을 위와 같이 변경해주었더니 원하는 결과를 얻을 수 있었다.

참고 링크

kotlin Code 참고

기본 model 생성 Code 참고

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant