|
import gradio as gr |
|
from diffusers import StableDiffusionPipeline |
|
import torch |
|
|
|
|
|
device = "cuda" if torch.cuda.is_available() else "cpu" |
|
|
|
|
|
pipe = StableDiffusionPipeline.from_pretrained( |
|
"stabilityai/stable-diffusion-2-1", |
|
torch_dtype=torch.float16 if device == "cuda" else torch.float32, |
|
revision="fp16" if device == "cuda" else "main" |
|
).to(device) |
|
|
|
|
|
def generate_muse(prompt, output_type): |
|
if output_type == "Image": |
|
image = pipe(prompt).images[0] |
|
return image |
|
else: |
|
return "β οΈ 3D Model generation coming soon. Please select 'Image'." |
|
|
|
|
|
with gr.Blocks() as demo: |
|
gr.Markdown("## π¨ Welcome to **MUSE**") |
|
gr.Markdown("Turn your architectural, artistic, or design ideas into stunning visual concepts.\n\nπ§ Just describe your **muse**, pick a format, and let the AI do the rest.") |
|
|
|
with gr.Row(): |
|
with gr.Column(): |
|
prompt = gr.Textbox( |
|
label="ποΈ Describe your muse idea", |
|
placeholder="e.g. a floating bamboo pavilion shaped like a jellyfish with fabric sails", |
|
lines=3 |
|
) |
|
output_type = gr.Radio(["Image", "3D Model"], label="π Choose output type", value="Image") |
|
generate_button = gr.Button("β¨ Generate Muse") |
|
|
|
with gr.Column(): |
|
image_output = gr.Image(label="π¨ Your Muse Output") |
|
|
|
generate_button.click(fn=generate_muse, inputs=[prompt, output_type], outputs=image_output) |
|
|
|
demo.launch() |
|
|
|
|