raiseRuntimeError("When merging inpainting model with a normal one, A must be the inpainting model.")
ifa.shape[1]==4andb.shape[1]==8:
raiseRuntimeError("When merging pix2pix model with a normal one, A must be the pix2pix model.")
raiseRuntimeError("When merging instruct-pix2pix model with a normal one, A must be the instruct-pix2pix model.")
ifa.shape[1]==8andb.shape[1]==4:#If we have an InstructPix2Pix model...
ifa.shape[1]==8andb.shape[1]==4:#If we have an Instruct-Pix2Pix 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
result_is_instruct_pix2pix_model =True
else:
asserta.shape[1]==9andb.shape[1]==4,f"Bad dimensions for merged layer {key}: A={a.shape}, B={b.shape}"