{"record":{"id":"4f7c536493a06500","repo":"Comfy-Org/ComfyUI","slug":"unsupported-rife-model-expected-5-blocks-found","errorCode":null,"errorMessage":"Unsupported RIFE model: expected 5 blocks, found {len(channels)}","messagePattern":"Unsupported RIFE model: expected 5 blocks, found (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"comfy_extras/frame_interpolation_models/ifnet.py","lineNumber":130,"sourceCode":"            else:\n                fd, mask, feat = block(\n                    torch.cat((warped_img0, warped_img1, self.warp(f0, flow[:, :2]), self.warp(f1, flow[:, 2:4]), timestep, mask, feat), 1),\n                    flow, scale=self.scale_list[i])\n                flow = flow.add_(fd)\n            warped_img0 = self.warp(img0, flow[:, :2])\n            warped_img1 = self.warp(img1, flow[:, 2:4])\n        return torch.lerp(warped_img1, warped_img0, torch.sigmoid(mask))\n\n\ndef detect_rife_config(state_dict):\n    head_ch = state_dict[\"encode.cnn3.weight\"].shape[1]  # ConvTranspose2d: (in_ch, out_ch, kH, kW)\n    channels = []\n    for i in range(5):\n        key = f\"blocks.{i}.conv0.1.0.weight\"\n        if key in state_dict:\n            channels.append(state_dict[key].shape[0])\n    if len(channels) != 5:\n        raise ValueError(f\"Unsupported RIFE model: expected 5 blocks, found {len(channels)}\")\n    return head_ch, channels\n","sourceCodeStart":112,"sourceCodeEnd":132,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy_extras/frame_interpolation_models/ifnet.py#L112-L132","documentation":"Raised by detect_rife_config() in comfy_extras/frame_interpolation_models/ifnet.py when probing a RIFE checkpoint's state dict: it reads the encoder channel count and then scans blocks.0..4.conv0.1.0.weight, requiring exactly 5 residual blocks with the expected key layout. Fewer than 5 matching keys means the checkpoint is a different RIFE architecture generation (RIFE v2/v4/v4.x variants have different block counts or key names) and this IFNet implementation cannot load it.","triggerScenarios":"Loading a RIFE .pth into the frame-interpolation node (comfy_extras/nodes_frame_interpolation.py calls detect_rife_config(sd) before constructing IFNet) where the checkpoint is an older/newer RIFE version whose block keys are absent or shaped differently — e.g. RIFE v2 checkpoints, community 'rife47' variants with renumbered blocks, or pruned/re-keyed state dicts.","commonSituations":"Downloading RIFE weights from community mirrors (flownet.pkl / .pth from HF) that are a different version than the supported 4.x family; renaming a trained/finetuned checkpoint; or using checkpoint-conversion tooling that strips 'module.' prefixes or renumbers blocks, breaking the key pattern the detector expects.","solutions":["Use a RIFE v4-family checkpoint known to work with ComfyUI's frame interpolation node (the officially referenced 4.x weights).","Inspect the state dict keys (torch.load then list(sd.keys())) and confirm blocks.0-4.conv0.1.0.weight all exist; if prefixed with 'module.', strip the prefix before load.","If the checkpoint is a different architecture version, convert it or obtain the matching version's weights rather than expecting this loader to handle it.","Verify integrity of the download — truncated files can load partially with missing keys."],"exampleFix":"# before\nsd = torch.load('rife_v2.pth')\ndetect_rife_config(sd)  # ValueError: expected 5 blocks, found 0\n\n# after: use supported v4-family weights, and normalize prefixes if needed\nsd = torch.load('rife46.pth')\nsd = { k[len('module.'):] if k.startswith('module.') else k: v for k, v in sd.items() }\ndetect_rife_config(sd)","handlingStrategy":"validation","validationCode":"import torch\n\ndef is_supported_rife(sd) -> bool:\n    if 'encode.cnn3.weight' not in sd: return False\n    keys = [f'blocks.{i}.conv0.1.0.weight' for i in range(5)]\n    return all(k in sd for k in keys)\n\nsd = torch.load(path, map_location='cpu')\nassert is_supported_rife(sd), 'checkpoint is not a supported RIFE v4-family model'","typeGuard":"def is_supported_rife(sd) -> bool:\n    if 'encode.cnn3.weight' not in sd: return False\n    return all(f'blocks.{i}.conv0.1.0.weight' in sd for i in range(5))","tryCatchPattern":"try:\n    head_ch, channels = detect_rife_config(sd)\nexcept ValueError as e:\n    raise RuntimeError(f'Incompatible RIFE checkpoint ({path}): {e}') from e","preventionTips":["Download RIFE weights from the source the node documentation references.","Strip 'module.' prefixes from DataParallel-saved checkpoints before loading.","List state-dict keys and check for the blocks.0-4 pattern before wiring the file in."],"tags":["rife","frame-interpolation","model-loading","checkpoint"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}