File size: 1,648 Bytes
772ea32
 
 
 
 
 
 
dcb02b2
772ea32
 
 
 
dcb02b2
772ea32
 
dcb02b2
772ea32
 
 
 
 
dcb02b2
 
 
 
 
 
 
 
 
 
 
 
 
 
96533d3
dcb02b2
 
 
 
 
 
 
 
 
 
 
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
# from diffusers import StableDiffusionXLPipeline, EulerAncestralDiscreteScheduler
# import torch

# def generate_animagine_xl(prompt: str):
#     model_id = "Linaqruf/animagine-xl"
#     pipe = StableDiffusionXLPipeline.from_pretrained(
#         model_id,
#         torch_dtype=torch.float16,
#         use_safetensors=True,
#         variant="fp16"
#     )
#     pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config)
#     pipe = pipe.to("cuda")
#     image = pipe(prompt=prompt, width=1024, height=1024).images[0]
#     image.save("output_animagine_xl.png")
#     print("โœ… ์ €์žฅ ์™„๋ฃŒ: output_animagine_xl.png")
#     return image

# if __name__ == "__main__":
#     prompt = "๊ทธ๋…€๋ฅผ ๋ฐ”๋ผ๋ณด๋Š” ํ•œ ๋‚จ์ž์˜ ์•ผ๋ง"
#     generate_animagine_xl(prompt)


from diffusers import StableDiffusionXLPipeline, EulerAncestralDiscreteScheduler
import torch

# (1) ๋ชจ๋ธ๊ณผ ์Šค์ผ€์ค„๋Ÿฌ๋ฅผ ์ „์—ญ์—์„œ ํ•œ ๋ฒˆ๋งŒ ์ดˆ๊ธฐํ™”
model_id = "Linaqruf/animagine-xl"
pipe = StableDiffusionXLPipeline.from_pretrained(
    model_id,
    torch_dtype=torch.float16,
    use_safetensors=True,
    variant="fp16"
)
pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config)
pipe = pipe.to("cpu")  # ๋˜๋Š” "cpu"๋กœ ๋ณ€๊ฒฝ ๊ฐ€๋Šฅ

# (2) ์ด๋ฏธ์ง€ ์ƒ์„ฑ ํ•จ์ˆ˜
def generate_animagine_xl(prompt: str):
    image = pipe(prompt=prompt, width=1024, height=1024).images[0]
    image.save("output_animagine_xl.png")
    print("โœ… ์ €์žฅ ์™„๋ฃŒ: output_animagine_xl.png")
    return image

if __name__ == "__main__":
    prompt = "๊ทธ๋…€๋ฅผ ๋ฐ”๋ผ๋ณด๋Š” ํ•œ ๋‚จ์ž์˜ ์•ผ๋ง"
    generate_animagine_xl(prompt)