Skip to content

Commit

Permalink
Create app.py
Browse files Browse the repository at this point in the history
created complex demo demonstrating capabilities of gradio to handle large workloads , fixes issue  gradio-app#5217
  • Loading branch information
sambhavnoobcoder authored Oct 9, 2023
1 parent b83064d commit d75ad7a
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions demo/complex_demo/app.py
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()

0 comments on commit d75ad7a

Please sign in to comment.