Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] jsonschema.exceptions.ValidationError: '{}' is not of type 'array' #615

Closed
alan20062006 opened this issue Mar 30, 2024 · 4 comments
Closed
Labels
bug Something isn't working stale

Comments

@alan20062006
Copy link

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.

@alan20062006 alan20062006 added the bug Something isn't working label Mar 30, 2024
@loeweh
Copy link

loeweh commented Apr 9, 2024

I have the same issue. switching to sam raises the bug

@gio-foldai
Copy link

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}])

Copy link

This issue is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale label May 12, 2024
Copy link

This issue was closed because it has been inactive for 14 days since being marked as stale.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working stale
Projects
None yet
Development

No branches or pull requests

3 participants