Charch-630 / FGI-Matting

The official repository for Deep Image Matting with Flexible Guidance Input
GNU General Public License v3.0
58 stars 12 forks source link

Variation of line thickness #4

Open WANGEOGEO opened 2 years ago

WANGEOGEO commented 2 years ago

Hi,

After reading through the code, I found that there is no specific pipeline showing how the 'thickness' of lines drawing through points are varied during training. To my understanding, there will be 5 levels of thickness: 600, 260, 140, 80 and 40. As the training goes on, when a specific iteration number is reached, the thickness will be changed to next level (from 600->260 directly for example). Is my understanding correct?

Charch-630 commented 2 years ago

We have only released the demo and the evaluation code. Most of the training part including the Progressive Trimap Deformation has been removed in this version. But the principle is simple, and you can try to implement is yourself.

You misunderstand about the variation of the thickness of the scribbles. In Figure 3 in the paper, I just want to show what the guidance map looks like with different thickness. In fact, the change of thickness is a smooth process. Here is the relationship between thickness and training step. Descriptions are in 4.1 in the paper and thickness==40 when step >530000.

2021-11-23 11-32-26屏幕截图

WANGEOGEO commented 2 years ago

Ah, I see. So the core Idea is to find an exponential function to adjust my thickness. Actually while implementing the Trimap Deformation, I found it requires a pretty long time to generate the deformed trimap for training, which includes cubic line fitting and curve plotting. Is this a normal condition? Since I am currently plotting curves by plotting circles along it, I think my implementation might be wrong.

Charch-630 commented 2 years ago

My training speed is about 5s~8s/10iterations. And I use two 2080Ti with batchsize 5 on each one. It was trained on our lab's server. image

I pick 3 points to do curve fitting each time, then I use np.polyfit(x, y, 3)and np.poly1d() to generate the curve function. After that I pick 10 equally spaced points on the curve, note that the first and the last points are the first and the last sampled points that are used to generate the curve function. And I use cv2.line to link the 10 points.

WANGEOGEO commented 2 years ago

After some experiments, I found that my implementation of drawing curves (draw circles) achieves similar performance as drawing lines. But, I found that the main bottleneck of Trimap Deformation in my case was sampling points in FG/BG. I found it quite time-consuming to only use np.where to generate points, and trying to figure out a more efficient implementation for my case. Thanks for showing me the stats and approaches!