Posts

Showing posts with the label Gradio

Updating tab labels in gradio

 In Gradio, you can update the labels of the tabs in a Tabbed layout by modifying the labels of the layout's tabs. Here's how you can update tab labels in Gradio: ```python import gradio as gr # Create a function to be displayed in the first tab. def function_1():     return "This is Tab 1 content" # Create a function to be displayed in the second tab. def function_2():     return "This is Tab 2 content" # Create a Tabbed layout with default tab labels. layout = gr.Interface(fn=[function_1, function_2], layout="tabbed") # Set custom labels for the tabs. layout.layout_set_tab_labels(["Tab 1", "Tab 2"]) layout.launch() ``` In this example, we first create two functions (`function_1` and `function_2`) to be displayed in two different tabs. Then, we create a `Tabbed` layout with default tab labels. To update the tab labels, we use the `layout_set_tab_labels` method and pass a list of custom labels as an argument. By running this cod