Add to docs (#1866)

This commit is contained in:
Freddy Boulton 2022-07-25 10:20:10 -04:00 committed by GitHub
parent 5988aa758c
commit 1779187692
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 4 deletions

View File

@ -26,6 +26,7 @@ from gradio.components import (
Highlightedtext,
HighlightedText,
Image,
Interpretation,
Json,
Label,
Markdown,

View File

@ -4015,10 +4015,13 @@ class Markdown(IOComponent, Changeable):
############################
@document()
class Dataset(Clickable, Component):
"""
Used to create a output widget for showing datasets. Used to render the examples
box in the interface.
Used to create an output widget for showing datasets. Used to render the examples
box.
Preprocessing: this component does *not* accept input.
Postprocessing: expects a {list} of {lists} corresponding to the dataset data.
"""
def __init__(
@ -4088,9 +4091,12 @@ class Dataset(Clickable, Component):
)
@document()
class Interpretation(Component):
"""
Used to create an interpretation widget for a component.
Preprocessing: this component does *not* accept input.
Postprocessing: expects a {dict} with keys "original" and "interpretation".
"""
def __init__(
@ -4101,6 +4107,12 @@ class Interpretation(Component):
elem_id: Optional[str] = None,
**kwargs,
):
"""
Parameters:
component: Which component to show in the interpretation widget.
visible: Whether or not the interpretation is visible.
elem_id: An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.
"""
Component.__init__(self, visible=visible, elem_id=elem_id, **kwargs)
self.component = component

View File

@ -1,7 +1,7 @@
<script type="module" src="https://gradio.s3-us-west-2.amazonaws.com/3.1.0/gradio.js"></script>
# Custom Machine Learning Interpretations with Blocks
Docs: Blocks
Docs: blocks, interpretation
Tags: INTERPRETATION, SENTIMENT ANALYSIS
**Prerequisite**: This Guide requires you to know about Blocks and the interpretation feature of Interfaces.

View File

@ -56,7 +56,8 @@ def add_supported_events():
component["events"].append("edit()")
if issubclass(component["class"], Submittable):
component["events"].append("submit()")
component["events"] = ", ".join(component["events"])
if component["events"]:
component["events"] = ", ".join(component["events"])
add_supported_events()
@ -79,6 +80,7 @@ override_signature("Column", "with gradio.Column():")
override_signature("Tabs", "with gradio.Tabs():")
override_signature("Group", "with gradio.Group():")
override_signature("Box", "with gradio.Box():")
override_signature("Dataset", "gr.Dataset(components, samples)")
def find_cls(target_cls):

View File

@ -56,8 +56,10 @@
{% if "examples-format" in obj["tags"] %}
<p class="text-lg text-gray-500">Format expected for examples: {{ obj["tags"]["examples-format"] }}</p>
{% endif %}
{% if obj["events"]|length > 0 %}
<p class="text-lg text-gray-500">Supported events: <em>{{ obj["events"] }}</em></p>
{% endif %}
{% endif %}
{% if obj["example"] %}
<h4 class="mt-4 p-3 font-semibold">Example Usage</h4>