def hairstyle_transfer(self, im1_path, im2_path, alpha_blend=True):
        nonblended_name = self.__prepare_filename(im1_path, im2_path, False)
        blended_name = self.__prepare_filename(im1_path, im2_path, True)
        thefilename = blended_name if alpha_blend else nonblended_name
        if os.path.exists(thefilename):
            return thefilename
        else:
            if self.net is None:
                print('Model was not loaded. Loading default model')
                self.load_network()
            else:
                self.net.to(self.opts.device)
                if alpha_blend:
                    inner_face1, hair1, mask1 = utils.load_and_split_image(im1_path, return_mask=True)
                    inner_face2, hair2, mask2 = utils.load_and_split_image(im2_path, return_mask=True)
                else:
                    inner_face1, hair1 = utils.load_and_split_image(im1_path)
                inner_face2, hair2 = utils.load_and_split_image(im2_path)
            # print(f"Range of inner face: [{inner_face2.min()}, {inner_face2.max()}]")
            im2_orig = inner_face2 + hair2
            input_face = utils.numpy_uint8_to_torch(inner_face2.astype(np.uint8))
            input_hair = utils.numpy_uint8_to_torch(hair1.astype(np.uint8))
            if alpha_blend:
                masks = [
                 mask2]
                im_orig = [im2_orig]
            output = self.net.forward(input_face, input_hair, resize=False)
            output_images = output.cpu()
            for ii in range(output_images.shape[0]):
                img_generated = utils.torch_to_numpy_uint8(output_images[ii:ii + 1])
                if alpha_blend:
                    img_original = im_orig[ii]
                    im_mask = utils.gaussian_filter((masks[ii]), sigma=(self.alpha_blend_sigma))
                    # print(f"Range of image mask: [{im_mask.min()}, {im_mask.max()}]")
                    if img_original.shape[0] < 1024:
                        img_original = cv2.resize(img_original, (1024, 1024))
                    if im_mask.shape[0] < 1024:
                        im_mask = cv2.resize(im_mask, (1024, 1024))
                    masked_output = utils.alpha_blend_images(img_generated, img_original, im_mask)
                    # print(f"Range of masked output: [{masked_output.min()}, {masked_output.max()}]")
                    imageio.imwrite(blended_name, masked_output)
                imageio.imwrite(nonblended_name, img_generated)

            return thefilename
KeyError                                  Traceback (most recent call last)
/usr/local/lib/python3.10/dist-packages/PIL/Image.py in fromarray(obj, mode)
   3079         try:
-> 3080             mode, rawmode = _fromarray_typemap[typekey]
   3081         except KeyError as e:

KeyError: ((1, 1, 3), '<f8')

The above exception was the direct cause of the following exception:

TypeError                                 Traceback (most recent call last)
4 frames
/usr/local/lib/python3.10/dist-packages/PIL/Image.py in fromarray(obj, mode)
   3081         except KeyError as e:
   3082             msg = "Cannot handle this data type: %s, %s" % typekey
-> 3083             raise TypeError(msg) from e
   3084     else:
   3085         rawmode = mode

TypeError: Cannot handle this data type: (1, 1, 3), <f8