PayloadTooLargeError: request entity too large with TensorFlow

 Expo CLI 4.0.6 environment info:
    System:
      OS: macOS 11.2.2
      Shell: 3.1.2 - /usr/local/bin/fish
    Binaries:
      Node: 12.14.0 - /usr/local/bin/node
      Yarn: 1.22.0 - /usr/local/bin/yarn
      npm: 6.14.8 - /usr/local/bin/npm
    Managers:
      CocoaPods: 1.8.4 - /usr/local/bin/pod
    SDKs:
      iOS SDK:
        Platforms: iOS 14.4, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2
    IDEs:
      Xcode: 12.4/12D4e - /usr/bin/xcodebuild
    npmPackages:
      expo: ~40.0.0 => 40.0.1
      react: 16.13.1 => 16.13.1
      react-dom: 16.13.1 => 16.13.1
      react-native: https://github.com/expo/react-native/archive/sdk-40.0.1.tar.gz => 0.63.2
      react-native-web: ~0.13.12 => 0.13.18
    npmGlobalPackages:
      expo-cli: 4.0.6
    Expo Workflow: managed

Hey, I’m running into an issue trying to load some .bin files for a TensorFlow model. The code looks like this.

   const modelJson = require("./assets/models/trained-dice/model.json");

    const model = await tf.loadLayersModel(
      bundleResourceIO(modelJson, [
        require("./assets/models/trained-dice/group1-shard1of13.bin"),
        require("./assets/models/trained-dice/group1-shard2of13.bin"),
        require("./assets/models/trained-dice/group1-shard3of13.bin"),
        require("./assets/models/trained-dice/group1-shard4of13.bin"),
        require("./assets/models/trained-dice/group1-shard5of13.bin"),
        require("./assets/models/trained-dice/group1-shard6of13.bin"),
        require("./assets/models/trained-dice/group1-shard7of13.bin"),
        require("./assets/models/trained-dice/group1-shard8of13.bin"),
        require("./assets/models/trained-dice/group1-shard9of13.bin"),
        require("./assets/models/trained-dice/group1-shard10of13.bin"),
        require("./assets/models/trained-dice/group1-shard11of13.bin"),
        require("./assets/models/trained-dice/group1-shard12of13.bin"),
        require("./assets/models/trained-dice/group1-shard13of13.bin"),
      ])
    );

I’ve run into the error in the title of this post and I’m not sure how to configure expo so it can read larger files. Each bin is about 4mb. Does anyone have an idea what might be breaking?

at what point do you see the " PayloadTooLargeError" error? when you load the app locally? when you publish it?

  1. you should update to latest expo-cli
  2. my guess is your are logging file contents at some point. watch out for massive console.log. latest expo-cli will truncate logs that are too long

I’m seeing this when I load it locally

So I’m on latest expo and I don’t log anything out. Any other reasons this might break?I’m so stumped here.

can you share a minimal reproducible example?

Hey @nobrent

So while I was putting together a demo for you, it was actually a great exersise because it uncovered the other real issue. I guess I needed to use ts.loadGraphModel instead of loadLayerModel

This really wasn’t documented in Tensor Flows docs but has gotten our shared model working. Thanks so much for being welling to look at this. If anyone run’s into this, just swap out your tf.loadLayerModel with const model = await tf.loadGraphModel(...)

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.