Giter Club home page Giter Club logo

Comments (4)

oneThousand1000 avatar oneThousand1000 commented on August 22, 2024 1

Yes, it is not easy to run the remaining operations on batches. This is also the reason why, during testing, we only process one image at a time.

from hairmapper.

oneThousand1000 avatar oneThousand1000 commented on August 22, 2024

Hi omermosa!

You can input a batch of latent codes to HairMapper. But there are some modifications:

In single_mapper.py, Line 40

         x = bias_act.bias_act(x, b, act=self.activation,dim=2) # x = bias_act.bias_act(x, b, act=self.activation)

Line 82-91

        #x = x.squeeze(0)
        # Main layers.
        for idx in range(self.num_layers):
            layer = getattr(self, f'fc{idx}')
            x = layer(x)  # W
        #W_latent = torch.clone(x.unsqueeze(0))

        return x

then you can input a batch of latent codes to HairMapper like this:

    codes = []
    for code_path in code_list:
        code = np.load(code_path)
        codes.append(code)
    codes = np.concatenate(codes, axis=0) # shape: [batch size, 18, 512]

    mapper_input = codes.copy()
    mapper_input_tensor = torch.from_numpy(mapper_input).cuda().float()
    print('mapper_input_tensor shape: ', mapper_input_tensor.shape)
    edited_latent_codes_debug = codes.copy()
    mapper_out = mapper(mapper_input_tensor)
    print('mapper_out shape: ', mapper_out.shape, 'alpha', alpha)

    edited_latent_codes_debug[:, :8, :] += alpha * mapper_out.to('cpu').detach().numpy()

Good luck!

from hairmapper.

omermosa avatar omermosa commented on August 22, 2024

That is great; thank you so much!
I guess there is nothing to do to make the rest of the operations (getting hair mask and seamless clone ) run on batches right? since they involve opencv operations,

from hairmapper.

omermosa avatar omermosa commented on August 22, 2024

Yes, makes sense. Thank you very much!

from hairmapper.

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.