minivision-ai / Silent-Face-Anti-Spoofing

静默活体检测(Silent-Face-Anti-Spoofing)
Apache License 2.0
1.35k stars 447 forks source link

Converting Fine-tuned Weights for Mobile Deployment #129

Open KaranBhuva22 opened 3 months ago

KaranBhuva22 commented 3 months ago

Hello,

Thank you for developing the open-source silent anti-spoofing project! I'm currently working on integrating it into my application and have successfully fine-tuned your base models (versions 2.7_80x80_MiniFASNetV2.pth and 4_0_0_80x80_MiniFASNetV1SE.pth) by modifying the code.

To deploy these models on Android and iOS devices, I need them in a binary format. While you offer pre-built binaries for the base models, I'd like to convert my fine-tuned weights for optimal performance. Unfortunately, converting them myself with Caffe seems impractical as the framework hasn't received updates since 2020. I have tried to convert pth -> caffe -> ncnn but this solution works for the first model (2.7_80x80_MiniFASNetV2.pth), it's not compatible with the second model (4_0_0_80x80_MiniFASNetV1SE.pth). This is because the second model uses an SE module, which is not supported by the Pytorch2Caffe library.

I would greatly appreciate your assistance in converting our fine-tuned weights into a binary format suitable for mobile deployment. Since the conversion code isn't publicly available, any guidance or support would be extremely helpful.

@zhuyingSeu , @minivision-ailab

cao-nv commented 2 days ago

I think Pytorch -> PNNX (new NCNN format to handle Pytorch model better) -> NCNN. You can get both ONNX, PNNX, and NCNN in one go.

KaranBhuva22 commented 2 days ago

@cao-nv thanks I will look into it.