Giter VIP home page Giter VIP logo

Comments (3)

Zheng222 avatar Zheng222 commented on September 26, 2024

@nan-rock

IMDN/test_IMDN_AS.py

Lines 30 to 60 in f1170cf

def crop_forward(x, model, shave=32):
b, c, h, w = x.size()
h_half, w_half = h // 2, w // 2
h_size, w_size = h_half + shave - (h_half + shave) % 4, w_half + shave - (w_half + shave) % 4
inputlist = [
x[:, :, 0:h_size, 0:w_size],
x[:, :, 0:h_size, (w - w_size):w],
x[:, :, (h - h_size):h, 0:w_size],
x[:, :, (h - h_size):h, (w - w_size):w]]
outputlist = []
with torch.no_grad():
input_batch = torch.cat(inputlist, dim=0)
output_batch = model(input_batch)
outputlist.extend(output_batch.chunk(4, dim=0))
output = torch.zeros_like(x)
output[:, :, 0:h_half, 0:w_half] \
= outputlist[0][:, :, 0:h_half, 0:w_half]
output[:, :, 0:h_half, w_half:w] \
= outputlist[1][:, :, 0:h_half, (w_size - w + w_half):w_size]
output[:, :, h_half:h, 0:w_half] \
= outputlist[2][:, :, (h_size - h + h_half):h_size, 0:w_half]
output[:, :, h_half:h, w_half:w] \
= outputlist[3][:, :, (h_size - h + h_half):h_size, (w_size - w + w_half):w_size]
return output

from imdn.

nanmehta avatar nanmehta commented on September 26, 2024

thanks for the quick response.
i just wanted to ask as you mentioned in issue #9 regarding adaptive cropping tha it allows us to output exactly the same size as the target size. But does it make a difference in the overall result. As in the example you gave the output using this strategy is (2801x 2001) instead of 2800 X2000. But even we ignore 1 pixel from the boundary it wont make much difference

from imdn.

EvelyneCalista avatar EvelyneCalista commented on September 26, 2024

Hello, may I ask if I would like to use ACS, shall I modify the train code with the crop_forward too?
thank you.

from imdn.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.