If you have tried installing the original realesrgan and basicsr packages on a modern PyTorch 2.x + CUDA 12 Google Colab runtime lately, you already know how it goes: torchvision.transforms.functional_tensor was removed years ago, basicsr breaks on import, and half your GPU session disappears into wheel-pinning gymnastics.

When building AtelierPrint Vol. 1, a 6-piece coordinated architectural fine-art print collection, I needed true 300 DPI masters up to 7200 x 10800 px (24x36 in) across all five global frame ratios (2:3, 3:4, 4:5, 11x14, and ISO A2) with zero interpolation mush and zero pip dependency hell.

The fix turned out to be surprisingly small: the official RealESRGAN_x4plus.pth checkpoint is just a standard 23-block RRDBNet (num_in_ch=3, num_out_ch=3, num_feat=64, num_block=23, num_grow_ch=32). You do not need basicsr or facexlib at all.

1. Pure-PyTorch RRDBNet Inference (~60 lines)

Because PyTorch already ships torch.nn and torch.nn.functional.interpolate, you can instantiate the exact RRDBNet architecture directly and load the official params_ema state dictionary from RealESRGAN_x4plus.pth:

import torch import torch.nn as nn import torch.nn.functional as F class ResidualDenseBlock(nn.Module): def __init__(self, num_feat=64, num_grow_ch=32): super().__init__() self.conv1 = nn.Conv2d(num_feat, num_grow_ch, 3, 1, 1) self.conv2 = nn.Conv2d(num_feat + num_grow_ch, num_grow_ch, 3, 1, 1) self.conv3 = nn.Conv2d(num_feat + 2 * num_grow_ch, num_grow_ch, 3, 1, 1) self.conv4 = nn.Conv2d(num_feat + 3 * num_grow_ch, num_grow_ch, 3, 1, 1) self.conv5 = nn.Conv2d(num_feat + 4 * num_grow_ch, num_feat, 3, 1, 1) self.lrelu = nn.LeakyReLU(0.2, inplace=True) def forward(self, x): x1 = self.lrelu(self.conv1(x)) x2 = self.lrelu(self.conv2(torch.cat((x, x1), 1))) x3 = self.lrelu(self.conv3(torch.cat((x, x1, x2), 1))) x4 = self.lrelu(self.conv4(torch.cat((x, x1, x2, x3), 1))) x5 = self.conv5(torch.cat((x, x1, x2, x3, x4), 1)) return x5 * 0.2 + x class RRDB(nn.Module): def __init__(self, num_feat, num_grow_ch=32): super().__init__() self.rdb1 = ResidualDenseBlock(num_feat, num_grow_ch) self.rdb2 = ResidualDenseBlock(num_feat, num_grow_ch) self.rdb3 = ResidualDenseBlock(num_feat, num_grow_ch) def forward(self, x): out = self.rdb1(x) out = self.rdb2(out) out = self.rdb3(out) return out * 0.2 + x class RRDBNet(nn.Module): def __init__(self, num_in_ch=3, num_out_ch=3, num_feat=64, num_block=23, num_grow_ch=32): super().__init__() self.conv_first = nn.Conv2d(num_in_ch, num_feat, 3, 1, 1) self.body = nn.Sequential(*[RRDB(num_feat, num_grow_ch) for _ in range(num_block)]) self.conv_body = nn.Conv2d(num_feat, num_feat, 3, 1, 1) self.conv_up1 = nn.Conv2d(num_feat, num_feat, 3, 1, 1) self.conv_up2 = nn.Conv2d(num_feat, num_feat, 3, 1, 1) self.conv_hr = nn.Conv2d(num_feat, num_feat, 3, 1, 1) self.conv_last = nn.Conv2d(num_feat, num_out_ch, 3, 1, 1) self.lrelu = nn.LeakyReLU(0.2, inplace=True) def forward(self, x): feat = self.conv_first(x) body_feat = self.conv_body(self.body(feat)) feat = feat + body_feat feat = self.lrelu(self.conv_up1(F.interpolate(feat, scale_factor=2, mode="nearest"))) feat = self.lrelu(self.conv_up2(F.interpolate(feat, scale_factor=2, mode="nearest"))) return self.conv_last(self.lrelu(self.conv_hr(feat))) 

Running this in FP16 with 512x512 tiled inference (tile_pad=32) on an NVIDIA L4 GPU upscales six large masters cleanly in under 3 minutes with zero seam artifacts and zero external package failures.

2. Exporting All 5 Standard Global Frame Ratios at True 300 DPI

Most print buyers run into a quiet failure mode when ordering large wall art: a single 2:3 file gets cropped awkwardly inside an 11x14 or ISO A2 frame, or the JPEG header still carries 72 DPI metadata so print shops throw a low-resolution warning.

Once the 4x neural master is ready, a deterministic Pillow pass center-crops and exports all five frame ratios with explicit dpi=(300, 300) and 4:4:4 chroma (subsampling=0):

Ratio Pack Pixel Dimensions Print Sizes Covered
2:3 7200 x 10800 px 24x36, 20x30, 16x24, 12x18, 8x12, 4x6 in
3:4 5400 x 7200 px 18x24, 12x16, 9x12, 6x8 in
4:5 4800 x 6000 px 16x20, 12x15, 8x10, 4x5 in
11x14 3300 x 4200 px 11x14 in
ISO A2 4961 x 7016 px A2, A3, A4, A5 and 50x70 cm
fitted = cropped.resize((target_w, target_h), Image.Resampling.LANCZOS) fitted = fitted.filter(ImageFilter.UnsharpMask(radius=1.2, percent=45, threshold=4)) fitted.save( dst, format="JPEG", quality=95, subsampling=0, dpi=(300, 300), optimize=True, ) 

3. Automated + 100% Zoom Pixel QA

Before zipping any release, two verification gates catch issues early:

  1. Automated header check: confirm every output file is RGB, exact target dimensions, dpi >= 300, and non-corrupt.
  2. 100% zoom crop inspection: save a 512 x 512 px center crop from each 7200 x 10800 master and inspect it at 1:1 pixel zoom for ringing halos, tile seams, or flat mush on natural stone and shadow gradients.

Live Gallery & Full Collection

You can inspect all 6 pieces, switch frame styles (Oak, Walnut, Frameless), and view the full ratio reference table in the live interactive gallery: