metadata
tags:
- gradio-custom-component
- Image
title: gradio_niivueviewer
short_description: null
colorFrom: blue
colorTo: yellow
sdk: gradio
pinned: false
app_file: space.py
gradio_niivueviewer
A Gradio custom component for 3D medical imaging visualization using NiiVue (WebGL).
Installation
pip install gradio_niivueviewer
Usage
import gradio as gr
from gradio_niivueviewer import NiiVueViewer
example = NiiVueViewer().example_value()
demo = gr.Interface(
lambda x: x,
NiiVueViewer(), # interactive version of your component
NiiVueViewer(), # static version of your component
# examples=[[example]], # uncomment this line to view the "example version" of your component
)
if __name__ == "__main__":
demo.launch()
NiiVueViewer
Initialization
| name | type | default | description |
|---|---|---|---|
value |
|
None |
None |
label |
|
None |
None |
height |
|
500 |
None |
show_label |
|
True |
None |
container |
|
True |
None |
scale |
|
None |
None |
min_width |
|
160 |
None |
visible |
|
True |
None |
elem_id |
|
None |
None |
elem_classes |
|
None |
None |
render |
|
True |
None |
key |
|
None |
None |
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 preprocessed input data sent to the user's function in the backend.
- As input: Should return, the output data received by the component from the user's function in the backend.
def predict(
value: dict[str, typing.Any] | None
) -> dict[str, typing.Any] | None:
return value
NiiVueViewerData
class NiiVueViewerData(GradioModel):
background_url: str | None = None
overlay_url: str | None = None