except ValueError as e:
message = str(e)
if "must have the same shape" in message:
min_shape = np.array([x.shape for x in all_res]).min(axis=0)
all_res = [arr[:min_shape[0], :min_shape[1]].copy() for arr in all_res]
new_images = np.stack(all_res)
setattr(self, component, new_images)
return self
After Change
components = kwargs.get("components", "images")
if isinstance(components, (list, tuple)):
all_res = list(zip(*all_res))
else:
components = [components]
all_res = [all_res]
for component, res in zip(components, all_res):