Download app.py from arrowvain/README: direct link, hf CLI and curl.
- Browser
- Download file 1.07 kB
-
https://huggingface.co/spaces/arrowvain/README/resolve/main/app.py
- Command line
-
hf download hf://spaces/arrowvain/README/app.py
-
curl -L -o app.py https://huggingface.co/spaces/arrowvain/README/resolve/main/app.py
1.07 kB
| import gradio as gr | |
| from diffusers import StableDiffusionControlNetPipeline, ControlNetModel | |
| import torch | |
| from PIL import Image | |
| # মডেল লোড করুন | |
| controlnet = ControlNetModel.from_pretrained("lllyasviel/control_v11f1p_sd15_depth", torch_dtype=torch.float16) | |
| pipe = StableDiffusionControlNetPipeline.from_pretrained( | |
| "runwayml/stable-diffusion-v1-5", | |
| controlnet=controlnet, | |
| torch_dtype=torch.float16 | |
| ).to("cuda") | |
| def generate_new_bedsheet(bedroom_img, bedsheet_img): | |
| prompt = "a realistic bedroom with a new bedsheet, high quality, 4k" | |
| output = pipe( | |
| prompt=prompt, | |
| image=bedroom_img, | |
| control_image=bedsheet_img, | |
| ).images[0] | |
| return output | |
| # Gradio UI বানান | |
| iface = gr.Interface( | |
| fn=generate_new_bedsheet, | |
| inputs=[gr.Image(type="pil", label="Bedroom Photo"), gr.Image(type="pil", label="Bedsheet Design")], | |
| outputs=gr.Image(label="Result"), | |
| title="🎨 AI Bedsheet Changer", | |
| description="Upload a bedroom photo and a bedsheet design to see magic!" | |
| ) | |
| iface.launch() |