nuxt-hub / core

Build full-stack applications with Nuxt on CloudFlare, with zero configuration.
https://hub.nuxt.com
Apache License 2.0
993 stars 56 forks source link

HubAi dont return image in production with @cf/bytedance/stable-diffusion-xl-lightning (in dev it works) #242

Closed samulefevre closed 2 months ago

samulefevre commented 3 months ago
const res = await hubAI().run('@cf/bytedance/stable-diffusion-xl-lightning', {
   prompt,
}) // return Uint8Array
// seems like in production it don't return the image (in dev i get image)

const blob = new Blob([res])

// then save image with hubBlob() with blob
// in dev i see image in blobs, in prod i got empty image(15B)
Capture d’écran 2024-08-27 à 13 14 07 Capture d’écran 2024-08-27 à 15 49 54 Capture d’écran 2024-08-27 à 15 53 50

But why in cloudflare account, it say i use @cf/baai/bge-small-en-v1.5

(it works in dev, i got image but in prod no image)

i tried with other model : @cf/stabilityai/stable-diffusion-xl-base-1.0. same result works in dev but not working in production, what the hell is happening ?

atinux commented 3 months ago

Do you have a small reproduction I can investigate @samulefevre ?

On solution it to make sure to transform as blob only when it's not one:

let blob = await hubAI().run('@cf/bytedance/stable-diffusion-xl-lightning', {
   prompt,
})
if (blob instanceof Uint8Array) {
  blob = new Blob([blob])
}

I also have some @cf/baai/bge-small in my account on Cloudflare but I don't think it's related as beta models are not displayed in their dashboard.

samulefevre commented 2 months ago

It works with your solution, thank you !

atinux commented 2 months ago

Pushed a fix in v0.7.7 so you don't have to do this anymore normally 😊

samulefevre commented 2 months ago

Nice ! Thank you. Tested in preview, it works !