Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from diffusers import StableDiffusionPipeline
|
| 3 |
+
|
| 4 |
+
# Load the Hugging Face model
|
| 5 |
+
model_id = "kopyl/ui-icons-256"
|
| 6 |
+
pipeline = StableDiffusionPipeline.from_pretrained(model_id)
|
| 7 |
+
pipeline.to("cuda") # Use GPU for faster inference, if available
|
| 8 |
+
|
| 9 |
+
def generate_icon(prompt):
|
| 10 |
+
"""Generate an icon from a text prompt."""
|
| 11 |
+
result = pipeline(prompt).images[0] # Generate the image
|
| 12 |
+
return result
|
| 13 |
+
|
| 14 |
+
# Build Gradio Interface
|
| 15 |
+
with gr.Blocks() as app:
|
| 16 |
+
gr.Markdown("## 🖌️ Icon Generator App")
|
| 17 |
+
gr.Markdown("Generate 256x256 icons using the `kopyl/ui-icons-256` model.")
|
| 18 |
+
|
| 19 |
+
with gr.Row():
|
| 20 |
+
prompt_input = gr.Textbox(label="Enter a prompt", placeholder="E.g., 'a colorful app icon for a weather app'")
|
| 21 |
+
generate_button = gr.Button("Generate Icon")
|
| 22 |
+
|
| 23 |
+
output_image = gr.Image(label="Generated Icon")
|
| 24 |
+
|
| 25 |
+
def on_click(prompt):
|
| 26 |
+
return generate_icon(prompt)
|
| 27 |
+
|
| 28 |
+
generate_button.click(on_click, inputs=prompt_input, outputs=output_image)
|
| 29 |
+
|
| 30 |
+
app.launch() # Launch the app
|