89 "pixel_shuffle": blocks.pixel_shuffle_block
90 }.get(self.upsampler)
91 if upsample_block is None:
92 raise NotImplementedError("Upsample mode [%s] is not found" % self.upsampler) 93
94 if self.scale == 3:
95 upsample_blocks = upsample_block(
37 "BD": BicubicUpsample(scale_factor=scale)
38 }.get(degradation)
39 if self.upsample_func is None:
40 raise NotImplementedError("Degradation [%s] is not recognized" % degradation) 41
42 self.fnet = FNet(in_nc)
43 self.srnet = SRNet(in_nc, out_nc, nf, nb, self.upsample_func)
40 if device == "cpu!":
41 device = "cpu"
42 if device != "cpu" and not torch.cuda.is_available():
43 raise EnvironmentError("Either NVIDIA CUDA or the device (%s) isn't available." % device)44
45 self.clip: vs.VideoNode = clip
46 self._device: torch.device = torch.device(device)
f-strings are the fastest way to format strings as compared to the following methods:
%
format()
str.join
+
operator to concatinate stringTemplate.substitute
Some less preferred ways to format strings are the following:
from string import Template
menu = ('eggs', 'spam', 42.4)
old_order = "%s and %s: %.2f ¤" % menu # [consider-using-f-string]
beginner_order = menu[0] + " and " + menu[1] + ": " + str(menu[2]) + " ¤"
joined_order = " and ".join(menu[:2])
format_order = "{} and {}: {:0.2f} ¤".format(menu[0], menu[1], menu[2])
named_format_order = "{eggs} and {spam}: {price:0.2f} ¤".format(eggs=menu[0], spam=menu[1], price=menu[2])
template_order = Template('$eggs and $spam: $price ¤').substitute(eggs=menu[0], spam=menu[1], price=menu[2])
Consider using f-strings as shown below:
menu = ('eggs', 'spam', 42.4)
f_string_order = f"{menu[0]} and {menu[1]}: {menu[2]:0.2f} ¤"