import gradio as gr import random # Load the model model = gr.load("models/Purz/face-projection") def generate_image(text, seed): if seed is not None: random.seed(seed) # Define slight variations of the original prompt for different poses/positions variations = [ f"{text}, front view", f"{text}, side view", f"{text}, dynamic pose", f"{text}, close-up view" ] # Generate an image for each variation images = [model(variation) for variation in variations] return images # Define examples with pre-generated image previews examples = [ ["Humanoid Cat Warrior, Full View", None, "path/to/humanoid_cat_preview.jpg"], ["Warhammer Sisterhood", None, "path/to/warhammer_sisterhood_preview.jpg"], ["Future Robots war", None, "path/to/future_robots_war_preview.jpg"], ["Fantasy dragon", None, "path/to/fantasy_dragon_preview.jpg"] ] # Custom CSS for styling css = """ /* General button styles */ button { border-radius: 25px; /* Capsule shape */ padding: 10px 20px; font-size: 16px; font-weight: bold; color: white; background: linear-gradient(135deg, #6D5BBA, #8A2387); /* Gradient color */ border: none; cursor: pointer; transition: background 0.3s ease; } button:hover { background: linear-gradient(135deg, #8A2387, #6D5BBA); /* Gradient reverse on hover */ } /* Slider handle style */ input[type=range] { accent-color: #8A2387; /* Gradient color accent */ } /* Textbox styling */ .gr-textbox { border-radius: 8px; border: 1px solid #DDD; padding: 10px; } /* Output image styling */ .output_image { border: 2px solid #6D5BBA; border-radius: 10px; padding: 10px; background-color: #f9f9f9; } """ # Define a function to create the examples with preview images def create_example_row(example): return [gr.Example(value=example[0], examples=None, label=example[0], image=example[2])] # Gradio interface interface = gr.Interface( fn=generate_image, inputs=[ gr.Textbox(label="Type your imagination:", placeholder="Type or select an example..."), gr.Slider(minimum=0, maximum=10000, step=1, label="Seed (optional)") ], outputs=[gr.Image(label=f"Generated Image {i+1}") for i in range(4)], examples=create_example_row(examples), # Use pre-generated images for previews css=css, description="Note: The model is running on CPU; processing might take a bit longer. Thank you for your patience!" ) # Launch the interface interface.launch()