Coder Social home page Coder Social logo

Comments (1)

stakanich avatar stakanich commented on September 27, 2024

Hi. For these who will have this problem later:
In trainer.py there is row:
output = self.make_output(input_, hot_target)
and in the definition of this function later:

features = self.model(input_)
...
all_tasks_output = model1.make_logits(features, all=True)

In models/model_tools.py you can find it:

def forward(self, x):
        x = self.features(x)
        x = self.conv_last(x)
        x = self.avgpool(x)
        return x
def make_logits(self, features, all=False):
        all = all if self.multi_heads else False
        output = features.view(features.size(0), -1)
        spoof_out = self.spoofer(output)
        if all:
            type_spoof = self.spoof_type(output)
            lightning_type = self.lightning(output)
            real_atr = torch.sigmoid(self.real_atr(output))
            return spoof_out, type_spoof, lightning_type, real_atr
        return spoof_out

So, during a training, this model uses not only forward method, but one additional too. And in utils.py in build_model you can find these rows multiple times:

elif mode == 'convert':
    model.forward = model.forward_to_onnx

which is:

def forward_to_onnx(self,x):
        x = self.features(x)
        x = self.conv_last(x)
        x = self.avgpool(x)
        x = x.view(x.size(0), -1)
        spoof_out = self.spoofer(x)
        if isinstance(spoof_out, tuple):
            spoof_out = spoof_out[0]
        probab = F.softmax(spoof_out*self.scaling, dim=-1)
        return probab

With using one of these methods you will get an output with a shape [N, 2] where N - batch-size. First element is the confidence that image is real, and the second is the score for 'spoof' answer.

from light-weight-face-anti-spoofing.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.