File size: 1,068 Bytes
ef3e6ac
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
32
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()