MCPcopy Create free account
hub / github.com/IceClear/StableSR / __init__

Method __init__

scripts/util_image.py:687–708  ·  view source on GitHub ↗

Input: im: n x c x h x w, torch tensor, float, low-resolution image in SR pch_size, stride: patch setting sf: scale factor in image super-resolution

(self, im, pch_size, stride, sf=1)

Source from the content-addressed store, hash-verified

685
686class ImageSpliterTh:
687 def __init__(self, im, pch_size, stride, sf=1):
688 '''
689 Input:
690 im: n x c x h x w, torch tensor, float, low-resolution image in SR
691 pch_size, stride: patch setting
692 sf: scale factor in image super-resolution
693 '''
694 assert stride <= pch_size
695 self.stride = stride
696 self.pch_size = pch_size
697 self.sf = sf
698
699 bs, chn, height, width= im.shape
700 self.height_starts_list = self.extract_starts(height)
701 self.width_starts_list = self.extract_starts(width)
702 self.length = self.__len__()
703 self.num_pchs = 0
704
705 self.im_ori = im
706 self.im_res = torch.zeros([bs, chn, height*sf, width*sf], dtype=im.dtype, device=im.device)
707 self.pixel_count = torch.zeros([bs, chn, height*sf, width*sf], dtype=im.dtype, device=im.device)
708 self.weight = self._gaussian_weights(pch_size, pch_size, bs, im.device)
709
710 def extract_starts(self, length):
711 if length <= self.pch_size:

Callers

nothing calls this directly

Calls 3

extract_startsMethod · 0.95
__len__Method · 0.95
_gaussian_weightsMethod · 0.95

Tested by

no test coverage detected