{"record":{"id":"caee19eb20d4efb6","repo":"lllyasviel/Fooocus","slug":"image-streaming-only-available-if-source-is-webca","errorCode":null,"errorMessage":"Image streaming only available if source is 'webcam'.","messagePattern":"Image streaming only available if source is 'webcam'\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"modules/gradio_hijack.py","lineNumber":149,"sourceCode":"        self.shape = shape\n        self.height = height\n        self.width = width\n        self.image_mode = image_mode\n        valid_sources = [\"upload\", \"webcam\", \"canvas\"]\n        if source not in valid_sources:\n            raise ValueError(\n                f\"Invalid value for parameter `source`: {source}. Please choose from one of: {valid_sources}\"\n            )\n        self.source = source\n        if tool is None:\n            self.tool = \"sketch\" if source == \"canvas\" else \"editor\"\n        else:\n            self.tool = tool\n        self.invert_colors = invert_colors\n        self.streaming = streaming\n        self.show_download_button = show_download_button\n        if streaming and source != \"webcam\":\n            raise ValueError(\"Image streaming only available if source is 'webcam'.\")\n        self.select: EventListenerMethod\n        \"\"\"\n        Event listener for when the user clicks on a pixel within the image.\n        Uses event data gradio.SelectData to carry `index` to refer to the [x, y] coordinates of the clicked pixel.\n        See EventData documentation on how to use this event data.\n        \"\"\"\n        self.show_share_button = (\n            (utils.get_space() is not None)\n            if show_share_button is None\n            else show_share_button\n        )\n        IOComponent.__init__(\n            self,\n            label=label,\n            every=every,\n            show_label=show_label,\n            container=container,\n            scale=scale,","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/lllyasviel/Fooocus/blob/ae05379cc97bc4361ec8b4ec90193dab21be763f/modules/gradio_hijack.py#L131-L167","documentation":"The vendored gradio Image constructor only allows streaming=True when the image source is the webcam; otherwise it raises ValueError('Image streaming only available if source is 'webcam'.') at construction. Streaming means the component emits continuous webcam frames during interaction, which is meaningless for uploads or canvas sketches.","triggerScenarios":"Image(source='upload', streaming=True) or Image(source='canvas', streaming=True) — any combination where streaming is truthy but source != 'webcam'.","commonSituations":"Copy-pasting a webcam-streaming example and then changing source to 'upload' without clearing streaming; enabling streaming globally in a custom tab template applied to all image widgets.","solutions":["Either set source='webcam' or drop streaming=True.","Gate the flag: pass streaming=(source == 'webcam') when the same code builds multiple components.","Remember construction fails at app startup, so the traceback points at the component definition line — fix that literal."],"exampleFix":"# before\nImage(source='upload', streaming=True)\n# after\nImage(source='upload')  # or source='webcam' if streaming is intended","handlingStrategy":"validation","validationCode":"if streaming and source != 'webcam':\n    streaming = False  # or raise early with your own message","typeGuard":"def streamable(source: str, streaming: bool) -> bool:\n    return streaming and source == 'webcam'","tryCatchPattern":null,"preventionTips":["Pass streaming=(source == 'webcam') in shared component factories.","Treat .stream() listeners as webcam-only by design."],"tags":["gradio","ui","webcam","streaming","constructor-validation"],"backgroundTag":null,"analyzedSha":"ae05379cc97bc4361ec8b4ec90193dab21be763f","analyzedAt":"2026-08-15T04:23:59.533Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}