Upload README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,157 @@
|
|
1 |
---
|
2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
language: zh
|
3 |
+
license: creativeml-openrail-m
|
4 |
+
|
5 |
+
tags:
|
6 |
+
- stable-diffusion
|
7 |
+
- stable-diffusion-diffusers
|
8 |
+
- text-to-image
|
9 |
+
- zh
|
10 |
+
- Chinese
|
11 |
+
|
12 |
+
inference: false
|
13 |
+
extra_gated_prompt: |-
|
14 |
+
One more step before getting this model.
|
15 |
+
This model is open access and available to all, with a CreativeML OpenRAIL-M license further specifying rights and usage.
|
16 |
+
The CreativeML OpenRAIL License specifies:
|
17 |
+
|
18 |
+
1. You can't use the model to deliberately produce nor share illegal or harmful outputs or content
|
19 |
+
2. IDEA-CCNL claims no rights on the outputs you generate, you are free to use them and are accountable for their use which must not go against the provisions set in the license
|
20 |
+
3. You may re-distribute the weights and use the model commercially and/or as a service. If you do, please be aware you have to include the same use restrictions as the ones in the license and share a copy of the CreativeML OpenRAIL-M to all your users (please read the license entirely and carefully)
|
21 |
+
Please read the full license here: https://huggingface.co/spaces/CompVis/stable-diffusion-license
|
22 |
+
|
23 |
+
By clicking on "Access repository" below, you accept that your *contact information* (email address and username) can be shared with the model authors as well.
|
24 |
+
extra_gated_fields:
|
25 |
+
I have read the License and agree with its terms: checkbox
|
26 |
---
|
27 |
+
|
28 |
+
# AltDiffusion
|
29 |
+
|
30 |
+
| 名称 Name | 任务 Task | 语言 Language(s) | 模型 Model | Github |
|
31 |
+
|:----------:| :----: |:-------------------:| :----: |:------:|
|
32 |
+
| AltDiffusion | 多模态 Multimodal | 中英文 Chinese&English | Stable Diffusion | [FlaAI](https://github.com/FlagAI-Open/FlagAI) |
|
33 |
+
|
34 |
+
|
35 |
+
# 模型信息 Model Information
|
36 |
+
|
37 |
+
我们使用 [AltCLIP](https://github.com/FlagAI-Open/FlagAI/tree/master/examples/AltCLIP/README.md) 作为text encoder,基于 [Stable Diffusion](https://huggingface.co/CompVis/stable-diffusion) 训练了双语Diffusion模型,训练数据来自 [WuDao数据集](https://data.baai.ac.cn/details/WuDaoCorporaText) 和 [LAION](https://huggingface.co/datasets/ChristophSchuhmann/improved_aesthetics_6plus) 。
|
38 |
+
|
39 |
+
我们的版本在中英文对齐方面表现非常出色,是目前市面上开源的最强版本,保留了原版stable diffusion的大部分能力,并且在某些例子上比有着比原版模型更出色的能力。
|
40 |
+
|
41 |
+
AltDiffusion 模型由名为 AltCLIP 的双语 CLIP 模型支持,该模型也可在本项目中访问。您可以阅读 [此教程](https://github.com/FlagAI-Open/FlagAI/tree/master/examples/AltCLIP/README.md) 了解更多信息。
|
42 |
+
|
43 |
+
AltDiffusion模型现在支持线上演示,点击 [![Hugging Face Spaces](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue)](https://huggingface.co/spaces/BAAI/FlagStudio) 在线试玩!
|
44 |
+
|
45 |
+
Our model performs well in aligning Chinese and English, and is the strongest open source version on the market today, retaining most of the stable diffusion capabilities of the original, and in some cases even better than the original model.
|
46 |
+
|
47 |
+
We used [AltCLIP](https://github.com/FlagAI-Open/FlagAI/tree/master/examples/AltCLIP/README.md) as the text encoder, and trained a bilingual Diffusion model based on [Stable Diffusion](https://huggingface.co/CompVis/stable-diffusion), with training data from [WuDao dataset](https://data.baai.ac.cn/details/WuDaoCorporaText) and [LAION](https://huggingface.co/datasets/laion/laion2B-en).
|
48 |
+
|
49 |
+
AltDiffusion model is backed by a bilingual CLIP model named AltCLIP, which is also accessible in FlagAI. You can read [this tutorial](https://github.com/FlagAI-Open/FlagAI/tree/master/examples/AltCLIP/README.md) for more information.
|
50 |
+
|
51 |
+
AltDiffusion now supports online demo,Try out it by clicking [![Hugging Face Spaces](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue)](https://huggingface.co/spaces/BAAI/FlagStudio) !
|
52 |
+
|
53 |
+
# 模型权重 Model Weights
|
54 |
+
|
55 |
+
第一次运行AltDiffusion模型时会自动从 [这里](https://model.baai.ac.cn/model-detail/100076) 下载如下权重,
|
56 |
+
|
57 |
+
The following weights are automatically downloaded from [here](https://model.baai.ac.cn/model-detail/100076) when the AltDiffusion model is run for the first time:
|
58 |
+
|
59 |
+
| 模型名称 Model name | 大小 Size | 描述 Description |
|
60 |
+
|------------------------------|---------|-------------------------------------------------------|
|
61 |
+
| StableDiffusionSafetyChecker | 1.13G | 图片的安全检查器;Safety checker for image |
|
62 |
+
| AltDiffusion | 8.0G | 我们的双语AltDiffusion模型; Our bilingual AltDiffusion model |
|
63 |
+
| AltCLIP | 3.22G | 我们的双语AltCLIP模型;Our bilingual AltCLIP model |
|
64 |
+
|
65 |
+
|
66 |
+
# 示例 Example
|
67 |
+
|
68 |
+
以下示例将为文本输入`Anime portrait of natalie portman as an anime girl by stanley artgerm lau, wlop, rossdraws, james jean, andrei riabovitchev, marc simonetti, and sakimichan, trending on artstation` 在目录`./AltDiffusionOutputs`下生成图片结果。
|
69 |
+
|
70 |
+
The following example will generate image results for text input `Anime portrait of natalie portman as an anime girl by stanley artgerm lau, wlop, rossdraws, james jean, andrei riabovitchev, marc simonetti, and sakimichan, trending on artstation` under the default output directory `./AltDiffusionOutputs`
|
71 |
+
|
72 |
+
```python
|
73 |
+
import torch
|
74 |
+
from flagai.auto_model.auto_loader import AutoLoader
|
75 |
+
from flagai.model.predictor.predictor import Predictor
|
76 |
+
|
77 |
+
# Initialize
|
78 |
+
prompt = "Anime portrait of natalie portman as an anime girl by stanley artgerm lau, wlop, rossdraws, james jean, andrei riabovitchev, marc simonetti, and sakimichan, trending on artstation"
|
79 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
80 |
+
|
81 |
+
|
82 |
+
loader = AutoLoader(task_name="text2img", #contrastive learning
|
83 |
+
model_name="AltDiffusion",
|
84 |
+
model_dir="./checkpoints")
|
85 |
+
|
86 |
+
model = loader.get_model()
|
87 |
+
model.eval()
|
88 |
+
model.to(device)
|
89 |
+
predictor = Predictor(model)
|
90 |
+
predictor.predict_generate_images(prompt)
|
91 |
+
```
|
92 |
+
|
93 |
+
|
94 |
+
您可以在`predict_generate_images`函数里通过改变参数来调整设置,具体信息如下:
|
95 |
+
|
96 |
+
More parameters of predict_generate_images for you to adjust for `predict_generate_images` are listed below:
|
97 |
+
|
98 |
+
|
99 |
+
| 参数名 Parameter | 类型 Type | 描述 Description |
|
100 |
+
|--------------------------------|------------|-------------------------------------------------------|
|
101 |
+
| prompt | str | 提示文本; The prompt text |
|
102 |
+
| out_path | str | 输出路径; The output path to save images |
|
103 |
+
| n_samples | int | 输出图片数量; Number of images to be generate |
|
104 |
+
| skip_grid | bool | 如果为True, 会将所有图片拼接在一起,输出一张新的图片; If set to true, image gridding step will be skipped |
|
105 |
+
| ddim_step | int | DDIM模型的步数; Number of steps in ddim model |
|
106 |
+
| plms | bool | 如果为True, 则会使用plms模型; If set to true, PLMS Sampler instead of DDIM Sampler will be applied |
|
107 |
+
| scale | float | 这个值决定了文本在多大程度上影响生成的图片,值越大影响力越强; This value determines how important the prompt incluences generate images |
|
108 |
+
| H | int | 图片的高度; Height of image |
|
109 |
+
| W | int | 图片的宽度; Width of image |
|
110 |
+
| C | int | 图片的channel数; Numeber of channels of generated images |
|
111 |
+
| seed | int | 随机种子; Random seed number |
|
112 |
+
|
113 |
+
注意:模型推理要求一张至少10G以上的GPU。
|
114 |
+
|
115 |
+
Note that the model inference requires a GPU of at least 10G above.
|
116 |
+
|
117 |
+
|
118 |
+
# 更多生成结果 More Results
|
119 |
+
|
120 |
+
## 中英文对齐能力 Chinese and English alignment ability
|
121 |
+
|
122 |
+
### prompt:dark elf princess, highly detailed, d & d, fantasy, highly detailed, digital painting, trending on artstation, concept art, sharp focus, illustration, art by artgerm and greg rutkowski and fuji choko and viktoria gavrilenko and hoang lap
|
123 |
+
### 英文生成结果/Generated results from English prompts
|
124 |
+
|
125 |
+
![image](https://github.com/FlagAI-Open/FlagAI/blob/master/examples/AltDiffusion/imgs/en_%E6%9A%97%E9%BB%91%E7%B2%BE%E7%81%B5.png)
|
126 |
+
|
127 |
+
### prompt:黑暗精灵公主,非常详细,幻想,非常详细,数字绘画,概念艺术,敏锐的焦点,插图
|
128 |
+
### 中文生成结果/Generated results from Chinese prompts
|
129 |
+
![image](https://github.com/FlagAI-Open/FlagAI/blob/master/examples/AltDiffusion/imgs/cn_%E6%9A%97%E9%BB%91%E7%B2%BE%E7%81%B5.png)
|
130 |
+
|
131 |
+
## 中文表现能力/The performance for Chinese prompts
|
132 |
+
|
133 |
+
## prompt:带墨镜的男孩肖像,充满细节,8K高清
|
134 |
+
![image](https://github.com/FlagAI-Open/FlagAI/blob/master/examples/AltDiffusion/imgs/%E5%B0%8F%E7%94%B7%E5%AD%A9.png)
|
135 |
+
|
136 |
+
|
137 |
+
## prompt:带墨镜的中国男孩肖像,充满细节,8K高清
|
138 |
+
![image](https://github.com/FlagAI-Open/FlagAI/blob/master/examples/AltDiffusion/imgs/cn_%E5%B0%8F%E7%94%B7%E5%AD%A9.png)
|
139 |
+
|
140 |
+
## 长图生成能力/The ability to generate long images
|
141 |
+
|
142 |
+
### prompt: 一只带着帽子的小狗
|
143 |
+
### 原版 stable diffusion:
|
144 |
+
![image](https://github.com/FlagAI-Open/FlagAI/blob/master/examples/AltDiffusion/imgs/%E5%A4%9A%E5%B0%BA%E5%BA%A6%E7%8B%97%EF%BC%88%E4%B8%8D%E5%A5%BD%EF%BC%89.png)
|
145 |
+
|
146 |
+
### Ours:
|
147 |
+
![image](https://github.com/FlagAI-Open/FlagAI/blob/master/examples/AltDiffusion/imgs/%E5%A4%9A%E5%B0%BA%E5%BA%A6%E7%8B%97%EF%BC%88%E5%A5%BD%EF%BC%89.png)
|
148 |
+
|
149 |
+
注: 此处长图生成技术由右脑科技(RightBrain AI)提供。
|
150 |
+
|
151 |
+
Note: The long image generation technology here is provided by Right Brain Technology.
|
152 |
+
|
153 |
+
# 许可/License
|
154 |
+
|
155 |
+
该模型通过 [CreativeML Open RAIL-M license](https://huggingface.co/spaces/CompVis/stable-diffusion-license) 获得许可。作者对您生成的输出不主张任何权利,您可以自由使用它们并对它们的使用负责,不得违反本许可中的规定。该许可证禁止您分享任何违反任何法律、对他人造成伤害、传播任���可能造成伤害的个人信息、传播错误信息和针对弱势群体的任何内容。您可以出于商业目的修改和使用模型,但必须包含相同使用限制的副本。有关限制的完整列表,请[阅读许可证](https://huggingface.co/spaces/CompVis/stable-diffusion-license) 。
|
156 |
+
|
157 |
+
The model is licensed with a [CreativeML Open RAIL-M license](https://huggingface.co/spaces/CompVis/stable-diffusion-license). The authors claim no rights on the outputs you generate, you are free to use them and are accountable for their use which must not go against the provisions set in this license. The license forbids you from sharing any content that violates any laws, produce any harm to a person, disseminate any personal information that would be meant for harm, spread misinformation and target vulnerable groups. You can modify and use the model for commercial purposes, but a copy of the same use restrictions must be included. For the full list of restrictions please [read the license](https://huggingface.co/spaces/CompVis/stable-diffusion-license) .
|