rembg
rembg copied to clipboard
[BUG] '{}' is not of type 'array' when using sam model.
Describe the bug Unable to use the "sam" model in cli. rembg i -m sam -x '{ "sam_prompt": [{"type": "point", "data": [724, 740], "label": 1}] }' .\1305696_1704870215425_1705054411.png xxx.png Getting error: '{}' is not of type 'array'
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 rembg i -m sam -x '{ "sam_prompt": [{"type": "point", "data": [724, 740], "label": 1}] }' .\1305696_1704870215425_1705054411.png xxx.png
OS Version: window 11
Rembg version: v2.0.53
Hi, Gao. Have you solved this problem yet? I think I have the same problem with you.
Hi, Gao. Have you solved this problem yet? I think I have the same problem with you.
not solved
Does anyone know why this is happening?
I have the same problem. Have you solved it?
I think it stems from the default being wrong here - https://github.com/danielgatis/rembg/blob/0dcdb080ae083de57084c38e93fb210534c5c693/rembg/sessions/sam.py#L153
This is also relevant to #577
This is a character escaping issue. If you are running this from the cmd prompt, it should look like this:
rembg i -m sam -x "{ \"sam_prompt\": [{\"type\": \"point\", \"data\": [724, 740], \"label\": 1}] }" .\1305696_1704870215425_1705054411.png xxx.png
If you're running from PowerShell 5.1, it should look like this:
rembg i -m sam -x '{ \"sam_prompt\": [{\"type\": \"point\", \"data\": [724, 740], \"label\": 1}] }' .\1305696_1704870215425_1705054411.png xxx.png
If you're running from PowerShell 7.4, it should look like this:
rembg i -m sam -x '{ "sam_prompt": [{"type": "point", "data": [724, 740], "label": 1}] }' .\1305696_1704870215425_1705054411.png xxx.png
I got the same error on the HTTP server.
How to solve this when using it interactively on the HTTP server?
The error reporting location should be located in Link Text It means there is a problem with the json format input of your prompt.
Hello, is anybody help me "how to to use SAM model with library usage".
I am trying to handle as following code line but I am getting error.
bg_cleaned_image = remove(data=my_image, session=rembg.new_session("sam", sam_prompt=[{"type": "point", "data": [724, 740], "label": 1}])
Error
raise error
jsonschema.exceptions.ValidationError: '{}' is not of type 'array'
Failed validating 'type' in schema:
'type': 'array'},
'type': {'type': 'string'}},
'type': 'object'},
'type': 'array'}
On instance:
'{}'
Hello, is anybody help me "how to to use SAM model with library usage".
I am trying to handle as following code line but I am getting error.
bg_cleaned_image = remove(data=my_image, session=rembg.new_session("sam", sam_prompt=[{"type": "point", "data": [724, 740], "label": 1}])
Error
raise error jsonschema.exceptions.ValidationError: '{}' is not of type 'array' Failed validating 'type' in schema: 'type': 'array'}, 'type': {'type': 'string'}}, 'type': 'object'}, 'type': 'array'} On instance: '{}'
Hello, Try with sam_prompt outside of the session argument. For me it works with the following code :
session_rmbg = new_session(model_name="sam")
input ect...
output = remove(input, session=session_rmbg, sam_prompt=[{"type": 'point', "data": [1600, 2400], "label": 1}])
This issue is stale because it has been open for 30 days with no activity.