Create a mobile friendly pytorch model for action recognition, object detection and object tracking

username: pushpendrapratap
cooked: <p>the state of the art pytorch model should have the following capabilities:</p>
<ol>
<li>all of its layers and operations should be compatible with the native mobile devices (<code>Android</code> and <code>iOS</code>)</li>
<li>for <strong>Android</strong>: <code>pytorch -&gt; ONNX -&gt; TensorFlow -&gt; tflite</code>
</li>
<li>for <strong>iOS</strong>: <code>pytorch -&gt; coremltools -&gt; coreml</code>
</li>
<li>model should able to use hardware acceleration on mobile devices (if the mobile supports)</li>
</ol>
<p>Any help will be very much appreciated <img src="https://discuss.pytorch.org/images/emoji/apple/slightly_smiling_face.png?v=9" title=":slightly_smiling_face:" class="emoji" alt=":slightly_smiling_face:"><br>
Also, I’ve 2 months’ time frame for this. So, I’ll keep posting my progress here itself (just in case, if it can be of help to anyone).</p>

username: pushpendrapratap
cooked: <p>I have created a simple neural net (for image classification on CIFAR dataset, given on pytorch official docs 60 mins. blitz section). Now, after doing the following conversion:<br>
<code>pytorch -&gt; ONNX -&gt; TensorFlow -&gt; tflite</code></p>
<p>I’m using following code to convert <code>.pb -&gt; .tflite</code>:</p>
<pre><code class="lang-auto">converter = tf.compat.v1.lite.TFLiteConverter.from_frozen_graph(
    graph_def_file="../models/my_cifar_net.pb", input_arrays=["my_input"], output_arrays=["my_output"])

converter.optimizations = [tf.lite.Optimize.DEFAULT]
tf_lite_model = converter.convert()

with tf.io.gfile.GFile('../models/my_cifar_net.tflite', 'wb') as f:
    f.write(tf_lite_model)
</code></pre>
<p>All other converted models (like, <code>.pth, .onnx, .pb</code>) are giving correct output on an example data except <code>.tflite</code>, as I’m getting the following error:</p>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/5/8/581b5fbc2c4ac1d5f0ac9d7a881ef3736f9e95de.png" data-download-href="https://discuss.pytorch.org/uploads/default/581b5fbc2c4ac1d5f0ac9d7a881ef3736f9e95de" title="tflite_invoke_Screenshot_from_2020_07_13_17_20_51"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/5/8/581b5fbc2c4ac1d5f0ac9d7a881ef3736f9e95de_2_690x387.png" alt="tflite_invoke_Screenshot_from_2020_07_13_17_20_51" data-base62-sha1="czqFhwuyMBMbmXFa1Ax2ftydUh8" width="690" height="387" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/5/8/581b5fbc2c4ac1d5f0ac9d7a881ef3736f9e95de_2_690x387.png, https://discuss.pytorch.org/uploads/default/optimized/3X/5/8/581b5fbc2c4ac1d5f0ac9d7a881ef3736f9e95de_2_1035x580.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/5/8/581b5fbc2c4ac1d5f0ac9d7a881ef3736f9e95de_2_1380x774.png 2x" data-dominant-color="F3F5F4"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">tflite_invoke_Screenshot_from_2020_07_13_17_20_51</span><span class="informations">1745×980 143 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<p>And, I’m using following versions of diff. libraries:</p>
<ul>
<li>numpy==1.18.2</li>
<li>pandas==1.0.3</li>
<li>torch==1.5.1</li>
<li>torchvision==0.6.1</li>
<li>onnx==1.7.0</li>
<li>coremltools==4.0b1</li>
<li>onnxmltools==1.7.0</li>
<li>onnx-tf==1.6.0</li>
<li>tensorflow==2.2.0</li>
<li>tensorflow-addons==0.10.0</li>
</ul>