ZhangYuanhan-AI / CelebA-Spoof

[ECCV2020] A Large-Scale Face Anti-Spoofing Dataset
531 stars 92 forks source link

Can you share the training script? #30

Closed Coderx7 closed 2 years ago

Coderx7 commented 3 years ago

Hi, Thans a lot for sharing your work. really appreciate it. Can you also share the training script that was used to achieve your results? Its much appreciated.

Coderx7 commented 3 years ago

@Davidzhangyuanhan I'd appreciate any feedback on this.

ZhangYuanhan-AI commented 3 years ago

Because of the rule of the company, I can't share the training script recently. But I can explain any training details here if you ask.

hamhanry commented 3 years ago

Hi @Davidzhangyuanhan , thanks for your sharing research to the community. could you share more the parameter you use during training or any undescribed in the paper? however, the training results i tried is still cant compared to the result in your paper. as for now, i found still so many False Positives. Thanks

ZhangYuanhan-AI commented 2 years ago

Here, we share part of our data loading pipeline code:

%%%%Transform%%%%%
        self.transform_ColorJitter= transforms.Compose([
            transforms.Resize((self.new_width, self.new_height)),
            transforms.ColorJitter(saturation = 1),
            transforms.ToTensor(),
            transforms.Normalize(mean = (0.5, 0.5, 0.5), std = (0.5, 0.5, 0.5))
           ])

def __getitem__(self, idx):
        filename =  self.metas[idx][0]
        cls = self.metas[idx][1]

        img = cv2_loader(filename)
        real_h,real_w,c = img.shape

        #Load bounding box
        assert os.path.exists(filename[:-4] + '_BB.txt'),'path not exists' + filename

        with open(filename[:-4] + '_BB.txt','r') as f:
            material = f.readline()
        try:
            x,y,w,h,score = material.strip().split(' ')
        except:
            print('[Rank' + str(self.rank) + ']' + filename)

        try:
            w = int(float(w))
            h = int(float(h))
            x = int(float(x))
            y = int(float(y))
            w = int(w*(real_w / 224))
            h = int(h*(real_h / 224))
            x = int(x*(real_w / 224))
            y = int(y*(real_h / 224))

            #Crop image
            if y < 0:
                y1 = 0
            else:
                y1 = y

            if x < 0:
                x1 = 0
            else:
                x1 = x

            if y1 + h > real_h:
                y2 = real_h
            else:
                y2 = y + h

            if x1 + w > real_w:
                x2 = real_w
            else:
                x2 =  x + w
            img = img[y1:y2,x1:x2,:]

        assert img.shape[0] != 0 and img.shape[1] != 0,'img_path:' + filename + ' idx:' + str(idx)
        img = Image.fromarray(cv2.cvtColor(img,cv2.COLOR_BGR2RGB)) 
        img = self.transform_ColorJitter(img)
        assert img.shape[0] == 3,filename 
        return img, cls