资源简介

此工程针对tensorflow自己训练的模型,pb转pbtxt,pb和pbtxt可以用opencv进行调用。 大家尽量不要再下载这个文档了,积分太贵了,我无法改积分。建议大家直接把opencv更新到4.0以上,用opencv的Sample/dnn里面的脚本转换就可以了。opencv调用也建议用opencv4.0以上版本。

资源截图

代码片段和文件信息

#include 
#include 

#include 
#include 
#include 

#include “common.hpp“

std::string keys =
    “{ help  h     | | Print help message. }“
    “{ @alias      | | An alias name of model to extract preprocessing parameters from models.yml file. }“
    “{ zoo         | models.yml | An optional path to file with preprocessing parameters }“
    “{ input i     | | Path to input image or video file. Skip this argument to capture frames from a camera.}“
    “{ framework f | | Optional name of an origin framework of the model. Detect it automatically if it does not set. }“
    “{ classes     | | Optional path to a text file with names of classes. }“
    “{ backend     | 0 | Choose one of computation backends: “
                        “0: automatically (by default) “
                        “1: Halide language (http://halide-lang.org/) “
                        “2: Intel‘s Deep Learning Inference Engine (https://software.intel.com/openvino-toolkit) “
                        “3: OpenCV implementation }“
    “{ target      | 0 | Choose one of target computation devices: “
                        “0: CPU target (by default) “
                        “1: OpenCL “
                        “2: OpenCL fp16 (half-float precision) “
                        “3: VPU }“;

using namespace cv;
using namespace dnn;

std::vector classes;

int main(int argc char** argv)
{
    CommandLineParser parser(argc argv keys);

    const std::string modelName = parser.get(“@alias“);
    const std::string zooFile = parser.get(“zoo“);

    keys += genPreprocArguments(modelName zooFile);

    parser = CommandLineParser(argc argv keys);
    parser.about(“Use this script to run classification deep learning networks using OpenCV.“);
    if (argc == 1 || parser.has(“help“))
    {
        parser.printMessage();
        return 0;
    }

    float scale = parser.get(“scale“);
    Scalar mean = parser.get(“mean“);
    bool swapRB = parser.get(“rgb“);
    int inpWidth = parser.get(“width“);
    int inpHeight = parser.get(“height“);
    String model = findFile(parser.get(“model“));
    String config = findFile(parser.get(“config“));
    String framework = parser.get(“framework“);
    int backendId = parser.get(“backend“);
    int targetId = parser.get(“target“);

    // Open file with classes names.
    if (parser.has(“classes“))
    {
        std::string file = parser.get(“classes“);
        std::ifstream ifs(file.c_str());
        if (!ifs.is_open())
            CV_Error(Error::StsError “File “ + file + “ not found“);
        std::string line;
        while (std::getline(ifs line))
        {
            classes.push_back(line);
        }
    }

    if (!parser.check())
    {
        parser.printErrors();
        return 1;
    }
    CV_Assert(!model.empty());

    //! [Read and initialize network]
    Ne

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2019-05-16 20:11  pb_convert_pbtxt\
     目录           0  2019-04-22 10:49  pb_convert_pbtxt\dnn\
     文件        5137  2019-04-16 21:10  pb_convert_pbtxt\dnn\classification.cpp
     文件        3763  2019-04-16 21:10  pb_convert_pbtxt\dnn\classification.py
     文件         681  2019-04-16 21:10  pb_convert_pbtxt\dnn\CMakeLists.txt
     文件        7072  2019-04-16 21:10  pb_convert_pbtxt\dnn\colorization.cpp
     文件        2943  2019-04-16 21:10  pb_convert_pbtxt\dnn\colorization.py
     文件        4435  2019-04-16 21:10  pb_convert_pbtxt\dnn\common.hpp
     文件        4913  2019-04-16 21:10  pb_convert_pbtxt\dnn\common.py
     文件         563  2019-04-18 08:18  pb_convert_pbtxt\dnn\convert.py
     文件       10854  2019-04-16 21:10  pb_convert_pbtxt\dnn\custom_layers.hpp
     文件        2719  2019-04-16 21:10  pb_convert_pbtxt\dnn\edge_detection.py
     目录           0  2019-04-22 10:49  pb_convert_pbtxt\dnn\face_detector\
     文件       28092  2019-04-16 21:10  pb_convert_pbtxt\dnn\face_detector\deploy.prototxt
     文件        2495  2019-04-16 21:10  pb_convert_pbtxt\dnn\face_detector\download_weights.py
     文件        3639  2019-04-16 21:10  pb_convert_pbtxt\dnn\face_detector\how_to_train_face_detector.txt
     文件       34912  2019-04-16 21:10  pb_convert_pbtxt\dnn\face_detector\opencv_face_detector.pbtxt
     文件         465  2019-04-16 21:10  pb_convert_pbtxt\dnn\face_detector\solver.prototxt
     文件       28842  2019-04-16 21:10  pb_convert_pbtxt\dnn\face_detector\test.prototxt
     文件       30504  2019-04-16 21:10  pb_convert_pbtxt\dnn\face_detector\train.prototxt
     文件         824  2019-04-16 21:10  pb_convert_pbtxt\dnn\face_detector\weights.meta4
     文件        1845  2019-04-16 21:10  pb_convert_pbtxt\dnn\fast_neural_style.py
     文件       10472  2019-04-17 07:53  pb_convert_pbtxt\dnn\graph_convert.py
     文件        6937  2019-04-16 21:10  pb_convert_pbtxt\dnn\js_face_recognition.html
     文件        5271  2019-04-16 21:10  pb_convert_pbtxt\dnn\mask_rcnn.py
     文件        5052  2019-04-16 21:10  pb_convert_pbtxt\dnn\mobilenet_ssd_accuracy.py
     文件        3583  2019-04-16 21:10  pb_convert_pbtxt\dnn\models.yml
     文件        9920  2019-04-16 21:10  pb_convert_pbtxt\dnn\object_detection.cpp
     文件        9221  2019-04-16 21:10  pb_convert_pbtxt\dnn\object_detection.py
     文件        5808  2019-04-16 21:10  pb_convert_pbtxt\dnn\openpose.cpp
     文件        6517  2019-04-16 21:10  pb_convert_pbtxt\dnn\openpose.py
............此处省略15个文件信息

评论

共有 条评论