Download app.py from DataThree/MUSE: direct link, hf CLI and curl.
- Browser
- Download file 1.65 kB
-
https://huggingface.co/spaces/DataThree/MUSE/resolve/main/app.py
- Command line
-
hf download hf://spaces/DataThree/MUSE/app.py
-
curl -L -o app.py https://huggingface.co/spaces/DataThree/MUSE/resolve/main/app.py
1.65 kB
| import gradio as gr | |
| from diffusers import StableDiffusionPipeline | |
| import torch | |
| # β Choose device (GPU if available, else CPU) | |
| device = "cuda" if torch.cuda.is_available() else "cpu" | |
| # β Load the model with correct settings | |
| 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) | |
| # β Generate image or placeholder for 3D | |
| 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'." | |
| # β Gradio UI layout | |
| 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() | |