Skip to main content

Visualise any type of files

Project description


tags: [gradio-custom-component, File] title: gradio_viewer short_description: Visualise files colorFrom: blue colorTo: yellow sdk: gradio pinned: false app_file: space.py

gradio_viewer

PyPI - Version

Visualise any type of files

Installation

pip install gradio_viewer

Usage

import gradio as gr
from gradio_viewer import Viewer


def set_interface():
    view_with_ms = Viewer(
        value=[
            "./demo/data/Le_Petit_Chaperon_Rouge_Modifie.docx",
            "./demo/data/mermaid_graph-2.html",
            "./demo/data/graphique_couts_annuels.png",
            "./demo/data/Le_Petit_Chaperon_Rouge.zouzou",
        ],
        elem_classes=["visualisation"],
        n=1,
        height=300,
        visible=True,
    )

    view_without_ms = Viewer(
        value=[
            "./demo/data/Le_Petit_Chaperon_Rouge_Modifie.docx",
            "./demo/data/mermaid_graph-2.html",
            "./demo/data/graphique_couts_annuels.png",
            "./demo/data/Le_Petit_Chaperon_Rouge.zouzou",
        ],
        elem_classes=["visualisation"],
        n=2,
        height=300,
        visible=True,
        ms_files=False,
    )
    empty_view = view_without_ms
    return view_with_ms, view_without_ms, empty_view


with gr.Blocks() as demo:
    with gr.Row():
        view_with_ms = Viewer(visible=False)
        view_without_ms = Viewer(visible=False)
        empty_view = Viewer(visible=False)
    demo.load(set_interface, outputs=[view_with_ms, view_without_ms]).then(
        fn=lambda: Viewer(visible=True, value=None),
        outputs=empty_view,
    )

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

Viewer

Initialization

name type default description
value
Any
None None
height
int | None
None None
label
str | None
None None
info
str | None
None None
show_label
bool | None
None None
container
bool
True None
scale
int | None
None None
min_width
int | None
None None
interactive
bool | None
None None
visible
bool
True None
elem_id
str | None
None None
elem_classes
list[str] | str | None
None None
render
bool
True None
load_fn
Callable[..., Any] | None
None None
every
Timer | float | None
None None
n
int
0 None
ms_files
bool
True None
libre_office
bool
True None
interface_language
str
"fr" None

Events

name description
change
upload

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, the data after preprocessing, sent to the user's function in the backend.
  • As input: Should return, expects a str filepath or URL, or a list[str] of filepaths/URLs.
def predict(
    value: str
) -> str | list[str] | None:
    return value

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gradio_viewer-0.0.9.tar.gz (1.4 MB view details)

Uploaded Source

Built Distribution

gradio_viewer-0.0.9-py3-none-any.whl (1.3 MB view details)

Uploaded Python 3

File details

Details for the file gradio_viewer-0.0.9.tar.gz.

File metadata

  • Download URL: gradio_viewer-0.0.9.tar.gz
  • Upload date:
  • Size: 1.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.18

File hashes

Hashes for gradio_viewer-0.0.9.tar.gz
Algorithm Hash digest
SHA256 e70b67d9a03d905dde94bac5e48ff5f1fef3da04b453401c1cbe561cedda7ba0
MD5 7f24116b6f38b77393de013cff1f6b39
BLAKE2b-256 19f7064fdaf3effd7f64be037a39398b9591bda3fe549b1c1fa53316a8dbfd53

See more details on using hashes here.

File details

Details for the file gradio_viewer-0.0.9-py3-none-any.whl.

File metadata

File hashes

Hashes for gradio_viewer-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 4d5e2f468ed0f3d902a5fd3ce2c732deaf613680bbf465558e73960f47d7742f
MD5 e25f6dee64bd45cdd781a1054933eeac
BLAKE2b-256 66ce886ddd7183f41adb81daac0d17e69ca3663dc13a1ff21636191c8c3eec1a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page