File size: 1,077 Bytes
8c62f70
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cfbd2ef
8c62f70
 
cfbd2ef
8c62f70
 
cfbd2ef
 
8c62f70
 
cfbd2ef
8c62f70
 
 
cfbd2ef
 
8c62f70
 
 
 
 
 
 
cfbd2ef
8c62f70
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
52
53
54
55
56
---
license: creativeml-openrail-m
language:
- en
base_model:
- black-forest-labs/FLUX.1-dev
pipeline_tag: text-to-image
---


## Example code

```python
import torch
from diffusers import AutoPipelineForText2Image

# PEFT
from peft import PeftModel, PeftConfig

# 
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

# 
print("In progress...")
pipe = AutoPipelineForText2Image.from_pretrained(
    "black-forest-labs/FLUX.1-dev", 
    torch_dtype=torch.float16  # bfloat16
)
pipe.to(device)

# 
print("Loading lora 로드 중...")
pipe.load_lora_weights(
    'Heartsync/Flux-NSFW-uncensored', 
    weight_name='lora.safetensors',
    adapter_name="uncensored"
)

# 이미지 생성
prompt = "A woman in a sheer white dress standing on a beach at sunset"

seed = 42
generator = torch.Generator(device=device).manual_seed(seed)

image = pipe(
    prompt=prompt,
    negative_prompt=negative_prompt,
    guidance_scale=7.0,
    num_inference_steps=28,
    width=1024,
    height=1024,
    generator=generator,
).images[0]

image.save("generated_image.png")
```