Skip to content

RangeError: Maximum call stack size exceeded for image buffer input #247

Closed
@zeke

Description

@zeke

I've got this code:

import Replicate from 'replicate'

const replicate = new Replicate()

const model = 'yorickvp/llava-v1.6-34b:41ecfbfb261e6c1adf3ad896c9066ca98346996d7c4045c5bc944a79d430f174'

export default async function describeImage (imageBuffer) {
  const input = {
    image: imageBuffer,
    prompt: "What's happening in this image?"
  }
  const output = await replicate.run(model, { input })
  return output
}

And this image:

IMG_1700

I'm trying to feed this image to https://replicate.com/yorickvp/llava-v1.6-34b as a buffer:

const buffer = await readFile(imagePath)
console.log({ buffer })
{
  buffer: <Buffer ff d8 ff e1 01 08 45 78 69 66 00 00 4d 4d 00 2a 00 00 00 08 00 06 01 12 00 03 00 00 00 01 00 01 00 00 01 1a 00 05 00 00 00 01 00 00 00 56 01 1b 00 05 ... 401476 more bytes>
}

But I'm getting this error:

Error processing images: RangeError: Maximum call stack size exceeded
    at bytesToBase64 (/Users/z/Desktop/los-angeles/node_modules/replicate/lib/util.js:136:35)
    at /Users/z/Desktop/los-angeles/node_modules/replicate/lib/util.js:245:18
    at transform (/Users/z/Desktop/los-angeles/node_modules/replicate/lib/util.js:272:16)
    at transform (/Users/z/Desktop/los-angeles/node_modules/replicate/lib/util.js:267:25)
    at transformFileInputs (/Users/z/Desktop/los-angeles/node_modules/replicate/lib/util.js:219:24)
    at Replicate.createPrediction (/Users/z/Desktop/los-angeles/node_modules/replicate/lib/predictions.js:33:22)
    at Replicate.run (/Users/z/Desktop/los-angeles/node_modules/replicate/index.js:138:43)
    at describeImage (file:///Users/z/Desktop/los-angeles/describe-image.js:14:34)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions