Closed alan20062006 closed 1 month ago
I have the same issue. switching to sam raises the bug
Stumbled on this today. This seems to be a bug in sam.py, where
prompt = kwargs.get("sam_prompt", "{}") # here "{}" should be []
But the reason this bug went undiscovered is that you're supposed to tell sam what to segment, passing a prompt, for example:
rembg.remove(img, session=REMBG_SESSION, sam_prompt=[{"type": "point", "data": [0, 0], "label": 1}])
This issue is stale because it has been open for 30 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.
Describe the bug When switching from isnet-general-use to sam. Encountered the following bug
` File "/Users/XX/opt/anaconda3/envs/genai/lib/python3.11/site-packages/rembg/bg.py", line 257, in remove masks = session.predict(img, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/XX/opt/anaconda3/envs/genai/lib/python3.11/site-packages/rembg/sessions/sam.py", line 169, in predict validate(instance=prompt, schema=schema) File "/Users/XX/opt/anaconda3/envs/genai/lib/python3.11/site-packages/jsonschema/validators.py", line 1312, in validate raise error jsonschema.exceptions.ValidationError: '{}' is not of type 'array'
Failed validating 'type' in schema: {'items': {'properties': {'data': {'items': {'type': 'number'}, 'type': 'array'}, 'label': {'type': 'integer'}, 'type': {'type': 'string'}}, 'type': 'object'}, 'type': 'array'}
On instance: '{}'`
To Reproduce I was using isnet-general-use for a long time and is looking for a better solution so I changed to sam.
Rembg version: v 2.0.53
Additional context Add any other context about the problem here.