lllyasviel/Fooocus · error · ValueError

Image streaming only available if source is 'webcam'.

Error message

Image streaming only available if source is 'webcam'.

What it means

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.

Source

Thrown at modules/gradio_hijack.py:149

        self.shape = shape
        self.height = height
        self.width = width
        self.image_mode = image_mode
        valid_sources = ["upload", "webcam", "canvas"]
        if source not in valid_sources:
            raise ValueError(
                f"Invalid value for parameter `source`: {source}. Please choose from one of: {valid_sources}"
            )
        self.source = source
        if tool is None:
            self.tool = "sketch" if source == "canvas" else "editor"
        else:
            self.tool = tool
        self.invert_colors = invert_colors
        self.streaming = streaming
        self.show_download_button = show_download_button
        if streaming and source != "webcam":
            raise ValueError("Image streaming only available if source is 'webcam'.")
        self.select: EventListenerMethod
        """
        Event listener for when the user clicks on a pixel within the image.
        Uses event data gradio.SelectData to carry `index` to refer to the [x, y] coordinates of the clicked pixel.
        See EventData documentation on how to use this event data.
        """
        self.show_share_button = (
            (utils.get_space() is not None)
            if show_share_button is None
            else show_share_button
        )
        IOComponent.__init__(
            self,
            label=label,
            every=every,
            show_label=show_label,
            container=container,
            scale=scale,

View on GitHub (pinned to ae05379cc9)

Solutions

  1. Either set source='webcam' or drop streaming=True.
  2. Gate the flag: pass streaming=(source == 'webcam') when the same code builds multiple components.
  3. Remember construction fails at app startup, so the traceback points at the component definition line — fix that literal.

Example fix

# before
Image(source='upload', streaming=True)
# after
Image(source='upload')  # or source='webcam' if streaming is intended
Defensive patterns

Strategy: validation

Validate before calling

if streaming and source != 'webcam':
    streaming = False  # or raise early with your own message

Type guard

def streamable(source: str, streaming: bool) -> bool:
    return streaming and source == 'webcam'

Prevention

When it happens

Trigger: Image(source='upload', streaming=True) or Image(source='canvas', streaming=True) — any combination where streaming is truthy but source != 'webcam'.

Common situations: 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.

Related errors


AI-assisted analysis of lllyasviel/Fooocus@ae05379cc9 (2026-08-15). Data as JSON: /api/errors/caee19eb20d4efb6. Report an issue: GitHub.