LearningBasedSamplingMatting
LearningBasedSamplingMatting copied to clipboard
Load alpha question
Hi, thanks for your great work.
I have a question about alpha loading, why you set the value 0-10 to 0, and set 245-255 to 255? Is this a thick?
And did you try to load the original alpha value for training, what's the diffenence of the two results?
def load_alpha(self, alpha_path): alpha = cv2.imread(alpha_path, 0) alpha = np.where(alpha<10, 0, alpha) alpha = np.where(alpha>245, 255, alpha) return np.clip(np.float32(alpha/255.0), 0, 1.0)
The original DIM dataset provides training alpha matte as jpg so there are some compression artifacts.
I haven't done any experiments regarding this, but I don't think it will differ that much.
Those artifacts DO affect trimap generation though.
Hi, thanks for your great work. I have a question about alpha loading, why you set the value 0-10 to 0, and set 245-255 to 255? Is this a thick? And did you try to load the original alpha value for training, what's the diffenence of the two results?
def load_alpha(self, alpha_path): alpha = cv2.imread(alpha_path, 0) alpha = np.where(alpha<10, 0, alpha) alpha = np.where(alpha>245, 255, alpha) return np.clip(np.float32(alpha/255.0), 0, 1.0)
Because when we are actually calculating the alpha loss, we calculate the unknown region. The original alpha value is 0-255, but even if the pixel value is close to 255, we think it should belong to the foreground. In the end, if you use 245 for the loss calculation, the result is that there is a possibility of misleading loss. The adjustment here is to make the model prediction more confident.