dimitribarbot / sd-webui-birefnet

BiRefNet for AUTOMATIC1111 Stable Diffusion WebUI
Other
19 stars 0 forks source link

API error BiRefNetPipeline.process() missing 1 required positional argument: 'edge_mask_width #3

Open skyliwq opened 2 weeks ago

skyliwq commented 2 weeks ago

API error curl -X 'POST' \ 'http://localhost:7860/birefnet/single' \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -d '{ "image": "https://nog.aliyuncs.com/data/styles/style/531.png", "resolution": "", "model_name": "General", "return_foreground": true, "return_edge_mask": true, "edge_mask_width":64, "output_dir": "outputs/birefnet/", "device_id": 0, "send_output": true, "save_output": false, "use_model_cache": true, "flag_force_cpu": false }'

TypeError: BiRefNetPipeline.process() missing 1 required positional argument: 'edge_mask_width'

dimitribarbot commented 2 weeks ago

Hi @skyliwq, it should be fixed if you update your extension to the latest version (in UI, by going to your "Extensions" tab and clicking on "Check for updates" and then "Apply and restart UI").

Do you confirm?

skyliwq commented 2 weeks ago

I encountered an error when submitting a BASE64 encoded image.

* API error: POST: http://127.0.0.1:7860/birefnet/single {'error': 'RuntimeError', 'detail': '', 'body': '', 'errors': 'The size of tensor a (4) must match the size of tensor b (3) at non-singleton dimension 0'} 2024-09-09 15:39:13 Traceback (most recent call last): 2024-09-09 15:39:13 File "/app/stable-diffusion-webui/venv/lib/python3.11/site-packages/anyio/streams/memory.py", line 98, in receive 2024-09-09 15:39:13 return self.receive_nowait() 2024-09-09 15:39:13 ^^^^^^^^^^^^^^^^^^^^^ 2024-09-09 15:39:13 File "/app/stable-diffusion-webui/venv/lib/python3.11/site-packages/anyio/streams/memory.py", line 93, in receive_nowait 2024-09-09 15:39:13 raise WouldBlock 2024-09-09 15:39:13 anyio.WouldBlock 2024-09-09 15:39:13 2024-09-09 15:39:13 During handling of the above exception, another exception occurred: 2024-09-09 15:39:13 2024-09-09 15:39:13 Traceback (most recent call last): 2024-09-09 15:39:13 File "/app/stable-diffusion-webui/venv/lib/python3.11/site-packages/starlette/middleware/base.py", line 78, in call_next 2024-09-09 15:39:13 message = await recv_stream.receive() 2024-09-09 15:39:13 ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2024-09-09 15:39:13 File "/app/stable-diffusion-webui/venv/lib/python3.11/site-packages/anyio/streams/memory.py", line 118, in receive 2024-09-09 15:39:13 raise EndOfStream 2024-09-09 15:39:13 anyio.EndOfStream 2024-09-09 15:39:13 2024-09-09 15:39:13 During handling of the above exception, another exception occurred: 2024-09-09 15:39:13 2024-09-09 15:39:13 Traceback (most recent call last): 2024-09-09 15:39:13 File "/app/stable-diffusion-webui/modules/api/api.py", line 186, in exception_handling 2024-09-09 15:39:13 return await call_next(request) 2024-09-09 15:39:13 ^^^^^^^^^^^^^^^^^^^^^^^^ 2024-09-09 15:39:13 File "/app/stable-diffusion-webui/venv/lib/python3.11/site-packages/starlette/middleware/base.py", line 84, in call_next 2024-09-09 15:39:13 raise app_exc 2024-09-09 15:39:13 File "/app/stable-diffusion-webui/venv/lib/python3.11/site-packages/starlette/middleware/base.py", line 70, in coro 2024-09-09 15:39:13 await self.app(scope, receive_or_disconnect, send_no_error) 2024-09-09 15:39:13 File "/app/stable-diffusion-webui/venv/lib/python3.11/site-packages/starlette/middleware/base.py", line 108, in call 2024-09-09 15:39:13 response = await self.dispatch_func(request, call_next) 2024-09-09 15:39:13 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2024-09-09 15:39:13 File "/app/stable-diffusion-webui/modules/api/api.py", line 150, in log_and_time 2024-09-09 15:39:13 res: Response = await call_next(req) 2024-09-09 15:39:13 ^^^^^^^^^^^^^^^^^^^^ 2024-09-09 15:39:13 File "/app/stable-diffusion-webui/venv/lib/python3.11/site-packages/starlette/middleware/base.py", line 84, in call_next 2024-09-09 15:39:13 raise app_exc 2024-09-09 15:39:13 File "/app/stable-diffusion-webui/venv/lib/python3.11/site-packages/starlette/middleware/base.py", line 70, in coro 2024-09-09 15:39:13 await self.app(scope, receive_or_disconnect, send_no_error) 2024-09-09 15:39:13 File "/app/stable-diffusion-webui/venv/lib/python3.11/site-packages/starlette/middleware/cors.py", line 84, in call 2024-09-09 15:39:13 await self.app(scope, receive, send) 2024-09-09 15:39:13 File "/app/stable-diffusion-webui/venv/lib/python3.11/site-packages/starlette/middleware/gzip.py", line 26, in call 2024-09-09 15:39:13 await self.app(scope, receive, send) 2024-09-09 15:39:13 File "/app/stable-diffusion-webui/venv/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 79, in call 2024-09-09 15:39:13 raise exc 2024-09-09 15:39:13 File "/app/stable-diffusion-webui/venv/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 68, in call 2024-09-09 15:39:13 await self.app(scope, receive, sender) 2024-09-09 15:39:13 File "/app/stable-diffusion-webui/venv/lib/python3.11/site-packages/fastapi/middleware/asyncexitstack.py", line 21, in call 2024-09-09 15:39:13 raise e 2024-09-09 15:39:13 File "/app/stable-diffusion-webui/venv/lib/python3.11/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in call 2024-09-09 15:39:13 await self.app(scope, receive, send) 2024-09-09 15:39:13 File "/app/stable-diffusion-webui/venv/lib/python3.11/site-packages/starlette/routing.py", line 718, in call 2024-09-09 15:39:13 await route.handle(scope, receive, send) 2024-09-09 15:39:13 File "/app/stable-diffusion-webui/venv/lib/python3.11/site-packages/starlette/routing.py", line 276, in handle 2024-09-09 15:39:13 await self.app(scope, receive, send) 2024-09-09 15:39:13 File "/app/stable-diffusion-webui/venv/lib/python3.11/site-packages/starlette/routing.py", line 66, in app 2024-09-09 15:39:13 response = await func(request) 2024-09-09 15:39:13 ^^^^^^^^^^^^^^^^^^^ 2024-09-09 15:39:13 File "/app/stable-diffusion-webui/venv/lib/python3.11/site-packages/fastapi/routing.py", line 237, in app 2024-09-09 15:39:13 raw_response = await run_endpoint_function( 2024-09-09 15:39:13 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2024-09-09 15:39:13 File "/app/stable-diffusion-webui/venv/lib/python3.11/site-packages/fastapi/routing.py", line 163, in run_endpoint_function 2024-09-09 15:39:13 return await dependant.call(*values) 2024-09-09 15:39:13 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2024-09-09 15:39:13 File "/app/stable-diffusion-webui/extensions/sd-webui-birefnet/scripts/api.py", line 152, in execute_birefnet_single 2024-09-09 15:39:13 mask_base64, output_image_base64, edge_mask_base64 = process_image( 2024-09-09 15:39:13 ^^^^^^^^^^^^^^ 2024-09-09 15:39:13 File "/app/stable-diffusion-webui/extensions/sd-webui-birefnet/scripts/api.py", line 99, in process_image 2024-09-09 15:39:13 mask, foreground, edge_mask = pipeline.process(image, resolution, return_mask, return_foreground, return_edge_mask, edge_mask_width) 2024-09-09 15:39:13 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2024-09-09 15:39:13 File "/app/stable-diffusion-webui/extensions/sd-webui-birefnet/internal_birefnet/pipeline.py", line 138, in process 2024-09-09 15:39:13 image_proc = image_preprocessor.proc(image_pil) 2024-09-09 15:39:13 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2024-09-09 15:39:13 File "/app/stable-diffusion-webui/extensions/sd-webui-birefnet/internal_birefnet/pipeline.py", line 69, in proc 2024-09-09 15:39:13 image_tf = cast(torch.Tensor, self.transform_image(image)) 2024-09-09 15:39:13 ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2024-09-09 15:39:13 File "/app/stable-diffusion-webui/venv/lib/python3.11/site-packages/torchvision/transforms/transforms.py", line 95, in call 2024-09-09 15:39:13 img = t(img) 2024-09-09 15:39:13 ^^^^^^ 2024-09-09 15:39:13 File "/app/stable-diffusion-webui/venv/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl 2024-09-09 15:39:13 return self._call_impl(args, kwargs) 2024-09-09 15:39:13 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2024-09-09 15:39:13 File "/app/stable-diffusion-webui/venv/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1527, in _call_impl 2024-09-09 15:39:13 return forward_call(*args, **kwargs) 2024-09-09 15:39:13 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2024-09-09 15:39:13 File "/app/stable-diffusion-webui/venv/lib/python3.11/site-packages/torchvision/transforms/transforms.py", line 277, in forward 2024-09-09 15:39:13 return F.normalize(tensor, self.mean, self.std, self.inplace) 2024-09-09 15:39:13 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2024-09-09 15:39:13 File "/app/stable-diffusion-webui/venv/lib/python3.11/site-packages/torchvision/transforms/functional.py", line 363, in normalize 2024-09-09 15:39:13 return F_t.normalize(tensor, mean=mean, std=std, inplace=inplace) 2024-09-09 15:39:13 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2024-09-09 15:39:13 File "/app/stable-diffusion-webui/venv/lib/python3.11/site-packages/torchvision/transforms/_functionaltensor.py", line 928, in normalize 2024-09-09 15:39:13 return tensor.sub(mean).div_(std) 2024-09-09 15:39:13 ^^^^^^^^^^^^^^^^^ 2024-09-09 15:39:13 RuntimeError: The size of tensor a (4) must match the size of tensor b (3) at non-singleton dimension 0 2024-09-09 15:39:13 2024-09-09 15:39:13 ---

dimitribarbot commented 2 weeks ago

I can't reproduce your issue but I tried to fix it using PyTorch recommendations. After update to the latest version, is it working now?

skyliwq commented 2 weeks ago

Thank you, it works now.

dimitribarbot commented 2 weeks ago

Thank you for reporting.