Spaces:
Runtime error
Runtime error
LPX55
Refactor app.py to utilize shared functions for greeting, calculation, and image processing, enhancing modularity and code reuse. Introduce space loading tabs for dynamic integration of popular Hugging Face Spaces.
4cc700d
import gradio as gr | |
from shared_functions import greet, download_text | |
def greeting_tab(): | |
gr.Markdown("## Greeting Generator") | |
with gr.Row(): | |
with gr.Column(): | |
name = gr.Textbox(label="Name", info="Enter your name", placeholder="e.g. Alex") | |
intensity = gr.Slider(1, 20, value=3, step=1, label="Intensity", info="How excited should the greeting be?") | |
with gr.Accordion("Advanced Options", open=False): | |
exclaim = gr.Checkbox(label="Shout (all caps)", info="Make the greeting all uppercase and add exclamations") | |
greet_btn = gr.Button("Greet") | |
with gr.Column(): | |
greet_output = gr.Textbox(label="Greeting", lines=2) | |
download_greet_btn = gr.DownloadButton(label="Download Greeting", value=download_text, inputs=greet_output) | |
gr.Examples( | |
[["Jill", 1, False], ["Sam", 3, True], ["Alex", 5, False]], | |
inputs=[name, intensity, exclaim], | |
outputs=greet_output, | |
fn=greet | |
) | |
greet_btn.click(greet, [name, intensity, exclaim], greet_output) |