margaretmz / Cartoonizer-with-TFLite

How to create a Cartoonizer Android app with TensorFlow Lite models.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fix metadata in tflite models

margaretmz opened this issue · comments

I figured out the (black) image issue on Android! It was caused by incorrect image post processing (from tflite metadata).

@sayakpaul please fix the metadata in the tflite models as follows:
update from
output_image_normalization.options.mean = [0.0] output_image_normalization.options.std = [1.0]
to
output_image_normalization.options.mean = [-1]. output_image_normalization.options.std = [0.00784313] # 1/127.5

I have verified that this will mirror the post processing in the conversion notebook, and it works on Android.

cc: @khanhlvg

When adding metadata to the tflite models, I also find it helpful to put a date stamp in the version code for example something like this: v3_2020-08-03. Otherwise it's really difficult for me to keep track of the various model versions.

FYI here is what the int8 one look like on Android after I fixed the metadata issue:

image

I'm excited to finish the app and looking forward to our E2E tutorial.

commented

This is super exciting! Thanks Margaret :)

@margaretmz thanks so much for your hard work on this. I have updated everything as per your feedback.

Updated Colab Notebooks:

Model files:

Let me know if anything is unclear.

Thanks @sayakpaul for the updates! The int8 and dr models now work in Android.
FP16 one still crashes and I asked @khanhlvg to help take a look at it.

Fair enough @margaretmz. Thank you for the updates.

Closing this issue. As @khanhlvg provided some guidance here: #6