コード例 #1
0
        # facial features in images and map the style image onto content image
        # style_image = tf.image.resize_with_crop_or_pad(style_image, 1500,1500)

        # Trying face detection with OpenCV
        x, y, w, h = detectAnime(path_to_pics + filename, i)
        if x is not None:
            print(x, y, w, h)
        style_image = ImageUtils.grab_image("out.png")
        # style_image = tf.image.resize_with_crop_or_pad(style_image, 1000,1000)

        # Testing code ends here

        style_orig = style_image
        style_image = ImageUtils.image_op(
            images=[content_image, style_image],
            # Change this from a + b to something else
            # May use CNN to map features
            op=lambda a, b: ImageUtils.clip_0_1(a + b))

        print(" - Generating image", i)
        stylized_image = hub_model(tf.constant(content_image),
                                   tf.constant(style_image))[0]

        # Uncomment this and comment out previous stylized_image definition to
        # map style image on content image without style transfer
        # stylized_image = style_image

        # Clear figure and update images
        fig.clf()
        plotset1 = (  # This shows 2x3 5-plot layout
            ((2, 3, 1), content_image, 'Content Image'),
コード例 #2
0
            # style_image = tf.image.resize_with_crop_or_pad(style_image, 1500,1500)

            # Trying face detection with OpenCV
            x, y, w, h = detectAnime(path_to_pics + filename, i)
            if x is not None:
                print(x, y, w, h)
            style_image = ImageUtils.grab_image("out.png")
            # style_image = tf.image.resize_with_crop_or_pad(style_image, 1000,1000)

            # Testing code ends here

            style_orig = style_image
            style_image = ImageUtils.image_op(
                images=[content_image, style_image],
                # Change this from a + b to something else
                # May use CNN to map features
                # op     = lambda a, b: ImageUtils.clip_0_1(a*0.2 + b*1.8) # Grossly Overemphasizes style image
                # op     = lambda a, b: ImageUtils.clip_0_1(a*0.7 + b*1) # Overemphasizes style image
                op=lambda a, b: ImageUtils.clip_0_1(a + b))

            print(" - Generating image", i)
            stylized_image = hub_model(tf.constant(content_image),
                                       tf.constant(style_image))[0]

            # Uncomment this and comment out previous stylized_image definition to
            # map style image on content image without style transfer
            # stylized_image = style_image

            # Clear figure and update images
            # fig.clf()
            # plotset1 = (    # This shows 2x3 5-plot layout