2,851
社区成员




在使用real-esrgan-x4plus模型对图片进行超分处理时,如何根据待处理的图片选择合适的模型呢?有哪些需要注意的呢?
准备4个模型,输入尺寸分别为128x128、256x256、384x384和512x512,对不同输入尺寸的图片,需要根据尺寸合理地选择模型:
def _select_model_size(self, height, width):
if width <= 128 and height <= 128:
return False, (128, 128)
elif width <= 256 and height <= 256:
return False, (256, 256)
elif width <= 384 and height <= 384:
return False, (384, 384)
elif width <= 512 and height <= 512:
return False, (512, 512)
elif width <= 512 or height <= 512:
return True, (512, 512)
return False, (-1, -1)
函数_select_model_size的返回值中包括两个值:布尔型的表示是否需要切分,二元组型的表示所选大模型。当需要对原图进行切分时,要优先按512x512进行切分,靠边的部分再选择合适尺寸的模型。
另外,为了避免对切分后超分处理的结果进行拼接时,不会出现如下图所示的竖纹,相邻两块切开需要至少16像素的重叠: