`RangeError: Maximum call stack size exceeded` for image buffer input
zeke opened this issue ยท 9 comments
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:
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)
@aron Yeah, I think the Files API would be the best solution to this. Let's chat about what's blocking us from shipping that.
I hadn't realized it hasn't been merged yet.
Ah yeah same.. I was thinking, "Isn't this file supposed to be uploaded automatically by the client now?" That explains it.
Files API sounds good to me. ๐๐ผ
Hey any updates on when this fix will be merged? I'm following the upload guide that can be accessed from any model and neither File, Blob, and Buffer uploads all give me this error. Thanks
Hey any updates on when this fix will be merged? I'm following the upload guide that can be accessed from any model and neither File, Blob, and Buffer uploads all give me this error. Thanks
Hello, I also have the same problem. Were you able to find a solution?
We're going to ship #184, but in the short term you can temporarily work around it by npm installing this branch from GitHub:
npm install replicate/replicate-javascript#fix-rangeerror
We're going to ship #184, but in the short term you can temporarily work around it by npm installing this branch from GitHub:
npm install replicate/replicate-javascript#fix-rangeerror
Thanks a lot ,you saved my life๐๐ฟ
We're going to ship #184, but in the short term you can temporarily work around it by npm installing this branch from GitHub:
npm install replicate/replicate-javascript#fix-rangeerrorThanks a lot ,you saved my life๐๐ฟ
mine too. please ship this PR
