本文整理汇总了Python中data.common.set_channel方法的典型用法代码示例。如果您正苦于以下问题:Python common.set_channel方法的具体用法?Python common.set_channel怎么用?Python common.set_channel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类data.common
的用法示例。
在下文中一共展示了common.set_channel方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __getitem__
# 需要导入模块: from data import common [as 别名]
# 或者: from data.common import set_channel [as 别名]
def __getitem__(self, idx):
if self.train:
lr, hr, filename = self._load_file(idx)
lr, hr= self.get_patch(*[lr, hr])
lr, hr = common.set_channel(lr, hr, n_channels=self.args.n_colors)
lr_tensor, hr_tensor = common.np2Tensor(
lr, hr, rgb_range=self.args.rgb_range
)
return lr_tensor, hr_tensor,filename
else:
lr, hr, filename = self._load_file(idx)
lr, hr= self.get_patch(*[lr, hr])
lr, hr = common.set_channel(lr, hr, n_channels=self.args.n_colors)
lr_tensor, hr_tensor = common.np2Tensor(
lr, hr, rgb_range=self.args.rgb_range
)
return lr_tensor, hr_tensor,filename
示例2: __getitem__
# 需要导入模块: from data import common [as 别名]
# 或者: from data.common import set_channel [as 别名]
def __getitem__(self, idx):
lr, hr, filename = self._load_file(idx)
pair = self.get_patch(lr, hr)
pair = common.set_channel(*pair, n_channels=self.args.n_colors)
pair_t = common.np2Tensor(*pair, rgb_range=self.args.rgb_range)
return pair_t[0], pair_t[1], filename
示例3: __getitem__
# 需要导入模块: from data import common [as 别名]
# 或者: from data.common import set_channel [as 别名]
def __getitem__(self, idx):
filename = os.path.splitext(os.path.basename(self.filelist[idx]))[0]
lr = imageio.imread(self.filelist[idx])
lr, = common.set_channel(lr, n_channels=self.args.n_colors)
lr_t, = common.np2Tensor(lr, rgb_range=self.args.rgb_range)
return lr_t, -1, filename
示例4: __getitem__
# 需要导入模块: from data import common [as 别名]
# 或者: from data.common import set_channel [as 别名]
def __getitem__(self, idx):
success, lr = self.vidcap.read()
if success:
self.n_frames += 1
lr, = common.set_channel(lr, n_channels=self.args.n_colors)
lr_t, = common.np2Tensor(lr, rgb_range=self.args.rgb_range)
return lr_t, -1, '{}_{:0>5}'.format(self.filename, self.n_frames)
else:
vidcap.release()
return None
示例5: __getitem__
# 需要导入模块: from data import common [as 别名]
# 或者: from data.common import set_channel [as 别名]
def __getitem__(self, idx):
lr, hr, filename = self._load_file(idx)
lr, hr = self._get_patch(lr, hr)
lr, hr = common.set_channel([lr, hr], self.args.n_colors)
lr_tensor, hr_tensor = common.np2Tensor([lr, hr], self.args.rgb_range)
return lr_tensor, hr_tensor, filename
示例6: __getitem__
# 需要导入模块: from data import common [as 别名]
# 或者: from data.common import set_channel [as 别名]
def __getitem__(self, idx):
lr, nl, mk, hr, filename = self._load_file(idx)
lr, nl, mk, hr = self._get_patch(lr, nl, mk, hr)
lr, hr = common.set_channel([lr, hr], self.args.n_colors)
#print('The size of lr, hr images are {}, {}'.format(lr.shape, hr.shape))
lr_tensor, nl_tensor, mk_tensor, hr_tensor = common.np2Tensor([lr, nl, mk, hr], self.args.rgb_range)
# if self.model_flag.lower() == 'finetune':
return lr_tensor, nl_tensor, mk_tensor, hr_tensor, filename
# else:
# return lr_tensor, hr_tensor, filename
示例7: __getitem__
# 需要导入模块: from data import common [as 别名]
# 或者: from data.common import set_channel [as 别名]
def __getitem__(self, idx):
filename = os.path.split(self.filelist[idx])[-1]
filename, _ = os.path.splitext(filename)
lr = misc.imread(self.filelist[idx])
lr = common.set_channel([lr], self.args.n_colors)[0]
return common.np2Tensor([lr], self.args.rgb_range)[0], -1, filename
示例8: __getitem__
# 需要导入模块: from data import common [as 别名]
# 或者: from data.common import set_channel [as 别名]
def __getitem__(self, idx):
lr, hr, filename = self._load_file(idx)
lr, hr = self.get_patch(lr, hr)
lr, hr = common.set_channel(lr, hr, n_channels=self.args.n_colors)
lr_tensor, hr_tensor = common.np2Tensor(
lr, hr, rgb_range=self.args.rgb_range
)
return lr_tensor, hr_tensor, filename
示例9: __getitem__
# 需要导入模块: from data import common [as 别名]
# 或者: from data.common import set_channel [as 别名]
def __getitem__(self, idx):
filename = os.path.split(self.filelist[idx])[-1]
filename, _ = os.path.splitext(filename)
lr = imageio.imread(self.filelist[idx])
lr, = common.set_channel(lr, n_channels=self.args.n_colors)
lr_t, = common.np2Tensor(lr, rgb_range=self.args.rgb_range)
return lr_t, -1, filename
示例10: __getitem__
# 需要导入模块: from data import common [as 别名]
# 或者: from data.common import set_channel [as 别名]
def __getitem__(self, idx):
lr, hr, filename = self._load_file(idx)
lr, hr = self.get_patch(lr, hr)
lr, hr = common.set_channel(lr, hr, n_channels=self.args.n_colors)
lr_tensor, hr_tensor = common.np2Tensor(
lr, hr, rgb_range=self.args.rgb_range
)
return lr_tensor, hr_tensor, filename
示例11: test
# 需要导入模块: from data import common [as 别名]
# 或者: from data.common import set_channel [as 别名]
def test(self):
torch.set_grad_enabled(False)
self.ckp.write_log('\nEvaluation on video:')
self.model.eval()
timer_test = utility.timer()
for idx_scale, scale in enumerate(self.scale):
vidcap = cv2.VideoCapture(self.args.dir_demo)
total_frames = int(vidcap.get(cv2.CAP_PROP_FRAME_COUNT))
vidwri = cv2.VideoWriter(
self.ckp.get_path('{}_x{}.avi'.format(self.filename, scale)),
cv2.VideoWriter_fourcc(*'XVID'),
vidcap.get(cv2.CAP_PROP_FPS),
(
int(scale * vidcap.get(cv2.CAP_PROP_FRAME_WIDTH)),
int(scale * vidcap.get(cv2.CAP_PROP_FRAME_HEIGHT))
)
)
tqdm_test = tqdm(range(total_frames), ncols=80)
for _ in tqdm_test:
success, lr = vidcap.read()
if not success: break
lr, = common.set_channel(lr, n_channels=self.args.n_colors)
lr, = common.np2Tensor(lr, rgb_range=self.args.rgb_range)
lr, = self.prepare(lr.unsqueeze(0))
sr = self.model(lr, idx_scale)
sr = utility.quantize(sr, self.args.rgb_range).squeeze(0)
normalized = sr * 255 / self.args.rgb_range
ndarr = normalized.byte().permute(1, 2, 0).cpu().numpy()
vidwri.write(ndarr)
vidcap.release()
vidwri.release()
self.ckp.write_log(
'Total: {:.2f}s\n'.format(timer_test.toc()), refresh=True
)
torch.set_grad_enabled(True)