Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i want to change mask,a problem occured #11

Open
zhangbaijin opened this issue Sep 10, 2019 · 5 comments
Open

i want to change mask,a problem occured #11

zhangbaijin opened this issue Sep 10, 2019 · 5 comments

Comments

@zhangbaijin
Copy link

zhangbaijin commented Sep 10, 2019

it's my code :

 def mask_width(img):
    image = img.copy()
    height = image.shape[0]
    width = image.shape[1]
    new_width = int(width * MASK_PERCENTAGE)
    mask = np.ones([height, new_width, 3])
    missing_x = img[:, :new_width]
    missing_y = img[:, width - new_width:]
    missing_part = np.concatenate((missing_x, missing_y), axis=1)
    image = image[:, :width - new_width]
    image = image[:, new_width:]
    return image, missing_part
    
def get_masked_images(images):
    mask_images = []
    missing_images = []
    for image in images:
        mask_image, missing_image = mask_width(image)
        mask_images.append(mask_image)
        missing_images.append(missing_image)
    return np.array(mask_images), np.array(missing_images)

def get_demask_images(original_images, generated_images):
    demask_images = []
    for o_image, g_image in zip(original_images, generated_images):
        width = g_image.shape[1] // 2
        x_image = g_image[:, :width]
        y_image = g_image[:, width:]
        o_image = np.concatenate((x_image,o_image, y_image), axis=1)
        demask_images.append(o_image)
    return np.asarray(demask_images)

i also change def dcrm_loss
d_input_shape = (int(INPUT_SHAPE[0] * (MASK_PERCENTAGE * 2)), int(INPUT_SHAPE[1] * (MASK_PERCENTAGE * 2)), INPUT_SHAPE[2])

and change def gen_loss
g_input_shape = (int(INPUT_SHAPE[0] * (MASK_PERCENTAGE * 2)), int(INPUT_SHAPE[1] * (MASK_PERCENTAGE * 2)), INPUT_SHAPE[2])

and i train:
Error when checking input: expected input_2 to have shape (256, 128, 3) but got array with shape (128, 128, 3)
......
thanks for your time!

@bendangnuksung
Copy link
Owner

All the models (Generator, Discriminator) need an Input Shape of (256, 128, 3). As I can see you are feeding an image shape of (128, 128, 3), make sure your custom data preparation is correct.

@zhangbaijin
Copy link
Author

zhangbaijin commented Sep 10, 2019 via email

@bendangnuksung
Copy link
Owner

To train with shape of (128, 128, 3) you need to change values in two files:

  1. prepare_data.py :
    input_shape = (256, 256)
    # to
    input_shape = (128, 128)
  1. outpaint.ipynb :
    INPUT_SHAPE = (256, 256, 3)
    # to
    INPUT_SHAPE = (128, 128, 3) 

After you modified the file you need to prepare the data again for (128,128,3) shape using prepare_data.py then you can start training the model.

@zhangbaijin
Copy link
Author

excuse me ,Maybe you don't understand what I mean.What you did before was to expand on both sides. Now I want to make it around . So i changed the code,but
Error when checking input: expected input_2 to have shape (256, 128, 3) but got array with shape (128, 128, 3)
It's not just a change prepare_data.py and outpaint.ipynb ..

thanks for your time!!

@bendangnuksung
Copy link
Owner

I don't see any code changes that in those three functions (mask_width(), get_masked_images(), get_demask_images()) you have mention above.

Now I want to make it around

I did not understand this part either. Can you elaborate?
I hope you understand why we use input shape of (256, 128, 3) instead of (128,128,3)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants