Skip to content

Commit

Permalink
Add cos xl (#710)
Browse files Browse the repository at this point in the history
* Add V_PREDICTION_EDM handing for CosXL models

Add V_PREDICTION_EDM handing for CosXL models

* Get correct sigmas from checkpoint.

* Round to 3 sig digs in order to make compatible with comfy implementation

* Add sigma data like ComfyUI has

---------

Co-authored-by: Gavin Chapman <gchapman@MAINPC>
  • Loading branch information
GavChap and Gavin Chapman authored May 23, 2024
1 parent 7eb5cba commit 77bdb92
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ldm_patched/modules/model_sampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,11 @@ def __init__(self, model_config=None):

sigma_min = sampling_settings.get("sigma_min", 0.002)
sigma_max = sampling_settings.get("sigma_max", 120.0)
self.set_sigma_range(sigma_min, sigma_max)
sigma_data = sampling_settings.get("sigma_data", 1.0)
self.set_sigma_range(sigma_min, sigma_max, sigma_data)

def set_sigma_range(self, sigma_min, sigma_max):
def set_sigma_range(self, sigma_min, sigma_max, sigma_data):
self.sigma_data = sigma_data
sigmas = torch.linspace(math.log(sigma_min), math.log(sigma_max), 1000).exp()

self.register_buffer('sigmas', sigmas) #for compatibility with some schedulers
Expand Down
5 changes: 5 additions & 0 deletions ldm_patched/modules/supported_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ class SDXL(supported_models_base.BASE):
def model_type(self, state_dict, prefix=""):
if "v_pred" in state_dict:
return model_base.ModelType.V_PREDICTION
elif "edm_vpred.sigma_max" in state_dict:
self.sampling_settings["sigma_max"] = round(float(state_dict["edm_vpred.sigma_max"].item()),3)
if "edm_vpred.sigma_min" in state_dict:
self.sampling_settings["sigma_min"] = round(float(state_dict["edm_vpred.sigma_min"].item()),3)
return model_base.ModelType.V_PREDICTION_EDM
else:
return model_base.ModelType.EPS

Expand Down

0 comments on commit 77bdb92

Please sign in to comment.