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

Fix generator input.size() not equal to output.size() #57

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Fix generator input.size() not equal to output.size() #57

wants to merge 2 commits into from

Conversation

wasd96040501
Copy link

fix #4

def output_align(input, output):
    """
    In testing, sometimes output is several pixels less than irregular-size input,
    here is to fill them
    """
    if output.size() != input.size():
        diff_width = input.size(-1) - output.size(-1)
        diff_height = input.size(-2) - output.size(-2)
        m = nn.ReplicationPad2d((0, diff_width, 0, diff_height))
        output = m(output)

    return output

This function is from @youyuge34
Because images are resized to (256, 256) in training stage, this function has no side effect when running in training stage.

@wasd96040501 wasd96040501 reopened this Mar 8, 2019
@GuardSkill
Copy link

but the outputs in the forwarding process are not a single one, can it add into the forwarding process like this?
self.output_align(inputs,outputs)

@Mistariano
Copy link

but the outputs in the forwarding process are not a single one, can it add into the forwarding process like this?
self.output_align(inputs,outputs)

In test mode the batch size is set to 1 so, from my perspective, it's ok.


BTW my solution for the problem is to apply a resizing transformation on those images in load_item in dataset.py

def load_item(self, index):
    ...
    if size != 0:
        img = self.resize(img, size, size)
    else:
        img = self.resize(img, img.shape[0] // 4 * 4, img.shape[1] // 4 * 4)
    
    # also apply it on masks and edges

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

Successfully merging this pull request may close these issues.

A bug that edge image size will change after EdgeModel
4 participants