huggingface.js icon indicating copy to clipboard operation
huggingface.js copied to clipboard

SAM on JS? (Segment Anything Model)

Open hpssjellis opened this issue 2 years ago • 5 comments

I have a JS file that does segmentation but it does not run SAM.

https://hpssjellis.github.io/my-examples-of-huggingfacejs/public/hug11-15b.html

SAM (Segment Anything Model) is now on Huggingface https://huggingface.co/docs/transformers/main/en/model_doc/sam

The main model is at facebook/sam-vit-huge

but when I try that model get errors different from the working default model facebook/detr-resnet-50-panoptic

The errors I am getting are


Uncaught (in promise) Error: Task not found for this model
    at HfInference.request (inference.js:125:15)
    at async HfInference.imageSegmentation (inference.js:78:12)
    at async myHugginFaceLoad (hug11-15b.html:26:36)


I am busy with some other coding. If not, I could probably solve this issue, but does anyone have any suggestions of what the problem is? It is most likely the model input or output parameters are slightly different.

If anyone gets my model working please post your version of my code here.

hpssjellis avatar Apr 23 '23 15:04 hpssjellis

Hi @hpssjellis

It looks like an image-to-image model, see https://github.com/huggingface/huggingface.js/issues/157 and https://github.com/huggingface/api-inference-community/pull/223

It's not yet added to huggingface JS, I'll also look into getting the model the appropriate task

coyotte508 avatar Apr 23 '23 16:04 coyotte508

Ah it looks like it's a "mask generation" task, not image to image. Will definitely be supported in the near future on HF.

By the way cc @radames , you can make it run in your browser directly with transformers.js I think and @radames did that if I'm not mistaken?

coyotte508 avatar Apr 23 '23 17:04 coyotte508

hi @hpssjellis , is SAM is not yet integrated on the API inference and it be there soon, we'll add another task here mask-generation On another note, I've been working on a example using the SAM embeddings with an ONNX quantized model to predict the masks on the front-end, it also uses our huggingface.js to run the request.

radames avatar Apr 24 '23 16:04 radames

@radames any updates of SAM in huggingfacejs?

felri avatar Aug 01 '23 12:08 felri

bump

smyja avatar Nov 25 '23 20:11 smyja