Phase 2
This commit is contained in:
1 parent
45886f01b2
commit
520d96aac3
27 files changed
+333
-253
No files matched your search
@@ -92,10 +92,6 @@ class ZetaChromaModel(BaseModel):
|
||||
|
||||
transformer_state_dict = load_file(transformer_path, device="cpu")
|
||||
|
||||
# cast to dtype
|
||||
for key in transformer_state_dict:
|
||||
transformer_state_dict[key] = transformer_state_dict[key].to(dtype)
|
||||
|
||||
# Auto-detect use_x0 from checkpoint
|
||||
use_x0 = "__x0__" in transformer_state_dict
|
||||
|
||||
@@ -107,10 +103,9 @@ class ZetaChromaModel(BaseModel):
|
||||
use_x0=use_x0,
|
||||
)
|
||||
|
||||
with torch.device("meta"):
|
||||
transformer = ZImageDCT(model_params)
|
||||
|
||||
transformer.load_state_dict(transformer_state_dict, assign=True)
|
||||
transformer = ZImageDCT.load_from_state_dict(
|
||||
transformer_state_dict, dtype, config=model_params
|
||||
)
|
||||
del transformer_state_dict
|
||||
|
||||
transformer.to(self.quantize_device, dtype=dtype)
|
||||
|
||||
@@ -6,6 +6,8 @@ from typing import List, Optional
|
||||
import math
|
||||
|
||||
import torch
|
||||
|
||||
from toolkit.models.v2._mixin import OstrisModelMixin
|
||||
import torch.nn as nn
|
||||
import torch.nn.functional as F
|
||||
from torch import Tensor
|
||||
@@ -449,7 +451,7 @@ class SimpleMLPAdaLN(nn.Module):
|
||||
return self.final_layer(x)
|
||||
|
||||
|
||||
class ZImageDCT(nn.Module):
|
||||
class ZImageDCT(nn.Module, OstrisModelMixin):
|
||||
def __init__(self, params: ZImageDCTParams):
|
||||
super().__init__()
|
||||
self.config = FakeConfig()
|
||||
|
||||
Reference in new issue
Block a user