Upload 9 files
Browse files- safety_checker/config.json +179 -0
- safety_checker/pytorch_model.bin +3 -0
- scheduler/scheduler_config.json +14 -0
- tokenizer/clip_tokenizer_roberta.py +246 -0
- tokenizer/special_tokens_map.json +7 -0
- tokenizer/tokenizer_config.json +21 -0
- tokenizer/vocab.txt +0 -0
- unet/config.json +47 -0
- unet/diffusion_pytorch_model.bin +3 -0
safety_checker/config.json
ADDED
@@ -0,0 +1,179 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_commit_hash": null,
|
3 |
+
"_name_or_path": "/data/pretrained_weights/stable-diffusion-2-1-zh-v0/safety_checker",
|
4 |
+
"architectures": [
|
5 |
+
"StableDiffusionSafetyChecker"
|
6 |
+
],
|
7 |
+
"initializer_factor": 1.0,
|
8 |
+
"logit_scale_init_value": 2.6592,
|
9 |
+
"model_type": "clip",
|
10 |
+
"projection_dim": 768,
|
11 |
+
"text_config": {
|
12 |
+
"_name_or_path": "",
|
13 |
+
"add_cross_attention": false,
|
14 |
+
"architectures": null,
|
15 |
+
"attention_dropout": 0.0,
|
16 |
+
"bad_words_ids": null,
|
17 |
+
"begin_suppress_tokens": null,
|
18 |
+
"bos_token_id": 0,
|
19 |
+
"chunk_size_feed_forward": 0,
|
20 |
+
"cross_attention_hidden_size": null,
|
21 |
+
"decoder_start_token_id": null,
|
22 |
+
"diversity_penalty": 0.0,
|
23 |
+
"do_sample": false,
|
24 |
+
"dropout": 0.0,
|
25 |
+
"early_stopping": false,
|
26 |
+
"encoder_no_repeat_ngram_size": 0,
|
27 |
+
"eos_token_id": 2,
|
28 |
+
"exponential_decay_length_penalty": null,
|
29 |
+
"finetuning_task": null,
|
30 |
+
"forced_bos_token_id": null,
|
31 |
+
"forced_eos_token_id": null,
|
32 |
+
"hidden_act": "quick_gelu",
|
33 |
+
"hidden_size": 768,
|
34 |
+
"id2label": {
|
35 |
+
"0": "LABEL_0",
|
36 |
+
"1": "LABEL_1"
|
37 |
+
},
|
38 |
+
"initializer_factor": 1.0,
|
39 |
+
"initializer_range": 0.02,
|
40 |
+
"intermediate_size": 3072,
|
41 |
+
"is_decoder": false,
|
42 |
+
"is_encoder_decoder": false,
|
43 |
+
"label2id": {
|
44 |
+
"LABEL_0": 0,
|
45 |
+
"LABEL_1": 1
|
46 |
+
},
|
47 |
+
"layer_norm_eps": 1e-05,
|
48 |
+
"length_penalty": 1.0,
|
49 |
+
"max_length": 20,
|
50 |
+
"max_position_embeddings": 77,
|
51 |
+
"min_length": 0,
|
52 |
+
"model_type": "clip_text_model",
|
53 |
+
"no_repeat_ngram_size": 0,
|
54 |
+
"num_attention_heads": 12,
|
55 |
+
"num_beam_groups": 1,
|
56 |
+
"num_beams": 1,
|
57 |
+
"num_hidden_layers": 12,
|
58 |
+
"num_return_sequences": 1,
|
59 |
+
"output_attentions": false,
|
60 |
+
"output_hidden_states": false,
|
61 |
+
"output_scores": false,
|
62 |
+
"pad_token_id": 1,
|
63 |
+
"prefix": null,
|
64 |
+
"problem_type": null,
|
65 |
+
"pruned_heads": {},
|
66 |
+
"remove_invalid_values": false,
|
67 |
+
"repetition_penalty": 1.0,
|
68 |
+
"return_dict": true,
|
69 |
+
"return_dict_in_generate": false,
|
70 |
+
"sep_token_id": null,
|
71 |
+
"suppress_tokens": null,
|
72 |
+
"task_specific_params": null,
|
73 |
+
"temperature": 1.0,
|
74 |
+
"tf_legacy_loss": false,
|
75 |
+
"tie_encoder_decoder": false,
|
76 |
+
"tie_word_embeddings": true,
|
77 |
+
"tokenizer_class": null,
|
78 |
+
"top_k": 50,
|
79 |
+
"top_p": 1.0,
|
80 |
+
"torch_dtype": null,
|
81 |
+
"torchscript": false,
|
82 |
+
"transformers_version": "4.23.1",
|
83 |
+
"typical_p": 1.0,
|
84 |
+
"use_bfloat16": false,
|
85 |
+
"vocab_size": 49408
|
86 |
+
},
|
87 |
+
"text_config_dict": {
|
88 |
+
"hidden_size": 768,
|
89 |
+
"intermediate_size": 3072,
|
90 |
+
"num_attention_heads": 12,
|
91 |
+
"num_hidden_layers": 12
|
92 |
+
},
|
93 |
+
"torch_dtype": "float32",
|
94 |
+
"transformers_version": null,
|
95 |
+
"vision_config": {
|
96 |
+
"_name_or_path": "",
|
97 |
+
"add_cross_attention": false,
|
98 |
+
"architectures": null,
|
99 |
+
"attention_dropout": 0.0,
|
100 |
+
"bad_words_ids": null,
|
101 |
+
"begin_suppress_tokens": null,
|
102 |
+
"bos_token_id": null,
|
103 |
+
"chunk_size_feed_forward": 0,
|
104 |
+
"cross_attention_hidden_size": null,
|
105 |
+
"decoder_start_token_id": null,
|
106 |
+
"diversity_penalty": 0.0,
|
107 |
+
"do_sample": false,
|
108 |
+
"dropout": 0.0,
|
109 |
+
"early_stopping": false,
|
110 |
+
"encoder_no_repeat_ngram_size": 0,
|
111 |
+
"eos_token_id": null,
|
112 |
+
"exponential_decay_length_penalty": null,
|
113 |
+
"finetuning_task": null,
|
114 |
+
"forced_bos_token_id": null,
|
115 |
+
"forced_eos_token_id": null,
|
116 |
+
"hidden_act": "quick_gelu",
|
117 |
+
"hidden_size": 1024,
|
118 |
+
"id2label": {
|
119 |
+
"0": "LABEL_0",
|
120 |
+
"1": "LABEL_1"
|
121 |
+
},
|
122 |
+
"image_size": 224,
|
123 |
+
"initializer_factor": 1.0,
|
124 |
+
"initializer_range": 0.02,
|
125 |
+
"intermediate_size": 4096,
|
126 |
+
"is_decoder": false,
|
127 |
+
"is_encoder_decoder": false,
|
128 |
+
"label2id": {
|
129 |
+
"LABEL_0": 0,
|
130 |
+
"LABEL_1": 1
|
131 |
+
},
|
132 |
+
"layer_norm_eps": 1e-05,
|
133 |
+
"length_penalty": 1.0,
|
134 |
+
"max_length": 20,
|
135 |
+
"min_length": 0,
|
136 |
+
"model_type": "clip_vision_model",
|
137 |
+
"no_repeat_ngram_size": 0,
|
138 |
+
"num_attention_heads": 16,
|
139 |
+
"num_beam_groups": 1,
|
140 |
+
"num_beams": 1,
|
141 |
+
"num_channels": 3,
|
142 |
+
"num_hidden_layers": 24,
|
143 |
+
"num_return_sequences": 1,
|
144 |
+
"output_attentions": false,
|
145 |
+
"output_hidden_states": false,
|
146 |
+
"output_scores": false,
|
147 |
+
"pad_token_id": null,
|
148 |
+
"patch_size": 14,
|
149 |
+
"prefix": null,
|
150 |
+
"problem_type": null,
|
151 |
+
"pruned_heads": {},
|
152 |
+
"remove_invalid_values": false,
|
153 |
+
"repetition_penalty": 1.0,
|
154 |
+
"return_dict": true,
|
155 |
+
"return_dict_in_generate": false,
|
156 |
+
"sep_token_id": null,
|
157 |
+
"suppress_tokens": null,
|
158 |
+
"task_specific_params": null,
|
159 |
+
"temperature": 1.0,
|
160 |
+
"tf_legacy_loss": false,
|
161 |
+
"tie_encoder_decoder": false,
|
162 |
+
"tie_word_embeddings": true,
|
163 |
+
"tokenizer_class": null,
|
164 |
+
"top_k": 50,
|
165 |
+
"top_p": 1.0,
|
166 |
+
"torch_dtype": null,
|
167 |
+
"torchscript": false,
|
168 |
+
"transformers_version": "4.23.1",
|
169 |
+
"typical_p": 1.0,
|
170 |
+
"use_bfloat16": false
|
171 |
+
},
|
172 |
+
"vision_config_dict": {
|
173 |
+
"hidden_size": 1024,
|
174 |
+
"intermediate_size": 4096,
|
175 |
+
"num_attention_heads": 16,
|
176 |
+
"num_hidden_layers": 24,
|
177 |
+
"patch_size": 14
|
178 |
+
}
|
179 |
+
}
|
safety_checker/pytorch_model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:16d28f2b37109f222cdc33620fdd262102ac32112be0352a7f77e9614b35a394
|
3 |
+
size 1216064769
|
scheduler/scheduler_config.json
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_class_name": "EulerDiscreteScheduler",
|
3 |
+
"_diffusers_version": "0.9.0",
|
4 |
+
"beta_end": 0.012,
|
5 |
+
"beta_schedule": "scaled_linear",
|
6 |
+
"beta_start": 0.00085,
|
7 |
+
"clip_sample": false,
|
8 |
+
"num_train_timesteps": 1000,
|
9 |
+
"prediction_type": "v_prediction",
|
10 |
+
"set_alpha_to_one": false,
|
11 |
+
"skip_prk_steps": true,
|
12 |
+
"steps_offset": 1,
|
13 |
+
"trained_betas": null
|
14 |
+
}
|
tokenizer/clip_tokenizer_roberta.py
ADDED
@@ -0,0 +1,246 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers.models.bert.tokenization_bert import *
|
2 |
+
import os
|
3 |
+
|
4 |
+
|
5 |
+
class CLIPTokenizerRoberta(PreTrainedTokenizer):
|
6 |
+
r"""
|
7 |
+
Construct a BERT tokenizer. Based on WordPiece.
|
8 |
+
|
9 |
+
This tokenizer inherits from [`PreTrainedTokenizer`] which contains most of the main methods. Users should refer to
|
10 |
+
this superclass for more information regarding those methods.
|
11 |
+
|
12 |
+
Args:
|
13 |
+
vocab_file (`str`):
|
14 |
+
File containing the vocabulary.
|
15 |
+
do_lower_case (`bool`, *optional*, defaults to `True`):
|
16 |
+
Whether or not to lowercase the input when tokenizing.
|
17 |
+
do_basic_tokenize (`bool`, *optional*, defaults to `True`):
|
18 |
+
Whether or not to do basic tokenization before WordPiece.
|
19 |
+
never_split (`Iterable`, *optional*):
|
20 |
+
Collection of tokens which will never be split during tokenization. Only has an effect when
|
21 |
+
`do_basic_tokenize=True`
|
22 |
+
unk_token (`str`, *optional*, defaults to `"[UNK]"`):
|
23 |
+
The unknown token. A token that is not in the vocabulary cannot be converted to an ID and is set to be this
|
24 |
+
token instead.
|
25 |
+
sep_token (`str`, *optional*, defaults to `"[SEP]"`):
|
26 |
+
The separator token, which is used when building a sequence from multiple sequences, e.g. two sequences for
|
27 |
+
sequence classification or for a text and a question for question answering. It is also used as the last
|
28 |
+
token of a sequence built with special tokens.
|
29 |
+
pad_token (`str`, *optional*, defaults to `"[PAD]"`):
|
30 |
+
The token used for padding, for example when batching sequences of different lengths.
|
31 |
+
cls_token (`str`, *optional*, defaults to `"[CLS]"`):
|
32 |
+
The classifier token which is used when doing sequence classification (classification of the whole sequence
|
33 |
+
instead of per-token classification). It is the first token of the sequence when built with special tokens.
|
34 |
+
mask_token (`str`, *optional*, defaults to `"[MASK]"`):
|
35 |
+
The token used for masking values. This is the token used when training this model with masked language
|
36 |
+
modeling. This is the token which the model will try to predict.
|
37 |
+
tokenize_chinese_chars (`bool`, *optional*, defaults to `True`):
|
38 |
+
Whether or not to tokenize Chinese characters.
|
39 |
+
|
40 |
+
This should likely be deactivated for Japanese (see this
|
41 |
+
[issue](https://github.com/huggingface/transformers/issues/328)).
|
42 |
+
strip_accents (`bool`, *optional*):
|
43 |
+
Whether or not to strip all accents. If this option is not specified, then it will be determined by the
|
44 |
+
value for `lowercase` (as in the original BERT).
|
45 |
+
"""
|
46 |
+
|
47 |
+
vocab_files_names = VOCAB_FILES_NAMES
|
48 |
+
pretrained_vocab_files_map = PRETRAINED_VOCAB_FILES_MAP
|
49 |
+
pretrained_init_configuration = PRETRAINED_INIT_CONFIGURATION
|
50 |
+
max_model_input_sizes = PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
|
51 |
+
|
52 |
+
def __init__(
|
53 |
+
self,
|
54 |
+
vocab_file,
|
55 |
+
do_lower_case=True,
|
56 |
+
do_basic_tokenize=True,
|
57 |
+
never_split=None,
|
58 |
+
unk_token="[UNK]",
|
59 |
+
sep_token="[SEP]",
|
60 |
+
pad_token="[PAD]",
|
61 |
+
cls_token="[CLS]",
|
62 |
+
mask_token="[MASK]",
|
63 |
+
tokenize_chinese_chars=True,
|
64 |
+
strip_accents=None,
|
65 |
+
**kwargs
|
66 |
+
):
|
67 |
+
super().__init__(
|
68 |
+
do_lower_case=do_lower_case,
|
69 |
+
do_basic_tokenize=do_basic_tokenize,
|
70 |
+
never_split=never_split,
|
71 |
+
unk_token=unk_token,
|
72 |
+
sep_token=sep_token,
|
73 |
+
pad_token=pad_token,
|
74 |
+
cls_token=cls_token,
|
75 |
+
mask_token=mask_token,
|
76 |
+
tokenize_chinese_chars=tokenize_chinese_chars,
|
77 |
+
strip_accents=strip_accents,
|
78 |
+
**kwargs,
|
79 |
+
)
|
80 |
+
|
81 |
+
if not os.path.isfile(vocab_file):
|
82 |
+
raise ValueError(
|
83 |
+
f"Can't find a vocabulary file at path '{vocab_file}'. To load the vocabulary from a Google pretrained"
|
84 |
+
" model use `tokenizer = BertTokenizer.from_pretrained(PRETRAINED_MODEL_NAME)`"
|
85 |
+
)
|
86 |
+
self.vocab = load_vocab(vocab_file)
|
87 |
+
self.ids_to_tokens = collections.OrderedDict([(ids, tok) for tok, ids in self.vocab.items()])
|
88 |
+
self.do_basic_tokenize = do_basic_tokenize
|
89 |
+
if do_basic_tokenize:
|
90 |
+
self.basic_tokenizer = BasicTokenizer(
|
91 |
+
do_lower_case=do_lower_case,
|
92 |
+
never_split=never_split,
|
93 |
+
tokenize_chinese_chars=tokenize_chinese_chars,
|
94 |
+
strip_accents=strip_accents,
|
95 |
+
)
|
96 |
+
self.wordpiece_tokenizer = WordpieceTokenizer(vocab=self.vocab, unk_token=self.unk_token)
|
97 |
+
|
98 |
+
@property
|
99 |
+
def do_lower_case(self):
|
100 |
+
return self.basic_tokenizer.do_lower_case
|
101 |
+
|
102 |
+
@property
|
103 |
+
def vocab_size(self):
|
104 |
+
return len(self.vocab)
|
105 |
+
|
106 |
+
def get_vocab(self):
|
107 |
+
return dict(self.vocab, **self.added_tokens_encoder)
|
108 |
+
|
109 |
+
def _tokenize(self, text):
|
110 |
+
split_tokens = []
|
111 |
+
if self.do_basic_tokenize:
|
112 |
+
for token in self.basic_tokenizer.tokenize(text, never_split=self.all_special_tokens):
|
113 |
+
|
114 |
+
# If the token is part of the never_split set
|
115 |
+
if token in self.basic_tokenizer.never_split:
|
116 |
+
split_tokens.append(token)
|
117 |
+
else:
|
118 |
+
split_tokens += self.wordpiece_tokenizer.tokenize(token)
|
119 |
+
else:
|
120 |
+
split_tokens = self.wordpiece_tokenizer.tokenize(text)
|
121 |
+
return split_tokens
|
122 |
+
|
123 |
+
def _convert_token_to_id(self, token):
|
124 |
+
"""Converts a token (str) in an id using the vocab."""
|
125 |
+
return self.vocab.get(token, self.vocab.get(self.unk_token))
|
126 |
+
|
127 |
+
def _convert_id_to_token(self, index):
|
128 |
+
"""Converts an index (integer) in a token (str) using the vocab."""
|
129 |
+
return self.ids_to_tokens.get(index, self.unk_token)
|
130 |
+
|
131 |
+
def convert_tokens_to_string(self, tokens):
|
132 |
+
"""Converts a sequence of tokens (string) in a single string."""
|
133 |
+
out_string = " ".join(tokens).replace(" ##", "").strip()
|
134 |
+
return out_string
|
135 |
+
|
136 |
+
def build_inputs_with_special_tokens(
|
137 |
+
self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None
|
138 |
+
) -> List[int]:
|
139 |
+
"""
|
140 |
+
Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and
|
141 |
+
adding special tokens. A BERT sequence has the following format:
|
142 |
+
|
143 |
+
- single sequence: `[CLS] X [SEP]`
|
144 |
+
- pair of sequences: `[CLS] A [SEP] B [SEP]`
|
145 |
+
|
146 |
+
Args:
|
147 |
+
token_ids_0 (`List[int]`):
|
148 |
+
List of IDs to which the special tokens will be added.
|
149 |
+
token_ids_1 (`List[int]`, *optional*):
|
150 |
+
Optional second list of IDs for sequence pairs.
|
151 |
+
|
152 |
+
Returns:
|
153 |
+
`List[int]`: List of [input IDs](../glossary#input-ids) with the appropriate special tokens.
|
154 |
+
"""
|
155 |
+
sep = [49407]
|
156 |
+
cls = [49406]
|
157 |
+
|
158 |
+
if token_ids_1 is None:
|
159 |
+
return cls + token_ids_0 + sep
|
160 |
+
# return [self.cls_token_id] + token_ids_0 + [self.sep_token_id]
|
161 |
+
# cls = [self.cls_token_id]
|
162 |
+
# sep = [self.sep_token_id]
|
163 |
+
|
164 |
+
return cls + token_ids_0 + sep + token_ids_1 + sep
|
165 |
+
|
166 |
+
def get_special_tokens_mask(
|
167 |
+
self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None,
|
168 |
+
already_has_special_tokens: bool = False
|
169 |
+
) -> List[int]:
|
170 |
+
"""
|
171 |
+
Retrieve sequence ids from a token list that has no special tokens added. This method is called when adding
|
172 |
+
special tokens using the tokenizer `prepare_for_model` method.
|
173 |
+
|
174 |
+
Args:
|
175 |
+
token_ids_0 (`List[int]`):
|
176 |
+
List of IDs.
|
177 |
+
token_ids_1 (`List[int]`, *optional*):
|
178 |
+
Optional second list of IDs for sequence pairs.
|
179 |
+
already_has_special_tokens (`bool`, *optional*, defaults to `False`):
|
180 |
+
Whether or not the token list is already formatted with special tokens for the model.
|
181 |
+
|
182 |
+
Returns:
|
183 |
+
`List[int]`: A list of integers in the range [0, 1]: 1 for a special token, 0 for a sequence token.
|
184 |
+
"""
|
185 |
+
|
186 |
+
if already_has_special_tokens:
|
187 |
+
return super().get_special_tokens_mask(
|
188 |
+
token_ids_0=token_ids_0, token_ids_1=token_ids_1, already_has_special_tokens=True
|
189 |
+
)
|
190 |
+
|
191 |
+
if token_ids_1 is not None:
|
192 |
+
return [1] + ([0] * len(token_ids_0)) + [1] + ([0] * len(token_ids_1)) + [1]
|
193 |
+
return [1] + ([0] * len(token_ids_0)) + [1]
|
194 |
+
|
195 |
+
def create_token_type_ids_from_sequences(
|
196 |
+
self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None
|
197 |
+
) -> List[int]:
|
198 |
+
"""
|
199 |
+
Create a mask from the two sequences passed to be used in a sequence-pair classification task. A BERT sequence
|
200 |
+
pair mask has the following format:
|
201 |
+
|
202 |
+
```
|
203 |
+
0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1
|
204 |
+
| first sequence | second sequence |
|
205 |
+
```
|
206 |
+
|
207 |
+
If `token_ids_1` is `None`, this method only returns the first portion of the mask (0s).
|
208 |
+
|
209 |
+
Args:
|
210 |
+
token_ids_0 (`List[int]`):
|
211 |
+
List of IDs.
|
212 |
+
token_ids_1 (`List[int]`, *optional*):
|
213 |
+
Optional second list of IDs for sequence pairs.
|
214 |
+
|
215 |
+
Returns:
|
216 |
+
`List[int]`: List of [token type IDs](../glossary#token-type-ids) according to the given sequence(s).
|
217 |
+
"""
|
218 |
+
# sep = [self.sep_token_id]
|
219 |
+
# cls = [self.cls_token_id]
|
220 |
+
sep = [49407]
|
221 |
+
cls = [49406]
|
222 |
+
if token_ids_1 is None:
|
223 |
+
return len(cls + token_ids_0 + sep) * [0]
|
224 |
+
return len(cls + token_ids_0 + sep) * [0] + len(token_ids_1 + sep) * [1]
|
225 |
+
|
226 |
+
def save_vocabulary(self, save_directory: str, filename_prefix: Optional[str] = None) -> Tuple[str]:
|
227 |
+
index = 0
|
228 |
+
if os.path.isdir(save_directory):
|
229 |
+
vocab_file = os.path.join(
|
230 |
+
save_directory, (filename_prefix + "-" if filename_prefix else "") + VOCAB_FILES_NAMES["vocab_file"]
|
231 |
+
)
|
232 |
+
else:
|
233 |
+
vocab_file = (filename_prefix + "-" if filename_prefix else "") + save_directory
|
234 |
+
with open(vocab_file, "w", encoding="utf-8") as writer:
|
235 |
+
for token, token_index in sorted(self.vocab.items(), key=lambda kv: kv[1]):
|
236 |
+
if index != token_index:
|
237 |
+
logger.warning(
|
238 |
+
f"Saving vocabulary to {vocab_file}: vocabulary indices are not consecutive."
|
239 |
+
" Please check that the vocabulary is not corrupted!"
|
240 |
+
)
|
241 |
+
index = token_index
|
242 |
+
writer.write(token + "\n")
|
243 |
+
index += 1
|
244 |
+
return (vocab_file,)
|
245 |
+
|
246 |
+
|
tokenizer/special_tokens_map.json
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cls_token": "[CLS]",
|
3 |
+
"mask_token": "[MASK]",
|
4 |
+
"pad_token": "[PAD]",
|
5 |
+
"sep_token": "[SEP]",
|
6 |
+
"unk_token": "[UNK]"
|
7 |
+
}
|
tokenizer/tokenizer_config.json
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cls_token": "[CLS]",
|
3 |
+
"do_basic_tokenize": true,
|
4 |
+
"do_lower_case": true,
|
5 |
+
"mask_token": "[MASK]",
|
6 |
+
"model_max_length": 77,
|
7 |
+
"never_split": null,
|
8 |
+
"pad_token": "[PAD]",
|
9 |
+
"sep_token": "[SEP]",
|
10 |
+
"strip_accents": null,
|
11 |
+
"tokenize_chinese_chars": true,
|
12 |
+
"tokenizer_class": "CLIPTokenizerRoberta",
|
13 |
+
"auto_map": {
|
14 |
+
"AutoTokenizer": [
|
15 |
+
"clip_tokenizer_roberta.CLIPTokenizerRoberta",
|
16 |
+
null
|
17 |
+
]
|
18 |
+
},
|
19 |
+
"unk_token": "[UNK]",
|
20 |
+
"use_fast": true
|
21 |
+
}
|
tokenizer/vocab.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|
unet/config.json
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_class_name": "UNet2DConditionModel",
|
3 |
+
"_diffusers_version": "0.9.0",
|
4 |
+
"_name_or_path": "/data/pretrained_weights/stable-diffusion-2-1-zh-v0",
|
5 |
+
"act_fn": "silu",
|
6 |
+
"attention_head_dim": [
|
7 |
+
5,
|
8 |
+
10,
|
9 |
+
20,
|
10 |
+
20
|
11 |
+
],
|
12 |
+
"block_out_channels": [
|
13 |
+
320,
|
14 |
+
640,
|
15 |
+
1280,
|
16 |
+
1280
|
17 |
+
],
|
18 |
+
"center_input_sample": false,
|
19 |
+
"cross_attention_dim": 1024,
|
20 |
+
"down_block_types": [
|
21 |
+
"CrossAttnDownBlock2D",
|
22 |
+
"CrossAttnDownBlock2D",
|
23 |
+
"CrossAttnDownBlock2D",
|
24 |
+
"DownBlock2D"
|
25 |
+
],
|
26 |
+
"downsample_padding": 1,
|
27 |
+
"dual_cross_attention": false,
|
28 |
+
"flip_sin_to_cos": true,
|
29 |
+
"freq_shift": 0,
|
30 |
+
"in_channels": 4,
|
31 |
+
"layers_per_block": 2,
|
32 |
+
"mid_block_scale_factor": 1,
|
33 |
+
"norm_eps": 1e-05,
|
34 |
+
"norm_num_groups": 32,
|
35 |
+
"num_class_embeds": null,
|
36 |
+
"only_cross_attention": false,
|
37 |
+
"out_channels": 4,
|
38 |
+
"sample_size": 96,
|
39 |
+
"up_block_types": [
|
40 |
+
"UpBlock2D",
|
41 |
+
"CrossAttnUpBlock2D",
|
42 |
+
"CrossAttnUpBlock2D",
|
43 |
+
"CrossAttnUpBlock2D"
|
44 |
+
],
|
45 |
+
"upcast_attention": true,
|
46 |
+
"use_linear_projection": true
|
47 |
+
}
|
unet/diffusion_pytorch_model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ea40608d6ca2035594a00b9f49c90a58e8e6fdea7a4dc9db03ea04cc9fd02949
|
3 |
+
size 3463877477
|