File size: 1,028 Bytes
06ae90e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import gradio as gr
from diffusers import StableDiffusionPipeline

# Load the Hugging Face model
model_id = "kopyl/ui-icons-256"
pipeline = StableDiffusionPipeline.from_pretrained(model_id)
pipeline.to("cuda")  # Use GPU for faster inference, if available

def generate_icon(prompt):
    """Generate an icon from a text prompt."""
    result = pipeline(prompt).images[0]  # Generate the image
    return result

# Build Gradio Interface
with gr.Blocks() as app:
    gr.Markdown("## ๐Ÿ–Œ๏ธ Icon Generator App")
    gr.Markdown("Generate 256x256 icons using the `kopyl/ui-icons-256` model.")
    
    with gr.Row():
        prompt_input = gr.Textbox(label="Enter a prompt", placeholder="E.g., 'a colorful app icon for a weather app'")
        generate_button = gr.Button("Generate Icon")
    
    output_image = gr.Image(label="Generated Icon")
    
    def on_click(prompt):
        return generate_icon(prompt)
    
    generate_button.click(on_click, inputs=prompt_input, outputs=output_image)

app.launch()  # Launch the app