{"record":{"id":"e0773a06fb11daca","repo":"invoke-ai/InvokeAI","slug":"invalid-realesrgan-model-self-model-name","errorCode":null,"errorMessage":"Invalid RealESRGAN model: {self.model_name}","messagePattern":"Invalid RealESRGAN model: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"invokeai/app/invocations/upscale.py","lineNumber":90,"sourceCode":"                num_grow_ch=32,\n                scale=4,\n            )\n            netscale = 4\n        elif self.model_name in [\"RealESRGAN_x2plus.pth\"]:\n            # x2 RRDBNet model\n            rrdbnet_model = RRDBNet(\n                num_in_ch=3,\n                num_out_ch=3,\n                num_feat=64,\n                num_block=23,\n                num_grow_ch=32,\n                scale=2,\n            )\n            netscale = 2\n        else:\n            msg = f\"Invalid RealESRGAN model: {self.model_name}\"\n            context.logger.error(msg)\n            raise ValueError(msg)\n\n        loadnet = context.models.load_remote_model(\n            source=ESRGAN_MODEL_URLS[self.model_name],\n        )\n\n        with loadnet as loadnet_model:\n            upscaler = RealESRGAN(\n                scale=netscale,\n                loadnet=loadnet_model,\n                model=rrdbnet_model,\n                half=False,\n                tile=self.tile_size,\n            )\n\n            # prepare image - Real-ESRGAN uses cv2 internally, and cv2 uses BGR vs RGB for PIL\n            # TODO: This strips the alpha... is that okay?\n            cv2_image = cv2.cvtColor(np.array(image.convert(\"RGB\")), cv2.COLOR_RGB2BGR)\n            upscaled_image = upscaler.upscale(cv2_image)","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/invocations/upscale.py#L72-L108","documentation":"The RealESRGAN upscale invocation only recognizes a fixed set of model names (its ESRGAN_MODEL_URLS map keys, e.g. RealESRGAN_x4plus, RealESRGAN_x2plus, and the anime variants). When self.model_name is not a key of that map, it logs and raises ValueError.","triggerScenarios":"Passing model_name values like 'RealESRGAN_x4plus_anime_6B' misspelled, 'esrgan-x4', or any name absent from ESRGAN_MODEL_URLS when invoking the upscale invocation.","commonSituations":"Workflow JSON referencing a model renamed across InvokeAI versions; mixing up RealESRGAN names with plain ESRGAN model names; typo or wrong capitalization.","solutions":["Set model_name to one of the exact keys in ESRGAN_MODEL_URLS (e.g. 'RealESRGAN_x4plus')","Update stale workflows to current RealESRGAN model names","Check the invocation's model_name enum/field description for the accepted list"],"exampleFix":"// before\nmodel_name=\"RealESRGAN_x4\"\n// after\nmodel_name=\"RealESRGAN_x4plus\"","handlingStrategy":"validation","validationCode":"from invokeai.app.invocations.upscale import ESRGAN_MODEL_URLS\nif model_name not in ESRGAN_MODEL_URLS:\n    raise ValueError(f\"model_name must be one of {sorted(ESRGAN_MODEL_URLS)}, got {model_name!r}\")","typeGuard":"def is_valid_realesrgan_model(name: str) -> bool:\n    from invokeai.app.invocations.upscale import ESRGAN_MODEL_URLS\n    return name in ESRGAN_MODEL_URLS","tryCatchPattern":"try:\n    output = invocation.invoke(context)\nexcept ValueError as e:\n    if str(e).startswith(\"Invalid RealESRGAN model\"):\n        invocation.model_name = \"RealESRGAN_x4plus\"\n        output = invocation.invoke(context)\n    else:\n        raise","preventionTips":["Pick model_name from the field's enum/dropdown, never type it manually","After version upgrades, re-check the ESRGAN_MODEL_URLS key set","Distinguish RealESRGAN names from generic ESRGAN checkpoint names"],"tags":["validation","invokeai","upscale"],"backgroundTag":"invalid-enum-value","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}