File size: 2,570 Bytes
09b2f5a
 
590eb27
 
 
 
 
 
 
 
09b2f5a
590eb27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
license: mit
language: 
  - en
tags:
- stable-diffusion
- stable-diffusion-diffusers
- text-to-image
datasets:
- wx44wx/three-kingdoms-blip-captions
---

__Stable Diffusion fine tuned on [Romance of the Three Kingdoms XI: Officer Portraits](https://kongming.net/11/portraits/).__

Put in a text prompt and generate your own Officier in Three Kingdoms.

trained using this [script](https://github.com/LambdaLabsML/examples/tree/main/stable-diffusion-finetuning) with this [dataset](https://huggingface.co/datasets/wx44wx/three-kingdoms-blip-captions).

> a man in armor
![image.png](https://github.com/WangXin93/three-kingdoms-stable-diffusion/raw/main/assets/a-man-in-armor.png)

> a women in red dress
![image.png](https://github.com/WangXin93/three-kingdoms-stable-diffusion/raw/main/assets/a-women-in-red-dress.png)

> a women in armor
 ![image.png](https://github.com/WangXin93/three-kingdoms-stable-diffusion/raw/main/assets/a-women-in-armor.png)

## Usage

```bash
!pip install diffusers==0.19.3
!pip install transformers scipy ftfy
```

```python
import torch
from diffusers import StableDiffusionPipeline
from torch import autocast

pipe = StableDiffusionPipeline.from_pretrained("wx44wx/sd-three-kingdoms-diffusers", torch_dtype=torch.float16)  
pipe = pipe.to("cuda")

prompt = "a man in armor"
scale = 3
n_samples = 4

# Sometimes the nsfw checker is confused by the Pokémon images, you can disable
# it at your own risk here
disable_safety = False

if disable_safety:
  def null_safety(images, **kwargs):
      return images, False
  pipe.safety_checker = null_safety

with autocast("cuda"):
  images = pipe(n_samples*[prompt], guidance_scale=scale).images

for idx, im in enumerate(images):
  im.save(f"{idx:06}.png")
```

## Model description

Trained on [BLIP captioned Three Kingdoms Officers images](https://huggingface.co/datasets/wx44wx/three-kingdoms-blip-captions) using 1xA6000 GPUs for around 16,000 steps.

## Links

- [Lambda Diffusers](https://github.com/LambdaLabsML/lambda-diffusers)
- [Captioned Three Kingdoms dataset](https://huggingface.co/datasets/wx44wx/three-kingdoms-blip-captions)
- [Model weights in Diffusers format](https://huggingface.co/wx44wx/sd-three-kingdoms-diffusers)
- [Original model weights](https://huggingface.co/wx44wx/three-kingdoms-stable-diffusion)
- [Training code](https://github.com/justinpinkney/stable-diffusion)

Trained by [Xin Wang](wangxin93.github.io). Thanks [kongming.net](kongming.net) for their archived images and [justinpinkney](https://github.com/justinpinkney/stable-diffusion) for the code.