Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,138 @@
|
|
1 |
---
|
2 |
license: creativeml-openrail-m
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
license: creativeml-openrail-m
|
3 |
+
tags:
|
4 |
+
- stable-diffusion
|
5 |
+
- stable-diffusion-diffusers
|
6 |
+
- text-to-image
|
7 |
+
inference: false
|
8 |
+
language: ko
|
9 |
---
|
10 |
+
|
11 |
+
# my-korean-stable-diffusion-v1-5
|
12 |
+
|
13 |
+
It's [runwayml/stable-diffusion-v1-5](https://huggingface.co/runwayml/stable-diffusion-v1-5) model, just text encoder and tokenizer replaced with my [Bingsu/clip-vit-large-patch14-ko](https://huggingface.co/Bingsu/clip-vit-large-patch14-ko).
|
14 |
+
|
15 |
+
# Usage
|
16 |
+
|
17 |
+
```sh
|
18 |
+
pip install transformers accelerate>=0.14.0 diffusers>=0.7.0 ftfy
|
19 |
+
```
|
20 |
+
|
21 |
+
```python
|
22 |
+
import torch
|
23 |
+
from diffusers import StableDiffusionPipeline, EulerAncestralDiscreteScheduler
|
24 |
+
|
25 |
+
repo = "Bingsu/my-korean-stable-diffusion-v1-5"
|
26 |
+
euler_ancestral_scheduler = EulerAncestralDiscreteScheduler.from_config(repo, subfolder="scheduler")
|
27 |
+
pipe = StableDiffusionPipeline.from_pretrained(
|
28 |
+
repo, scheduler=euler_ancestral_scheduler, torch_dtype=torch.float16,
|
29 |
+
)
|
30 |
+
pipe.to("cuda")
|
31 |
+
```
|
32 |
+
|
33 |
+
```python
|
34 |
+
prompt = "ํ์ฑ์์ ๋ง์ ํ๊ณ ์๋ ์ฐ์ฃผ์ธ ์ฌ์ง"
|
35 |
+
seed = 23957
|
36 |
+
generator = torch.Generator("cuda").manual_seed(seed)
|
37 |
+
image = pipe(prompt, num_inference_steps=25, generator=generator).images[0]
|
38 |
+
```
|
39 |
+
|
40 |
+
```python
|
41 |
+
image
|
42 |
+
```
|
43 |
+
![Imgur](https://i.imgur.com/JwthHe1.png)
|
44 |
+
|
45 |
+
## more examples
|
46 |
+
|
47 |
+
```python
|
48 |
+
prompt = "๊ณ ํ๋ฆฌํฐ ํ์ ๊ณ ์์ด ์ฌ์ง"
|
49 |
+
seed = 46399
|
50 |
+
generator = torch.Generator("cuda").manual_seed(seed)
|
51 |
+
pipe(prompt, num_inference_steps=25, generator=generator).images[0]
|
52 |
+
```
|
53 |
+
![Imgur](https://i.imgur.com/Ex6zbjN.png)
|
54 |
+
|
55 |
+
```python
|
56 |
+
prompt = "๊ณ ํ๋ฆฌํฐ ํ์ ๊ณ ์์ด ์ฌ์ง, ํผ์๋
ธ๋ฅผ ์น๋ ์ค"
|
57 |
+
seed = 12345
|
58 |
+
generator = torch.Generator("cuda").manual_seed(seed)
|
59 |
+
pipe(prompt, num_inference_steps=25, generator=generator).images[0]
|
60 |
+
```
|
61 |
+
![Imgur](https://i.imgur.com/1d4GpTH.png)
|
62 |
+
|
63 |
+
```python
|
64 |
+
prompt = "๋ฌ๊ณผ ๋ณ์ด ๋ณด์ด๋ ๋ฐคํ๋์ ๋ฐฐ๊ฒฝ์ผ๋ก ํ ํด๋ณ๊ฐ ์ฌ์ง"
|
65 |
+
seed = 1234246
|
66 |
+
generator = torch.Generator("cuda").manual_seed(seed)
|
67 |
+
pipe(prompt, num_inference_steps=25, generator=generator).images[0]
|
68 |
+
```
|
69 |
+
![Imgur](https://i.imgur.com/9NhKaAo.png)
|
70 |
+
|
71 |
+
# Uses
|
72 |
+
|
73 |
+
## Direct Use
|
74 |
+
The model is intended for research purposes only. Possible research areas and
|
75 |
+
tasks include
|
76 |
+
|
77 |
+
- Safe deployment of models which have the potential to generate harmful content.
|
78 |
+
- Probing and understanding the limitations and biases of generative models.
|
79 |
+
- Generation of artworks and use in design and other artistic processes.
|
80 |
+
- Applications in educational or creative tools.
|
81 |
+
- Research on generative models.
|
82 |
+
|
83 |
+
Excluded uses are described below.
|
84 |
+
|
85 |
+
### Misuse, Malicious Use, and Out-of-Scope Use
|
86 |
+
_Note: This section is taken from the [DALLE-MINI model card](https://huggingface.co/dalle-mini/dalle-mini), but applies in the same way to Stable Diffusion v1_.
|
87 |
+
|
88 |
+
|
89 |
+
The model should not be used to intentionally create or disseminate images that create hostile or alienating environments for people. This includes generating images that people would foreseeably find disturbing, distressing, or offensive; or content that propagates historical or current stereotypes.
|
90 |
+
|
91 |
+
#### Out-of-Scope Use
|
92 |
+
The model was not trained to be factual or true representations of people or events, and therefore using the model to generate such content is out-of-scope for the abilities of this model.
|
93 |
+
|
94 |
+
#### Misuse and Malicious Use
|
95 |
+
Using the model to generate content that is cruel to individuals is a misuse of this model. This includes, but is not limited to:
|
96 |
+
|
97 |
+
- Generating demeaning, dehumanizing, or otherwise harmful representations of people or their environments, cultures, religions, etc.
|
98 |
+
- Intentionally promoting or propagating discriminatory content or harmful stereotypes.
|
99 |
+
- Impersonating individuals without their consent.
|
100 |
+
- Sexual content without consent of the people who might see it.
|
101 |
+
- Mis- and disinformation
|
102 |
+
- Representations of egregious violence and gore
|
103 |
+
- Sharing of copyrighted or licensed material in violation of its terms of use.
|
104 |
+
- Sharing content that is an alteration of copyrighted or licensed material in violation of its terms of use.
|
105 |
+
|
106 |
+
## Limitations and Bias
|
107 |
+
|
108 |
+
### Limitations
|
109 |
+
|
110 |
+
- The model does not achieve perfect photorealism
|
111 |
+
- The model cannot render legible text
|
112 |
+
- The model does not perform well on more difficult tasks which involve compositionality, such as rendering an image corresponding to โA red cube on top of a blue sphereโ
|
113 |
+
- Faces and people in general may not be generated properly.
|
114 |
+
- The model was trained mainly with English captions and will not work as well in other languages.
|
115 |
+
- The autoencoding part of the model is lossy
|
116 |
+
- The model was trained on a large-scale dataset
|
117 |
+
[LAION-5B](https://laion.ai/blog/laion-5b/) which contains adult material
|
118 |
+
and is not fit for product use without additional safety mechanisms and
|
119 |
+
considerations.
|
120 |
+
- No additional measures were used to deduplicate the dataset. As a result, we observe some degree of memorization for images that are duplicated in the training data.
|
121 |
+
The training data can be searched at [https://rom1504.github.io/clip-retrieval/](https://rom1504.github.io/clip-retrieval/) to possibly assist in the detection of memorized images.
|
122 |
+
|
123 |
+
### Bias
|
124 |
+
|
125 |
+
While the capabilities of image generation models are impressive, they can also reinforce or exacerbate social biases.
|
126 |
+
Stable Diffusion v1 was trained on subsets of [LAION-2B(en)](https://laion.ai/blog/laion-5b/),
|
127 |
+
which consists of images that are primarily limited to English descriptions.
|
128 |
+
Texts and images from communities and cultures that use other languages are likely to be insufficiently accounted for.
|
129 |
+
This affects the overall output of the model, as white and western cultures are often set as the default. Further, the
|
130 |
+
ability of the model to generate content with non-English prompts is significantly worse than with English-language prompts.
|
131 |
+
|
132 |
+
### Safety Module
|
133 |
+
|
134 |
+
The intended use of this model is with the [Safety Checker](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/safety_checker.py) in Diffusers.
|
135 |
+
This checker works by checking model outputs against known hard-coded NSFW concepts.
|
136 |
+
The concepts are intentionally hidden to reduce the likelihood of reverse-engineering this filter.
|
137 |
+
Specifically, the checker compares the class probability of harmful concepts in the embedding space of the `CLIPTextModel` *after generation* of the images.
|
138 |
+
The concepts are passed into the model with the generated image and compared to a hand-engineered weight for each NSFW concept.
|