{"record":{"id":"f488ef747d8c2e40","repo":"ultralytics/yolov5","slug":"error-yolov5-tf-js-inference-is-not-supported","errorCode":null,"errorMessage":"ERROR: YOLOv5 TF.js inference is not supported","messagePattern":"ERROR: YOLOv5 TF\\.js inference is not supported","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"models/common.py","lineNumber":639,"sourceCode":"            if edgetpu:  # TF Edge TPU https://coral.ai/software/#edgetpu-runtime\n                LOGGER.info(f\"Loading {w} for TensorFlow Lite Edge TPU inference...\")\n                delegate = {\"Linux\": \"libedgetpu.so.1\", \"Darwin\": \"libedgetpu.1.dylib\", \"Windows\": \"edgetpu.dll\"}[\n                    platform.system()\n                ]\n                interpreter = Interpreter(model_path=w, experimental_delegates=[load_delegate(delegate)])\n            else:  # TFLite\n                LOGGER.info(f\"Loading {w} for TensorFlow Lite inference...\")\n                interpreter = Interpreter(model_path=w)  # load TFLite model\n            interpreter.allocate_tensors()  # allocate\n            input_details = interpreter.get_input_details()  # inputs\n            output_details = interpreter.get_output_details()  # outputs\n            # load metadata\n            with contextlib.suppress(zipfile.BadZipFile), zipfile.ZipFile(w, \"r\") as model:\n                meta_file = model.namelist()[0]\n                meta = ast.literal_eval(model.read(meta_file).decode(\"utf-8\"))\n                stride, names = int(meta[\"stride\"]), meta[\"names\"]\n        elif tfjs:  # TF.js\n            raise NotImplementedError(\"ERROR: YOLOv5 TF.js inference is not supported\")\n        # PaddlePaddle\n        elif paddle:\n            LOGGER.info(f\"Loading {w} for PaddlePaddle inference...\")\n            check_requirements(\"paddlepaddle-gpu\" if cuda else \"paddlepaddle>=3.0.0\")\n            import paddle.inference as pdi\n\n            w = Path(w)\n            if w.is_dir():\n                model_file = next(w.rglob(\"*.json\"), None)\n                params_file = next(w.rglob(\"*.pdiparams\"), None)\n            elif w.suffix == \".pdiparams\":\n                model_file = w.with_name(\"model.json\")\n                params_file = w\n            else:\n                raise ValueError(f\"Invalid model path {w}. Provide model directory or a .pdiparams file.\")\n\n            if not (model_file and params_file and model_file.is_file() and params_file.is_file()):\n                raise FileNotFoundError(f\"Model files not found in {w}. Both .json and .pdiparams files are required.\")","sourceCodeStart":621,"sourceCodeEnd":657,"githubUrl":"https://github.com/ultralytics/yolov5/blob/20d1d78a08277e365d57bfa3a2cce752772d9e59/models/common.py#L621-L657","documentation":"DetectMultiBackend raises NotImplementedError for TF.js model bundles. The branch recognizes the tfjs format (a directory or .pb-based graph produced by tensorflowjs) but deliberately has no inference implementation, so loading a TF.js-exported YOLOv5 model for inference is rejected. Export to TF.js is supported; running inference on it in this repo is not.","triggerScenarios":"Calling DetectMultiBackend('yolov5_web_model/') (the directory produced by export.py --include tfjs) or otherwise passing a tfjs-format path; converting weights with tensorflow_converter and pointing val.py/detect.py at the result.","commonSituations":"Users export tfjs for browser deployment and then try to validate accuracy locally with val.py; CI pipelines that reuse one export artifact for every backend test.","solutions":["Run TF.js inference where it is supported: in the browser via the exported web_model, or convert with tensorflowjs_converter and load in Node/browser.","For local sanity checks, export and validate a TFLite or saved_model instead: python export.py --weights yolov5s.pt --include tflite.","Compare outputs against the .pt or ONNX model rather than the tfjs bundle."],"exampleFix":"# before\nmodel = DetectMultiBackend('yolov5_web_model/')  # NotImplementedError\n\n# after\n# validate with tflite locally; deploy tfjs bundle in browser only\nmodel = DetectMultiBackend('yolov5s-fp16.tflite')","handlingStrategy":"type-guard","validationCode":"def is_tfjs_artifact(path: str) -> bool:\n    \"\"\"Detect the tfjs export shape that DetectMultiBackend rejects.\"\"\"\n    from pathlib import Path\n    p = Path(path)\n    return p.is_dir() and (p / 'model.json').exists() or str(path).endswith('.pb') and 'web_model' in str(path)","typeGuard":"SUPPORTED_SUFFIXES = ('.pt', '.torchscript', '.onnx', '.engine', '.tflite', '.pb', '.pdiparams')\n\ndef is_inferable_backend(path: str) -> bool:\n    \"\"\"False for tfjs bundles, which have no local inference path.\"\"\"\n    from pathlib import Path\n    p = Path(path)\n    if p.is_dir():\n        return not (p / 'model.json').exists()  # tfjs dir shape\n    return p.suffix in SUPPORTED_SUFFIXES","tryCatchPattern":"try:\n    model = DetectMultiBackend(w)\nexcept NotImplementedError as e:\n    if 'TF.js' in str(e):\n        raise SystemExit('tfjs is browser-only; validate with tflite instead') from e","preventionTips":["Validate accuracy with tflite/saved_model exports; treat tfjs as browser-only output.","Document per-format deployability in your export pipeline."],"tags":["tfjs","inference","unsupported-format","export"],"backgroundTag":null,"analyzedSha":"20d1d78a08277e365d57bfa3a2cce752772d9e59","analyzedAt":"2026-08-15T02:56:15.443Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}