Search code examples
pythonpython-3.xrembg

NO_SUCHFILE ...\u2net.onnx .u2net\u2net.onnx failed. File doesn't exist , rembg


from rembg import remove
from PIL import Image
input_path = 'input.png'
output_path = 'output.png'
input = Image.open(input_path)
output = remove(input)
output.save(output_path)

I get an error

sess = C.InferenceSession(session_options, self._model_path, True, self._read_config_from_model)
onnxruntime.capi.onnxruntime_pybind11_state.NoSuchFile: [ONNXRuntimeError] : 3 : NO_SUCHFILE : Load model from C:\Users\User\.u2net\u2net.onnx failed:Load model C:\Users\User\.u2net\u2net.onnx failed. File doesn't exist

I can't figure out what's wrong, I checked everything


Solution

  • https://github.com/danielgatis/rembg/releases/download/v0.0.0/u2net.onnx

    Make sure that after the download is completed, copy U2Net.onnx to C: \ Users \ <your username> . u2net \ this folder Then reopen the code.