title: How to load model with tf.loadModel from firebase storage?
body: <p>I am developing an app in ionic3 framework for recognizing drawn characters and I am having trouble with the import of the model. I have imported the model from Keras (converted with <code>tensorflowjs_converter</code>) into my ionic3 app in two different ways:</p>
  
  <ol>
  <li>The <code>model.json</code> and weight files (shards) are placed into the folder <code>/assets/models</code>.</li>
  <li>The <code>model.json</code> and weight files (shards) are being hosted in firebase storage.</li>
  </ol>
  
  <p>When launching the app in the browser with the <b>first method</b>, the model and weights are correctly loaded and I am able to predict the classes. But when launching the app, with the same method into my Android device with <code>ionic cordova run android --device</code>, the model seems to not retrieve the data from the weight files as it gives the following error:</p>
  
  <p><code>Based on the provided shape, [3, 3, 32, 64], the tensor should have 18432 values but has 917</code>.</p>
  
  <p>Now, I tried to host the files in firebase storage to try and fix this issue. I retrieve the <code>model.json</code> from storage and I still get the same error as stated above <b>in both browser and device</b>.</p>
  
  <p>From the experience of storing the shards and model locally in the app, I came to the conclusion that the shards are not being recognized in the device either both ways. </p>
  
  <p>Also, when using the firebase storage method <b>in device</b>, when trying to fetch the model from the url, I catch the following error: <code>Failed to fetch</code>.</p>
  
  <p>Here is the code of retrieving the shards and the model:</p>
  
  <pre><code>const modelURL: string = await this.db.getModel();
  const shards: string[] = await this.db.getShards();
  </code></pre>
  
  <p><code>modelURL</code> and <code>shards</code> contains the download urls from firebase storage. The model and the shards are kept together on the same level: </p>
  
  <pre><code>/* Firebase Storage hierarchy */
  
  https://firebasestorage.googleapis.com/v0/b/project-foo.com/o/model%2Fmodel.json?alt=media&amp;token=******
  https://firebasestorage.googleapis.com/v0/b/project-foo.com/o/model%2Fgroup1-shard1of4?alt=media&amp;token=******
  https://firebasestorage.googleapis.com/v0/b/project-foo.com/o/model%2Fgroup1-shard2of4?alt=media&amp;token=******
  https://firebasestorage.googleapis.com/v0/b/project-foo.com/o/model%2Fgroup1-shard3of4?alt=media&amp;token=******
  https://firebasestorage.googleapis.com/v0/b/project-foo.com/o/model%2Fgroup1-shard4of4?alt=media&amp;token=******
  </code></pre>
  
  <p>So with that, I pass the download url of the model into <code>tf.loadModel</code>:</p>
  
  <pre><code>import * as tf from '@tensorflow/tfjs';    
  
  await tf.loadModel(modelURL).then(model =&gt; {
      const output: any = model.predict(img);
  });
  </code></pre>
  
  <p>So, is there any way to pass the shards into <code>tf.loadModel()</code>, fetched from firebase storage, so that in my device and browser I can retrieve all of the data required in order to predict from the model?</p>
  
  <p>Thank you for your help.</p>