Introducing Gradio Clients
WatchIntroducing Gradio Clients
WatchNew to Gradio? Start here: Getting Started
See the Release History
gradio.AnnotatedImage(···)
tuple
consisting of a str
filepath to a base image and list
of annotations. Each annotation itself is tuple
of a mask (as a str
filepath to image) and a str
label.def predict(
value: tuple[str, list[tuple[str, str]]] | None
)
...
tuple[Image, list[Annotation]]
. The Image
itself can be str
filepath, numpy.ndarray
, or PIL.Image
. Each Annotation
is a tuple[Mask, str]
. The Mask
can be either a tuple
of 4 int
's representing the bounding box coordinates (x1, y1, x2, y2), or 0-1 confidence mask in the form of a numpy.ndarray
of the same shape as the image, while the second element of the Annotation
tuple is a str
label.def predict(···) -> tuple[np.ndarray | PIL.Image.Image | str, list[tuple[np.ndarray | tuple[int, int, int, int], str]]] | None
...
return value
Class | Interface String Shortcut | Initialization |
---|---|---|
| "annotatedimage" | Uses default values |
Event listeners allow you to respond to user interactions with the UI components you've defined in a Gradio Blocks app. When a user interacts with an element, such as changing a slider value or uploading an image, a function is called.
The AnnotatedImage component supports the following event listeners. Each event listener takes the same parameters, which are listed in the Event Parameters table below.
Listener | Description |
---|---|
| Event listener for when the user selects or deselects the AnnotatedImage. Uses event data gradio.SelectData to carry |