Skip to content

Instantly share code, notes, and snippets.

@andreyryabtsev
Last active June 5, 2024 04:56
Show Gist options
  • Save andreyryabtsev/243aa3eefa6e06891dda7b1583d1d08f to your computer and use it in GitHub Desktop.
Save andreyryabtsev/243aa3eefa6e06891dda7b1583d1d08f to your computer and use it in GitHub Desktop.
BackMatting.ipynb
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tolchx
Copy link

tolchx commented Jun 1, 2020

Hello, I have an error when I run this section of the code:

#!CUDA_VISIBLE_DEVICES=0 python test_background-matting_image.py -m real-hand-held -i colab_inputs_video/input/ -o colab_inputs_video/output/ -tb colab_inputs_video/background/
!CUDA_VISIBLE_DEVICES=0 python test_background-matting_image.py -m real-fixed-cam -i colab_inputs_video/input/ -o colab_inputs_video/output/ -tb colab_inputs_video/background/ -b colab_inputs_video/$BM_SOURCE_STILL

error:


Traceback (most recent call last):
  File "test_background-matting_image.py", line 92, in <module>
    back_img10=cv2.imread(os.path.join(args.target_back,filename.replace('_img.png','.png'))); back_img10=cv2.cvtColor(back_img10,cv2.COLOR_BGR2RGB);
cv2.error: OpenCV(3.4.5) /io/opencv/modules/imgproc/src/color.cpp:181: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'

I did the test with several videos, with different amount of frames, 600/900/1000 frames, for example.
But it always stops at 441 and the error appears.

What could be the cause?

In the folder: Background-Matting / colab_inputs_video / inputs, the remaining frames appear, it does not end at frame 441

Thank you

@Flock1
Copy link

Flock1 commented Jun 4, 2020

@tolchx, I'm not sure but I think there is a problem with arguments. Instead of --tb, just use --back. Also, how are your results? Can you share them with me because I'm not getting that good results. I had to do some post-processing.

@tolchx
Copy link

tolchx commented Jun 10, 2020

@tolchx, I'm not sure but I think there is a problem with arguments. Instead of --tb, just use --back. Also, how are your results? Can you share them with me because I'm not getting that good results. I had to do some post-processing.

I had good results with some videos, I'm experimenting with other material, here I uploaded a video, use the algorithm to segment the dancers, and then apply styletransfer https://www.instagram.com/p/CAsK54qgx_9/
I will try the solution you recommend, thanks

@Flock1
Copy link

Flock1 commented Jun 12, 2020

@tolchx, you are using it for something interesting. Can you elaborate on what you are doing? Also, did you make any changes to the code? Because I had to do some post-processing to get good results.

@zbvictory
Copy link

zbvictory commented Sep 23, 2020

@Flock1 Have you got a good result? Can you share some tips? thanks
and I too got the same error

Done: 154/351
Done: 155/351
Traceback (most recent call last):
File "test_background-matting_image.py", line 92, in
back_img10=cv2.imread(os.path.join(args.target_back,filename.replace('_img.png','.png'))); back_img10=cv2.cvtColor(back_img10,cv2.COLOR_BGR2RGB);
cv2.error: OpenCV(3.4.5) /io/opencv/modules/imgproc/src/color.cpp:181: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'

@Flock1
Copy link

Flock1 commented Sep 24, 2020

@zbvictory, as I mentioned here, this error happens because the folder doesn't have the image you want to work with. Do check the folder you're getting the image from.

My raw results weren't that good. I'll share the changes I made.

@zbvictory
Copy link

@Flock1 Thank you very much for your reply and look forward to your sharing !

@Sicily-F
Copy link

Sicily-F commented Dec 23, 2020

Hi! I have a small query. I am very interesting in background matting as a technique, however, I don't have photos with a separate background with and without the subject - I have photos of birds in a cage, and I wish to remove the background of the cage bars. I used the background photo for each image as the cropped background of the cage, so the photos are not the same size for the segmentation.

I got this error code
CUDA Device: 0 Using image mode

But it didn't seem like the segmentation actually was performed on the 7 examples of background and image that I provided - any advice would be GREATLY appreciated!

My results when I try and plot are [] instead of any images

@Flock1
Copy link

Flock1 commented Dec 29, 2020

@Sicily-F, from what I can imagine this is probably because it's not reading the images. Can you post the whole error? I might be able to figure out where exactly is the problem

@amrzv
Copy link

amrzv commented Feb 4, 2023

This colab is no longer works because tf<2 is no longer supported in google colaboratory.

@saidulu31
Copy link

I'm getting issue when Setting up the environment:

Screenshot 2024-01-16 172758

can u please explain how to solve this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment