import gradio as gr import random # Example T-shirt mockup generation function (replace with actual implementation) def generate_tshirt_mockup(style, color, graphics, text=None): # Generate a mockup based on T-shirt style, color, graphics, and optionally text mockup = f"Generated T-shirt mockup:\nStyle: {style}\nColor: {color}\nGraphics: {graphics}\nText: {text}" if text else f"Generated T-shirt mockup:\nStyle: {style}\nColor: {color}\nGraphics: {graphics}" return mockup examples = [ "Casual T-shirt, Blue, with abstract art", "Formal T-shirt, White, with logo", "Sports T-shirt, Red, with team name", ] css=""" #col-container { margin: 0 auto; max-width: 520px; } """ with gr.Blocks(css=css) as demo: with gr.Column(elem_id="col-container"): gr.Markdown(f""" # T-shirt Mockup Generator """) with gr.Row(): style = gr.Dropdown( label="T-shirt Style", choices=["Casual", "Formal", "Sports"], default="Casual", container=False, ) run_button = gr.Button("Generate Mockup", scale=0) result = gr.Textbox(label="Mockup", placeholder="Generated Mockup", readonly=True) with gr.Accordion("Design Options", open=False): color = gr.Textbox( label="T-shirt Color", placeholder="Enter color", visible=True, ) graphics = gr.Textbox( label="Graphics", placeholder="Enter graphic details", visible=True, ) text = gr.Textbox( label="Text (optional)", placeholder="Enter text for T-shirt", visible=True, ) gr.Examples( examples=examples, inputs=[style] ) run_button.click( fn=generate_tshirt_mockup, inputs=[style, color, graphics, text], outputs=[result] ) demo.queue().launch()