karanjakhar/yolov5-export-to-raspberry-pi

Running inference on YOLOV5-int8.tflite

Closed this issue · 8 comments

Thanks for your work.
Its working fine for quantized yolov5 fp16 model but did not work for int8 yolov5 model. Can you tell me on how I can change it for the int8 quantized models?

There are some slight changes we have to make to run it with int8. I will try to add those. Sorry for the delay.

There are some slight changes we have to make to run it with int8. I will try to add those. Sorry for the delay.

Thanks for the reply .I have completed the task .

could you please provide the int8 model example?

Thanks in advance!

Hello, I got the following error when launching

python3 yolov5_tflite_image_inference.py -w yolov5s-int8.tflite -i images/bus.jpg
ValueError: Cannot set tensor: Got value of type FLOAT32 but expected type UINT8 for input 446, name: input_1

Is something wrong with the conversion? I have followed the ultralytics indications...

Okey, I have fixed this error and now the image input array is in uint8 data type.
However, I get the following error now:

/home/pi/repos/yolov5-export-to-raspberry-pi/yolov5_tflite_inference.py:92: RuntimeWarning: invalid value encountered in true_divide
  ious = intersections / unions
Traceback (most recent call last):
  File "yolov5_tflite_image_inference.py", line 86, in <module>
    detect_image(opt.weights,opt.img_path,opt.img_size,opt.conf_thres,opt.iou_thres)
  File "yolov5_tflite_image_inference.py", line 42, in detect_image
    result_boxes = scale_coords(size,np.array(result_boxes),(original_size[1],original_size[0]))
  File "/home/pi/repos/yolov5-export-to-raspberry-pi/utils.py", line 35, in scale_coords
    coords[:, [0, 2]] -= pad[0]  # x padding
numpy.core._exceptions.UFuncTypeError: Cannot cast ufunc 'subtract' output from dtype('float64') to dtype('uint8') with casting rule 'same_kind'

Any idea in how to solve this?

Hello, how to solve the model reasoning of yolov5_int8 inference? I've been struggling with this problem recently.

Can you paste your problem here?

There are some slight changes we have to make to run it with int8. I will try to add those. Sorry for the delay.

Thanks for the reply .I have completed the task .

hello,Can you provide the yolov5-tflite-int8 inference code? I'm very interested in this。