Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions ldm/modules/embedding_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,13 @@ def save(self, ckpt_path):
ckpt_path,
)

def load(self, ckpt_path):
def load(self, ckpt_path, full=True):
ckpt = torch.load(ckpt_path, map_location='cpu')

self.string_to_token_dict = ckpt['string_to_token']
self.string_to_param_dict = ckpt['string_to_param']
self.string_to_token_dict = ckpt["string_to_token"]
self.string_to_param_dict = ckpt["string_to_param"]
if not full:
for key, value in self.string_to_param_dict.items():
self.string_to_param_dict[key] = torch.nn.Parameter(value.half())

def get_embedding_norms_squared(self):
all_params = torch.cat(
Expand Down
2 changes: 1 addition & 1 deletion ldm/simplet2i.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ def load_model(self):
)
model = self._load_model_from_config(config, self.weights)
if self.embedding_path is not None:
model.embedding_manager.load(self.embedding_path)
model.embedding_manager.load(self.embedding_path, self.full_precision)
self.model = model.to(self.device)
# model.to doesn't change the cond_stage_model.device used to move the tokenizer output, so set it here
self.model.cond_stage_model.device = self.device
Expand Down