danielgatis / rembg

Rembg is a tool to remove images background
MIT License
15.39k stars 1.75k forks source link

[BUG] custom model on windows #629

Closed x0rtrunks closed 1 month ago

x0rtrunks commented 2 months ago

Describe the bug Is it actually possible to use custom models on windows? I'm unable to execute the command line to use a custom model without an error message of some kind.

Custom model example

rembg i -m u2net_custom -x '{"model_path": "~/.u2net/u2net.onnx"}' path/to/input.png path/to/output.png

To Reproduce Steps to reproduce the behavior:

My example command: rembg i -m u2net_custom -x '{"model_path": "~/.u2netyolov8x-seg.onnx"}' "D:\Test\2024-04-26-1716-K13.png" "c:\test\rembgtest.png"

No matter what I try for the model_path I get this: Error: Invalid value for 'INPUT': 'C:\Users\user.u2net\yolov8x-seg.onnx}'': No such file or directory

Even if I use a full absolute path to the model file. And the file it says does not exist, does actually exist.

It looks like it's picking up the space between "model_path" and the actual path as the input variable rather than the path. I've tried all sorts of ways to enclose that part of the command but it doesn't work.

OS Version: win10

Rembg version: v2.0.56

x0rtrunks commented 1 month ago

The command needs to be escaped in windows. Should probably be mentioned in the examples.

rembg i -m u2net_custom -x "{\"model_path\": \"C:/Users/user/.u2net/yolov8x-seg.onnx\"}" "D:\test\2024-04-26-1716-K13.png" "c:\spider\yolo\rembgtest.png"