rembg
rembg copied to clipboard
About how to run rembg using a self trained model on Windows
When I trained my U2net model and wanted to use it to run Rembg, I initially used the method described by the author in README.md
rembg i -m u2net_custom -x '{"model_path": "~/.u2net/u2net.onnx"}' path/to/input.png path/to/output.png
But I encountered the following error:
Traceback (most recent call last):
File "D:\Anaconda3\envs\rembg\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "D:\Anaconda3\envs\rembg\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "D:\Anaconda3\envs\rembg\Scripts\rembg.exe_main.py", line 4, in
I have found that this issue has also been mentioned in many issues, such as:issues #629 issues #636
It seems to be caused by the inconsistency between Linux system commands and Windows system commands. The author mentioned Linux commands in README.md, but after my attempts, I found that the correct command for Windows is:
rembg i -m u2net_custom -x "{\"model_path\": \"C:/your model path/your model name.onnx\"}" ./images/input.jpg ./images/output.jpg
I have successfully used the model I trained myself, it need to pay attention to the '\' '/' issue between the model path and the image path. I hope it can help people who are also facing this problem.