I am using Flutter in Android Studio. I trained a model in YOLOv7 (Roboflow) and I converted the model to TFlite in Google Colab with this website as reference: Export Yolo V7 to Tensorflow Lite
My Colab code:
!pip install onnx onnxruntime onnxsim onnx-tf
!git clone https://github.com/WongKinYiu/yolov7.git
%cd yolov7
!wget https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7.pt
!pip install -r requirements.txt
from google.colab import drive
drive.mount('/content/gdrive')
!cp /content/gdrive/MyDrive/best.pt /content/yolov7
!python export.py --weights /content/yolov7/best.pt --grid --end2end --simplify \
--topk-all 100 --iou-thres 0.65 --conf-thres 0.35 --img-size 640 640 --max-wh 640
!pip install tensorflow tensorflow_probability
!mkdir tfmodel
!onnx-tf convert -i best.onnx -o tfmodel/
import tensorflow as tf
converter = tf.lite.TFLiteConverter.from_saved_model('tfmodel/')
tflite_model = converter.convert()
with open('tfmodel/best.tflite', 'wb') as f:
f.write(tflite_model)
After deploying it on my object detection app, I get the following error: Failed to initialize detector. The input tensor should have dimensions 1 x height x width x 3. Got 1 x 3 x 640 x 640., null, null).
I believe the issue is the channel? How should I fix this error?