3

Python models/research/object-detection API を使用して、独自のデータセットで coco-ssd を再トレーニングしました。モデルを保存しました & モデルは ipython ノートブックで動作します。私はそれを変換するためにtfjs_converterを使用しました

テスト 1; 私のコード

    image.src = imageURL;
    var img;
    const runButton = document.getElementById('run');
    runButton.onclick = async () => {
        console.log('model start');
        const model = await modelPromise;

        console.log('model loaded');
        const zeros = tf.zeros([1, 224, 224, 3]);

        const batched = tf.tidy(() => {
        if (!(image instanceof tf.Tensor)) {
            img = tf.fromPixels(image);
         }
      // Reshape to a single-element batch so we can pass it to executeAsync.
          return img.expandDims(0);
       });
       console.log('model loaded - now predict .. start');
       const result = await model.executeAsync(batched) ;
       console.log('model loaded - now predict - ready'); //  Error seen 
       batched.dispose();
       tf.dispose(result);

    model loaded - now predict .. start ( i tried chaning the model to Coco-ssd model same error)
   tensor_array.ts:116 Uncaught (in promise) Error: TensorArray : Could not write to TensorArray index 0,
          because the value dtype is int32, but TensorArray dtype is float32.
      at e.write (tensor_array.ts:116)
      at tensor_array.ts:162
      at Array.forEach (<anonymous>)
      at e.writeMany (tensor_array.ts:162)
      at e.scatter (tensor_array.ts:252)
      at control_executor.ts:127
      at callbacks.ts:17
      at Object.next (callbacks.ts:17)
      at callbacks.ts:17```

     Test 2; ---- using tfjs-model/coco-ssd/demo ----------------------------------
      did yarn , yarn watch  

    I replaced the coo-ssd model which works correctly, with my re-trained model  (only switched the models)
      //BASE_PATH = "https://storage.googleapis.com/tfjs-models/savedmodel/";
        BASE_PATH = "http://localhost:1234/web_model/";
    //this.modelPath = "" + BASE_PATH + this.getPrefix(e) + 
    "/tensorflowjs_model.pb", this.weightPath = "" + BASE_PATH + 
    this.getPrefix(e) + "/weights_manifest.json";
    ``this.modelPath = "" + BASE_PATH +  "tensorflowjs_model.pb", 
      this.weightPath = "" +BASE_PATH + "weights_manifest.json";``

    I get an error
    io_utils.ts:116 Uncaught (in promise) RangeError: byte length of float32Array should be a multiple of 4
        at new Float32Array (<anonymous>)
        at o (io_utils.ts:116)
        at Object.decodeWeights (io_utils.ts:79)
        at e.<anonymous> (frozen_model.ts:109)
        at exports_regularizers.ts:47
        at Object.next (exports_regularizers.ts:47)
        at s (exports_regularizers.ts:47)```


    model loaded - now predict .. start ( i tried chaning the model to Coco-ssd model same error)
    ```tensor_array.ts:116 Uncaught (in promise) Error: TensorArray : Could not write to TensorArray index 0,
          because the value dtype is int32, but TensorArray dtype is float32.
        at e.write (tensor_array.ts:116)
        at tensor_array.ts:162
        at Array.forEach (<anonymous>)
        at e.writeMany (tensor_array.ts:162)
        at e.scatter (tensor_array.ts:252)
        at control_executor.ts:127```
        at callbacks.ts:17
        at Object.next (callbacks.ts:17)
        at callbacks.ts:17


4

2 に答える 2

0

これらの変換パラメータを試してください。mobilenet_v1 output_node_names="Postprocessor/ExpandDims_1,Postprocessor/Slice" で再トレーニングした後、彼らは私のために働きました

https://github.com/tensorflow/tfjs-models/tree/master/coco-ssd

于 2019-03-01T01:27:34.897 に答える