geekyutao / Inpaint-Anything

Inpaint anything using Segment Anything and inpainting models.
Apache License 2.0
6.4k stars 525 forks source link

Can't use the "CLICK" and Problem "AttributeError: shape. Did you mean: 'save'?" #113

Open cidxb opened 11 months ago

cidxb commented 11 months ago

Hi, new here.

I followed the instructions and downloaded all the necessary stuff. OS: Ubuntu 2204 Environment: python 3.10 And when I use the command as follows:

python remove_anything_video.py \
    --input_video ./1.mp4 \
    --coords_type click \
    --point_coords 652 162 \
    --point_labels 1 \
    --dilate_kernel_size 15 \
    --output_dir ./results \
    --sam_model_type "vit_h" \
    --sam_ckpt ./pretrained_models/sam_vit_h_4b8939.pth \
    --lama_config lama/configs/prediction/default.yaml \
    --lama_ckpt ./pretrained_models/big-lama \
    --tracker_ckpt vitb_384_mae_ce_32x4_ep300 \
    --vi_ckpt ./pretrained_models/sttn.pth \
    --mask_idx 2 \
    --fps 25

The process will stuck; More precisely in the script remove_anything_video.py line 378 get_clicked_point() and it is a function from utils.py in line 58

After some testing, it is the problem in lines 60 to 61 cv2.namedWindow("image")

cv2.imshow("image", img) Seems the whole program will stuck in this line. However I have tested the cv2.imshow function separately, and it works. So I wonder if anyone has an explanation for it? Another guess is that it cannot read the image from /tmp/. (I tested it read the image from the tmp of Ubuntu system )

So I changed to use the default --coords_type key_in This time it runs to almost the end, but it comes back with an error in the final stage of storing I think? With this : Inpainting ... Traceback (most recent call last): File "/home/clark/Projects/Inpaint-Anything-main/remove_anything_video.py", line 393, in <module> iio.mimwrite(video_rm_w_mask_p, all_frame_rm_w_mask, fps=fps) File "/home/clark/anaconda3/envs/FinRL/lib/python3.10/site-packages/imageio/v2.py", line 495, in mimwrite return file.write(ims, is_batch=True, **kwargs) File "/home/clark/anaconda3/envs/FinRL/lib/python3.10/site-packages/imageio/plugins/pyav.py", line 626, in write if any(f.shape != ndimage[0].shape for f in ndimage): File "/home/clark/anaconda3/envs/FinRL/lib/python3.10/site-packages/imageio/plugins/pyav.py", line 626, in <genexpr> if any(f.shape != ndimage[0].shape for f in ndimage): File "/home/clark/anaconda3/envs/FinRL/lib/python3.10/site-packages/PIL/Image.py", line 528, in __getattr__ raise AttributeError(name) AttributeError: shape. Did you mean: 'save'?

I think it is a dependence problem. But I am not sure, didn't find anything similar in the issues section... Hope somebody can help...

ert485 commented 1 month ago

This looks like the same error I had due to dependency issues. When I followed the installation steps in the readme (in the correct section), it worked fine. I had python version 3.10