{"record":{"id":"e954f057c8978928","repo":"lllyasviel/Fooocus","slug":"error-running-this-interpretation-for-images-requ","errorCode":null,"errorMessage":"Error: running this interpretation for images requires scikit-image, please install it first.","messagePattern":"Error: running this interpretation for images requires scikit-image, please install it first\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"modules/gradio_hijack.py","lineNumber":356,"sourceCode":"            segments: Number of interpretation segments to split image into.\n        \"\"\"\n        self.interpretation_segments = segments\n        return self\n\n    def _segment_by_slic(self, x):\n        \"\"\"\n        Helper method that segments an image into superpixels using slic.\n        Parameters:\n            x: base64 representation of an image\n        \"\"\"\n        x = processing_utils.decode_base64_to_image(x)\n        if self.shape is not None:\n            x = processing_utils.resize_and_crop(x, self.shape)\n        resized_and_cropped_image = np.array(x)\n        try:\n            from skimage.segmentation import slic\n        except (ImportError, ModuleNotFoundError) as err:\n            raise ValueError(\n                \"Error: running this interpretation for images requires scikit-image, please install it first.\"\n            ) from err\n        try:\n            segments_slic = slic(\n                resized_and_cropped_image,\n                self.interpretation_segments,\n                compactness=10,\n                sigma=1,\n                start_label=1,\n            )\n        except TypeError:  # For skimage 0.16 and older\n            segments_slic = slic(\n                resized_and_cropped_image,\n                self.interpretation_segments,\n                compactness=10,\n                sigma=1,\n            )\n        return segments_slic, resized_and_cropped_image","sourceCodeStart":338,"sourceCodeEnd":374,"githubUrl":"https://github.com/lllyasviel/Fooocus/blob/ae05379cc97bc4361ec8b4ec90193dab21be763f/modules/gradio_hijack.py#L338-L374","documentation":"_segment_by_slic in the vendored gradio Image lazily imports skimage.segmentation.slic to compute superpixels for interpretation; if scikit-image is not installed the ImportError is caught and re-raised as ValueError('Error: running this interpretation for images requires scikit-image, please install it first.'). Only the image-interpretation feature needs scikit-image; the rest of the app does not.","triggerScenarios":"Clicking Interpret in the UI on an Image input (or calling the interpret API) in an environment where scikit-image is missing — the failure occurs exactly when the slic import runs, not at startup.","commonSituations":"Minimal Docker/venv installs that skipped optional deps; a fresh Fooocus install whose requirements file omits scikit-image; interpretation invoked accidentally via API clients.","solutions":["Install the dependency: pip install scikit-image (match your requirements file's version pin if present).","If you don't use interpretation, simply avoid the Interpret action — nothing else needs it.","For Docker images, add scikit-image to the requirements layer and rebuild."],"exampleFix":"# before: interpretation fails with ValueError\n# after\npip install scikit-image","handlingStrategy":"validation","validationCode":"try:\n    import skimage.segmentation  # noqa\n    interpretation_available = True\nexcept ImportError:\n    interpretation_available = False\n# hide/disable the Interpret button when interpretation_available is False","typeGuard":"def interpretation_supported() -> bool:\n    try:\n        import skimage  # noqa\n        return True\n    except ImportError:\n        return False","tryCatchPattern":"try:\n    interp = image_component.interpret(fn)\nexcept ValueError as e:\n    if 'scikit-image' in str(e):\n        print('Install scikit-image to enable interpretation: pip install scikit-image')\n    else:\n        raise","preventionTips":["Declare scikit-image in your deployment's requirements if you expose interpretation.","Probe optional deps at startup and disable the feature in the UI when missing."],"tags":["gradio","optional-dependency","scikit-image","interpretation","environment"],"backgroundTag":null,"analyzedSha":"ae05379cc97bc4361ec8b4ec90193dab21be763f","analyzedAt":"2026-08-15T04:23:59.533Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}