File size: 4,252 Bytes
0a428a8
 
 
 
 
 
 
 
 
 
 
 
e4b1580
de27ffa
0a428a8
 
e4b1580
0a428a8
 
 
5c8cc25
0a428a8
3455b93
 
7d7617d
 
54b10bf
6190ed9
54b10bf
7d7617d
 
 
 
 
 
 
6190ed9
7d7617d
 
 
 
6190ed9
 
7d7617d
 
 
 
6190ed9
 
7d7617d
 
 
 
e105842
 
 
 
e4b1580
 
e105842
 
 
 
 
5398fb7
 
 
 
 
e4b1580
 
 
 
 
 
 
 
830f94d
e105842
3455b93
 
830f94d
 
 
 
 
 
 
 
 
 
 
 
 
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
---
license: other
license_name: flux-1-dev-non-commercial-license
license_link: LICENSE.md
language:
- en
tags:
- art
---

# Modern Anime LoRA Adapter for FLUX.1 dev

![eyecatch](eyecatch2.jpg)

## Usage
- ComfyUI
1. Download [v0.1 lora](modern-anime-lora.safetensors) or [v2.0 lora](modern-anime-lora-2.safetensors).
2. Move the file to ComfyUI/models/loras.
3. Lunch ComfyUI.
4. Load [the workflow](anime-workflow.json).
5. Queue prompt. (trigger words: modern anime style,)
6. Get the following image.
![example](example.jpg)

- diffusers
1. Install libraries (diffusers etc.).
```bash
pip install diffusers peft
``` 
2. Run the following code.
```python
import torch
from diffusers import FluxPipeline

pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", torch_dtype=torch.bfloat16)
pipe.load_lora_weights("alfredplpl/flux.1-dev-modern-anime-lora", weight_name="modern-anime-lora.safetensors")
pipe=pipe.to("cuda")

prompt = "modern anime style, An anime girl holding a sword. She is wearing school uniform. She is saying \"Hello World\" with the speech bubble."
image = pipe(
    prompt,
    height=1344,
    width=768,
    guidance_scale=3.5,
    output_type="pil",
    num_inference_steps=50,
    max_sequence_length=512,
    generator=torch.Generator(device="cuda").manual_seed(0),
    joint_attention_kwargs={"scale": 1.0}
).images[0]
image.save("flux-dev.png")
```

### Examples

**Please use ChatGPT or Claude to make a prompt!**

# v0.1

![example1](example1.jpg)
```
modern anime style, A close-up portrait of a young girl with green hair. Her hair is vibrant and shoulder-length, framing her face softly. She has large, expressive eyes that are slightly tilted upward, with a gentle and calm expression. Her facial features are delicate, with a small nose and soft lips. The background is simple, focusing attention on her face, with soft lighting that highlights her features. The overall style of the illustration is warm and inviting, with a soft color palette and a slightly dreamy atmosphere.
```

![example2](example2.jpg)
```
modern anime style, A full-body illustration of a girl with white curly hair styled in loose waves. She is wearing a black sleeveless top and blue hot pants. The girl has a mature and confident expression, with eyes that convey a sense of wisdom and allure. She is standing with a relaxed posture, perhaps with one hand on her hip, and the background is simple to keep the focus on her. The overall style of the illustration is elegant, with attention to detail in her clothing and features, and a modern, fashionable atmosphere.
```

# v2.0
![example4](example4.jpg)
```
modern anime style, Anime girl with long purple hair. She is wearing a blue and yellow jacket with a white collared shirt underneath. The shirt has a red tie with a cross on it. The girl is making a peace sign with her hand.
```



## How to make the LoRA Adapter
I used [sd-scripts](https://github.com/kohya-ss/sd-scripts/tree/sd3) (the sd3 branch). The parameters is as follows:
```bash
accelerate launch --num_cpu_threads_per_process 1 flux_train_network.py --pretrained_model_name_or_path '/mnt/NVM/flux/flux1-dev.safetensors'  --clip_l '/mnt/NVM/flux/clip_l.safetensors'  --t5xxl '/mnt/NVM/flux/t5xxl_fp16.safetensors'  --ae '/mnt/NVM/flux/ae.safetensors'  --cache_latents --save_model_as safetensors --sdpa --persistent_data_loader_workers --max_data_loader_n_workers 2 --seed 42 --gradient_checkpointing --save_precision bf16 --network_module networks.lora_flux --network_dim 16 --network_alpha 16 --optimizer_type adamw8bit --learning_rate 1e-3 --network_train_unet_only --cache_text_encoder_outputs --cache_text_encoder_outputs --max_train_epochs 3 --save_every_n_epochs 1 --dataset_config flux_lora.toml --output_dir /mnt/NVM/flux --output_name flux_lora --timestep_sampling sigmoid --model_prediction_type raw --discrete_flow_shift 3.0 --guidance_scale 1.0 --loss_type l2 --mixed_precision bf16 --full_bf16 --max_bucket_reso 2048 --min_bucket_reso 512 --apply_t5_attn_mask --lr_scheduler cosine --lr_warmup_steps 10
```
```toml
[general]
enable_bucket = true

[[datasets]]
resolution = 1024 
batch_size = 4

  [[datasets.subsets]]
  image_dir = '/mnt/NVM/flux_lora'
  metadata_file = 'flux_lora.json'
```