File size: 762 Bytes
703e263
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from .sd_vae_encoder import SDVAEEncoderStateDictConverter, SDVAEEncoder


class SDXLVAEEncoder(SDVAEEncoder):
    def __init__(self, upcast_to_float32=True):
        super().__init__()
        self.scaling_factor = 0.13025
    
    @staticmethod
    def state_dict_converter():
        return SDXLVAEEncoderStateDictConverter()


class SDXLVAEEncoderStateDictConverter(SDVAEEncoderStateDictConverter):
    def __init__(self):
        super().__init__()

    def from_diffusers(self, state_dict):
        state_dict = super().from_diffusers(state_dict)
        return state_dict, {"upcast_to_float32": True}
    
    def from_civitai(self, state_dict):
        state_dict = super().from_civitai(state_dict)
        return state_dict, {"upcast_to_float32": True}