Kardbord / hfapigo

Unofficial (Golang) Go bindings for the Hugging Face Inference API
MIT License
61 stars 5 forks source link

Text-To-Image example throw error 'unknown image format' #17

Closed gimaldi closed 1 year ago

gimaldi commented 1 year ago

I'm trying the "Text-To-Image" example. After entering a prompt, it give me the following error:

Sending request.......unknown image format:

I have tried debugging the sample code and I found that var chrv, after 'select/case' evaluation (case chrv := <-ch:), at line 56, contain an error:

`(dlv) print chrv

main.ChanRv·1 {

    resp: image.Image nil,

    format: "",

    err: error(*errors.errorString) *{

            s: "{\"error\":\"memory_efficient_attention() got an unexpected keyword argument 'scale'\"}",},}

(dlv) quit`

I have tried to found a 'scale' object in your sources, but I din't find anything. Anyway, other examples work perfectly, so thank for your efforts.

Ciao gianluca

Kardbord commented 1 year ago

Hi @gimaldi, thanks for the issue! It looks to me like this is a new bug somewhere in HF's Inference API. The text-to-image models hosted on their website are currently returning the same error, for example runwayml/stable-diffusion-v1-5.

Screenshot 2023-05-06 145930

I'll leave this issue open for now and keep an eye on things. I haven't found any reference to this issue on their forums yet, but hopefully it will be fixed soon.

Kardbord commented 1 year ago

Thanks for pointing out the poor error handling in the text-to-image example. I've updated it in v1.2.1.

gimaldi commented 1 year ago

Hi @TannerKvarfordt, in this thread, https://github.com/huggingface/huggingface.js/issues/182, I have found a reference to a working model: prompthero/openjourney-v4

For now I had hardcoded the above string in your main.go, inside goroutine: img, fmt, err := hfapigo.SendTextToImageRequest("prompthero/openjourney-v4", &hfapigo.TextToImageRequest{//code}

Thanks for your quick response.

Kardbord commented 1 year ago

Good find! Looks like a more permanent solution is coming with huggingface/api-inference-community#246.

Kardbord commented 1 year ago

This has been resolved! Any model should work now.

gimaldi commented 1 year ago

Hi, I confirm is working.

Thank you very much. Ciao