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)
| 685 | |
| 686 | class 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: |
nothing calls this directly
no test coverage detected