Skip to content

Commit

Permalink
SD3 Support.
Browse files Browse the repository at this point in the history
  • Loading branch information
comfyanonymous committed Jun 10, 2024
1 parent a5e6a63 commit 8c4a9be
Show file tree
Hide file tree
Showing 17 changed files with 132,182 additions and 5 deletions.
33 changes: 32 additions & 1 deletion comfy/latent_formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ def __init__(self, scale_factor=0.18215):
self.taesd_decoder_name = "taesd_decoder"

class SDXL(LatentFormat):
scale_factor = 0.13025

def __init__(self):
self.scale_factor = 0.13025
self.latent_rgb_factors = [
# R G B
[ 0.3920, 0.4054, 0.4549],
Expand Down Expand Up @@ -104,3 +105,33 @@ def __init__(self):
[-0.3087, -0.1535, 0.0366],
[ 0.0290, -0.1574, -0.4078]
]

class SD3(LatentFormat):
latent_channels = 16
def __init__(self):
self.scale_factor = 1.5305
self.shift_factor = 0.0609
self.latent_rgb_factors = [
[-0.0645, 0.0177, 0.1052],
[ 0.0028, 0.0312, 0.0650],
[ 0.1848, 0.0762, 0.0360],
[ 0.0944, 0.0360, 0.0889],
[ 0.0897, 0.0506, -0.0364],
[-0.0020, 0.1203, 0.0284],
[ 0.0855, 0.0118, 0.0283],
[-0.0539, 0.0658, 0.1047],
[-0.0057, 0.0116, 0.0700],
[-0.0412, 0.0281, -0.0039],
[ 0.1106, 0.1171, 0.1220],
[-0.0248, 0.0682, -0.0481],
[ 0.0815, 0.0846, 0.1207],
[-0.0120, -0.0055, -0.0867],
[-0.0749, -0.0634, -0.0456],
[-0.1418, -0.1457, -0.1259]
]

def process_in(self, latent):
return (latent - self.shift_factor) * self.scale_factor

def process_out(self, latent):
return (latent / self.scale_factor) + self.shift_factor
Loading

0 comments on commit 8c4a9be

Please sign in to comment.