Skip to main content
The Image component allows users to upload or display images.

Basic usage

Constructor

str | PIL.Image | np.ndarray | Callable | None
default:"None"
Default image to display. Can be filepath, URL, PIL Image, or numpy array
str
default:"'webp'"
File format for saving (e.g., “png”, “jpg”, “webp”)
Literal['numpy', 'pil', 'filepath']
default:"'numpy'"
Format passed to prediction function:
  • "numpy" - numpy array with shape (height, width, 3), values 0-255
  • "pil" - PIL Image object
  • "filepath" - string path to temporary file
list[Literal['upload', 'webcam', 'clipboard']] | None
default:"None"
Input sources:
  • "upload" - File upload box
  • "webcam" - Webcam capture
  • "clipboard" - Paste from clipboard
Defaults to all three if not streaming
Literal['RGB', 'RGBA', 'L', ...] | None
default:"'RGB'"
PIL image mode. “RGB” for color, “L” for grayscale
int | str | None
default:"None"
Component height in pixels or CSS units
int | str | None
default:"None"
Component width in pixels or CSS units
bool
default:"False"
If True, automatically streams webcam feed in live interfaces
list[Literal['download', 'share', 'fullscreen'] | Button] | None
default:"None"
Buttons to display. By default, all built-in buttons are shown

Events

  • change - Triggered when image changes
  • upload - Triggered when image is uploaded
  • clear - Triggered when image is cleared
  • stream - Triggered during streaming
  • select - Triggered when image is selected
  • input - Triggered on input

Examples

PIL image input

Webcam only

Grayscale images