segment-anything icon indicating copy to clipboard operation
segment-anything copied to clipboard

"AssertionError: set_torch_image input must be BCHW with long side 1024. "

Open cappelletti4636 opened this issue 1 year ago • 3 comments

Hi

I have been working with SAM, but I have this problem:

"AssertionError: set_torch_image input must be BCHW with long side 1024. "

The problem occurred when I run the "generated" method :

sam_mask.generate(image)

Can I work with different image sizes?

cappelletti4636 avatar Jun 01 '23 22:06 cappelletti4636

I was running into this and the problem is a misleading error message, the model throws that error if you pass an image with an alpha channel. It needs to be converted to RGB first.

gfodor avatar Jun 03 '23 02:06 gfodor

https://github.com/ByungKwanLee/Full-Segment-Anything addresses the ciritical issues of SAM, which supports batch-input on the full-grid prompt (automatic mask generation) with post-processing: removing duplicated or small regions and holes, under flexible input image size

ByungKwanLee avatar Oct 13 '23 21:10 ByungKwanLee

I was running into this and the problem is a misleading error message, the model throws that error if you pass an image with an alpha channel. It needs to be converted to RGB first.

Thank you :)

Was putting a Comfy workflow together that uses the stability API nodes with the SD3 API and figured I'd add InstantID and a Face Detailer before the custom upscaler node and the FD kept throwing up this error. Saw your reply and added a convert to RGB node to feed into the FD and that fixed it :)

RunebinderOG avatar May 11 '24 15:05 RunebinderOG