File size: 2,175 Bytes
84b2c1e
dae1059
84b2c1e
 
 
 
 
 
cf3a5f9
24d448e
84b2c1e
 
 
 
076542d
2adcc6b
dae1059
e7ce024
 
076542d
2adcc6b
84b2c1e
 
e7ce024
 
84b2c1e
 
e7ce024
 
84b2c1e
 
 
 
 
e7ce024
cf3a5f9
 
 
076542d
 
 
 
 
 
e7ce024
 
076542d
8f82489
84b2c1e
dae1059
84b2c1e
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51

import gradio as gr
import torch
from diffusers import AutoencoderKL, StableDiffusionXLPipeline,StableDiffusionPipeline

pipe = StableDiffusionPipeline.from_single_file(
    "https://huggingface.co/ethe/Architecture_model/blob/main/architectureExterior_v40Exterior.safetensors",
    # "/mnt/pfs-guan-ssai/cv/panxuhao/checkpoints/stable-diffusion-xl-base-1.0/sd_xl_base_1.0.safetensors",
    torch_dtype=torch.float32,
    # local_files_only=True,
    variant="fp16", 
    use_safetensors=True,
)

num_images_per_prompt = 4
positive_prompt = 'Modern Elegance:Explore the seamless blend of sleek lines, minimalist aesthetics, and cutting-edge design in modern interior decor'

negative_prompt = '(nsfw:1.3),(Nude:1.3),(Naked:1.3),low quality, blurry, bad anatomy, worst quality, text, watermark, normal quality, ugly, signature, lowres, deformed, disfigured, cropped, jpeg artifacts, error, \
                    mutation, logo, watermark,text, logo,contact, error, blurry, cropped, username, artist name, (worst quality, low quality:1.4),monochrome,'
def inference(prompt,ref_image):
    prompt  += positive_prompt
    image = pipe(
        prompt=prompt, 
        negative_prompt=negative_prompt,
        num_inference_steps=20, 
        # cross_attention_kwargs={"scale": lora_scale}, 
        generator=torch.manual_seed(0),
        width=512,
        height=512,
        guidance_scale=7.0,
        use_karras_sigmas=True,
        num_images_per_prompt=num_images_per_prompt,  # 如果是 4, image 就是四张图片组成的 List
    ).images
    return image

with gr.Row():
    input_prompt = gr.Textbox(placeholder="输入你对室内设计的要求,以便 AI 能够更好地满足你的需求。", label="要求")
with gr.Row():
    ref_image = gr.Image(height=512, width=512, label="参考图片")
    
    result_image = gr.Gallery(label="可能满足你需求的室内设计图:", 
                                    columns=3, 
                                    height="auto", 
                                    object_fit="contain")
demo = gr.Interface(
    fn=inference,
    inputs=[input_prompt,ref_image],
    outputs=[result_image]
)

demo.launch()