简体   繁体   English

如何在tensorflow.js中截断可可SSD模型?

[英]How to truncate coco ssd model in tensorflow.js?

ML / Tensorflow beginner. ML / Tensorflow初学者。

I'm having trouble trying to get one of the layers from the coco ssd model imported as a package in a React application. 我在尝试从作为应用程序包中的包导入的coco ssd模型中获取一层时遇到了麻烦。 I'm following the Pacman tensorflow.js example to retrain the model. 我正在遵循Pacman tensorflow.js示例来重新训练模型。

  const modelPromise = cocoSsd.load();
  Promise.all([modelPromise])
    .then(cocoModel => {
      console.log(cocoModel[0]);

      var cocoModel = cocoModel[0].model;
      console.log(cocoModel);

      const layer = cocoModel.getLayer('conv_pw_13_relu');
      this.truncatedCocoModel = tf.model({inputs: cocoModel.inputs, outputs:
                                                              layer.output});
   })
   .catch(error => {
      console.error(error);
   });

In the const layer line I get the error message that 'cocoModel.getLayer is not a function'. 在const层行中,我收到错误消息“ cocoModel.getLayer不是函数”。 The Pacman example is using the mobilenet model which I guess has this function. Pacman示例使用的是mobilenet模型,我想它具有此功能。

What are my options here? 我在这里有什么选择? I looked around using the browser console but I can't find this function anywhere and looking online didn't help much (is there any place online where I can see the whole structure of the cocoSSD model by Google?) 我使用浏览器控制台环顾四周,但在任何地方都找不到此功能,并且在网上看也无济于事(在网上有什么地方可以看到Google的cocoSSD模型的整个结构吗?)

模型功能

Using the npm package https://cdn.jsdelivr.net/npm/@tensorflow-models/coco-ssd , you cannot retrieve any layer. 使用npm包https://cdn.jsdelivr.net/npm/@tensorflow-models/coco-ssd ,您无法检索任何层。

load returns an instance of ObjectDetection which does not have the getLayer property. load返回一个不具有getLayer属性的ObjectDetection实例。

If you want to retrieve the layer, you would have to load the graph model as described here 如果要检索图层,则必须按此处所述加载图形模型

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM