Skip to content

Commit

Permalink
fix(examples): load_param always failed (Tencent#4001)
Browse files Browse the repository at this point in the history
  • Loading branch information
jedi007 authored Jul 6, 2022
1 parent 1892c25 commit 434e55c
Show file tree
Hide file tree
Showing 25 changed files with 52 additions and 52 deletions.
4 changes: 2 additions & 2 deletions examples/fasterrcnn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ static int detect_fasterrcnn(const cv::Mat& bgr, std::vector<Object>& objects)
// https://dl.dropboxusercontent.com/s/o6ii098bu51d139/faster_rcnn_models.tgz?dl=0
// ZF_faster_rcnn_final.caffemodel
// the ncnn model https://github.com/nihui/ncnn-assets/tree/master/models
if (!fasterrcnn.load_param("ZF_faster_rcnn_final.param"))
if (fasterrcnn.load_param("ZF_faster_rcnn_final.param"))
exit(-1);
if (!fasterrcnn.load_model("ZF_faster_rcnn_final.bin"))
if (fasterrcnn.load_model("ZF_faster_rcnn_final.bin"))
exit(-1);

// hyper parameters taken from
Expand Down
4 changes: 2 additions & 2 deletions examples/mobilenetssd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ static int detect_mobilenet(const cv::Mat& bgr, std::vector<Object>& objects)
// model is converted from https://github.com/chuanqi305/MobileNet-SSD
// and can be downloaded from https://drive.google.com/open?id=0ByaKLD9QaPtucWk0Y0dha1VVY0U
// the ncnn model https://github.com/nihui/ncnn-assets/tree/master/models
if (!mobilenet.load_param("mobilenet_ssd_voc_ncnn.param"))
if (mobilenet.load_param("mobilenet_ssd_voc_ncnn.param"))
exit(-1);
if (!mobilenet.load_model("mobilenet_ssd_voc_ncnn.bin"))
if (mobilenet.load_model("mobilenet_ssd_voc_ncnn.bin"))
exit(-1);

const int target_size = 300;
Expand Down
4 changes: 2 additions & 2 deletions examples/mobilenetv2ssdlite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ static int detect_mobilenetv2(const cv::Mat& bgr, std::vector<Object>& objects)
// original pretrained model from https://github.com/chuanqi305/MobileNetv2-SSDLite
// https://github.com/chuanqi305/MobileNetv2-SSDLite/blob/master/ssdlite/voc/deploy.prototxt
// the ncnn model https://github.com/nihui/ncnn-assets/tree/master/models
if (!mobilenetv2.load_param("mobilenetv2_ssdlite_voc.param"))
if (mobilenetv2.load_param("mobilenetv2_ssdlite_voc.param"))
exit(-1);
if (!mobilenetv2.load_model("mobilenetv2_ssdlite_voc.bin"))
if (mobilenetv2.load_model("mobilenetv2_ssdlite_voc.bin"))
exit(-1);

const int target_size = 300;
Expand Down
4 changes: 2 additions & 2 deletions examples/mobilenetv3ssdlite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ static int detect_mobilenetv3(const cv::Mat& bgr, std::vector<Object>& objects)
#endif // NCNN_VULKAN

// converted ncnn model from https://github.com/ujsyehao/mobilenetv3-ssd
if (!mobilenetv3.load_param("./mobilenetv3_ssdlite_voc.param"))
if (mobilenetv3.load_param("./mobilenetv3_ssdlite_voc.param"))
exit(-1);
if (!mobilenetv3.load_model("./mobilenetv3_ssdlite_voc.bin"))
if (mobilenetv3.load_model("./mobilenetv3_ssdlite_voc.bin"))
exit(-1);

const int target_size = 300;
Expand Down
4 changes: 2 additions & 2 deletions examples/nanodet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,9 @@ static int detect_nanodet(const cv::Mat& bgr, std::vector<Object>& objects)

// original pretrained model from https://github.com/RangiLyu/nanodet
// the ncnn model https://github.com/nihui/ncnn-assets/tree/master/models
if (!nanodet.load_param("nanodet_m.param"))
if (nanodet.load_param("nanodet_m.param"))
exit(-1);
if (!nanodet.load_model("nanodet_m.bin"))
if (nanodet.load_model("nanodet_m.bin"))
exit(-1);

int width = bgr.cols;
Expand Down
4 changes: 2 additions & 2 deletions examples/nanodetplus_pnnx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,9 @@ static int detect_nanodet(const cv::Mat& bgr, std::vector<Object>& objects)
// the ncnn model https://github.com/nihui/ncnn-assets/tree/master/models
// nanodet.load_param("nanodet-plus-m_320.torchscript.ncnn.param");
// nanodet.load_model("nanodet-plus-m_320.torchscript.ncnn.bin");
if (!nanodet.load_param("nanodet-plus-m_416.torchscript.ncnn.param"))
if (nanodet.load_param("nanodet-plus-m_416.torchscript.ncnn.param"))
exit(-1);
if (!nanodet.load_model("nanodet-plus-m_416.torchscript.ncnn.bin"))
if (nanodet.load_model("nanodet-plus-m_416.torchscript.ncnn.bin"))
exit(-1);

int width = bgr.cols;
Expand Down
4 changes: 2 additions & 2 deletions examples/p2pnet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ static int detect_crowd(const cv::Mat& bgr, std::vector<CrowdPoint>& crowd_point
// model is converted from
// https://github.com/TencentYoutuResearch/CrowdCounting-P2PNet
// the ncnn model https://pan.baidu.com/s/1O1CBgvY6yJkrK8Npxx3VMg pwd: ezhx
if (!net.load_param("p2pnet.param"))
if (net.load_param("p2pnet.param"))
exit(-1);
if (!net.load_model("p2pnet.bin"))
if (net.load_model("p2pnet.bin"))
exit(-1);

int width = bgr.cols;
Expand Down
4 changes: 2 additions & 2 deletions examples/peleenetssd_seg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ static int detect_peleenet(const cv::Mat& bgr, std::vector<Object>& objects, ncn
// model is converted from https://github.com/eric612/MobileNet-YOLO
// and can be downloaded from https://drive.google.com/open?id=1Wt6jKv13sBRMHgrGAJYlOlRF-o80pC0g
// the ncnn model https://github.com/nihui/ncnn-assets/tree/master/models
if (!peleenet.load_param("pelee.param"))
if (peleenet.load_param("pelee.param"))
exit(-1);
if (!peleenet.load_model("pelee.bin"))
if (peleenet.load_model("pelee.bin"))
exit(-1);

const int target_size = 304;
Expand Down
4 changes: 2 additions & 2 deletions examples/retinaface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,9 @@ static int detect_retinaface(const cv::Mat& bgr, std::vector<FaceObject>& faceob
// the ncnn model https://github.com/nihui/ncnn-assets/tree/master/models
// retinaface.load_param("retinaface-R50.param");
// retinaface.load_model("retinaface-R50.bin");
if (!retinaface.load_param("mnet.25-opt.param"))
if (retinaface.load_param("mnet.25-opt.param"))
exit(-1);
if (!retinaface.load_model("mnet.25-opt.bin"))
if (retinaface.load_model("mnet.25-opt.bin"))
exit(-1);

const float prob_threshold = 0.8f;
Expand Down
4 changes: 2 additions & 2 deletions examples/rfcn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ static int detect_rfcn(const cv::Mat& bgr, std::vector<Object>& objects)
// https://github.com/YuwenXiong/py-R-FCN/blob/master/models/pascal_voc/ResNet-50/rfcn_end2end/test_agnostic.prototxt
// https://1drv.ms/u/s!AoN7vygOjLIQqUWHpY67oaC7mopf
// resnet50_rfcn_final.caffemodel
if (!rfcn.load_param("rfcn_end2end.param"))
if (rfcn.load_param("rfcn_end2end.param"))
exit(-1);
if (!rfcn.load_model("rfcn_end2end.bin"))
if (rfcn.load_model("rfcn_end2end.bin"))
exit(-1);

const int target_size = 224;
Expand Down
4 changes: 2 additions & 2 deletions examples/rvm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ static int detect_rvm(const cv::Mat& bgr, cv::Mat& pha, cv::Mat& fgr)
net.opt.use_vulkan_compute = false;
//original pretrained model from https://github.com/PeterL1n/RobustVideoMatting
//ncnn model https://pan.baidu.com/s/11iEY2RGfzWFtce8ue7T3JQ password: d9t6
if (!net.load_param("rvm_512.param"))
if (net.load_param("rvm_512.param"))
exit(-1);
if (!net.load_model("rvm_512.bin"))
if (net.load_model("rvm_512.bin"))
exit(-1);

//if you use another input size,pleaze change input shape
Expand Down
4 changes: 2 additions & 2 deletions examples/scrfd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,9 @@ static int detect_scrfd(const cv::Mat& bgr, std::vector<FaceObject>& faceobjects
// model is converted from
// https://github.com/deepinsight/insightface/tree/master/detection/scrfd
// the ncnn model https://github.com/nihui/ncnn-assets/tree/master/models
if (!scrfd.load_param("scrfd_500m-opt2.param"))
if (scrfd.load_param("scrfd_500m-opt2.param"))
exit(-1);
if (!scrfd.load_model("scrfd_500m-opt2.bin"))
if (scrfd.load_model("scrfd_500m-opt2.bin"))
exit(-1);

int width = bgr.cols;
Expand Down
4 changes: 2 additions & 2 deletions examples/scrfd_crowdhuman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,9 @@ static int detect_scrfd(const cv::Mat& bgr, std::vector<FaceObject>& faceobjects
// but I have one for detecing cat face, you can have a try here:
// https://drive.google.com/file/d/1JogkKa0f_09HkENbCnXy9hRYxm35wKTn

if (!scrfd.load_param("scrfd_crowdhuman.param"))
if (scrfd.load_param("scrfd_crowdhuman.param"))
exit(-1);
if (!scrfd.load_model("scrfd_crowdhuman.bin"))
if (scrfd.load_model("scrfd_crowdhuman.bin"))
exit(-1);

int width = bgr.cols;
Expand Down
4 changes: 2 additions & 2 deletions examples/shufflenetv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ static int detect_shufflenetv2(const cv::Mat& bgr, std::vector<float>& cls_score

// https://github.com/miaow1988/ShuffleNet_V2_pytorch_caffe
// models can be downloaded from https://github.com/miaow1988/ShuffleNet_V2_pytorch_caffe/releases
if (!shufflenetv2.load_param("shufflenet_v2_x0.5.param"))
if (shufflenetv2.load_param("shufflenet_v2_x0.5.param"))
exit(-1);
if (!shufflenetv2.load_model("shufflenet_v2_x0.5.bin"))
if (shufflenetv2.load_model("shufflenet_v2_x0.5.bin"))
exit(-1);

ncnn::Mat in = ncnn::Mat::from_pixels_resize(bgr.data, ncnn::Mat::PIXEL_BGR, bgr.cols, bgr.rows, 224, 224);
Expand Down
4 changes: 2 additions & 2 deletions examples/simplepose.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ static int detect_posenet(const cv::Mat& bgr, std::vector<KeyPoint>& keypoints)
// pose_net.export('pose')
// then mxnet2ncnn
// the ncnn model https://github.com/nihui/ncnn-assets/tree/master/models
if (!posenet.load_param("pose.param"))
if (posenet.load_param("pose.param"))
exit(-1);
if (!posenet.load_model("pose.bin"))
if (posenet.load_model("pose.bin"))
exit(-1);

int w = bgr.cols;
Expand Down
4 changes: 2 additions & 2 deletions examples/squeezenet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ static int detect_squeezenet(const cv::Mat& bgr, std::vector<float>& cls_scores)
squeezenet.opt.use_vulkan_compute = true;

// the ncnn model https://github.com/nihui/ncnn-assets/tree/master/models
if (!squeezenet.load_param("squeezenet_v1.1.param"))
if (squeezenet.load_param("squeezenet_v1.1.param"))
exit(-1);
if (!squeezenet.load_model("squeezenet_v1.1.bin"))
if (squeezenet.load_model("squeezenet_v1.1.bin"))
exit(-1);

ncnn::Mat in = ncnn::Mat::from_pixels_resize(bgr.data, ncnn::Mat::PIXEL_BGR, bgr.cols, bgr.rows, 227, 227);
Expand Down
4 changes: 2 additions & 2 deletions examples/squeezenet_c_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ static int detect_squeezenet(const cv::Mat& bgr, std::vector<float>& cls_scores)
ncnn_net_set_option(squeezenet, opt);

// the ncnn model https://github.com/nihui/ncnn-assets/tree/master/models
if (!ncnn_net_load_param(squeezenet, "squeezenet_v1.1.param"))
if (ncnn_net_load_param(squeezenet, "squeezenet_v1.1.param"))
exit(-1);
if (!ncnn_net_load_model(squeezenet, "squeezenet_v1.1.bin"))
if (ncnn_net_load_model(squeezenet, "squeezenet_v1.1.bin"))
exit(-1);

ncnn_mat_t in = ncnn_mat_from_pixels_resize(bgr.data, NCNN_MAT_PIXEL_BGR, bgr.cols, bgr.rows, bgr.cols * 3, 227, 227, NULL);
Expand Down
4 changes: 2 additions & 2 deletions examples/squeezenetssd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ static int detect_squeezenet(const cv::Mat& bgr, std::vector<Object>& objects)
// squeezenet_ssd_voc_deploy.prototxt
// https://drive.google.com/open?id=0B3gersZ2cHIxdGpyZlZnbEQ5Snc
// the ncnn model https://github.com/nihui/ncnn-assets/tree/master/models
if (!squeezenet.load_param("squeezenet_ssd_voc.param"))
if (squeezenet.load_param("squeezenet_ssd_voc.param"))
exit(-1);
if (!squeezenet.load_model("squeezenet_ssd_voc.bin"))
if (squeezenet.load_model("squeezenet_ssd_voc.bin"))
exit(-1);

const int target_size = 300;
Expand Down
4 changes: 2 additions & 2 deletions examples/yolact.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ static int detect_yolact(const cv::Mat& bgr, std::vector<Object>& objects)
// original model converted from https://github.com/dbolya/yolact
// yolact_resnet50_54_800000.pth
// the ncnn model https://github.com/nihui/ncnn-assets/tree/master/models
if (!yolact.load_param("yolact.param"))
if (yolact.load_param("yolact.param"))
exit(-1);
if (!yolact.load_model("yolact.bin"))
if (yolact.load_model("yolact.bin"))
exit(-1);

const int target_size = 550;
Expand Down
4 changes: 2 additions & 2 deletions examples/yolov2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ static int detect_yolov2(const cv::Mat& bgr, std::vector<Object>& objects)
// https://github.com/eric612/MobileNet-YOLO/blob/master/models/yolov2/mobilenet_yolo_deploy.prototxt
// https://github.com/eric612/MobileNet-YOLO/blob/master/models/yolov2/mobilenet_yolo_deploy_iter_80000.caffemodel
// the ncnn model https://github.com/nihui/ncnn-assets/tree/master/models
if (!yolov2.load_param("mobilenet_yolo.param"))
if (yolov2.load_param("mobilenet_yolo.param"))
exit(-1);
if (!yolov2.load_model("mobilenet_yolo.bin"))
if (yolov2.load_model("mobilenet_yolo.bin"))
exit(-1);

const int target_size = 416;
Expand Down
4 changes: 2 additions & 2 deletions examples/yolov3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ static int detect_yolov3(const cv::Mat& bgr, std::vector<Object>& objects)
// param : https://drive.google.com/open?id=1V9oKHP6G6XvXZqhZbzNKL6FI_clRWdC-
// bin : https://drive.google.com/open?id=1DBcuFCr-856z3FRQznWL_S5h-Aj3RawA
// the ncnn model https://github.com/nihui/ncnn-assets/tree/master/models
if (!yolov3.load_param("mobilenetv2_yolov3.param"))
if (yolov3.load_param("mobilenetv2_yolov3.param"))
exit(-1);
if (!yolov3.load_model("mobilenetv2_yolov3.bin"))
if (yolov3.load_model("mobilenetv2_yolov3.bin"))
exit(-1);

const int target_size = 352;
Expand Down
4 changes: 2 additions & 2 deletions examples/yolov4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ static int init_yolov4(ncnn::Net* yolov4, int* target_size)
*target_size = 608;
#endif

if (!yolov4->load_param(yolov4_param))
if (yolov4->load_param(yolov4_param))
exit(-1);
if (!yolov4->load_model(yolov4_model))
if (yolov4->load_model(yolov4_model))
exit(-1);

return 0;
Expand Down
8 changes: 4 additions & 4 deletions examples/yolov5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,16 +276,16 @@ static int detect_yolov5(const cv::Mat& bgr, std::vector<Object>& objects)
// original pretrained model from https://github.com/ultralytics/yolov5
// the ncnn model https://github.com/nihui/ncnn-assets/tree/master/models
#if YOLOV5_V60
if (!yolov5.load_param("yolov5s_6.0.param"))
if (yolov5.load_param("yolov5s_6.0.param"))
exit(-1);
if (!yolov5.load_model("yolov5s_6.0.bin"))
if (yolov5.load_model("yolov5s_6.0.bin"))
exit(-1);
#else
yolov5.register_custom_layer("YoloV5Focus", YoloV5Focus_layer_creator);

if (!yolov5.load_param("yolov5s.param"))
if (yolov5.load_param("yolov5s.param"))
exit(-1);
if (!yolov5.load_model("yolov5s.bin"))
if (yolov5.load_model("yolov5s.bin"))
exit(-1);
#endif

Expand Down
4 changes: 2 additions & 2 deletions examples/yolov5_pnnx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,9 @@ static int detect_yolov5(const cv::Mat& bgr, std::vector<Object>& objects)

// original pretrained model from https://github.com/ultralytics/yolov5
// the ncnn model https://github.com/nihui/ncnn-assets/tree/master/models
if (!yolov5.load_param("yolov5s.ncnn.param"))
if (yolov5.load_param("yolov5s.ncnn.param"))
exit(-1);
if (!yolov5.load_model("yolov5s.ncnn.bin"))
if (yolov5.load_model("yolov5s.ncnn.bin"))
exit(-1);

const int target_size = 640;
Expand Down
4 changes: 2 additions & 2 deletions examples/yolox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,9 @@ static int detect_yolox(const cv::Mat& bgr, std::vector<Object>& objects)
// ncnn model param: https://github.com/Megvii-BaseDetection/YOLOX/releases/download/0.1.1rc0/yolox_s_ncnn.tar.gz
// NOTE that newest version YOLOX remove normalization of model (minus mean and then div by std),
// which might cause your model outputs becoming a total mess, plz check carefully.
if (!yolox.load_param("yolox.param"))
if (yolox.load_param("yolox.param"))
exit(-1);
if (!yolox.load_model("yolox.bin"))
if (yolox.load_model("yolox.bin"))
exit(-1);

int img_w = bgr.cols;
Expand Down

0 comments on commit 434e55c

Please sign in to comment.