rapidrabbit76 / PaintsTensorFlow

line drawing colorization using TensorFlow
MIT License
52 stars 6 forks source link

Unable to test the model for an image #13

Closed Mps24-7uk closed 3 years ago

Mps24-7uk commented 3 years ago

Could we have an inference script for a single image with input color with respect to the point location instead of GUI? Could you also explain the line and hint parameter passed in the pred_image function of TensorModule.py, when I used the _buildHint function of Datasets.py to generate the hint parameter and passed it to the pred_image function, the predicted output is a dark color image. https://github.com/rapidrabbit76/PaintsTensorFlow/blob/a26de880dc43c915f3552b58e01a4314847fd58a/GUI/tensorModul/TensorModule.py#L22

rapidrabbit76 commented 3 years ago

@Mps24-7uk Sorry for the late reply.

  1. Could we have an inference script for a single image with input color with respect to the point location instead of GUI?

    • If you want random points u can use "_buildHint".
    • "dark color image" issues, u should check the hint value used as input. There was a problem that small hint points were lost during interpolation for resizing. simple way to solve this problem is to change RGB to RGBA and resize, then change to RGB to minimize the loss of hint points during the resizing process. (RGB -> RGBA -> resize -> RGB)
  2. explain the line and hint parameter for TensorModule.py

    • line: line is a grayscale numpy ndarray line-art image. ex: [512,512]
    • hint : hint is a numpy ndarray color point image of 3 channels (RBG) ex: [512,512,3]. hint is used in the model(Draft) by changing the white area (1.0) to 2.0 after normalization (-1 to 1 range) in the "PaintsTensorFlow.pred_image" method.

The _buildHint method is used to leak random pixels in a color image.

   def _buildHint(self, image):
        random = np.random.rand

        hint = np.ones_like(image)
        hint += 1

        leak_count = np.random.randint(16, 128)

        # leak position(random pixels in a color image.)
        x = np.random.randint(1, image.shape[0] - 1, leak_count)
        y = np.random.randint(1, image.shape[1] - 1, leak_count)

        def paintCel(i):
            color = image[x[i]][y[i]]
            hint[x[i]][y[i]] = color

            if random() > 0.5:
                hint[x[i]][y[i] + 1] = color
                hint[x[i]][y[i] - 1] = color

            if random() > 0.5:
                hint[x[i] + 1][y[i]] = color
                hint[x[i] - 1][y[i]] = color

        for i in range(leak_count):
            paintCel(i)
        return hint

For this project, we are currently working on a different repository

감사합니다.(Thank you.)