@@ -59,7 +59,7 @@ def to_cpu(self) -> T.Self:
5959 return self
6060
6161
62- class LossCollator (nn .Module ):
62+ class LossCollator (nn .Module ): # pylint:disable=too-many-instance-attributes
6363 """Compiles the chosen loss functions and calculates the values in the training loop
6464
6565 Parameters
@@ -68,6 +68,8 @@ class LossCollator(nn.Module):
6868 List of lost function names from configuration file to collate for loss calculation
6969 weights
7070 List of weights, corresponding to the the list of functions, to apply to each loss function
71+ color_order
72+ The color order that the model is training in
7173 use_mask
7274 ``True`` if loss should be masked as `penalize mask loss` has been selected
7375 eye_multiplier
@@ -82,13 +84,15 @@ class LossCollator(nn.Module):
8284 def __init__ (self ,
8385 functions : list [str ],
8486 weights : list [float ],
87+ color_order : T .Literal ["bgr" , "rgb" ],
8588 use_mask : bool ,
8689 eye_multiplier : float ,
8790 mouth_multiplier : float ,
8891 smallest_output : int ,
8992 mask_loss : str | None = None ) -> None :
90- logger .debug (parse_class_init (locals ()))
93+ logger .info (parse_class_init (locals ()))
9194 super ().__init__ ()
95+ self ._color_order : T .Literal ["bgr" , "rgb" ] = color_order
9296 self ._use_mask = use_mask
9397 self ._eye_multiplier = eye_multiplier
9498 self ._mouth_multiplier = mouth_multiplier
@@ -108,13 +112,12 @@ def __repr__(self) -> str:
108112 params = {"functions" : list (self ._functions ),
109113 "weights" : list (self ._weights .values ())}
110114 params |= {k [1 :]: v for k , v in self .__dict__ .items ()
111- if k in ("_use_mask" , "_eye_multiplier" , "_mouth_multiplier" ,
115+ if k in ("_color_order" , " _use_mask" , "_eye_multiplier" , "_mouth_multiplier" ,
112116 "_smallest_output" , "_mask_loss" )}
113117 s_params = ", " .join (f"{ k } ={ repr (v )} " for k , v in params .items ())
114118 return f"{ self .__class__ .__name__ } ({ s_params } )"
115119
116- @classmethod
117- def _configure_functions (cls ,
120+ def _configure_functions (self ,
118121 names : list [str ],
119122 weights : list [float ]) -> tuple [nn .ModuleDict , dict [str , float ]]:
120123 """Configure the selected loss functions and send to the correct device
@@ -148,7 +151,7 @@ def _configure_functions(cls,
148151 for name , weight in zip (names , weights ):
149152 if name is None or name == "none" or weight <= 0.0 :
150153 continue
151- functions [name ] = get_loss_function (name )
154+ functions [name ] = get_loss_function (name , self . _color_order )
152155 weight_dict [name ] = weight
153156
154157 logger .debug ("[Loss] Configured loss functions: %s" ,
0 commit comments