File size: 1,734 Bytes
1b242be
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# import torch
#
# path = "/u01/colombo/hungnt/hieuld/tts/StyleTTS2-LibriTTS/Models/LibriTTS/epochs_2nd_00020.pth"   # đổi thành đường dẫn file của bạn
#
# ckpt = torch.load(path, map_location="cpu")
#
# print("=== Top-level keys in checkpoint ===")
# for k in ckpt['net'].keys():
#     print("-", k)

import torch

# Load checkpoint
path = "/workspace/trainTTS/model/epochs_2nd_00020.pth"
# path = "/workspace/trainTTS/dangtr0408/StyleTTS2-lite/Models/base_model.pth"
ckpt = torch.load(path, map_location="cpu")


print("=== Keys trước khi xóa ===")
print(list(ckpt['net'].keys()))


# if 'decoder' in ckpt['net']:
#     del ckpt['net']['decoder']
#     print("✓ Xóa: decoder")

# if 'predictor' in ckpt['net']:
#     del ckpt['net']['predictor']
#     print("✓ Xóa: predictor")

# if 'text_encoder' in ckpt['net']:
#     del ckpt['net']['text_encoder']
#     print("✓ Xóa: text_encoder")

# if 'style_encoder' in ckpt['net']:
#     del ckpt['net']['style_encoder']
#     print("✓ Xóa: style_encoder")

# if 'text_aligner' in ckpt['net']:
#     del ckpt['net']['text_aligner']
#     print("✓ Xóa: text_aligner")

# if 'pitch_extractor' in ckpt['net']:
#     del ckpt['net']['pitch_extractor']
#     print("✓ Xóa: pitch_extractor")

# if 'mpd' in ckpt['net']:
#     del ckpt['net']['mpd']
#     print("✓ Xóa: mpd")

# if 'msd' in ckpt['net']:
#     del ckpt['net']['msd']
#     print("✓ Xóa: msd")

# print("\n=== Keys sau khi xóa ===")
# print(list(ckpt['net'].keys()))

# # Save checkpoint mới
# new_path = "/workspace/trainTTS/epoch_4_layer.pth"
# torch.save(ckpt, new_path)
# print(f"\n✓ Lưu checkpoint mới: {new_path}")