Added error check for the rare case a user merges a pix2pix model with a normal model using weighted sum. Also removed bad print message that interfered with merging progress bar.

This commit is contained in:
ULTRANOX\Chris 2023-01-26 04:38:04 -05:00
parent f4ec411f2c
commit f90798c6b6

View File

@ -186,9 +186,10 @@ def run_modelmerger(id_task, primary_model_name, secondary_model_name, tertiary_
if a.shape != b.shape and a.shape[0:1] + a.shape[2:] == b.shape[0:1] + b.shape[2:]:
if a.shape[1] == 4 and b.shape[1] == 9:
raise RuntimeError("When merging inpainting model with a normal one, A must be the inpainting model.")
if a.shape[1] == 4 and b.shape[1] == 8:
raise RuntimeError("When merging pix2pix model with a normal one, A must be the pix2pix model.")
if a.shape[1] == 8 and b.shape[1] == 4:#If we have an InstructPix2Pix model...
print("Detected possible merge of instruct model with non-instruct model.")
theta_0[key][:, 0:4, :, :] = theta_func2(a[:, 0:4, :, :], b, multiplier)#Merge only the vectors the models have in common. Otherwise we get an error due to dimension mismatch.
result_is_pix2pix_model = True
else: