Giter Site home page Giter Site logo

Comments (7)

yl4579 avatar yl4579 commented on August 25, 2024 1

You can just add a module. prefix to each of the keys by modifying the load_checkpoint function in models.py and pass the multigpu flag to this function:

def load_checkpoint(model, optimizer, path, load_only_params=True, multigpu=False):
    state = torch.load(path, map_location='cpu')
    params = state['net']
    for key in model:
        if key in params:
            print('%s loaded' % key)
            if multigpu:
                model[key].module.load_state_dict(params[key])
            else:
                model[key].load_state_dict(params[key])
    _ = [model[key].eval() for key in model]
    
    if not load_only_params:
        epoch = state["epoch"]
        iters = state["iters"]
        optimizer.load_state_dict(state["optimizer"])
    else:
        epoch = 0
        iters = 0
        
    return model, optimizer, epoch, iters`

from styletts.

yl4579 avatar yl4579 commented on August 25, 2024 1

Try replacing model[key].module.load_state_dict(params[key]) with

from collections import OrderedDict
state_dict = params[key]
new_state_dict = OrderedDict()
for k, v in state_dict.items():
        name = k[7:] # remove `module.`
        new_state_dict[name] = v
model[key].load_state_dict(new_state_dict)

from styletts.

crypticsymmetry avatar crypticsymmetry commented on August 25, 2024

Thank you for your help! much appreciated! <3

from styletts.

crypticsymmetry avatar crypticsymmetry commented on August 25, 2024

Sorry last question i believe :P.

now when I try inferencing using "Inference_LibriTTS.ipynb (CPU)" on a trained checkpoint that was trained using multiple gpus, I get these key mismatch errors. When inferencing was working fine on multi GPU trained checkpoints before updating the "Single -> multigpu model pertaining issue"
Edit: I think it may not be after updating the "Single -> multigpu issue" might just be multi GPU issues 🤷.

i tried adding/removing the "module" term
for key in model: if key in params: if not "discriminator" in key: print('%s loaded' % key) model[key].module.load_state_dict(params[key]) _ = [model[key].eval() for key in model] _ = [model[key].to(device) for key in model]

but I get "AttributeError: 'ProsodyPredictor' object has no attribute 'module'"
or
Keys Error Log:

RuntimeError: Error(s) in loading state_dict for ProsodyPredictor: Missing key(s) in state_dict: "text_encoder.lstms.0.weight_ih_l0", "text_encoder.lstms.0.weight_hh_l0", "text_encoder.lstms.0.bias_ih_l0", "text_encoder.lstms.0.bias_hh_l0", "text_encoder.lstms.0.weight_ih_l0_reverse", "text_encoder.lstms.0.weight_hh_l0_reverse", "text_encoder.lstms.0.bias_ih_l0_reverse", "text_encoder.lstms.0.bias_hh_l0_reverse", "text_encoder.lstms.1.fc.weight", "text_encoder.lstms.1.fc.bias", "text_encoder.lstms.2.weight_ih_l0", "text_encoder.lstms.2.weight_hh_l0", "text_encoder.lstms.2.bias_ih_l0", "text_encoder.lstms.2.bias_hh_l0", "text_encoder.lstms.2.weight_ih_l0_reverse", "text_encoder.lstms.2.weight_hh_l0_reverse", "text_encoder.lstms.2.bias_ih_l0_reverse", "text_encoder.lstms.2.bias_hh_l0_reverse", "text_encoder.lstms.3.fc.weight", "text_encoder.lstms.3.fc.bias", "text_encoder.lstms.4.weight_ih_l0", "text_encoder.lstms.4.weight_hh_l0", "text_encoder.lstms.4.bias_ih_l0", "text_encoder.lstms.4.bias_hh_l0", "text_encoder.lstms.4.weight_ih_l0_reverse", "text_encoder.lstms.4.weight_hh_l0_reverse", "text_encoder.lstms.4.bias_ih_l0_reverse", "text_encoder.lstms.4.bias_hh_l0_reverse", "text_encoder.lstms.5.fc.weight", "text_encoder.lstms.5.fc.bias", "lstm.weight_ih_l0", "lstm.weight_hh_l0", "lstm.bias_ih_l0", "lstm.bias_hh_l0", "lstm.weight_ih_l0_reverse", "lstm.weight_hh_l0_reverse", "lstm.bias_ih_l0_reverse", "lstm.bias_hh_l0_reverse", "duration_proj.linear_layer.weight", "duration_proj.linear_layer.bias", "shared.weight_ih_l0", "shared.weight_hh_l0"... Unexpected key(s) in state_dict: "module.text_encoder.lstms.0.weight_ih_l0", "module.text_encoder.lstms.0.weight_hh_l0", "module.text_encoder.lstms.0.bias_ih_l0", "module.text_encoder.lstms.0.bias_hh_l0", "module.text_encoder.lstms.0.weight_ih_l0_reverse", "module.text_encoder.lstms.0.weight_hh_l0_reverse", "module.text_encoder.lstms.0.bias_ih_l0_reverse", "module.text_encoder.lstms.0.bias_hh_l0_reverse", "module.text_encoder.lstms.1.fc.weight", "module.text_encoder.lstms.1.fc.bias", "module.text_encoder.lstms.2.weight_ih_l0", "module.text_encoder.lstms.2.weight_hh_l0", "module.text_encoder.lstms.2.bias_ih_l0", "module.text_encoder.lstms.2.bias_hh_l0", "module.text_encoder.lstms.2.weight_ih_l0_reverse", "module.text_encoder.lstms.2.weight_hh_l0_reverse", "module.text_encoder.lstms.2.bias_ih_l0_reverse", "module.text_encoder.lstms.2.bias_hh_l0_reverse", "module.text_encoder.lstms.3.fc.weight", "module.text_encoder.lstms.3.fc.bias", "module.text_encoder.lstms.4.weight_ih_l0", "module.text_encoder.lstms.4.weight_hh_l0", "module.text_encoder.lstms.4.bias_ih_l0", "module.text_encoder.lstms.4.bias_hh_l0", "module.text_encoder.lstms.4.weight_ih_l0_reverse", "module.text_encoder.lstms.4.weight_hh_l0_reverse", "module.text_encoder.lstms.4.bias_ih_l0_reverse", "module.text_encoder.lstms.4.bias_hh_l0_reverse", "module.text_encoder.lstms.5.fc.weight", "module.text_encoder.lstms.5.fc.bias", "module.lstm.weight_ih_l0", "module.lstm.weight_hh_l0", "module.lstm.bias_ih_l0", "module.lstm....

from styletts.

crypticsymmetry avatar crypticsymmetry commented on August 25, 2024

worked perfectly! Thanks!

from styletts.

crypticsymmetry avatar crypticsymmetry commented on August 25, 2024

Now im on to training the second step and I'm getting this not sure whats going on. tried changing some settings but not sure exactly what the error means.

it randomly stops at different points in the training.

Epoch [1/7], Step [170/3858], Loss: 0.72936, Avd Loss: 0.69588, Disc Loss: 1.34324, Dur Loss: 1.56399, Norm Loss: 2.10292, F0 Loss: 2.99774 Time elasped: 454.99550580978394 Epoch [1/7], Step [180/3858], Loss: 0.73733, Avd Loss: 0.77742, Disc Loss: 1.34751, Dur Loss: 1.61102, Norm Loss: 2.20635, F0 Loss: 3.32838 Time elasped: 481.4150426387787 Traceback (most recent call last): File "/workspace/StyleTTS/train_second.py", line 480, in <module> main() File "/opt/conda/lib/python3.10/site-packages/click/core.py", line 1130, in __call__ return self.main(*args, **kwargs) File "/opt/conda/lib/python3.10/site-packages/click/core.py", line 1055, in main rv = self.invoke(ctx) File "/opt/conda/lib/python3.10/site-packages/click/core.py", line 1404, in invoke return ctx.invoke(self.callback, **ctx.params) File "/opt/conda/lib/python3.10/site-packages/click/core.py", line 760, in invoke return __callback(*args, **kwargs) File "/workspace/StyleTTS/train_second.py", line 208, in main s = model.style_encoder(mel.unsqueeze(0).unsqueeze(1)) File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl return forward_call(*input, **kwargs) File "/opt/conda/lib/python3.10/site-packages/torch/nn/parallel/data_parallel.py", line 171, in forward outputs = self.parallel_apply(replicas, inputs, kwargs) File "/opt/conda/lib/python3.10/site-packages/torch/nn/parallel/data_parallel.py", line 181, in parallel_apply return parallel_apply(replicas, inputs, kwargs, self.device_ids[:len(replicas)]) File "/opt/conda/lib/python3.10/site-packages/torch/nn/parallel/parallel_apply.py", line 89, in parallel_apply output.reraise() File "/opt/conda/lib/python3.10/site-packages/torch/_utils.py", line 543, in reraise raise exception RuntimeError: Caught RuntimeError in replica 0 on device 0. Original Traceback (most recent call last): File "/opt/conda/lib/python3.10/site-packages/torch/nn/parallel/parallel_apply.py", line 64, in _worker output = module(*input, **kwargs) File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl return forward_call(*input, **kwargs) File "/workspace/StyleTTS/models.py", line 154, in forward h = self.shared(x) File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl return forward_call(*input, **kwargs) File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/container.py", line 204, in forward input = module(input) File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1212, in _call_impl result = forward_call(*input, **kwargs) File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/conv.py", line 463, in forward return self._conv_forward(input, self.weight, self.bias) File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/conv.py", line 459, in _conv_forward return F.conv2d(input, weight, bias, self.stride, RuntimeError: Calculated padded input size per channel: (5 x 3). Kernel size: (5 x 5). Kernel size can't be greater than actual input size

from styletts.

yl4579 avatar yl4579 commented on August 25, 2024

Please check yl4579/StyleTTS-VC#1, this is because the sample you have in your training set is too short. You need the samples to be at least one second. For the first stage of training, I added a line to skip batches with samples less than a second. I forgot to do that in the second stage, I will add it later.

from styletts.

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.