gradio-rerun


Namegradio-rerun JSON
Version 0.0.1 PyPI version JSON
download
home_pageNone
SummaryRerun viewer with Gradio
upload_time2024-04-29 19:34:23
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseNone
keywords rerun gradio-custom-component machine learning multimodal data rerun-viewer robotics visualization
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ---
tags: [gradio-custom-component, SimpleImage, multimodal data, visualization, machine learning, robotics]
title: gradio_rerun
short_description: Rerun viewer with Gradio
colorFrom: blue
colorTo: yellow
sdk: gradio
pinned: false
app_file: space.py
---

# `gradio_rerun`
<img alt="Static Badge" src="https://img.shields.io/badge/version%20-%200.0.1%20-%20orange"> <a href="https://github.com/radames/gradio-rerun-viewer/issues" target="_blank"><img alt="Static Badge" src="https://img.shields.io/badge/Issues-white?logo=github&logoColor=black"></a> 

Rerun viewer with Gradio

## Installation

```bash
pip install gradio_rerun
```

## Usage

```python
import gradio as gr
from gradio_rerun import Rerun


example = Rerun().example_value()


def predict(url: str, file_path: str | list[str] | None):
    if url:
        return url
    return file_path


with gr.Blocks(css=".gradio-container { max-width: unset!important; }") as demo:
    with gr.Row():
        with gr.Column():
            with gr.Group():
                file_path = gr.File(file_count="multiple", type="filepath")
                url = gr.Text(
                    info="Or use a URL",
                    label="URL",
                )
        with gr.Column():
            pass
    btn = gr.Button("Run", scale=0)
    with gr.Row():
        rerun_viewer = Rerun(height=900)

    inputs = [file_path, url]
    outputs = [rerun_viewer]

    gr.on([btn.click, file_path.upload], fn=predict, inputs=inputs, outputs=outputs)

    gr.Examples(
        examples=[
            [
                None,
                "https://app.rerun.io/version/0.15.1/examples/detect_and_track_objects.rrd",
            ],
            [
                ["./examples/rgbd.rrd"],
                None,
            ],
            [
                ["./examples/rrt-star.rrd"],
                None,
            ],
            [
                ["./examples/structure_from_motion.rrd"],
                None,
            ],
            [
                ["./examples/structure_from_motion.rrd", "./examples/rrt-star.rrd"],
                None,
            ],
        ],
        fn=predict,
        inputs=inputs,
        outputs=outputs,
        run_on_click=True,
    )

if __name__ == "__main__":
    demo.launch()

```

## `Rerun`

### Initialization

<table>
<thead>
<tr>
<th align="left">name</th>
<th align="left" style="width: 25%;">type</th>
<th align="left">default</th>
<th align="left">description</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left"><code>value</code></td>
<td align="left" style="width: 25%;">

```python
list[str] | None
```

</td>
<td align="left"><code>None</code></td>
<td align="left">A path or URL for the default value that Rerun component is going to take. If callable, the function will be called whenever the app loads to set the initial value of the component.</td>
</tr>

<tr>
<td align="left"><code>label</code></td>
<td align="left" style="width: 25%;">

```python
str | None
```

</td>
<td align="left"><code>None</code></td>
<td align="left">The label for this component. Appears above the component and is also used as the header if there are a table of examples for this component. If None and used in a `gr.Interface`, the label will be the name of the parameter this component is assigned to.</td>
</tr>

<tr>
<td align="left"><code>every</code></td>
<td align="left" style="width: 25%;">

```python
float | None
```

</td>
<td align="left"><code>None</code></td>
<td align="left">If `value` is a callable, run the function 'every' number of seconds while the client connection is open. Has no effect otherwise. Queue must be enabled. The event can be accessed (e.g. to cancel it) via this component's .load_event attribute.</td>
</tr>

<tr>
<td align="left"><code>show_label</code></td>
<td align="left" style="width: 25%;">

```python
bool | None
```

</td>
<td align="left"><code>None</code></td>
<td align="left">if True, will display label.</td>
</tr>

<tr>
<td align="left"><code>show_download_button</code></td>
<td align="left" style="width: 25%;">

```python
bool
```

</td>
<td align="left"><code>True</code></td>
<td align="left">If True, will display button to download image.</td>
</tr>

<tr>
<td align="left"><code>container</code></td>
<td align="left" style="width: 25%;">

```python
bool
```

</td>
<td align="left"><code>True</code></td>
<td align="left">If True, will place the component in a container - providing some extra padding around the border.</td>
</tr>

<tr>
<td align="left"><code>scale</code></td>
<td align="left" style="width: 25%;">

```python
int | None
```

</td>
<td align="left"><code>None</code></td>
<td align="left">relative size compared to adjacent Components. For example if Components A and B are in a Row, and A has scale=2, and B has scale=1, A will be twice as wide as B. Should be an integer. scale applies in Rows, and to top-level Components in Blocks where fill_height=True.</td>
</tr>

<tr>
<td align="left"><code>min_width</code></td>
<td align="left" style="width: 25%;">

```python
int
```

</td>
<td align="left"><code>160</code></td>
<td align="left">minimum pixel width, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in this Component being narrower than min_width, the min_width parameter will be respected first.</td>
</tr>

<tr>
<td align="left"><code>height</code></td>
<td align="left" style="width: 25%;">

```python
int | str
```

</td>
<td align="left"><code>640</code></td>
<td align="left">height of component in pixels. If a string is provided, will be interpreted as a CSS value. If None, will be set to 640px.</td>
</tr>

<tr>
<td align="left"><code>interactive</code></td>
<td align="left" style="width: 25%;">

```python
bool | None
```

</td>
<td align="left"><code>None</code></td>
<td align="left">if True, will allow users to upload and edit an image; if False, can only be used to display images. If not provided, this is inferred based on whether the component is used as an input or output.</td>
</tr>

<tr>
<td align="left"><code>visible</code></td>
<td align="left" style="width: 25%;">

```python
bool
```

</td>
<td align="left"><code>True</code></td>
<td align="left">If False, component will be hidden.</td>
</tr>

<tr>
<td align="left"><code>elem_id</code></td>
<td align="left" style="width: 25%;">

```python
str | None
```

</td>
<td align="left"><code>None</code></td>
<td align="left">An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.</td>
</tr>

<tr>
<td align="left"><code>elem_classes</code></td>
<td align="left" style="width: 25%;">

```python
list[str] | str | None
```

</td>
<td align="left"><code>None</code></td>
<td align="left">An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.</td>
</tr>

<tr>
<td align="left"><code>render</code></td>
<td align="left" style="width: 25%;">

```python
bool
```

</td>
<td align="left"><code>True</code></td>
<td align="left">If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.</td>
</tr>
</tbody></table>


### Events

| name | description |
|:-----|:------------|
| `clear` | This listener is triggered when the user clears the Rerun using the X button for the component. |
| `change` | Triggered when the value of the Rerun changes either because of user input (e.g. a user types in a textbox) OR because of a function update (e.g. an image receives a value from the output of an event trigger). See `.input()` for a listener that is only triggered by user input. |
| `upload` | This listener is triggered when the user uploads a file into the Rerun. |



### User function

The impact on the users predict function varies depending on whether the component is used as an input or output for an event (or both).

- When used as an Input, the component only impacts the input signature of the user function.
- When used as an output, the component only impacts the return signature of the user function.

The code snippet below is accurate in cases where the component is used as both an input and an output.

- **As output:** Is passed, a `str` containing the path to the image.
- **As input:** Should return, expects a `str` or `pathlib.Path` object containing the path to the image.

 ```python
 def predict(
     value: str | None
 ) -> list[gradio.data_classes.FileData]
    | gradio.data_classes.FileData
    | str
    | list[str]:
     return value
 ```
 

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "gradio-rerun",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "Rerun, gradio-custom-component, machine learning, multimodal data, rerun-viewer, robotics, visualization",
    "author": null,
    "author_email": "Radam\u00e9s Ajna <radamajna@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/fc/3b/74f97ddca1346c930c4f55ecbf1802bd7f2e8497c0b2eec4ef98e10d939b/gradio_rerun-0.0.1.tar.gz",
    "platform": null,
    "description": "---\ntags: [gradio-custom-component, SimpleImage, multimodal data, visualization, machine learning, robotics]\ntitle: gradio_rerun\nshort_description: Rerun viewer with Gradio\ncolorFrom: blue\ncolorTo: yellow\nsdk: gradio\npinned: false\napp_file: space.py\n---\n\n# `gradio_rerun`\n<img alt=\"Static Badge\" src=\"https://img.shields.io/badge/version%20-%200.0.1%20-%20orange\"> <a href=\"https://github.com/radames/gradio-rerun-viewer/issues\" target=\"_blank\"><img alt=\"Static Badge\" src=\"https://img.shields.io/badge/Issues-white?logo=github&logoColor=black\"></a> \n\nRerun viewer with Gradio\n\n## Installation\n\n```bash\npip install gradio_rerun\n```\n\n## Usage\n\n```python\nimport gradio as gr\nfrom gradio_rerun import Rerun\n\n\nexample = Rerun().example_value()\n\n\ndef predict(url: str, file_path: str | list[str] | None):\n    if url:\n        return url\n    return file_path\n\n\nwith gr.Blocks(css=\".gradio-container { max-width: unset!important; }\") as demo:\n    with gr.Row():\n        with gr.Column():\n            with gr.Group():\n                file_path = gr.File(file_count=\"multiple\", type=\"filepath\")\n                url = gr.Text(\n                    info=\"Or use a URL\",\n                    label=\"URL\",\n                )\n        with gr.Column():\n            pass\n    btn = gr.Button(\"Run\", scale=0)\n    with gr.Row():\n        rerun_viewer = Rerun(height=900)\n\n    inputs = [file_path, url]\n    outputs = [rerun_viewer]\n\n    gr.on([btn.click, file_path.upload], fn=predict, inputs=inputs, outputs=outputs)\n\n    gr.Examples(\n        examples=[\n            [\n                None,\n                \"https://app.rerun.io/version/0.15.1/examples/detect_and_track_objects.rrd\",\n            ],\n            [\n                [\"./examples/rgbd.rrd\"],\n                None,\n            ],\n            [\n                [\"./examples/rrt-star.rrd\"],\n                None,\n            ],\n            [\n                [\"./examples/structure_from_motion.rrd\"],\n                None,\n            ],\n            [\n                [\"./examples/structure_from_motion.rrd\", \"./examples/rrt-star.rrd\"],\n                None,\n            ],\n        ],\n        fn=predict,\n        inputs=inputs,\n        outputs=outputs,\n        run_on_click=True,\n    )\n\nif __name__ == \"__main__\":\n    demo.launch()\n\n```\n\n## `Rerun`\n\n### Initialization\n\n<table>\n<thead>\n<tr>\n<th align=\"left\">name</th>\n<th align=\"left\" style=\"width: 25%;\">type</th>\n<th align=\"left\">default</th>\n<th align=\"left\">description</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td align=\"left\"><code>value</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nlist[str] | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">A path or URL for the default value that Rerun component is going to take. If callable, the function will be called whenever the app loads to set the initial value of the component.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>label</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nstr | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">The label for this component. Appears above the component and is also used as the header if there are a table of examples for this component. If None and used in a `gr.Interface`, the label will be the name of the parameter this component is assigned to.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>every</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nfloat | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">If `value` is a callable, run the function 'every' number of seconds while the client connection is open. Has no effect otherwise. Queue must be enabled. The event can be accessed (e.g. to cancel it) via this component's .load_event attribute.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>show_label</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nbool | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">if True, will display label.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>show_download_button</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nbool\n```\n\n</td>\n<td align=\"left\"><code>True</code></td>\n<td align=\"left\">If True, will display button to download image.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>container</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nbool\n```\n\n</td>\n<td align=\"left\"><code>True</code></td>\n<td align=\"left\">If True, will place the component in a container - providing some extra padding around the border.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>scale</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nint | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">relative size compared to adjacent Components. For example if Components A and B are in a Row, and A has scale=2, and B has scale=1, A will be twice as wide as B. Should be an integer. scale applies in Rows, and to top-level Components in Blocks where fill_height=True.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>min_width</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nint\n```\n\n</td>\n<td align=\"left\"><code>160</code></td>\n<td align=\"left\">minimum pixel width, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in this Component being narrower than min_width, the min_width parameter will be respected first.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>height</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nint | str\n```\n\n</td>\n<td align=\"left\"><code>640</code></td>\n<td align=\"left\">height of component in pixels. If a string is provided, will be interpreted as a CSS value. If None, will be set to 640px.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>interactive</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nbool | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">if True, will allow users to upload and edit an image; if False, can only be used to display images. If not provided, this is inferred based on whether the component is used as an input or output.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>visible</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nbool\n```\n\n</td>\n<td align=\"left\"><code>True</code></td>\n<td align=\"left\">If False, component will be hidden.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>elem_id</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nstr | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>elem_classes</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nlist[str] | str | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>render</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nbool\n```\n\n</td>\n<td align=\"left\"><code>True</code></td>\n<td align=\"left\">If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.</td>\n</tr>\n</tbody></table>\n\n\n### Events\n\n| name | description |\n|:-----|:------------|\n| `clear` | This listener is triggered when the user clears the Rerun using the X button for the component. |\n| `change` | Triggered when the value of the Rerun changes either because of user input (e.g. a user types in a textbox) OR because of a function update (e.g. an image receives a value from the output of an event trigger). See `.input()` for a listener that is only triggered by user input. |\n| `upload` | This listener is triggered when the user uploads a file into the Rerun. |\n\n\n\n### User function\n\nThe impact on the users predict function varies depending on whether the component is used as an input or output for an event (or both).\n\n- When used as an Input, the component only impacts the input signature of the user function.\n- When used as an output, the component only impacts the return signature of the user function.\n\nThe code snippet below is accurate in cases where the component is used as both an input and an output.\n\n- **As output:** Is passed, a `str` containing the path to the image.\n- **As input:** Should return, expects a `str` or `pathlib.Path` object containing the path to the image.\n\n ```python\n def predict(\n     value: str | None\n ) -> list[gradio.data_classes.FileData]\n    | gradio.data_classes.FileData\n    | str\n    | list[str]:\n     return value\n ```\n \n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Rerun viewer with Gradio",
    "version": "0.0.1",
    "project_urls": {
        "repository": "https://github.com/radames/gradio-rerun-viewer"
    },
    "split_keywords": [
        "rerun",
        " gradio-custom-component",
        " machine learning",
        " multimodal data",
        " rerun-viewer",
        " robotics",
        " visualization"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e0826c55849d7fb9548473cceb2339ef54d8f5897aea936d6261c4731f90d297",
                "md5": "f0d5ac93629210ca092ef36a13d7e47d",
                "sha256": "6accaf085d74ac37dd081291112d4e4330103521999ecb77b7304b848e9c0fa8"
            },
            "downloads": -1,
            "filename": "gradio_rerun-0.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f0d5ac93629210ca092ef36a13d7e47d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 9796474,
            "upload_time": "2024-04-29T19:34:15",
            "upload_time_iso_8601": "2024-04-29T19:34:15.890070Z",
            "url": "https://files.pythonhosted.org/packages/e0/82/6c55849d7fb9548473cceb2339ef54d8f5897aea936d6261c4731f90d297/gradio_rerun-0.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fc3b74f97ddca1346c930c4f55ecbf1802bd7f2e8497c0b2eec4ef98e10d939b",
                "md5": "604a676a879b24d10e83abd57043c37c",
                "sha256": "18881a084ce1cf1f192f5ae5f777fed801af4f60e0900fc7821e569289bcd078"
            },
            "downloads": -1,
            "filename": "gradio_rerun-0.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "604a676a879b24d10e83abd57043c37c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 50884633,
            "upload_time": "2024-04-29T19:34:23",
            "upload_time_iso_8601": "2024-04-29T19:34:23.083780Z",
            "url": "https://files.pythonhosted.org/packages/fc/3b/74f97ddca1346c930c4f55ecbf1802bd7f2e8497c0b2eec4ef98e10d939b/gradio_rerun-0.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-29 19:34:23",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "radames",
    "github_project": "gradio-rerun-viewer",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "gradio-rerun"
}
        
Elapsed time: 0.25551s