forked from gradio-app/gradio
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
created complex demo demonstrating capabilities of gradio to handle large workloads , fixes issue gradio-app#5217
- Loading branch information
1 parent
b83064d
commit d75ad7a
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import gradio as gr | ||
|
||
# Define custom input components | ||
def create_custom_components(): | ||
components = [] | ||
for i in range(1000): | ||
components.append(gr.Textbox(label=f"Text Box {i}")) | ||
components.append(gr.Slider(label=f"Slider {i}", minimum=0, maximum=100)) | ||
components.append(gr.Number(label=f"Number {i}")) | ||
components.append(gr.Checkbox(label=f"Checkbox {i}")) | ||
components.append(gr.Radio(["Option 1", "Option 2", "Option 3"], label=f"Radio {i}")) | ||
components.append(gr.Button(label=f"Submit {i}")) | ||
components.append(gr.Image(label=f"Image {i}")) | ||
return components | ||
|
||
input_components = create_custom_components() | ||
|
||
# Define inference function | ||
def inference_function(*input_values): | ||
results = {} | ||
for i, value in enumerate(input_values): | ||
results[f"Input_{i}"] = value | ||
return results | ||
|
||
# Create a Gradio interface with the custom input components | ||
interface = gr.Interface( | ||
fn=inference_function, | ||
inputs=input_components, | ||
outputs=gr.JSON(), | ||
live=True, | ||
) | ||
|
||
# Launch the interface | ||
interface.launch() |