How to use own pre trained model with rembg? #523
Replies: 1 comment 1 reply
-
Just create file like this, and now you can run rembg with session named "U2netYour". === new session file in \rembg\sessions === import numpy as np from .base import BaseSession class U2netYourSession(BaseSession):
|
Beta Was this translation helpful? Give feedback.
-
Hlello, need some help here. I have own model u2net_epoch.pth and converted one u2net_epoch.onnx
I was tried to load model like this:
**
model_name = "u2net_epoch"
session = new_session(model_name)
output = remove(input_image,session=session)
**
Nothing happend, as i understand I need to create file like sessions\u2net_custom.py but I have no idea what to do with download part to make it work localy.
I was tried cli version:
**
rembg i -m u2net_custom -x '{"model_path": "
/.u2net/u2net_epoch.onnx"}' path/to/input.png path/to/output.png/.u2net/u2net_epoch.pth"}' path/to/input.png path/to/output.pngrembg i -m u2net_custom -x '{"model_path": "
**
got error "ValueError: model_path is required"
tried to hard code it inside "sessions\u2net_custom.py":
**
model_path = r"J:/my_model/u2net_epoch.onnx" or model_path = r"J:/my_model/u2net_epoch.pth"
**
got another error "NO_SUCHFILE : Load model from None failed:Load model None failed. File doesn't exist"
also tryed to place model files to C:\Users{user}.u2net nothing helps
So what clearly do with u2net_custom.py and how to use it for own models 🤔 would be apriciete for help 🤗
p.s. - rembg works perfectly with no errors with u2net.onnx inside C:\Users{user}.u2net if try to replace it =) it downloads new one of course
win 11
python 3.10 -m venv
Beta Was this translation helpful? Give feedback.
All reactions