surendramaran / YOLOv8-TfLite-Object-Detector

A sample android application of live object detection for any YOLOv8 detection model
https://www.surendramaran.com/
81 stars 23 forks source link

Android app crashes #5

Open parmarth-1208 opened 8 months ago

parmarth-1208 commented 8 months ago

When we run android app using float32 tflite model which we trained on image size 640 and yolov8m the app crashes so is it because of the size and yolov8m or what can be the problem im already trying to re-train my model on yolov8n and size 265 so will this solve my issue?

surendramaran commented 8 months ago

I understand, just use a resolution which is divisible by 32.

Try to train in that way.

Share with me your model's input and output shapes, In case you don't know then Go to https://netron.app And upload your model, then click on the properties and share the input and output shape .

On Fri, 15 Mar, 2024, 2:38 PM parmarth-1208, @.***> wrote:

When we run android app using float32 tflite model which we trained on image size 640 and yolov8m the app crashes so is it because of the size and yolov8m or what can be the problem im already trying to re-train my model on yolov8n and size 265 so will this solve my issue?

— Reply to this email directly, view it on GitHub https://github.com/surendramaran/YOLOv8-TfLite-Object-Detector/issues/5, or unsubscribe https://github.com/notifications/unsubscribe-auth/APXHH4KWMH7A2VSKA6XTSWDYYK3BXAVCNFSM6AAAAABEXTXR2KVHI2DSMVQWIX3LMV43ASLTON2WKOZSGE4DQMBUGI4TMOA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

parmarth-1208 commented 8 months ago

tensor: float32[1,640,640,3] input shape tensor: float32[1,14,8400] output shape

surendramaran commented 8 months ago

Any update on the new model? or share crash logs. The input and output shapes looks fine.

parmarth-1208 commented 8 months ago

tensor: float32[1,256,256,3] input shape tensor: float32[1,40,1344] output shape The Android crashes within few seconds without detection what can be the issue images resolution is also 256 and yolov8n model.

surendramaran commented 8 months ago

Can you check your lebal.txt file is it in the same format as it is in this repository, if this is fine then please share with me your model and the lebal.txt file to my email surendramaran8@gmail.com

parmarth-1208 commented 8 months ago

Hey done with the Android, thankyou for your help. Actually I'm developing a anpr system and in order to maintain a datasheet of detected number plates I'm coding the detection and storage process. For that I want path of "yolov8.weights" and "yolov8.cfg" I'm not getting what path should I replace this with if possible please help

surendramaran commented 7 months ago

Unfortunately I have not heard of these terms. If you can refrence any documentation regarding this, maybe I will understand.

HimangsKalita commented 7 months ago

Can you check your lebal.txt file is it in the same format as it is in this repository, if this is fine then please share with me your model and the lebal.txt file to my email surendramaran8@gmail.com

I also have the same issue here are my model properties

image

I have mailed you my model and labels can you please check subject should be yolo app crash

surendramaran commented 7 months ago

Sent your .pt file as well. This tflite throwed error when I tried to run in ultralytics environment.

On Tue, 23 Apr, 2024, 4:58 PM Himangshu Kalita, @.***> wrote:

It can detect 3 classes laptop, wallet and window class

On Mon, Apr 22, 2024 at 2:14 PM Surendra Maran @.***> wrote:

@HimangsKalita https://github.com/HimangsKalita How many classes your model can detect? by looking at the output it seems me 11, but your lebals.txt have 10 classes?

— Reply to this email directly, view it on GitHub < https://github.com/surendramaran/YOLOv8-TfLite-Object-Detector/issues/5#issuecomment-2068830930>,

or unsubscribe < https://github.com/notifications/unsubscribe-auth/AMLZD5MC6BGN2HLS5VRGVADY6TEVTAVCNFSM6AAAAABEXTXR2KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANRYHAZTAOJTGA>

. You are receiving this because you were mentioned.Message ID: @.*** com>

— Reply to this email directly, view it on GitHub https://github.com/surendramaran/YOLOv8-TfLite-Object-Detector/issues/5#issuecomment-2072053495, or unsubscribe https://github.com/notifications/unsubscribe-auth/APXHH4I3LEPT4Q5AG4GVSA3Y6ZAVTAVCNFSM6AAAAABEXTXR2KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANZSGA2TGNBZGU . You are receiving this because you commented.Message ID: @.*** com>

surendramaran commented 7 months ago

It is in private mode now

surendramaran commented 7 months ago

Your model isn't yolov8, it is yolov5, this repository is only intended for Yolov8. I can't help you with that. Thanks

HimangsKalita commented 7 months ago

at. Th

My bad I trained for both yolov5 and yolov8, and mistakenly put yolov5 file in assets. This time I tried again with yolov8 file it is working great

The detection speed is slow maybe because I trained model with images 640X640 resolution I will train again in 320X320 it might help

Untitled

ZubairAhmad97 commented 7 months ago

how to inference this

Screenshot from 2024-04-24 16-39-47

surendramaran commented 7 months ago

Is it trained in Yolov8 ?

ZubairAhmad97 commented 7 months ago

yes

surendramaran commented 7 months ago

Did you do anything different then usual to export? Please share with me your model.pt file

ZubairAhmad97 commented 7 months ago

!yolo export model= '/content/gdrive/MyDrive/Drone/yolov8/new_file/yolov8s.pt' format='tflite' int8 imgsz = 256

my actual model is float32 but quantized it using above CLI for better speed

surendramaran commented 7 months ago

I have exported tflite with int8 many times, it is the first time I saw int8 input and output type. Thanks for reporting, I will make changes in my code to adapt int8 tflite.

Kindly also share the ultralytics version that you used.

ZubairAhmad97 commented 7 months ago

Screenshot from 2024-04-25 10-13-27

ZubairAhmad97 commented 7 months ago

I have exported tflite with int8 many times, it is the first time I saw int8 input and output type. Thanks for reporting, I will make changes in my code to adapt int8 tflite.

Kindly also share the ultralytics version that you used.

While exporting its generating multiple files among that file one fully quantized file is there whose input and output is int8

surendramaran commented 7 months ago

I understood now. Well try using that file in ultralytics environment. It won't there as well. the actual int8 quantized model is only best_int8.tflite

surendramaran commented 7 months ago

Oh wait it worked this time, I don't know why it didn't work before. I should look more into this.

ZubairAhmad97 commented 7 months ago

Oh wait it worked this time, I don't know why it didn't work before. I should look more into this.

ok if you get any improvement in speed due to this please let me know

cjs2000 commented 3 months ago

How to convert YOLOV8n.pt model to tflite format? I am using the official conversion method:

from ultralytics import YOLO model = YOLO(r'run\yolov8n\weights\best.pt') model.export(format="tflite",opset=13,batch=1)

But the converted model was placed in the assets folder, and then the Android program crashed