Uminosachi / sd-webui-inpaint-anything

Inpaint Anything extension performs stable diffusion inpainting on a browser UI using masks from Segment Anything.
Apache License 2.0
1.03k stars 93 forks source link

Inpaint Anything - ERROR - The size of tensor a (0) must match the size of tensor b (256) at non-singleton dimension 1 #140

Open waldolin opened 3 months ago

waldolin commented 3 months ago

2024-03-28` 00:23:32,966 - Inpaint Anything - ERROR - The size of tensor a (0) must match the size of tensor b (256) at non-singleton dimension 1 2024-03-28 00:24:20,692 - Inpaint Anything - INFO - input_image: (819, 1024, 3) uint8 2024-03-28 00:24:23,079 - Inpaint Anything - INFO - SamAutomaticMaskGenerator sam_vit_l_0b3195.pth Traceback (most recent call last): File "C:\Users\lin\stable-diffusion-webui-directml\extensions\sd-webui-inpaint-anything\scripts\inpaint_anything.py", line 187, in run_sam sam_masks = inpalib.generate_sam_masks(input_image, sam_model_id, anime_style_chk) File "C:\Users\lin\stable-diffusion-webui-directml\extensions\sd-webui-inpaint-anything\inpalib\samlib.py", line 139, in generate_sam_masks sam_masks = sam_mask_generator.generate(input_image) File "C:\Users\lin\stable-diffusion-webui-directml\venv\lib\site-packages\torch\utils_contextlib.py", line 115, in decorate_context return func(*args, kwargs) File "C:\Users\lin\stable-diffusion-webui-directml\extensions\sd-webui-inpaint-anything\segment_anything_fb\automatic_mask_generator.py", line 151, in generate mask_data = self._generate_masks(image) File "C:\Users\lin\stable-diffusion-webui-directml\extensions\sd-webui-inpaint-anything\segment_anything_fb\automatic_mask_generator.py", line 194, in _generate_masks crop_data = self._process_crop(image, crop_box, layer_idx, orig_size) File "C:\Users\lin\stable-diffusion-webui-directml\extensions\sd-webui-inpaint-anything\segment_anything_fb\automatic_mask_generator.py", line 240, in _process_crop batch_data = self._process_batch(points, cropped_im_size, crop_box, orig_size) File "C:\Users\lin\stable-diffusion-webui-directml\extensions\sd-webui-inpaint-anything\segment_anything_fb\automatic_mask_generator.py", line 283, in _process_batch masks, ioupreds, = self.predictor.predict_torch( File "C:\Users\lin\stable-diffusion-webui-directml\venv\lib\site-packages\torch\utils_contextlib.py", line 115, in decorate_context return func(*args, *kwargs) File "C:\Users\lin\stable-diffusion-webui-directml\extensions\sd-webui-inpaint-anything\segment_anything_fb\predictor.py", line 222, in predict_torch sparse_embeddings, dense_embeddings = self.model.prompt_encoder( File "C:\Users\lin\stable-diffusion-webui-directml\venv\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl return forward_call(args, kwargs) File "C:\Users\lin\stable-diffusion-webui-directml\extensions\sd-webui-inpaint-anything\segment_anything_fb\modeling\prompt_encoder.py", line 155, in forward point_embeddings = self._embed_points(coords, labels, pad=(boxes is None)) File "C:\Users\lin\stable-diffusion-webui-directml\extensions\sd-webui-inpaint-anything\segment_anything_fb\modeling\prompt_encoder.py", line 89, in _embed_points point_embedding[labels == 0] += self.point_embeddings[0].weight RuntimeError: The size of tensor a (0) must match the size of tensor b (256) at non-singleton dimension 1

2024-03-28 00:24:34,510 - Inpaint Anything - ERROR - The size of tensor a (0) must match the size of tensor b (256) at non-singleton dimension 1

GOOGLE CHROME:Version 122.0.6261.129 (Official version) (64-bit) SD:version: 1.6.1   •  python: 3.10.7  •  torch: 2.0.0+cpu  •  xformers: N/A  •  gradio: 3.41.2  •  checkpoint: a47e380db3 i can not run Inpaint Anything, the error shows sement anything failed. The error information as above.

Uminosachi commented 3 months ago

The same error message as mentioned in issues #132 and #72. However, since the package is torch: 2.0.0+cpu and it's the CPU version, it might be a different issue. Please try deleting the venv folder under stable-diffusion-webui and reinstalling the packages from scratch.