xiang-wuu / ncnn-android-yolov7

Android Live Demo inferenece of Yolov7 using ncnn
GNU General Public License v3.0
126 stars 36 forks source link

"Unsupported Java." and Using Custom Model Successfully #16

Open dadin852 opened 1 year ago

dadin852 commented 1 year ago

The project requires JDK11 and android-ndk-r21e. You need to download the NDK from github manually.

By the way, this is the version that doesn't need downgrading (2023/05/22) : https://drive.google.com/file/d/12IyuXRKKGG2Zh_PBLE6dPFCeEGQYuiNp/view?usp=sharing New a Native C++ project named "MyJNI" and replace the app/scr/main.

dadin852 commented 1 year ago

Next, go to these reference : https://youtu.be/PukcRMN-Hs0 https://youtu.be/gOvvzS1-RuI https://blog.csdn.net/qq_43268106/article/details/127139216

Finally, we need to change output name to Convolution, instead of Permute : 螢幕擷取畫面 (2) 螢幕擷取畫面 (3)

Thank @xiang-wuu so much for this example!

jhony2507 commented 1 year ago

Hi dadin852,

I followed the steps recommended by you and in the videos indicated, but I still have a problem. The application closes right after turning on the camera. Using the weights available here in git (assets/yolov7-tiny.bin and yolov7-tiny.param) the application works normally on my cell phone.

Do you have any ideas to help me? Below is the modified excerpt from yolo.cpp yolo-tuny-custom

dadin852 commented 1 year ago

Seems that you're using Premute outputs. Would you try to set Convolution as outputs? 239368588-2d584147-b114-4aec-9459-e59a6c61c1b2

jhony2507 commented 1 year ago

Seems that you're using Premute outputs. Would you try to set Convolution as outputs? 239368588-2d584147-b114-4aec-9459-e59a6c61c1b2

Thanks for your feedback dadin852!

Unfortunately, I don't think I have enough experience to make this change.

I'm exporting the trained weights from pytroch to onnx with the command:

python export.py --weights yolov7-tiny.pt --simplify --topk-all 100 --iou-thres 0.50 --conf-thres 0.15 --img-size 448 448 --max-wh 448

to export from onnx to ncnn use: ./onnx2ncnn yolov7-tiny.onnx yolov7-tiny.param yolov7-tiny.bin

Should the changes suggested by you be made directly in the generated .param file or in the onnx file?

Below I am sending the generated .param file. yolov7-tiny.zip

dadin852 commented 1 year ago

Open your .param in Netron website : Screenshot_20230519_222033_Chrome Then you'll see the convolution output names.

For your model, you may use : "/model.77/m.0/Conv_output_0" instead of "output" "/model.77/m.1/Conv_output_0" instead of "286" "/model.77/m.2/Conv_output_0" instead of "298"

jhony2507 commented 1 year ago

Open your .param in Netron website : Screenshot_20230519_222033_Chrome Then you'll see the convolution output names.

For your model, you may use : "/model.77/m.0/Conv_output_0" instead of "output" "/model.77/m.1/Conv_output_0" instead of "286" "/model.77/m.2/Conv_output_0" instead of "298"

dadin852

It worked!!

I greatly appreciate your help! It was extremely useful!