Commit ·
47be7c7
0
Parent(s):
Duplicate from chflame163/ComfyUI_LayerStyle
Browse filesCo-authored-by: chflame163 <chflame163@users.noreply.huggingface.co>
This view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +41 -0
- ComfyUI/models/BEN/BEN2_Base.pth +3 -0
- ComfyUI/models/BEN/BEN_Base.pth +3 -0
- ComfyUI/models/BEN/config.json +6 -0
- ComfyUI/models/BiRefNet/BiRefNet-ep480.pth +3 -0
- ComfyUI/models/BiRefNet/RMBG-2.0/.gitattributes +40 -0
- ComfyUI/models/BiRefNet/RMBG-2.0/BiRefNet_config.py +11 -0
- ComfyUI/models/BiRefNet/RMBG-2.0/birefnet.py +2244 -0
- ComfyUI/models/BiRefNet/RMBG-2.0/collage5.png +3 -0
- ComfyUI/models/BiRefNet/RMBG-2.0/config.json +20 -0
- ComfyUI/models/BiRefNet/RMBG-2.0/diagram1.png +0 -0
- ComfyUI/models/BiRefNet/RMBG-2.0/model.safetensors +3 -0
- ComfyUI/models/BiRefNet/RMBG-2.0/preprocessor_config.json +23 -0
- ComfyUI/models/BiRefNet/RMBG-2.0/t4.png +3 -0
- ComfyUI/models/BiRefNet/pth/BiRefNet-general-epoch_244.pth +3 -0
- ComfyUI/models/BiRefNet/pvt_v2_b2.pth +3 -0
- ComfyUI/models/BiRefNet/pvt_v2_b5.pth +3 -0
- ComfyUI/models/BiRefNet/swin_base_patch4_window12_384_22kto1k.pth +3 -0
- ComfyUI/models/BiRefNet/swin_large_patch4_window12_384_22kto1k.pth +3 -0
- ComfyUI/models/EVF-SAM/evf-sam/.gitattributes +35 -0
- ComfyUI/models/EVF-SAM/evf-sam/README.md +12 -0
- ComfyUI/models/EVF-SAM/evf-sam/config.json +16 -0
- ComfyUI/models/EVF-SAM/evf-sam/pytorch_model.bin +3 -0
- ComfyUI/models/EVF-SAM/evf-sam/sentencepiece.bpe.model +3 -0
- ComfyUI/models/EVF-SAM/evf-sam/special_tokens_map.json +15 -0
- ComfyUI/models/EVF-SAM/evf-sam/tokenizer_config.json +22 -0
- ComfyUI/models/EVF-SAM/evf-sam2/.gitattributes +35 -0
- ComfyUI/models/EVF-SAM/evf-sam2/README.md +12 -0
- ComfyUI/models/EVF-SAM/evf-sam2/config.json +16 -0
- ComfyUI/models/EVF-SAM/evf-sam2/model.safetensors +3 -0
- ComfyUI/models/EVF-SAM/evf-sam2/sentencepiece.bpe.model +3 -0
- ComfyUI/models/EVF-SAM/evf-sam2/special_tokens_map.json +15 -0
- ComfyUI/models/EVF-SAM/evf-sam2/tokenizer_config.json +57 -0
- ComfyUI/models/Joy_caption/cgrkzexw-599808/clip_model.pt +3 -0
- ComfyUI/models/Joy_caption/cgrkzexw-599808/clip_model.pt.baiduyun.uploading.cfg +0 -0
- ComfyUI/models/Joy_caption/cgrkzexw-599808/config.yaml +39 -0
- ComfyUI/models/Joy_caption/cgrkzexw-599808/image_adapter.pt +3 -0
- ComfyUI/models/Joy_caption/cgrkzexw-599808/text_model/README.md +202 -0
- ComfyUI/models/Joy_caption/cgrkzexw-599808/text_model/adapter_config.json +34 -0
- ComfyUI/models/Joy_caption/cgrkzexw-599808/text_model/adapter_model.safetensors +3 -0
- ComfyUI/models/Joy_caption/cgrkzexw-599808/text_model/special_tokens_map.json +23 -0
- ComfyUI/models/Joy_caption/cgrkzexw-599808/text_model/tokenizer.json +0 -0
- ComfyUI/models/Joy_caption/cgrkzexw-599808/text_model/tokenizer_config.json +2064 -0
- ComfyUI/models/LLM/Phi-3.5-mini-instruct/.gitattributes +35 -0
- ComfyUI/models/LLM/Phi-3.5-mini-instruct/CODE_OF_CONDUCT.md +9 -0
- ComfyUI/models/LLM/Phi-3.5-mini-instruct/LICENSE +22 -0
- ComfyUI/models/LLM/Phi-3.5-mini-instruct/NOTICE.md +38 -0
- ComfyUI/models/LLM/Phi-3.5-mini-instruct/README.md +474 -0
- ComfyUI/models/LLM/Phi-3.5-mini-instruct/SECURITY.md +41 -0
- ComfyUI/models/LLM/Phi-3.5-mini-instruct/added_tokens.json +13 -0
.gitattributes
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
| 13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
ComfyUI/models/lama/erika.jit filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
ComfyUI/models/lama/manga_inpaintor.jit filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
ComfyUI/models/LLavacheckpoints/files_for_uform_gen2_qwen/temp.png filter=lfs diff=lfs merge=lfs -text
|
| 39 |
+
ComfyUI/models/BiRefNet/RMBG-2.0/collage5.png filter=lfs diff=lfs merge=lfs -text
|
| 40 |
+
ComfyUI/models/BiRefNet/RMBG-2.0/t4.png filter=lfs diff=lfs merge=lfs -text
|
| 41 |
+
ComfyUI/models/LLavacheckpoints/llama-joycaption-beta-one-hf-llava/tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
ComfyUI/models/BEN/BEN2_Base.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:926144a876bda06f125555b4f5a239ece89dc6eb838a863700ca9bf192161a1c
|
| 3 |
+
size 1134584206
|
ComfyUI/models/BEN/BEN_Base.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2ebc72f0aaf0693c97b58a9bcfed9198be044d601049173d698cc70087307483
|
| 3 |
+
size 1134588350
|
ComfyUI/models/BEN/config.json
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_name_or_path": "PramaLLC/BEN",
|
| 3 |
+
"architectures": ["PramaBEN_Base"],
|
| 4 |
+
"version": "1.0",
|
| 5 |
+
"torch_dtype": "float32",
|
| 6 |
+
}
|
ComfyUI/models/BiRefNet/BiRefNet-ep480.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:367a738b27e0556e703991e8160fe6b5217bec6c158a72a890d131dd11ba74f6
|
| 3 |
+
size 848968257
|
ComfyUI/models/BiRefNet/RMBG-2.0/.gitattributes
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
| 13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
model_not_working.not_safetensors filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
t4.png filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
collage.png filter=lfs diff=lfs merge=lfs -text
|
| 39 |
+
collage3.png filter=lfs diff=lfs merge=lfs -text
|
| 40 |
+
collage5.png filter=lfs diff=lfs merge=lfs -text
|
ComfyUI/models/BiRefNet/RMBG-2.0/BiRefNet_config.py
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import PretrainedConfig
|
| 2 |
+
|
| 3 |
+
class BiRefNetConfig(PretrainedConfig):
|
| 4 |
+
model_type = "SegformerForSemanticSegmentation"
|
| 5 |
+
def __init__(
|
| 6 |
+
self,
|
| 7 |
+
bb_pretrained=False,
|
| 8 |
+
**kwargs
|
| 9 |
+
):
|
| 10 |
+
self.bb_pretrained = bb_pretrained
|
| 11 |
+
super().__init__(**kwargs)
|
ComfyUI/models/BiRefNet/RMBG-2.0/birefnet.py
ADDED
|
@@ -0,0 +1,2244 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.path.expanduser('~') # Make up your file system as: SYS_HOME_DIR/codes/dis/BiRefNet, SYS_HOME_DIR/datasets/dis/xx, SYS_HOME_DIR/weights/xx
|
| 11 |
+
|
| 12 |
+
# TASK settings
|
| 13 |
+
self.task = ['DIS5K', 'COD', 'HRSOD', 'DIS5K+HRSOD+HRS10K', 'P3M-10k'][0]
|
| 14 |
+
self.training_set = {
|
| 15 |
+
'DIS5K': ['DIS-TR', 'DIS-TR+DIS-TE1+DIS-TE2+DIS-TE3+DIS-TE4'][0],
|
| 16 |
+
'COD': 'TR-COD10K+TR-CAMO',
|
| 17 |
+
'HRSOD': ['TR-DUTS', 'TR-HRSOD', 'TR-UHRSD', 'TR-DUTS+TR-HRSOD', 'TR-DUTS+TR-UHRSD', 'TR-HRSOD+TR-UHRSD', 'TR-DUTS+TR-HRSOD+TR-UHRSD'][5],
|
| 18 |
+
'DIS5K+HRSOD+HRS10K': 'DIS-TE1+DIS-TE2+DIS-TE3+DIS-TE4+DIS-TR+TE-HRS10K+TE-HRSOD+TE-UHRSD+TR-HRS10K+TR-HRSOD+TR-UHRSD', # leave DIS-VD for evaluation.
|
| 19 |
+
'P3M-10k': 'TR-P3M-10k',
|
| 20 |
+
}[self.task]
|
| 21 |
+
self.prompt4loc = ['dense', 'sparse'][0]
|
| 22 |
+
|
| 23 |
+
# Faster-Training settings
|
| 24 |
+
self.load_all = True
|
| 25 |
+
self.compile = True # 1. Trigger CPU memory leak in some extend, which is an inherent problem of PyTorch.
|
| 26 |
+
# Machines with > 70GB CPU memory can run the whole training on DIS5K with default setting.
|
| 27 |
+
# 2. Higher PyTorch version may fix it: https://github.com/pytorch/pytorch/issues/119607.
|
| 28 |
+
# 3. But compile in Pytorch > 2.0.1 seems to bring no acceleration for training.
|
| 29 |
+
self.precisionHigh = True
|
| 30 |
+
|
| 31 |
+
# MODEL settings
|
| 32 |
+
self.ms_supervision = True
|
| 33 |
+
self.out_ref = self.ms_supervision and True
|
| 34 |
+
self.dec_ipt = True
|
| 35 |
+
self.dec_ipt_split = True
|
| 36 |
+
self.cxt_num = [0, 3][1] # multi-scale skip connections from encoder
|
| 37 |
+
self.mul_scl_ipt = ['', 'add', 'cat'][2]
|
| 38 |
+
self.dec_att = ['', 'ASPP', 'ASPPDeformable'][2]
|
| 39 |
+
self.squeeze_block = ['', 'BasicDecBlk_x1', 'ResBlk_x4', 'ASPP_x3', 'ASPPDeformable_x3'][1]
|
| 40 |
+
self.dec_blk = ['BasicDecBlk', 'ResBlk', 'HierarAttDecBlk'][0]
|
| 41 |
+
|
| 42 |
+
# TRAINING settings
|
| 43 |
+
self.batch_size = 4
|
| 44 |
+
self.IoU_finetune_last_epochs = [
|
| 45 |
+
0,
|
| 46 |
+
{
|
| 47 |
+
'DIS5K': -50,
|
| 48 |
+
'COD': -20,
|
| 49 |
+
'HRSOD': -20,
|
| 50 |
+
'DIS5K+HRSOD+HRS10K': -20,
|
| 51 |
+
'P3M-10k': -20,
|
| 52 |
+
}[self.task]
|
| 53 |
+
][1] # choose 0 to skip
|
| 54 |
+
self.lr = (1e-4 if 'DIS5K' in self.task else 1e-5) * math.sqrt(self.batch_size / 4) # DIS needs high lr to converge faster. Adapt the lr linearly
|
| 55 |
+
self.size = 1024
|
| 56 |
+
self.num_workers = max(4, self.batch_size) # will be decrease to min(it, batch_size) at the initialization of the data_loader
|
| 57 |
+
|
| 58 |
+
# Backbone settings
|
| 59 |
+
self.bb = [
|
| 60 |
+
'vgg16', 'vgg16bn', 'resnet50', # 0, 1, 2
|
| 61 |
+
'swin_v1_t', 'swin_v1_s', # 3, 4
|
| 62 |
+
'swin_v1_b', 'swin_v1_l', # 5-bs9, 6-bs4
|
| 63 |
+
'pvt_v2_b0', 'pvt_v2_b1', # 7, 8
|
| 64 |
+
'pvt_v2_b2', 'pvt_v2_b5', # 9-bs10, 10-bs5
|
| 65 |
+
][6]
|
| 66 |
+
self.lateral_channels_in_collection = {
|
| 67 |
+
'vgg16': [512, 256, 128, 64], 'vgg16bn': [512, 256, 128, 64], 'resnet50': [1024, 512, 256, 64],
|
| 68 |
+
'pvt_v2_b2': [512, 320, 128, 64], 'pvt_v2_b5': [512, 320, 128, 64],
|
| 69 |
+
'swin_v1_b': [1024, 512, 256, 128], 'swin_v1_l': [1536, 768, 384, 192],
|
| 70 |
+
'swin_v1_t': [768, 384, 192, 96], 'swin_v1_s': [768, 384, 192, 96],
|
| 71 |
+
'pvt_v2_b0': [256, 160, 64, 32], 'pvt_v2_b1': [512, 320, 128, 64],
|
| 72 |
+
}[self.bb]
|
| 73 |
+
if self.mul_scl_ipt == 'cat':
|
| 74 |
+
self.lateral_channels_in_collection = [channel * 2 for channel in self.lateral_channels_in_collection]
|
| 75 |
+
self.cxt = self.lateral_channels_in_collection[1:][::-1][-self.cxt_num:] if self.cxt_num else []
|
| 76 |
+
|
| 77 |
+
# MODEL settings - inactive
|
| 78 |
+
self.lat_blk = ['BasicLatBlk'][0]
|
| 79 |
+
self.dec_channels_inter = ['fixed', 'adap'][0]
|
| 80 |
+
self.refine = ['', 'itself', 'RefUNet', 'Refiner', 'RefinerPVTInChannels4'][0]
|
| 81 |
+
self.progressive_ref = self.refine and True
|
| 82 |
+
self.ender = self.progressive_ref and False
|
| 83 |
+
self.scale = self.progressive_ref and 2
|
| 84 |
+
self.auxiliary_classification = False # Only for DIS5K, where class labels are saved in `dataset.py`.
|
| 85 |
+
self.refine_iteration = 1
|
| 86 |
+
self.freeze_bb = False
|
| 87 |
+
self.model = [
|
| 88 |
+
'BiRefNet',
|
| 89 |
+
][0]
|
| 90 |
+
if self.dec_blk == 'HierarAttDecBlk':
|
| 91 |
+
self.batch_size = 2 ** [0, 1, 2, 3, 4][2]
|
| 92 |
+
|
| 93 |
+
# TRAINING settings - inactive
|
| 94 |
+
self.preproc_methods = ['flip', 'enhance', 'rotate', 'pepper', 'crop'][:4]
|
| 95 |
+
self.optimizer = ['Adam', 'AdamW'][1]
|
| 96 |
+
self.lr_decay_epochs = [1e5] # Set to negative N to decay the lr in the last N-th epoch.
|
| 97 |
+
self.lr_decay_rate = 0.5
|
| 98 |
+
# Loss
|
| 99 |
+
self.lambdas_pix_last = {
|
| 100 |
+
# not 0 means opening this loss
|
| 101 |
+
# original rate -- 1 : 30 : 1.5 : 0.2, bce x 30
|
| 102 |
+
'bce': 30 * 1, # high performance
|
| 103 |
+
'iou': 0.5 * 1, # 0 / 255
|
| 104 |
+
'iou_patch': 0.5 * 0, # 0 / 255, win_size = (64, 64)
|
| 105 |
+
'mse': 150 * 0, # can smooth the saliency map
|
| 106 |
+
'triplet': 3 * 0,
|
| 107 |
+
'reg': 100 * 0,
|
| 108 |
+
'ssim': 10 * 1, # help contours,
|
| 109 |
+
'cnt': 5 * 0, # help contours
|
| 110 |
+
'structure': 5 * 0, # structure loss from codes of MVANet. A little improvement on DIS-TE[1,2,3], a bit more decrease on DIS-TE4.
|
| 111 |
+
}
|
| 112 |
+
self.lambdas_cls = {
|
| 113 |
+
'ce': 5.0
|
| 114 |
+
}
|
| 115 |
+
# Adv
|
| 116 |
+
self.lambda_adv_g = 10. * 0 # turn to 0 to avoid adv training
|
| 117 |
+
self.lambda_adv_d = 3. * (self.lambda_adv_g > 0)
|
| 118 |
+
|
| 119 |
+
# PATH settings - inactive
|
| 120 |
+
self.data_root_dir = os.path.join(self.sys_home_dir, 'datasets/dis')
|
| 121 |
+
self.weights_root_dir = os.path.join(self.sys_home_dir, 'weights')
|
| 122 |
+
self.weights = {
|
| 123 |
+
'pvt_v2_b2': os.path.join(self.weights_root_dir, 'pvt_v2_b2.pth'),
|
| 124 |
+
'pvt_v2_b5': os.path.join(self.weights_root_dir, ['pvt_v2_b5.pth', 'pvt_v2_b5_22k.pth'][0]),
|
| 125 |
+
'swin_v1_b': os.path.join(self.weights_root_dir, ['swin_base_patch4_window12_384_22kto1k.pth', 'swin_base_patch4_window12_384_22k.pth'][0]),
|
| 126 |
+
'swin_v1_l': os.path.join(self.weights_root_dir, ['swin_large_patch4_window12_384_22kto1k.pth', 'swin_large_patch4_window12_384_22k.pth'][0]),
|
| 127 |
+
'swin_v1_t': os.path.join(self.weights_root_dir, ['swin_tiny_patch4_window7_224_22kto1k_finetune.pth'][0]),
|
| 128 |
+
'swin_v1_s': os.path.join(self.weights_root_dir, ['swin_small_patch4_window7_224_22kto1k_finetune.pth'][0]),
|
| 129 |
+
'pvt_v2_b0': os.path.join(self.weights_root_dir, ['pvt_v2_b0.pth'][0]),
|
| 130 |
+
'pvt_v2_b1': os.path.join(self.weights_root_dir, ['pvt_v2_b1.pth'][0]),
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
# Callbacks - inactive
|
| 134 |
+
self.verbose_eval = True
|
| 135 |
+
self.only_S_MAE = False
|
| 136 |
+
self.use_fp16 = False # Bugs. It may cause nan in training.
|
| 137 |
+
self.SDPA_enabled = False # Bugs. Slower and errors occur in multi-GPUs
|
| 138 |
+
|
| 139 |
+
# others
|
| 140 |
+
self.device = [0, 'cpu'][0] # .to(0) == .to('cuda:0')
|
| 141 |
+
|
| 142 |
+
self.batch_size_valid = 1
|
| 143 |
+
self.rand_seed = 7
|
| 144 |
+
# run_sh_file = [f for f in os.listdir('.') if 'train.sh' == f] + [os.path.join('..', f) for f in os.listdir('..') if 'train.sh' == f]
|
| 145 |
+
# with open(run_sh_file[0], 'r') as f:
|
| 146 |
+
# lines = f.readlines()
|
| 147 |
+
# self.save_last = int([l.strip() for l in lines if '"{}")'.format(self.task) in l and 'val_last=' in l][0].split('val_last=')[-1].split()[0])
|
| 148 |
+
# self.save_step = int([l.strip() for l in lines if '"{}")'.format(self.task) in l and 'step=' in l][0].split('step=')[-1].split()[0])
|
| 149 |
+
# self.val_step = [0, self.save_step][0]
|
| 150 |
+
|
| 151 |
+
def print_task(self) -> None:
|
| 152 |
+
# Return task for choosing settings in shell scripts.
|
| 153 |
+
print(self.task)
|
| 154 |
+
|
| 155 |
+
|
| 156 |
+
|
| 157 |
+
### models/backbones/pvt_v2.py
|
| 158 |
+
|
| 159 |
+
import torch
|
| 160 |
+
import torch.nn as nn
|
| 161 |
+
from functools import partial
|
| 162 |
+
|
| 163 |
+
from timm.models.layers import DropPath, to_2tuple, trunc_normal_
|
| 164 |
+
from timm.models.registry import register_model
|
| 165 |
+
|
| 166 |
+
import math
|
| 167 |
+
|
| 168 |
+
# from config import Config
|
| 169 |
+
|
| 170 |
+
# config = Config()
|
| 171 |
+
|
| 172 |
+
class Mlp(nn.Module):
|
| 173 |
+
def __init__(self, in_features, hidden_features=None, out_features=None, act_layer=nn.GELU, drop=0.):
|
| 174 |
+
super().__init__()
|
| 175 |
+
out_features = out_features or in_features
|
| 176 |
+
hidden_features = hidden_features or in_features
|
| 177 |
+
self.fc1 = nn.Linear(in_features, hidden_features)
|
| 178 |
+
self.dwconv = DWConv(hidden_features)
|
| 179 |
+
self.act = act_layer()
|
| 180 |
+
self.fc2 = nn.Linear(hidden_features, out_features)
|
| 181 |
+
self.drop = nn.Dropout(drop)
|
| 182 |
+
|
| 183 |
+
self.apply(self._init_weights)
|
| 184 |
+
|
| 185 |
+
def _init_weights(self, m):
|
| 186 |
+
if isinstance(m, nn.Linear):
|
| 187 |
+
trunc_normal_(m.weight, std=.02)
|
| 188 |
+
if isinstance(m, nn.Linear) and m.bias is not None:
|
| 189 |
+
nn.init.constant_(m.bias, 0)
|
| 190 |
+
elif isinstance(m, nn.LayerNorm):
|
| 191 |
+
nn.init.constant_(m.bias, 0)
|
| 192 |
+
nn.init.constant_(m.weight, 1.0)
|
| 193 |
+
elif isinstance(m, nn.Conv2d):
|
| 194 |
+
fan_out = m.kernel_size[0] * m.kernel_size[1] * m.out_channels
|
| 195 |
+
fan_out //= m.groups
|
| 196 |
+
m.weight.data.normal_(0, math.sqrt(2.0 / fan_out))
|
| 197 |
+
if m.bias is not None:
|
| 198 |
+
m.bias.data.zero_()
|
| 199 |
+
|
| 200 |
+
def forward(self, x, H, W):
|
| 201 |
+
x = self.fc1(x)
|
| 202 |
+
x = self.dwconv(x, H, W)
|
| 203 |
+
x = self.act(x)
|
| 204 |
+
x = self.drop(x)
|
| 205 |
+
x = self.fc2(x)
|
| 206 |
+
x = self.drop(x)
|
| 207 |
+
return x
|
| 208 |
+
|
| 209 |
+
|
| 210 |
+
class Attention(nn.Module):
|
| 211 |
+
def __init__(self, dim, num_heads=8, qkv_bias=False, qk_scale=None, attn_drop=0., proj_drop=0., sr_ratio=1):
|
| 212 |
+
super().__init__()
|
| 213 |
+
assert dim % num_heads == 0, f"dim {dim} should be divided by num_heads {num_heads}."
|
| 214 |
+
|
| 215 |
+
self.dim = dim
|
| 216 |
+
self.num_heads = num_heads
|
| 217 |
+
head_dim = dim // num_heads
|
| 218 |
+
self.scale = qk_scale or head_dim ** -0.5
|
| 219 |
+
|
| 220 |
+
self.q = nn.Linear(dim, dim, bias=qkv_bias)
|
| 221 |
+
self.kv = nn.Linear(dim, dim * 2, bias=qkv_bias)
|
| 222 |
+
self.attn_drop_prob = attn_drop
|
| 223 |
+
self.attn_drop = nn.Dropout(attn_drop)
|
| 224 |
+
self.proj = nn.Linear(dim, dim)
|
| 225 |
+
self.proj_drop = nn.Dropout(proj_drop)
|
| 226 |
+
|
| 227 |
+
self.sr_ratio = sr_ratio
|
| 228 |
+
if sr_ratio > 1:
|
| 229 |
+
self.sr = nn.Conv2d(dim, dim, kernel_size=sr_ratio, stride=sr_ratio)
|
| 230 |
+
self.norm = nn.LayerNorm(dim)
|
| 231 |
+
|
| 232 |
+
self.apply(self._init_weights)
|
| 233 |
+
|
| 234 |
+
def _init_weights(self, m):
|
| 235 |
+
if isinstance(m, nn.Linear):
|
| 236 |
+
trunc_normal_(m.weight, std=.02)
|
| 237 |
+
if isinstance(m, nn.Linear) and m.bias is not None:
|
| 238 |
+
nn.init.constant_(m.bias, 0)
|
| 239 |
+
elif isinstance(m, nn.LayerNorm):
|
| 240 |
+
nn.init.constant_(m.bias, 0)
|
| 241 |
+
nn.init.constant_(m.weight, 1.0)
|
| 242 |
+
elif isinstance(m, nn.Conv2d):
|
| 243 |
+
fan_out = m.kernel_size[0] * m.kernel_size[1] * m.out_channels
|
| 244 |
+
fan_out //= m.groups
|
| 245 |
+
m.weight.data.normal_(0, math.sqrt(2.0 / fan_out))
|
| 246 |
+
if m.bias is not None:
|
| 247 |
+
m.bias.data.zero_()
|
| 248 |
+
|
| 249 |
+
def forward(self, x, H, W):
|
| 250 |
+
B, N, C = x.shape
|
| 251 |
+
q = self.q(x).reshape(B, N, self.num_heads, C // self.num_heads).permute(0, 2, 1, 3)
|
| 252 |
+
|
| 253 |
+
if self.sr_ratio > 1:
|
| 254 |
+
x_ = x.permute(0, 2, 1).reshape(B, C, H, W)
|
| 255 |
+
x_ = self.sr(x_).reshape(B, C, -1).permute(0, 2, 1)
|
| 256 |
+
x_ = self.norm(x_)
|
| 257 |
+
kv = self.kv(x_).reshape(B, -1, 2, self.num_heads, C // self.num_heads).permute(2, 0, 3, 1, 4)
|
| 258 |
+
else:
|
| 259 |
+
kv = self.kv(x).reshape(B, -1, 2, self.num_heads, C // self.num_heads).permute(2, 0, 3, 1, 4)
|
| 260 |
+
k, v = kv[0], kv[1]
|
| 261 |
+
|
| 262 |
+
if config.SDPA_enabled:
|
| 263 |
+
x = torch.nn.functional.scaled_dot_product_attention(
|
| 264 |
+
q, k, v,
|
| 265 |
+
attn_mask=None, dropout_p=self.attn_drop_prob, is_causal=False
|
| 266 |
+
).transpose(1, 2).reshape(B, N, C)
|
| 267 |
+
else:
|
| 268 |
+
attn = (q @ k.transpose(-2, -1)) * self.scale
|
| 269 |
+
attn = attn.softmax(dim=-1)
|
| 270 |
+
attn = self.attn_drop(attn)
|
| 271 |
+
|
| 272 |
+
x = (attn @ v).transpose(1, 2).reshape(B, N, C)
|
| 273 |
+
x = self.proj(x)
|
| 274 |
+
x = self.proj_drop(x)
|
| 275 |
+
|
| 276 |
+
return x
|
| 277 |
+
|
| 278 |
+
|
| 279 |
+
class Block(nn.Module):
|
| 280 |
+
|
| 281 |
+
def __init__(self, dim, num_heads, mlp_ratio=4., qkv_bias=False, qk_scale=None, drop=0., attn_drop=0.,
|
| 282 |
+
drop_path=0., act_layer=nn.GELU, norm_layer=nn.LayerNorm, sr_ratio=1):
|
| 283 |
+
super().__init__()
|
| 284 |
+
self.norm1 = norm_layer(dim)
|
| 285 |
+
self.attn = Attention(
|
| 286 |
+
dim,
|
| 287 |
+
num_heads=num_heads, qkv_bias=qkv_bias, qk_scale=qk_scale,
|
| 288 |
+
attn_drop=attn_drop, proj_drop=drop, sr_ratio=sr_ratio)
|
| 289 |
+
# NOTE: drop path for stochastic depth, we shall see if this is better than dropout here
|
| 290 |
+
self.drop_path = DropPath(drop_path) if drop_path > 0. else nn.Identity()
|
| 291 |
+
self.norm2 = norm_layer(dim)
|
| 292 |
+
mlp_hidden_dim = int(dim * mlp_ratio)
|
| 293 |
+
self.mlp = Mlp(in_features=dim, hidden_features=mlp_hidden_dim, act_layer=act_layer, drop=drop)
|
| 294 |
+
|
| 295 |
+
self.apply(self._init_weights)
|
| 296 |
+
|
| 297 |
+
def _init_weights(self, m):
|
| 298 |
+
if isinstance(m, nn.Linear):
|
| 299 |
+
trunc_normal_(m.weight, std=.02)
|
| 300 |
+
if isinstance(m, nn.Linear) and m.bias is not None:
|
| 301 |
+
nn.init.constant_(m.bias, 0)
|
| 302 |
+
elif isinstance(m, nn.LayerNorm):
|
| 303 |
+
nn.init.constant_(m.bias, 0)
|
| 304 |
+
nn.init.constant_(m.weight, 1.0)
|
| 305 |
+
elif isinstance(m, nn.Conv2d):
|
| 306 |
+
fan_out = m.kernel_size[0] * m.kernel_size[1] * m.out_channels
|
| 307 |
+
fan_out //= m.groups
|
| 308 |
+
m.weight.data.normal_(0, math.sqrt(2.0 / fan_out))
|
| 309 |
+
if m.bias is not None:
|
| 310 |
+
m.bias.data.zero_()
|
| 311 |
+
|
| 312 |
+
def forward(self, x, H, W):
|
| 313 |
+
x = x + self.drop_path(self.attn(self.norm1(x), H, W))
|
| 314 |
+
x = x + self.drop_path(self.mlp(self.norm2(x), H, W))
|
| 315 |
+
|
| 316 |
+
return x
|
| 317 |
+
|
| 318 |
+
|
| 319 |
+
class OverlapPatchEmbed(nn.Module):
|
| 320 |
+
""" Image to Patch Embedding
|
| 321 |
+
"""
|
| 322 |
+
|
| 323 |
+
def __init__(self, img_size=224, patch_size=7, stride=4, in_channels=3, embed_dim=768):
|
| 324 |
+
super().__init__()
|
| 325 |
+
img_size = to_2tuple(img_size)
|
| 326 |
+
patch_size = to_2tuple(patch_size)
|
| 327 |
+
|
| 328 |
+
self.img_size = img_size
|
| 329 |
+
self.patch_size = patch_size
|
| 330 |
+
self.H, self.W = img_size[0] // patch_size[0], img_size[1] // patch_size[1]
|
| 331 |
+
self.num_patches = self.H * self.W
|
| 332 |
+
self.proj = nn.Conv2d(in_channels, embed_dim, kernel_size=patch_size, stride=stride,
|
| 333 |
+
padding=(patch_size[0] // 2, patch_size[1] // 2))
|
| 334 |
+
self.norm = nn.LayerNorm(embed_dim)
|
| 335 |
+
|
| 336 |
+
self.apply(self._init_weights)
|
| 337 |
+
|
| 338 |
+
def _init_weights(self, m):
|
| 339 |
+
if isinstance(m, nn.Linear):
|
| 340 |
+
trunc_normal_(m.weight, std=.02)
|
| 341 |
+
if isinstance(m, nn.Linear) and m.bias is not None:
|
| 342 |
+
nn.init.constant_(m.bias, 0)
|
| 343 |
+
elif isinstance(m, nn.LayerNorm):
|
| 344 |
+
nn.init.constant_(m.bias, 0)
|
| 345 |
+
nn.init.constant_(m.weight, 1.0)
|
| 346 |
+
elif isinstance(m, nn.Conv2d):
|
| 347 |
+
fan_out = m.kernel_size[0] * m.kernel_size[1] * m.out_channels
|
| 348 |
+
fan_out //= m.groups
|
| 349 |
+
m.weight.data.normal_(0, math.sqrt(2.0 / fan_out))
|
| 350 |
+
if m.bias is not None:
|
| 351 |
+
m.bias.data.zero_()
|
| 352 |
+
|
| 353 |
+
def forward(self, x):
|
| 354 |
+
x = self.proj(x)
|
| 355 |
+
_, _, H, W = x.shape
|
| 356 |
+
x = x.flatten(2).transpose(1, 2)
|
| 357 |
+
x = self.norm(x)
|
| 358 |
+
|
| 359 |
+
return x, H, W
|
| 360 |
+
|
| 361 |
+
|
| 362 |
+
class PyramidVisionTransformerImpr(nn.Module):
|
| 363 |
+
def __init__(self, img_size=224, patch_size=16, in_channels=3, num_classes=1000, embed_dims=[64, 128, 256, 512],
|
| 364 |
+
num_heads=[1, 2, 4, 8], mlp_ratios=[4, 4, 4, 4], qkv_bias=False, qk_scale=None, drop_rate=0.,
|
| 365 |
+
attn_drop_rate=0., drop_path_rate=0., norm_layer=nn.LayerNorm,
|
| 366 |
+
depths=[3, 4, 6, 3], sr_ratios=[8, 4, 2, 1]):
|
| 367 |
+
super().__init__()
|
| 368 |
+
self.num_classes = num_classes
|
| 369 |
+
self.depths = depths
|
| 370 |
+
|
| 371 |
+
# patch_embed
|
| 372 |
+
self.patch_embed1 = OverlapPatchEmbed(img_size=img_size, patch_size=7, stride=4, in_channels=in_channels,
|
| 373 |
+
embed_dim=embed_dims[0])
|
| 374 |
+
self.patch_embed2 = OverlapPatchEmbed(img_size=img_size // 4, patch_size=3, stride=2, in_channels=embed_dims[0],
|
| 375 |
+
embed_dim=embed_dims[1])
|
| 376 |
+
self.patch_embed3 = OverlapPatchEmbed(img_size=img_size // 8, patch_size=3, stride=2, in_channels=embed_dims[1],
|
| 377 |
+
embed_dim=embed_dims[2])
|
| 378 |
+
self.patch_embed4 = OverlapPatchEmbed(img_size=img_size // 16, patch_size=3, stride=2, in_channels=embed_dims[2],
|
| 379 |
+
embed_dim=embed_dims[3])
|
| 380 |
+
|
| 381 |
+
# transformer encoder
|
| 382 |
+
dpr = [x.item() for x in torch.linspace(0, drop_path_rate, sum(depths))] # stochastic depth decay rule
|
| 383 |
+
cur = 0
|
| 384 |
+
self.block1 = nn.ModuleList([Block(
|
| 385 |
+
dim=embed_dims[0], num_heads=num_heads[0], mlp_ratio=mlp_ratios[0], qkv_bias=qkv_bias, qk_scale=qk_scale,
|
| 386 |
+
drop=drop_rate, attn_drop=attn_drop_rate, drop_path=dpr[cur + i], norm_layer=norm_layer,
|
| 387 |
+
sr_ratio=sr_ratios[0])
|
| 388 |
+
for i in range(depths[0])])
|
| 389 |
+
self.norm1 = norm_layer(embed_dims[0])
|
| 390 |
+
|
| 391 |
+
cur += depths[0]
|
| 392 |
+
self.block2 = nn.ModuleList([Block(
|
| 393 |
+
dim=embed_dims[1], num_heads=num_heads[1], mlp_ratio=mlp_ratios[1], qkv_bias=qkv_bias, qk_scale=qk_scale,
|
| 394 |
+
drop=drop_rate, attn_drop=attn_drop_rate, drop_path=dpr[cur + i], norm_layer=norm_layer,
|
| 395 |
+
sr_ratio=sr_ratios[1])
|
| 396 |
+
for i in range(depths[1])])
|
| 397 |
+
self.norm2 = norm_layer(embed_dims[1])
|
| 398 |
+
|
| 399 |
+
cur += depths[1]
|
| 400 |
+
self.block3 = nn.ModuleList([Block(
|
| 401 |
+
dim=embed_dims[2], num_heads=num_heads[2], mlp_ratio=mlp_ratios[2], qkv_bias=qkv_bias, qk_scale=qk_scale,
|
| 402 |
+
drop=drop_rate, attn_drop=attn_drop_rate, drop_path=dpr[cur + i], norm_layer=norm_layer,
|
| 403 |
+
sr_ratio=sr_ratios[2])
|
| 404 |
+
for i in range(depths[2])])
|
| 405 |
+
self.norm3 = norm_layer(embed_dims[2])
|
| 406 |
+
|
| 407 |
+
cur += depths[2]
|
| 408 |
+
self.block4 = nn.ModuleList([Block(
|
| 409 |
+
dim=embed_dims[3], num_heads=num_heads[3], mlp_ratio=mlp_ratios[3], qkv_bias=qkv_bias, qk_scale=qk_scale,
|
| 410 |
+
drop=drop_rate, attn_drop=attn_drop_rate, drop_path=dpr[cur + i], norm_layer=norm_layer,
|
| 411 |
+
sr_ratio=sr_ratios[3])
|
| 412 |
+
for i in range(depths[3])])
|
| 413 |
+
self.norm4 = norm_layer(embed_dims[3])
|
| 414 |
+
|
| 415 |
+
# classification head
|
| 416 |
+
# self.head = nn.Linear(embed_dims[3], num_classes) if num_classes > 0 else nn.Identity()
|
| 417 |
+
|
| 418 |
+
self.apply(self._init_weights)
|
| 419 |
+
|
| 420 |
+
def _init_weights(self, m):
|
| 421 |
+
if isinstance(m, nn.Linear):
|
| 422 |
+
trunc_normal_(m.weight, std=.02)
|
| 423 |
+
if isinstance(m, nn.Linear) and m.bias is not None:
|
| 424 |
+
nn.init.constant_(m.bias, 0)
|
| 425 |
+
elif isinstance(m, nn.LayerNorm):
|
| 426 |
+
nn.init.constant_(m.bias, 0)
|
| 427 |
+
nn.init.constant_(m.weight, 1.0)
|
| 428 |
+
elif isinstance(m, nn.Conv2d):
|
| 429 |
+
fan_out = m.kernel_size[0] * m.kernel_size[1] * m.out_channels
|
| 430 |
+
fan_out //= m.groups
|
| 431 |
+
m.weight.data.normal_(0, math.sqrt(2.0 / fan_out))
|
| 432 |
+
if m.bias is not None:
|
| 433 |
+
m.bias.data.zero_()
|
| 434 |
+
|
| 435 |
+
def init_weights(self, pretrained=None):
|
| 436 |
+
if isinstance(pretrained, str):
|
| 437 |
+
logger = 1
|
| 438 |
+
#load_checkpoint(self, pretrained, map_location='cpu', strict=False, logger=logger)
|
| 439 |
+
|
| 440 |
+
def reset_drop_path(self, drop_path_rate):
|
| 441 |
+
dpr = [x.item() for x in torch.linspace(0, drop_path_rate, sum(self.depths))]
|
| 442 |
+
cur = 0
|
| 443 |
+
for i in range(self.depths[0]):
|
| 444 |
+
self.block1[i].drop_path.drop_prob = dpr[cur + i]
|
| 445 |
+
|
| 446 |
+
cur += self.depths[0]
|
| 447 |
+
for i in range(self.depths[1]):
|
| 448 |
+
self.block2[i].drop_path.drop_prob = dpr[cur + i]
|
| 449 |
+
|
| 450 |
+
cur += self.depths[1]
|
| 451 |
+
for i in range(self.depths[2]):
|
| 452 |
+
self.block3[i].drop_path.drop_prob = dpr[cur + i]
|
| 453 |
+
|
| 454 |
+
cur += self.depths[2]
|
| 455 |
+
for i in range(self.depths[3]):
|
| 456 |
+
self.block4[i].drop_path.drop_prob = dpr[cur + i]
|
| 457 |
+
|
| 458 |
+
def freeze_patch_emb(self):
|
| 459 |
+
self.patch_embed1.requires_grad = False
|
| 460 |
+
|
| 461 |
+
@torch.jit.ignore
|
| 462 |
+
def no_weight_decay(self):
|
| 463 |
+
return {'pos_embed1', 'pos_embed2', 'pos_embed3', 'pos_embed4', 'cls_token'} # has pos_embed may be better
|
| 464 |
+
|
| 465 |
+
def get_classifier(self):
|
| 466 |
+
return self.head
|
| 467 |
+
|
| 468 |
+
def reset_classifier(self, num_classes, global_pool=''):
|
| 469 |
+
self.num_classes = num_classes
|
| 470 |
+
self.head = nn.Linear(self.embed_dim, num_classes) if num_classes > 0 else nn.Identity()
|
| 471 |
+
|
| 472 |
+
def forward_features(self, x):
|
| 473 |
+
B = x.shape[0]
|
| 474 |
+
outs = []
|
| 475 |
+
|
| 476 |
+
# stage 1
|
| 477 |
+
x, H, W = self.patch_embed1(x)
|
| 478 |
+
for i, blk in enumerate(self.block1):
|
| 479 |
+
x = blk(x, H, W)
|
| 480 |
+
x = self.norm1(x)
|
| 481 |
+
x = x.reshape(B, H, W, -1).permute(0, 3, 1, 2).contiguous()
|
| 482 |
+
outs.append(x)
|
| 483 |
+
|
| 484 |
+
# stage 2
|
| 485 |
+
x, H, W = self.patch_embed2(x)
|
| 486 |
+
for i, blk in enumerate(self.block2):
|
| 487 |
+
x = blk(x, H, W)
|
| 488 |
+
x = self.norm2(x)
|
| 489 |
+
x = x.reshape(B, H, W, -1).permute(0, 3, 1, 2).contiguous()
|
| 490 |
+
outs.append(x)
|
| 491 |
+
|
| 492 |
+
# stage 3
|
| 493 |
+
x, H, W = self.patch_embed3(x)
|
| 494 |
+
for i, blk in enumerate(self.block3):
|
| 495 |
+
x = blk(x, H, W)
|
| 496 |
+
x = self.norm3(x)
|
| 497 |
+
x = x.reshape(B, H, W, -1).permute(0, 3, 1, 2).contiguous()
|
| 498 |
+
outs.append(x)
|
| 499 |
+
|
| 500 |
+
# stage 4
|
| 501 |
+
x, H, W = self.patch_embed4(x)
|
| 502 |
+
for i, blk in enumerate(self.block4):
|
| 503 |
+
x = blk(x, H, W)
|
| 504 |
+
x = self.norm4(x)
|
| 505 |
+
x = x.reshape(B, H, W, -1).permute(0, 3, 1, 2).contiguous()
|
| 506 |
+
outs.append(x)
|
| 507 |
+
|
| 508 |
+
return outs
|
| 509 |
+
|
| 510 |
+
# return x.mean(dim=1)
|
| 511 |
+
|
| 512 |
+
def forward(self, x):
|
| 513 |
+
x = self.forward_features(x)
|
| 514 |
+
# x = self.head(x)
|
| 515 |
+
|
| 516 |
+
return x
|
| 517 |
+
|
| 518 |
+
|
| 519 |
+
class DWConv(nn.Module):
|
| 520 |
+
def __init__(self, dim=768):
|
| 521 |
+
super(DWConv, self).__init__()
|
| 522 |
+
self.dwconv = nn.Conv2d(dim, dim, 3, 1, 1, bias=True, groups=dim)
|
| 523 |
+
|
| 524 |
+
def forward(self, x, H, W):
|
| 525 |
+
B, N, C = x.shape
|
| 526 |
+
x = x.transpose(1, 2).view(B, C, H, W).contiguous()
|
| 527 |
+
x = self.dwconv(x)
|
| 528 |
+
x = x.flatten(2).transpose(1, 2)
|
| 529 |
+
|
| 530 |
+
return x
|
| 531 |
+
|
| 532 |
+
|
| 533 |
+
def _conv_filter(state_dict, patch_size=16):
|
| 534 |
+
""" convert patch embedding weight from manual patchify + linear proj to conv"""
|
| 535 |
+
out_dict = {}
|
| 536 |
+
for k, v in state_dict.items():
|
| 537 |
+
if 'patch_embed.proj.weight' in k:
|
| 538 |
+
v = v.reshape((v.shape[0], 3, patch_size, patch_size))
|
| 539 |
+
out_dict[k] = v
|
| 540 |
+
|
| 541 |
+
return out_dict
|
| 542 |
+
|
| 543 |
+
|
| 544 |
+
## @register_model
|
| 545 |
+
class pvt_v2_b0(PyramidVisionTransformerImpr):
|
| 546 |
+
def __init__(self, **kwargs):
|
| 547 |
+
super(pvt_v2_b0, self).__init__(
|
| 548 |
+
patch_size=4, embed_dims=[32, 64, 160, 256], num_heads=[1, 2, 5, 8], mlp_ratios=[8, 8, 4, 4],
|
| 549 |
+
qkv_bias=True, norm_layer=partial(nn.LayerNorm, eps=1e-6), depths=[2, 2, 2, 2], sr_ratios=[8, 4, 2, 1],
|
| 550 |
+
drop_rate=0.0, drop_path_rate=0.1)
|
| 551 |
+
|
| 552 |
+
|
| 553 |
+
|
| 554 |
+
## @register_model
|
| 555 |
+
class pvt_v2_b1(PyramidVisionTransformerImpr):
|
| 556 |
+
def __init__(self, **kwargs):
|
| 557 |
+
super(pvt_v2_b1, self).__init__(
|
| 558 |
+
patch_size=4, embed_dims=[64, 128, 320, 512], num_heads=[1, 2, 5, 8], mlp_ratios=[8, 8, 4, 4],
|
| 559 |
+
qkv_bias=True, norm_layer=partial(nn.LayerNorm, eps=1e-6), depths=[2, 2, 2, 2], sr_ratios=[8, 4, 2, 1],
|
| 560 |
+
drop_rate=0.0, drop_path_rate=0.1)
|
| 561 |
+
|
| 562 |
+
## @register_model
|
| 563 |
+
class pvt_v2_b2(PyramidVisionTransformerImpr):
|
| 564 |
+
def __init__(self, in_channels=3, **kwargs):
|
| 565 |
+
super(pvt_v2_b2, self).__init__(
|
| 566 |
+
patch_size=4, embed_dims=[64, 128, 320, 512], num_heads=[1, 2, 5, 8], mlp_ratios=[8, 8, 4, 4],
|
| 567 |
+
qkv_bias=True, norm_layer=partial(nn.LayerNorm, eps=1e-6), depths=[3, 4, 6, 3], sr_ratios=[8, 4, 2, 1],
|
| 568 |
+
drop_rate=0.0, drop_path_rate=0.1, in_channels=in_channels)
|
| 569 |
+
|
| 570 |
+
## @register_model
|
| 571 |
+
class pvt_v2_b3(PyramidVisionTransformerImpr):
|
| 572 |
+
def __init__(self, **kwargs):
|
| 573 |
+
super(pvt_v2_b3, self).__init__(
|
| 574 |
+
patch_size=4, embed_dims=[64, 128, 320, 512], num_heads=[1, 2, 5, 8], mlp_ratios=[8, 8, 4, 4],
|
| 575 |
+
qkv_bias=True, norm_layer=partial(nn.LayerNorm, eps=1e-6), depths=[3, 4, 18, 3], sr_ratios=[8, 4, 2, 1],
|
| 576 |
+
drop_rate=0.0, drop_path_rate=0.1)
|
| 577 |
+
|
| 578 |
+
## @register_model
|
| 579 |
+
class pvt_v2_b4(PyramidVisionTransformerImpr):
|
| 580 |
+
def __init__(self, **kwargs):
|
| 581 |
+
super(pvt_v2_b4, self).__init__(
|
| 582 |
+
patch_size=4, embed_dims=[64, 128, 320, 512], num_heads=[1, 2, 5, 8], mlp_ratios=[8, 8, 4, 4],
|
| 583 |
+
qkv_bias=True, norm_layer=partial(nn.LayerNorm, eps=1e-6), depths=[3, 8, 27, 3], sr_ratios=[8, 4, 2, 1],
|
| 584 |
+
drop_rate=0.0, drop_path_rate=0.1)
|
| 585 |
+
|
| 586 |
+
|
| 587 |
+
## @register_model
|
| 588 |
+
class pvt_v2_b5(PyramidVisionTransformerImpr):
|
| 589 |
+
def __init__(self, **kwargs):
|
| 590 |
+
super(pvt_v2_b5, self).__init__(
|
| 591 |
+
patch_size=4, embed_dims=[64, 128, 320, 512], num_heads=[1, 2, 5, 8], mlp_ratios=[4, 4, 4, 4],
|
| 592 |
+
qkv_bias=True, norm_layer=partial(nn.LayerNorm, eps=1e-6), depths=[3, 6, 40, 3], sr_ratios=[8, 4, 2, 1],
|
| 593 |
+
drop_rate=0.0, drop_path_rate=0.1)
|
| 594 |
+
|
| 595 |
+
|
| 596 |
+
|
| 597 |
+
### models/backbones/swin_v1.py
|
| 598 |
+
|
| 599 |
+
# --------------------------------------------------------
|
| 600 |
+
# Swin Transformer
|
| 601 |
+
# Copyright (c) 2021 Microsoft
|
| 602 |
+
# Licensed under The MIT License [see LICENSE for details]
|
| 603 |
+
# Written by Ze Liu, Yutong Lin, Yixuan Wei
|
| 604 |
+
# --------------------------------------------------------
|
| 605 |
+
|
| 606 |
+
import torch
|
| 607 |
+
import torch.nn as nn
|
| 608 |
+
import torch.nn.functional as F
|
| 609 |
+
import torch.utils.checkpoint as checkpoint
|
| 610 |
+
import numpy as np
|
| 611 |
+
from timm.models.layers import DropPath, to_2tuple, trunc_normal_
|
| 612 |
+
|
| 613 |
+
# from config import Config
|
| 614 |
+
|
| 615 |
+
|
| 616 |
+
# config = Config()
|
| 617 |
+
|
| 618 |
+
class Mlp(nn.Module):
|
| 619 |
+
""" Multilayer perceptron."""
|
| 620 |
+
|
| 621 |
+
def __init__(self, in_features, hidden_features=None, out_features=None, act_layer=nn.GELU, drop=0.):
|
| 622 |
+
super().__init__()
|
| 623 |
+
out_features = out_features or in_features
|
| 624 |
+
hidden_features = hidden_features or in_features
|
| 625 |
+
self.fc1 = nn.Linear(in_features, hidden_features)
|
| 626 |
+
self.act = act_layer()
|
| 627 |
+
self.fc2 = nn.Linear(hidden_features, out_features)
|
| 628 |
+
self.drop = nn.Dropout(drop)
|
| 629 |
+
|
| 630 |
+
def forward(self, x):
|
| 631 |
+
x = self.fc1(x)
|
| 632 |
+
x = self.act(x)
|
| 633 |
+
x = self.drop(x)
|
| 634 |
+
x = self.fc2(x)
|
| 635 |
+
x = self.drop(x)
|
| 636 |
+
return x
|
| 637 |
+
|
| 638 |
+
|
| 639 |
+
def window_partition(x, window_size):
|
| 640 |
+
"""
|
| 641 |
+
Args:
|
| 642 |
+
x: (B, H, W, C)
|
| 643 |
+
window_size (int): window size
|
| 644 |
+
|
| 645 |
+
Returns:
|
| 646 |
+
windows: (num_windows*B, window_size, window_size, C)
|
| 647 |
+
"""
|
| 648 |
+
B, H, W, C = x.shape
|
| 649 |
+
x = x.view(B, H // window_size, window_size, W // window_size, window_size, C)
|
| 650 |
+
windows = x.permute(0, 1, 3, 2, 4, 5).contiguous().view(-1, window_size, window_size, C)
|
| 651 |
+
return windows
|
| 652 |
+
|
| 653 |
+
|
| 654 |
+
def window_reverse(windows, window_size, H, W):
|
| 655 |
+
"""
|
| 656 |
+
Args:
|
| 657 |
+
windows: (num_windows*B, window_size, window_size, C)
|
| 658 |
+
window_size (int): Window size
|
| 659 |
+
H (int): Height of image
|
| 660 |
+
W (int): Width of image
|
| 661 |
+
|
| 662 |
+
Returns:
|
| 663 |
+
x: (B, H, W, C)
|
| 664 |
+
"""
|
| 665 |
+
B = int(windows.shape[0] / (H * W / window_size / window_size))
|
| 666 |
+
x = windows.view(B, H // window_size, W // window_size, window_size, window_size, -1)
|
| 667 |
+
x = x.permute(0, 1, 3, 2, 4, 5).contiguous().view(B, H, W, -1)
|
| 668 |
+
return x
|
| 669 |
+
|
| 670 |
+
|
| 671 |
+
class WindowAttention(nn.Module):
|
| 672 |
+
""" Window based multi-head self attention (W-MSA) module with relative position bias.
|
| 673 |
+
It supports both of shifted and non-shifted window.
|
| 674 |
+
|
| 675 |
+
Args:
|
| 676 |
+
dim (int): Number of input channels.
|
| 677 |
+
window_size (tuple[int]): The height and width of the window.
|
| 678 |
+
num_heads (int): Number of attention heads.
|
| 679 |
+
qkv_bias (bool, optional): If True, add a learnable bias to query, key, value. Default: True
|
| 680 |
+
qk_scale (float | None, optional): Override default qk scale of head_dim ** -0.5 if set
|
| 681 |
+
attn_drop (float, optional): Dropout ratio of attention weight. Default: 0.0
|
| 682 |
+
proj_drop (float, optional): Dropout ratio of output. Default: 0.0
|
| 683 |
+
"""
|
| 684 |
+
|
| 685 |
+
def __init__(self, dim, window_size, num_heads, qkv_bias=True, qk_scale=None, attn_drop=0., proj_drop=0.):
|
| 686 |
+
|
| 687 |
+
super().__init__()
|
| 688 |
+
self.dim = dim
|
| 689 |
+
self.window_size = window_size # Wh, Ww
|
| 690 |
+
self.num_heads = num_heads
|
| 691 |
+
head_dim = dim // num_heads
|
| 692 |
+
self.scale = qk_scale or head_dim ** -0.5
|
| 693 |
+
|
| 694 |
+
# define a parameter table of relative position bias
|
| 695 |
+
self.relative_position_bias_table = nn.Parameter(
|
| 696 |
+
torch.zeros((2 * window_size[0] - 1) * (2 * window_size[1] - 1), num_heads)) # 2*Wh-1 * 2*Ww-1, nH
|
| 697 |
+
|
| 698 |
+
# get pair-wise relative position index for each token inside the window
|
| 699 |
+
coords_h = torch.arange(self.window_size[0])
|
| 700 |
+
coords_w = torch.arange(self.window_size[1])
|
| 701 |
+
coords = torch.stack(torch.meshgrid([coords_h, coords_w], indexing='ij')) # 2, Wh, Ww
|
| 702 |
+
coords_flatten = torch.flatten(coords, 1) # 2, Wh*Ww
|
| 703 |
+
relative_coords = coords_flatten[:, :, None] - coords_flatten[:, None, :] # 2, Wh*Ww, Wh*Ww
|
| 704 |
+
relative_coords = relative_coords.permute(1, 2, 0).contiguous() # Wh*Ww, Wh*Ww, 2
|
| 705 |
+
relative_coords[:, :, 0] += self.window_size[0] - 1 # shift to start from 0
|
| 706 |
+
relative_coords[:, :, 1] += self.window_size[1] - 1
|
| 707 |
+
relative_coords[:, :, 0] *= 2 * self.window_size[1] - 1
|
| 708 |
+
relative_position_index = relative_coords.sum(-1) # Wh*Ww, Wh*Ww
|
| 709 |
+
self.register_buffer("relative_position_index", relative_position_index)
|
| 710 |
+
|
| 711 |
+
self.qkv = nn.Linear(dim, dim * 3, bias=qkv_bias)
|
| 712 |
+
self.attn_drop_prob = attn_drop
|
| 713 |
+
self.attn_drop = nn.Dropout(attn_drop)
|
| 714 |
+
self.proj = nn.Linear(dim, dim)
|
| 715 |
+
self.proj_drop = nn.Dropout(proj_drop)
|
| 716 |
+
|
| 717 |
+
trunc_normal_(self.relative_position_bias_table, std=.02)
|
| 718 |
+
self.softmax = nn.Softmax(dim=-1)
|
| 719 |
+
|
| 720 |
+
def forward(self, x, mask=None):
|
| 721 |
+
""" Forward function.
|
| 722 |
+
|
| 723 |
+
Args:
|
| 724 |
+
x: input features with shape of (num_windows*B, N, C)
|
| 725 |
+
mask: (0/-inf) mask with shape of (num_windows, Wh*Ww, Wh*Ww) or None
|
| 726 |
+
"""
|
| 727 |
+
B_, N, C = x.shape
|
| 728 |
+
qkv = self.qkv(x).reshape(B_, N, 3, self.num_heads, C // self.num_heads).permute(2, 0, 3, 1, 4)
|
| 729 |
+
q, k, v = qkv[0], qkv[1], qkv[2] # make torchscript happy (cannot use tensor as tuple)
|
| 730 |
+
|
| 731 |
+
q = q * self.scale
|
| 732 |
+
|
| 733 |
+
if config.SDPA_enabled:
|
| 734 |
+
x = torch.nn.functional.scaled_dot_product_attention(
|
| 735 |
+
q, k, v,
|
| 736 |
+
attn_mask=None, dropout_p=self.attn_drop_prob, is_causal=False
|
| 737 |
+
).transpose(1, 2).reshape(B_, N, C)
|
| 738 |
+
else:
|
| 739 |
+
attn = (q @ k.transpose(-2, -1))
|
| 740 |
+
|
| 741 |
+
relative_position_bias = self.relative_position_bias_table[self.relative_position_index.view(-1)].view(
|
| 742 |
+
self.window_size[0] * self.window_size[1], self.window_size[0] * self.window_size[1], -1) # Wh*Ww,Wh*Ww,nH
|
| 743 |
+
relative_position_bias = relative_position_bias.permute(2, 0, 1).contiguous() # nH, Wh*Ww, Wh*Ww
|
| 744 |
+
attn = attn + relative_position_bias.unsqueeze(0)
|
| 745 |
+
|
| 746 |
+
if mask is not None:
|
| 747 |
+
nW = mask.shape[0]
|
| 748 |
+
attn = attn.view(B_ // nW, nW, self.num_heads, N, N) + mask.unsqueeze(1).unsqueeze(0)
|
| 749 |
+
attn = attn.view(-1, self.num_heads, N, N)
|
| 750 |
+
attn = self.softmax(attn)
|
| 751 |
+
else:
|
| 752 |
+
attn = self.softmax(attn)
|
| 753 |
+
|
| 754 |
+
attn = self.attn_drop(attn)
|
| 755 |
+
|
| 756 |
+
x = (attn @ v).transpose(1, 2).reshape(B_, N, C)
|
| 757 |
+
x = self.proj(x)
|
| 758 |
+
x = self.proj_drop(x)
|
| 759 |
+
return x
|
| 760 |
+
|
| 761 |
+
|
| 762 |
+
class SwinTransformerBlock(nn.Module):
|
| 763 |
+
""" Swin Transformer Block.
|
| 764 |
+
|
| 765 |
+
Args:
|
| 766 |
+
dim (int): Number of input channels.
|
| 767 |
+
num_heads (int): Number of attention heads.
|
| 768 |
+
window_size (int): Window size.
|
| 769 |
+
shift_size (int): Shift size for SW-MSA.
|
| 770 |
+
mlp_ratio (float): Ratio of mlp hidden dim to embedding dim.
|
| 771 |
+
qkv_bias (bool, optional): If True, add a learnable bias to query, key, value. Default: True
|
| 772 |
+
qk_scale (float | None, optional): Override default qk scale of head_dim ** -0.5 if set.
|
| 773 |
+
drop (float, optional): Dropout rate. Default: 0.0
|
| 774 |
+
attn_drop (float, optional): Attention dropout rate. Default: 0.0
|
| 775 |
+
drop_path (float, optional): Stochastic depth rate. Default: 0.0
|
| 776 |
+
act_layer (nn.Module, optional): Activation layer. Default: nn.GELU
|
| 777 |
+
norm_layer (nn.Module, optional): Normalization layer. Default: nn.LayerNorm
|
| 778 |
+
"""
|
| 779 |
+
|
| 780 |
+
def __init__(self, dim, num_heads, window_size=7, shift_size=0,
|
| 781 |
+
mlp_ratio=4., qkv_bias=True, qk_scale=None, drop=0., attn_drop=0., drop_path=0.,
|
| 782 |
+
act_layer=nn.GELU, norm_layer=nn.LayerNorm):
|
| 783 |
+
super().__init__()
|
| 784 |
+
self.dim = dim
|
| 785 |
+
self.num_heads = num_heads
|
| 786 |
+
self.window_size = window_size
|
| 787 |
+
self.shift_size = shift_size
|
| 788 |
+
self.mlp_ratio = mlp_ratio
|
| 789 |
+
assert 0 <= self.shift_size < self.window_size, "shift_size must in 0-window_size"
|
| 790 |
+
|
| 791 |
+
self.norm1 = norm_layer(dim)
|
| 792 |
+
self.attn = WindowAttention(
|
| 793 |
+
dim, window_size=to_2tuple(self.window_size), num_heads=num_heads,
|
| 794 |
+
qkv_bias=qkv_bias, qk_scale=qk_scale, attn_drop=attn_drop, proj_drop=drop)
|
| 795 |
+
|
| 796 |
+
self.drop_path = DropPath(drop_path) if drop_path > 0. else nn.Identity()
|
| 797 |
+
self.norm2 = norm_layer(dim)
|
| 798 |
+
mlp_hidden_dim = int(dim * mlp_ratio)
|
| 799 |
+
self.mlp = Mlp(in_features=dim, hidden_features=mlp_hidden_dim, act_layer=act_layer, drop=drop)
|
| 800 |
+
|
| 801 |
+
self.H = None
|
| 802 |
+
self.W = None
|
| 803 |
+
|
| 804 |
+
def forward(self, x, mask_matrix):
|
| 805 |
+
""" Forward function.
|
| 806 |
+
|
| 807 |
+
Args:
|
| 808 |
+
x: Input feature, tensor size (B, H*W, C).
|
| 809 |
+
H, W: Spatial resolution of the input feature.
|
| 810 |
+
mask_matrix: Attention mask for cyclic shift.
|
| 811 |
+
"""
|
| 812 |
+
B, L, C = x.shape
|
| 813 |
+
H, W = self.H, self.W
|
| 814 |
+
assert L == H * W, "input feature has wrong size"
|
| 815 |
+
|
| 816 |
+
shortcut = x
|
| 817 |
+
x = self.norm1(x)
|
| 818 |
+
x = x.view(B, H, W, C)
|
| 819 |
+
|
| 820 |
+
# pad feature maps to multiples of window size
|
| 821 |
+
pad_l = pad_t = 0
|
| 822 |
+
pad_r = (self.window_size - W % self.window_size) % self.window_size
|
| 823 |
+
pad_b = (self.window_size - H % self.window_size) % self.window_size
|
| 824 |
+
x = F.pad(x, (0, 0, pad_l, pad_r, pad_t, pad_b))
|
| 825 |
+
_, Hp, Wp, _ = x.shape
|
| 826 |
+
|
| 827 |
+
# cyclic shift
|
| 828 |
+
if self.shift_size > 0:
|
| 829 |
+
shifted_x = torch.roll(x, shifts=(-self.shift_size, -self.shift_size), dims=(1, 2))
|
| 830 |
+
attn_mask = mask_matrix
|
| 831 |
+
else:
|
| 832 |
+
shifted_x = x
|
| 833 |
+
attn_mask = None
|
| 834 |
+
|
| 835 |
+
# partition windows
|
| 836 |
+
x_windows = window_partition(shifted_x, self.window_size) # nW*B, window_size, window_size, C
|
| 837 |
+
x_windows = x_windows.view(-1, self.window_size * self.window_size, C) # nW*B, window_size*window_size, C
|
| 838 |
+
|
| 839 |
+
# W-MSA/SW-MSA
|
| 840 |
+
attn_windows = self.attn(x_windows, mask=attn_mask) # nW*B, window_size*window_size, C
|
| 841 |
+
|
| 842 |
+
# merge windows
|
| 843 |
+
attn_windows = attn_windows.view(-1, self.window_size, self.window_size, C)
|
| 844 |
+
shifted_x = window_reverse(attn_windows, self.window_size, Hp, Wp) # B H' W' C
|
| 845 |
+
|
| 846 |
+
# reverse cyclic shift
|
| 847 |
+
if self.shift_size > 0:
|
| 848 |
+
x = torch.roll(shifted_x, shifts=(self.shift_size, self.shift_size), dims=(1, 2))
|
| 849 |
+
else:
|
| 850 |
+
x = shifted_x
|
| 851 |
+
|
| 852 |
+
if pad_r > 0 or pad_b > 0:
|
| 853 |
+
x = x[:, :H, :W, :].contiguous()
|
| 854 |
+
|
| 855 |
+
x = x.view(B, H * W, C)
|
| 856 |
+
|
| 857 |
+
# FFN
|
| 858 |
+
x = shortcut + self.drop_path(x)
|
| 859 |
+
x = x + self.drop_path(self.mlp(self.norm2(x)))
|
| 860 |
+
|
| 861 |
+
return x
|
| 862 |
+
|
| 863 |
+
|
| 864 |
+
class PatchMerging(nn.Module):
|
| 865 |
+
""" Patch Merging Layer
|
| 866 |
+
|
| 867 |
+
Args:
|
| 868 |
+
dim (int): Number of input channels.
|
| 869 |
+
norm_layer (nn.Module, optional): Normalization layer. Default: nn.LayerNorm
|
| 870 |
+
"""
|
| 871 |
+
def __init__(self, dim, norm_layer=nn.LayerNorm):
|
| 872 |
+
super().__init__()
|
| 873 |
+
self.dim = dim
|
| 874 |
+
self.reduction = nn.Linear(4 * dim, 2 * dim, bias=False)
|
| 875 |
+
self.norm = norm_layer(4 * dim)
|
| 876 |
+
|
| 877 |
+
def forward(self, x, H, W):
|
| 878 |
+
""" Forward function.
|
| 879 |
+
|
| 880 |
+
Args:
|
| 881 |
+
x: Input feature, tensor size (B, H*W, C).
|
| 882 |
+
H, W: Spatial resolution of the input feature.
|
| 883 |
+
"""
|
| 884 |
+
B, L, C = x.shape
|
| 885 |
+
assert L == H * W, "input feature has wrong size"
|
| 886 |
+
|
| 887 |
+
x = x.view(B, H, W, C)
|
| 888 |
+
|
| 889 |
+
# padding
|
| 890 |
+
pad_input = (H % 2 == 1) or (W % 2 == 1)
|
| 891 |
+
if pad_input:
|
| 892 |
+
x = F.pad(x, (0, 0, 0, W % 2, 0, H % 2))
|
| 893 |
+
|
| 894 |
+
x0 = x[:, 0::2, 0::2, :] # B H/2 W/2 C
|
| 895 |
+
x1 = x[:, 1::2, 0::2, :] # B H/2 W/2 C
|
| 896 |
+
x2 = x[:, 0::2, 1::2, :] # B H/2 W/2 C
|
| 897 |
+
x3 = x[:, 1::2, 1::2, :] # B H/2 W/2 C
|
| 898 |
+
x = torch.cat([x0, x1, x2, x3], -1) # B H/2 W/2 4*C
|
| 899 |
+
x = x.view(B, -1, 4 * C) # B H/2*W/2 4*C
|
| 900 |
+
|
| 901 |
+
x = self.norm(x)
|
| 902 |
+
x = self.reduction(x)
|
| 903 |
+
|
| 904 |
+
return x
|
| 905 |
+
|
| 906 |
+
|
| 907 |
+
class BasicLayer(nn.Module):
|
| 908 |
+
""" A basic Swin Transformer layer for one stage.
|
| 909 |
+
|
| 910 |
+
Args:
|
| 911 |
+
dim (int): Number of feature channels
|
| 912 |
+
depth (int): Depths of this stage.
|
| 913 |
+
num_heads (int): Number of attention head.
|
| 914 |
+
window_size (int): Local window size. Default: 7.
|
| 915 |
+
mlp_ratio (float): Ratio of mlp hidden dim to embedding dim. Default: 4.
|
| 916 |
+
qkv_bias (bool, optional): If True, add a learnable bias to query, key, value. Default: True
|
| 917 |
+
qk_scale (float | None, optional): Override default qk scale of head_dim ** -0.5 if set.
|
| 918 |
+
drop (float, optional): Dropout rate. Default: 0.0
|
| 919 |
+
attn_drop (float, optional): Attention dropout rate. Default: 0.0
|
| 920 |
+
drop_path (float | tuple[float], optional): Stochastic depth rate. Default: 0.0
|
| 921 |
+
norm_layer (nn.Module, optional): Normalization layer. Default: nn.LayerNorm
|
| 922 |
+
downsample (nn.Module | None, optional): Downsample layer at the end of the layer. Default: None
|
| 923 |
+
use_checkpoint (bool): Whether to use checkpointing to save memory. Default: False.
|
| 924 |
+
"""
|
| 925 |
+
|
| 926 |
+
def __init__(self,
|
| 927 |
+
dim,
|
| 928 |
+
depth,
|
| 929 |
+
num_heads,
|
| 930 |
+
window_size=7,
|
| 931 |
+
mlp_ratio=4.,
|
| 932 |
+
qkv_bias=True,
|
| 933 |
+
qk_scale=None,
|
| 934 |
+
drop=0.,
|
| 935 |
+
attn_drop=0.,
|
| 936 |
+
drop_path=0.,
|
| 937 |
+
norm_layer=nn.LayerNorm,
|
| 938 |
+
downsample=None,
|
| 939 |
+
use_checkpoint=False):
|
| 940 |
+
super().__init__()
|
| 941 |
+
self.window_size = window_size
|
| 942 |
+
self.shift_size = window_size // 2
|
| 943 |
+
self.depth = depth
|
| 944 |
+
self.use_checkpoint = use_checkpoint
|
| 945 |
+
|
| 946 |
+
# build blocks
|
| 947 |
+
self.blocks = nn.ModuleList([
|
| 948 |
+
SwinTransformerBlock(
|
| 949 |
+
dim=dim,
|
| 950 |
+
num_heads=num_heads,
|
| 951 |
+
window_size=window_size,
|
| 952 |
+
shift_size=0 if (i % 2 == 0) else window_size // 2,
|
| 953 |
+
mlp_ratio=mlp_ratio,
|
| 954 |
+
qkv_bias=qkv_bias,
|
| 955 |
+
qk_scale=qk_scale,
|
| 956 |
+
drop=drop,
|
| 957 |
+
attn_drop=attn_drop,
|
| 958 |
+
drop_path=drop_path[i] if isinstance(drop_path, list) else drop_path,
|
| 959 |
+
norm_layer=norm_layer)
|
| 960 |
+
for i in range(depth)])
|
| 961 |
+
|
| 962 |
+
# patch merging layer
|
| 963 |
+
if downsample is not None:
|
| 964 |
+
self.downsample = downsample(dim=dim, norm_layer=norm_layer)
|
| 965 |
+
else:
|
| 966 |
+
self.downsample = None
|
| 967 |
+
|
| 968 |
+
def forward(self, x, H, W):
|
| 969 |
+
""" Forward function.
|
| 970 |
+
|
| 971 |
+
Args:
|
| 972 |
+
x: Input feature, tensor size (B, H*W, C).
|
| 973 |
+
H, W: Spatial resolution of the input feature.
|
| 974 |
+
"""
|
| 975 |
+
|
| 976 |
+
# calculate attention mask for SW-MSA
|
| 977 |
+
Hp = int(np.ceil(H / self.window_size)) * self.window_size
|
| 978 |
+
Wp = int(np.ceil(W / self.window_size)) * self.window_size
|
| 979 |
+
img_mask = torch.zeros((1, Hp, Wp, 1), device=x.device) # 1 Hp Wp 1
|
| 980 |
+
h_slices = (slice(0, -self.window_size),
|
| 981 |
+
slice(-self.window_size, -self.shift_size),
|
| 982 |
+
slice(-self.shift_size, None))
|
| 983 |
+
w_slices = (slice(0, -self.window_size),
|
| 984 |
+
slice(-self.window_size, -self.shift_size),
|
| 985 |
+
slice(-self.shift_size, None))
|
| 986 |
+
cnt = 0
|
| 987 |
+
for h in h_slices:
|
| 988 |
+
for w in w_slices:
|
| 989 |
+
img_mask[:, h, w, :] = cnt
|
| 990 |
+
cnt += 1
|
| 991 |
+
|
| 992 |
+
mask_windows = window_partition(img_mask, self.window_size) # nW, window_size, window_size, 1
|
| 993 |
+
mask_windows = mask_windows.view(-1, self.window_size * self.window_size)
|
| 994 |
+
attn_mask = mask_windows.unsqueeze(1) - mask_windows.unsqueeze(2)
|
| 995 |
+
attn_mask = attn_mask.masked_fill(attn_mask != 0, float(-100.0)).masked_fill(attn_mask == 0, float(0.0))
|
| 996 |
+
|
| 997 |
+
for blk in self.blocks:
|
| 998 |
+
blk.H, blk.W = H, W
|
| 999 |
+
if self.use_checkpoint:
|
| 1000 |
+
x = checkpoint.checkpoint(blk, x, attn_mask)
|
| 1001 |
+
else:
|
| 1002 |
+
x = blk(x, attn_mask)
|
| 1003 |
+
if self.downsample is not None:
|
| 1004 |
+
x_down = self.downsample(x, H, W)
|
| 1005 |
+
Wh, Ww = (H + 1) // 2, (W + 1) // 2
|
| 1006 |
+
return x, H, W, x_down, Wh, Ww
|
| 1007 |
+
else:
|
| 1008 |
+
return x, H, W, x, H, W
|
| 1009 |
+
|
| 1010 |
+
|
| 1011 |
+
class PatchEmbed(nn.Module):
|
| 1012 |
+
""" Image to Patch Embedding
|
| 1013 |
+
|
| 1014 |
+
Args:
|
| 1015 |
+
patch_size (int): Patch token size. Default: 4.
|
| 1016 |
+
in_channels (int): Number of input image channels. Default: 3.
|
| 1017 |
+
embed_dim (int): Number of linear projection output channels. Default: 96.
|
| 1018 |
+
norm_layer (nn.Module, optional): Normalization layer. Default: None
|
| 1019 |
+
"""
|
| 1020 |
+
|
| 1021 |
+
def __init__(self, patch_size=4, in_channels=3, embed_dim=96, norm_layer=None):
|
| 1022 |
+
super().__init__()
|
| 1023 |
+
patch_size = to_2tuple(patch_size)
|
| 1024 |
+
self.patch_size = patch_size
|
| 1025 |
+
|
| 1026 |
+
self.in_channels = in_channels
|
| 1027 |
+
self.embed_dim = embed_dim
|
| 1028 |
+
|
| 1029 |
+
self.proj = nn.Conv2d(in_channels, embed_dim, kernel_size=patch_size, stride=patch_size)
|
| 1030 |
+
if norm_layer is not None:
|
| 1031 |
+
self.norm = norm_layer(embed_dim)
|
| 1032 |
+
else:
|
| 1033 |
+
self.norm = None
|
| 1034 |
+
|
| 1035 |
+
def forward(self, x):
|
| 1036 |
+
"""Forward function."""
|
| 1037 |
+
# padding
|
| 1038 |
+
_, _, H, W = x.size()
|
| 1039 |
+
if W % self.patch_size[1] != 0:
|
| 1040 |
+
x = F.pad(x, (0, self.patch_size[1] - W % self.patch_size[1]))
|
| 1041 |
+
if H % self.patch_size[0] != 0:
|
| 1042 |
+
x = F.pad(x, (0, 0, 0, self.patch_size[0] - H % self.patch_size[0]))
|
| 1043 |
+
|
| 1044 |
+
x = self.proj(x) # B C Wh Ww
|
| 1045 |
+
if self.norm is not None:
|
| 1046 |
+
Wh, Ww = x.size(2), x.size(3)
|
| 1047 |
+
x = x.flatten(2).transpose(1, 2)
|
| 1048 |
+
x = self.norm(x)
|
| 1049 |
+
x = x.transpose(1, 2).view(-1, self.embed_dim, Wh, Ww)
|
| 1050 |
+
|
| 1051 |
+
return x
|
| 1052 |
+
|
| 1053 |
+
|
| 1054 |
+
class SwinTransformer(nn.Module):
|
| 1055 |
+
""" Swin Transformer backbone.
|
| 1056 |
+
A PyTorch impl of : `Swin Transformer: Hierarchical Vision Transformer using Shifted Windows` -
|
| 1057 |
+
https://arxiv.org/pdf/2103.14030
|
| 1058 |
+
|
| 1059 |
+
Args:
|
| 1060 |
+
pretrain_img_size (int): Input image size for training the pretrained model,
|
| 1061 |
+
used in absolute postion embedding. Default 224.
|
| 1062 |
+
patch_size (int | tuple(int)): Patch size. Default: 4.
|
| 1063 |
+
in_channels (int): Number of input image channels. Default: 3.
|
| 1064 |
+
embed_dim (int): Number of linear projection output channels. Default: 96.
|
| 1065 |
+
depths (tuple[int]): Depths of each Swin Transformer stage.
|
| 1066 |
+
num_heads (tuple[int]): Number of attention head of each stage.
|
| 1067 |
+
window_size (int): Window size. Default: 7.
|
| 1068 |
+
mlp_ratio (float): Ratio of mlp hidden dim to embedding dim. Default: 4.
|
| 1069 |
+
qkv_bias (bool): If True, add a learnable bias to query, key, value. Default: True
|
| 1070 |
+
qk_scale (float): Override default qk scale of head_dim ** -0.5 if set.
|
| 1071 |
+
drop_rate (float): Dropout rate.
|
| 1072 |
+
attn_drop_rate (float): Attention dropout rate. Default: 0.
|
| 1073 |
+
drop_path_rate (float): Stochastic depth rate. Default: 0.2.
|
| 1074 |
+
norm_layer (nn.Module): Normalization layer. Default: nn.LayerNorm.
|
| 1075 |
+
ape (bool): If True, add absolute position embedding to the patch embedding. Default: False.
|
| 1076 |
+
patch_norm (bool): If True, add normalization after patch embedding. Default: True.
|
| 1077 |
+
out_indices (Sequence[int]): Output from which stages.
|
| 1078 |
+
frozen_stages (int): Stages to be frozen (stop grad and set eval mode).
|
| 1079 |
+
-1 means not freezing any parameters.
|
| 1080 |
+
use_checkpoint (bool): Whether to use checkpointing to save memory. Default: False.
|
| 1081 |
+
"""
|
| 1082 |
+
|
| 1083 |
+
def __init__(self,
|
| 1084 |
+
pretrain_img_size=224,
|
| 1085 |
+
patch_size=4,
|
| 1086 |
+
in_channels=3,
|
| 1087 |
+
embed_dim=96,
|
| 1088 |
+
depths=[2, 2, 6, 2],
|
| 1089 |
+
num_heads=[3, 6, 12, 24],
|
| 1090 |
+
window_size=7,
|
| 1091 |
+
mlp_ratio=4.,
|
| 1092 |
+
qkv_bias=True,
|
| 1093 |
+
qk_scale=None,
|
| 1094 |
+
drop_rate=0.,
|
| 1095 |
+
attn_drop_rate=0.,
|
| 1096 |
+
drop_path_rate=0.2,
|
| 1097 |
+
norm_layer=nn.LayerNorm,
|
| 1098 |
+
ape=False,
|
| 1099 |
+
patch_norm=True,
|
| 1100 |
+
out_indices=(0, 1, 2, 3),
|
| 1101 |
+
frozen_stages=-1,
|
| 1102 |
+
use_checkpoint=False):
|
| 1103 |
+
super().__init__()
|
| 1104 |
+
|
| 1105 |
+
self.pretrain_img_size = pretrain_img_size
|
| 1106 |
+
self.num_layers = len(depths)
|
| 1107 |
+
self.embed_dim = embed_dim
|
| 1108 |
+
self.ape = ape
|
| 1109 |
+
self.patch_norm = patch_norm
|
| 1110 |
+
self.out_indices = out_indices
|
| 1111 |
+
self.frozen_stages = frozen_stages
|
| 1112 |
+
|
| 1113 |
+
# split image into non-overlapping patches
|
| 1114 |
+
self.patch_embed = PatchEmbed(
|
| 1115 |
+
patch_size=patch_size, in_channels=in_channels, embed_dim=embed_dim,
|
| 1116 |
+
norm_layer=norm_layer if self.patch_norm else None)
|
| 1117 |
+
|
| 1118 |
+
# absolute position embedding
|
| 1119 |
+
if self.ape:
|
| 1120 |
+
pretrain_img_size = to_2tuple(pretrain_img_size)
|
| 1121 |
+
patch_size = to_2tuple(patch_size)
|
| 1122 |
+
patches_resolution = [pretrain_img_size[0] // patch_size[0], pretrain_img_size[1] // patch_size[1]]
|
| 1123 |
+
|
| 1124 |
+
self.absolute_pos_embed = nn.Parameter(torch.zeros(1, embed_dim, patches_resolution[0], patches_resolution[1]))
|
| 1125 |
+
trunc_normal_(self.absolute_pos_embed, std=.02)
|
| 1126 |
+
|
| 1127 |
+
self.pos_drop = nn.Dropout(p=drop_rate)
|
| 1128 |
+
|
| 1129 |
+
# stochastic depth
|
| 1130 |
+
dpr = [x.item() for x in torch.linspace(0, drop_path_rate, sum(depths))] # stochastic depth decay rule
|
| 1131 |
+
|
| 1132 |
+
# build layers
|
| 1133 |
+
self.layers = nn.ModuleList()
|
| 1134 |
+
for i_layer in range(self.num_layers):
|
| 1135 |
+
layer = BasicLayer(
|
| 1136 |
+
dim=int(embed_dim * 2 ** i_layer),
|
| 1137 |
+
depth=depths[i_layer],
|
| 1138 |
+
num_heads=num_heads[i_layer],
|
| 1139 |
+
window_size=window_size,
|
| 1140 |
+
mlp_ratio=mlp_ratio,
|
| 1141 |
+
qkv_bias=qkv_bias,
|
| 1142 |
+
qk_scale=qk_scale,
|
| 1143 |
+
drop=drop_rate,
|
| 1144 |
+
attn_drop=attn_drop_rate,
|
| 1145 |
+
drop_path=dpr[sum(depths[:i_layer]):sum(depths[:i_layer + 1])],
|
| 1146 |
+
norm_layer=norm_layer,
|
| 1147 |
+
downsample=PatchMerging if (i_layer < self.num_layers - 1) else None,
|
| 1148 |
+
use_checkpoint=use_checkpoint)
|
| 1149 |
+
self.layers.append(layer)
|
| 1150 |
+
|
| 1151 |
+
num_features = [int(embed_dim * 2 ** i) for i in range(self.num_layers)]
|
| 1152 |
+
self.num_features = num_features
|
| 1153 |
+
|
| 1154 |
+
# add a norm layer for each output
|
| 1155 |
+
for i_layer in out_indices:
|
| 1156 |
+
layer = norm_layer(num_features[i_layer])
|
| 1157 |
+
layer_name = f'norm{i_layer}'
|
| 1158 |
+
self.add_module(layer_name, layer)
|
| 1159 |
+
|
| 1160 |
+
self._freeze_stages()
|
| 1161 |
+
|
| 1162 |
+
def _freeze_stages(self):
|
| 1163 |
+
if self.frozen_stages >= 0:
|
| 1164 |
+
self.patch_embed.eval()
|
| 1165 |
+
for param in self.patch_embed.parameters():
|
| 1166 |
+
param.requires_grad = False
|
| 1167 |
+
|
| 1168 |
+
if self.frozen_stages >= 1 and self.ape:
|
| 1169 |
+
self.absolute_pos_embed.requires_grad = False
|
| 1170 |
+
|
| 1171 |
+
if self.frozen_stages >= 2:
|
| 1172 |
+
self.pos_drop.eval()
|
| 1173 |
+
for i in range(0, self.frozen_stages - 1):
|
| 1174 |
+
m = self.layers[i]
|
| 1175 |
+
m.eval()
|
| 1176 |
+
for param in m.parameters():
|
| 1177 |
+
param.requires_grad = False
|
| 1178 |
+
|
| 1179 |
+
|
| 1180 |
+
def forward(self, x):
|
| 1181 |
+
"""Forward function."""
|
| 1182 |
+
x = self.patch_embed(x)
|
| 1183 |
+
|
| 1184 |
+
Wh, Ww = x.size(2), x.size(3)
|
| 1185 |
+
if self.ape:
|
| 1186 |
+
# interpolate the position embedding to the corresponding size
|
| 1187 |
+
absolute_pos_embed = F.interpolate(self.absolute_pos_embed, size=(Wh, Ww), mode='bicubic')
|
| 1188 |
+
x = (x + absolute_pos_embed) # B Wh*Ww C
|
| 1189 |
+
|
| 1190 |
+
outs = []#x.contiguous()]
|
| 1191 |
+
x = x.flatten(2).transpose(1, 2)
|
| 1192 |
+
x = self.pos_drop(x)
|
| 1193 |
+
for i in range(self.num_layers):
|
| 1194 |
+
layer = self.layers[i]
|
| 1195 |
+
x_out, H, W, x, Wh, Ww = layer(x, Wh, Ww)
|
| 1196 |
+
|
| 1197 |
+
if i in self.out_indices:
|
| 1198 |
+
norm_layer = getattr(self, f'norm{i}')
|
| 1199 |
+
x_out = norm_layer(x_out)
|
| 1200 |
+
|
| 1201 |
+
out = x_out.view(-1, H, W, self.num_features[i]).permute(0, 3, 1, 2).contiguous()
|
| 1202 |
+
outs.append(out)
|
| 1203 |
+
|
| 1204 |
+
return tuple(outs)
|
| 1205 |
+
|
| 1206 |
+
def train(self, mode=True):
|
| 1207 |
+
"""Convert the model into training mode while keep layers freezed."""
|
| 1208 |
+
super(SwinTransformer, self).train(mode)
|
| 1209 |
+
self._freeze_stages()
|
| 1210 |
+
|
| 1211 |
+
def swin_v1_t():
|
| 1212 |
+
model = SwinTransformer(embed_dim=96, depths=[2, 2, 6, 2], num_heads=[3, 6, 12, 24], window_size=7)
|
| 1213 |
+
return model
|
| 1214 |
+
|
| 1215 |
+
def swin_v1_s():
|
| 1216 |
+
model = SwinTransformer(embed_dim=96, depths=[2, 2, 18, 2], num_heads=[3, 6, 12, 24], window_size=7)
|
| 1217 |
+
return model
|
| 1218 |
+
|
| 1219 |
+
def swin_v1_b():
|
| 1220 |
+
model = SwinTransformer(embed_dim=128, depths=[2, 2, 18, 2], num_heads=[4, 8, 16, 32], window_size=12)
|
| 1221 |
+
return model
|
| 1222 |
+
|
| 1223 |
+
def swin_v1_l():
|
| 1224 |
+
model = SwinTransformer(embed_dim=192, depths=[2, 2, 18, 2], num_heads=[6, 12, 24, 48], window_size=12)
|
| 1225 |
+
return model
|
| 1226 |
+
|
| 1227 |
+
|
| 1228 |
+
|
| 1229 |
+
### models/modules/deform_conv.py
|
| 1230 |
+
|
| 1231 |
+
import torch
|
| 1232 |
+
import torch.nn as nn
|
| 1233 |
+
from torchvision.ops import deform_conv2d
|
| 1234 |
+
|
| 1235 |
+
|
| 1236 |
+
class DeformableConv2d(nn.Module):
|
| 1237 |
+
def __init__(self,
|
| 1238 |
+
in_channels,
|
| 1239 |
+
out_channels,
|
| 1240 |
+
kernel_size=3,
|
| 1241 |
+
stride=1,
|
| 1242 |
+
padding=1,
|
| 1243 |
+
bias=False):
|
| 1244 |
+
|
| 1245 |
+
super(DeformableConv2d, self).__init__()
|
| 1246 |
+
|
| 1247 |
+
assert type(kernel_size) == tuple or type(kernel_size) == int
|
| 1248 |
+
|
| 1249 |
+
kernel_size = kernel_size if type(kernel_size) == tuple else (kernel_size, kernel_size)
|
| 1250 |
+
self.stride = stride if type(stride) == tuple else (stride, stride)
|
| 1251 |
+
self.padding = padding
|
| 1252 |
+
|
| 1253 |
+
self.offset_conv = nn.Conv2d(in_channels,
|
| 1254 |
+
2 * kernel_size[0] * kernel_size[1],
|
| 1255 |
+
kernel_size=kernel_size,
|
| 1256 |
+
stride=stride,
|
| 1257 |
+
padding=self.padding,
|
| 1258 |
+
bias=True)
|
| 1259 |
+
|
| 1260 |
+
nn.init.constant_(self.offset_conv.weight, 0.)
|
| 1261 |
+
nn.init.constant_(self.offset_conv.bias, 0.)
|
| 1262 |
+
|
| 1263 |
+
self.modulator_conv = nn.Conv2d(in_channels,
|
| 1264 |
+
1 * kernel_size[0] * kernel_size[1],
|
| 1265 |
+
kernel_size=kernel_size,
|
| 1266 |
+
stride=stride,
|
| 1267 |
+
padding=self.padding,
|
| 1268 |
+
bias=True)
|
| 1269 |
+
|
| 1270 |
+
nn.init.constant_(self.modulator_conv.weight, 0.)
|
| 1271 |
+
nn.init.constant_(self.modulator_conv.bias, 0.)
|
| 1272 |
+
|
| 1273 |
+
self.regular_conv = nn.Conv2d(in_channels,
|
| 1274 |
+
out_channels=out_channels,
|
| 1275 |
+
kernel_size=kernel_size,
|
| 1276 |
+
stride=stride,
|
| 1277 |
+
padding=self.padding,
|
| 1278 |
+
bias=bias)
|
| 1279 |
+
|
| 1280 |
+
def forward(self, x):
|
| 1281 |
+
#h, w = x.shape[2:]
|
| 1282 |
+
#max_offset = max(h, w)/4.
|
| 1283 |
+
|
| 1284 |
+
offset = self.offset_conv(x)#.clamp(-max_offset, max_offset)
|
| 1285 |
+
modulator = 2. * torch.sigmoid(self.modulator_conv(x))
|
| 1286 |
+
|
| 1287 |
+
x = deform_conv2d(
|
| 1288 |
+
input=x,
|
| 1289 |
+
offset=offset,
|
| 1290 |
+
weight=self.regular_conv.weight,
|
| 1291 |
+
bias=self.regular_conv.bias,
|
| 1292 |
+
padding=self.padding,
|
| 1293 |
+
mask=modulator,
|
| 1294 |
+
stride=self.stride,
|
| 1295 |
+
)
|
| 1296 |
+
return x
|
| 1297 |
+
|
| 1298 |
+
|
| 1299 |
+
|
| 1300 |
+
|
| 1301 |
+
### utils.py
|
| 1302 |
+
|
| 1303 |
+
import torch.nn as nn
|
| 1304 |
+
|
| 1305 |
+
|
| 1306 |
+
def build_act_layer(act_layer):
|
| 1307 |
+
if act_layer == 'ReLU':
|
| 1308 |
+
return nn.ReLU(inplace=True)
|
| 1309 |
+
elif act_layer == 'SiLU':
|
| 1310 |
+
return nn.SiLU(inplace=True)
|
| 1311 |
+
elif act_layer == 'GELU':
|
| 1312 |
+
return nn.GELU()
|
| 1313 |
+
|
| 1314 |
+
raise NotImplementedError(f'build_act_layer does not support {act_layer}')
|
| 1315 |
+
|
| 1316 |
+
|
| 1317 |
+
def build_norm_layer(dim,
|
| 1318 |
+
norm_layer,
|
| 1319 |
+
in_format='channels_last',
|
| 1320 |
+
out_format='channels_last',
|
| 1321 |
+
eps=1e-6):
|
| 1322 |
+
layers = []
|
| 1323 |
+
if norm_layer == 'BN':
|
| 1324 |
+
if in_format == 'channels_last':
|
| 1325 |
+
layers.append(to_channels_first())
|
| 1326 |
+
layers.append(nn.BatchNorm2d(dim))
|
| 1327 |
+
if out_format == 'channels_last':
|
| 1328 |
+
layers.append(to_channels_last())
|
| 1329 |
+
elif norm_layer == 'LN':
|
| 1330 |
+
if in_format == 'channels_first':
|
| 1331 |
+
layers.append(to_channels_last())
|
| 1332 |
+
layers.append(nn.LayerNorm(dim, eps=eps))
|
| 1333 |
+
if out_format == 'channels_first':
|
| 1334 |
+
layers.append(to_channels_first())
|
| 1335 |
+
else:
|
| 1336 |
+
raise NotImplementedError(
|
| 1337 |
+
f'build_norm_layer does not support {norm_layer}')
|
| 1338 |
+
return nn.Sequential(*layers)
|
| 1339 |
+
|
| 1340 |
+
|
| 1341 |
+
class to_channels_first(nn.Module):
|
| 1342 |
+
|
| 1343 |
+
def __init__(self):
|
| 1344 |
+
super().__init__()
|
| 1345 |
+
|
| 1346 |
+
def forward(self, x):
|
| 1347 |
+
return x.permute(0, 3, 1, 2)
|
| 1348 |
+
|
| 1349 |
+
|
| 1350 |
+
class to_channels_last(nn.Module):
|
| 1351 |
+
|
| 1352 |
+
def __init__(self):
|
| 1353 |
+
super().__init__()
|
| 1354 |
+
|
| 1355 |
+
def forward(self, x):
|
| 1356 |
+
return x.permute(0, 2, 3, 1)
|
| 1357 |
+
|
| 1358 |
+
|
| 1359 |
+
|
| 1360 |
+
### dataset.py
|
| 1361 |
+
|
| 1362 |
+
_class_labels_TR_sorted = (
|
| 1363 |
+
'Airplane, Ant, Antenna, Archery, Axe, BabyCarriage, Bag, BalanceBeam, Balcony, Balloon, Basket, BasketballHoop, Beatle, Bed, Bee, Bench, Bicycle, '
|
| 1364 |
+
'BicycleFrame, BicycleStand, Boat, Bonsai, BoomLift, Bridge, BunkBed, Butterfly, Button, Cable, CableLift, Cage, Camcorder, Cannon, Canoe, Car, '
|
| 1365 |
+
'CarParkDropArm, Carriage, Cart, Caterpillar, CeilingLamp, Centipede, Chair, Clip, Clock, Clothes, CoatHanger, Comb, ConcretePumpTruck, Crack, Crane, '
|
| 1366 |
+
'Cup, DentalChair, Desk, DeskChair, Diagram, DishRack, DoorHandle, Dragonfish, Dragonfly, Drum, Earphone, Easel, ElectricIron, Excavator, Eyeglasses, '
|
| 1367 |
+
'Fan, Fence, Fencing, FerrisWheel, FireExtinguisher, Fishing, Flag, FloorLamp, Forklift, GasStation, Gate, Gear, Goal, Golf, GymEquipment, Hammock, '
|
| 1368 |
+
'Handcart, Handcraft, Handrail, HangGlider, Harp, Harvester, Headset, Helicopter, Helmet, Hook, HorizontalBar, Hydrovalve, IroningTable, Jewelry, Key, '
|
| 1369 |
+
'KidsPlayground, Kitchenware, Kite, Knife, Ladder, LaundryRack, Lightning, Lobster, Locust, Machine, MachineGun, MagazineRack, Mantis, Medal, MemorialArchway, '
|
| 1370 |
+
'Microphone, Missile, MobileHolder, Monitor, Mosquito, Motorcycle, MovingTrolley, Mower, MusicPlayer, MusicStand, ObservationTower, Octopus, OilWell, '
|
| 1371 |
+
'OlympicLogo, OperatingTable, OutdoorFitnessEquipment, Parachute, Pavilion, Piano, Pipe, PlowHarrow, PoleVault, Punchbag, Rack, Racket, Rifle, Ring, Robot, '
|
| 1372 |
+
'RockClimbing, Rope, Sailboat, Satellite, Scaffold, Scale, Scissor, Scooter, Sculpture, Seadragon, Seahorse, Seal, SewingMachine, Ship, Shoe, ShoppingCart, '
|
| 1373 |
+
'ShoppingTrolley, Shower, Shrimp, Signboard, Skateboarding, Skeleton, Skiing, Spade, SpeedBoat, Spider, Spoon, Stair, Stand, Stationary, SteeringWheel, '
|
| 1374 |
+
'Stethoscope, Stool, Stove, StreetLamp, SweetStand, Swing, Sword, TV, Table, TableChair, TableLamp, TableTennis, Tank, Tapeline, Teapot, Telescope, Tent, '
|
| 1375 |
+
'TobaccoPipe, Toy, Tractor, TrafficLight, TrafficSign, Trampoline, TransmissionTower, Tree, Tricycle, TrimmerCover, Tripod, Trombone, Truck, Trumpet, Tuba, '
|
| 1376 |
+
'UAV, Umbrella, UnevenBars, UtilityPole, VacuumCleaner, Violin, Wakesurfing, Watch, WaterTower, WateringPot, Well, WellLid, Wheel, Wheelchair, WindTurbine, Windmill, WineGlass, WireWhisk, Yacht'
|
| 1377 |
+
)
|
| 1378 |
+
class_labels_TR_sorted = _class_labels_TR_sorted.split(', ')
|
| 1379 |
+
|
| 1380 |
+
|
| 1381 |
+
### models/backbones/build_backbones.py
|
| 1382 |
+
|
| 1383 |
+
import torch
|
| 1384 |
+
import torch.nn as nn
|
| 1385 |
+
from collections import OrderedDict
|
| 1386 |
+
from torchvision.models import vgg16, vgg16_bn, VGG16_Weights, VGG16_BN_Weights, resnet50, ResNet50_Weights
|
| 1387 |
+
# from models.pvt_v2 import pvt_v2_b0, pvt_v2_b1, pvt_v2_b2, pvt_v2_b5
|
| 1388 |
+
# from models.swin_v1 import swin_v1_t, swin_v1_s, swin_v1_b, swin_v1_l
|
| 1389 |
+
# from config import Config
|
| 1390 |
+
|
| 1391 |
+
|
| 1392 |
+
config = Config()
|
| 1393 |
+
|
| 1394 |
+
def build_backbone(bb_name, pretrained=True, params_settings=''):
|
| 1395 |
+
if bb_name == 'vgg16':
|
| 1396 |
+
bb_net = list(vgg16(pretrained=VGG16_Weights.DEFAULT if pretrained else None).children())[0]
|
| 1397 |
+
bb = nn.Sequential(OrderedDict({'conv1': bb_net[:4], 'conv2': bb_net[4:9], 'conv3': bb_net[9:16], 'conv4': bb_net[16:23]}))
|
| 1398 |
+
elif bb_name == 'vgg16bn':
|
| 1399 |
+
bb_net = list(vgg16_bn(pretrained=VGG16_BN_Weights.DEFAULT if pretrained else None).children())[0]
|
| 1400 |
+
bb = nn.Sequential(OrderedDict({'conv1': bb_net[:6], 'conv2': bb_net[6:13], 'conv3': bb_net[13:23], 'conv4': bb_net[23:33]}))
|
| 1401 |
+
elif bb_name == 'resnet50':
|
| 1402 |
+
bb_net = list(resnet50(pretrained=ResNet50_Weights.DEFAULT if pretrained else None).children())
|
| 1403 |
+
bb = nn.Sequential(OrderedDict({'conv1': nn.Sequential(*bb_net[0:3]), 'conv2': bb_net[4], 'conv3': bb_net[5], 'conv4': bb_net[6]}))
|
| 1404 |
+
else:
|
| 1405 |
+
bb = eval('{}({})'.format(bb_name, params_settings))
|
| 1406 |
+
if pretrained:
|
| 1407 |
+
bb = load_weights(bb, bb_name)
|
| 1408 |
+
return bb
|
| 1409 |
+
|
| 1410 |
+
def load_weights(model, model_name):
|
| 1411 |
+
save_model = torch.load(config.weights[model_name], map_location='cpu')
|
| 1412 |
+
model_dict = model.state_dict()
|
| 1413 |
+
state_dict = {k: v if v.size() == model_dict[k].size() else model_dict[k] for k, v in save_model.items() if k in model_dict.keys()}
|
| 1414 |
+
# to ignore the weights with mismatched size when I modify the backbone itself.
|
| 1415 |
+
if not state_dict:
|
| 1416 |
+
save_model_keys = list(save_model.keys())
|
| 1417 |
+
sub_item = save_model_keys[0] if len(save_model_keys) == 1 else None
|
| 1418 |
+
state_dict = {k: v if v.size() == model_dict[k].size() else model_dict[k] for k, v in save_model[sub_item].items() if k in model_dict.keys()}
|
| 1419 |
+
if not state_dict or not sub_item:
|
| 1420 |
+
print('Weights are not successully loaded. Check the state dict of weights file.')
|
| 1421 |
+
return None
|
| 1422 |
+
else:
|
| 1423 |
+
print('Found correct weights in the "{}" item of loaded state_dict.'.format(sub_item))
|
| 1424 |
+
model_dict.update(state_dict)
|
| 1425 |
+
model.load_state_dict(model_dict)
|
| 1426 |
+
return model
|
| 1427 |
+
|
| 1428 |
+
|
| 1429 |
+
|
| 1430 |
+
### models/modules/decoder_blocks.py
|
| 1431 |
+
|
| 1432 |
+
import torch
|
| 1433 |
+
import torch.nn as nn
|
| 1434 |
+
# from models.aspp import ASPP, ASPPDeformable
|
| 1435 |
+
# from config import Config
|
| 1436 |
+
|
| 1437 |
+
|
| 1438 |
+
# config = Config()
|
| 1439 |
+
|
| 1440 |
+
|
| 1441 |
+
class BasicDecBlk(nn.Module):
|
| 1442 |
+
def __init__(self, in_channels=64, out_channels=64, inter_channels=64):
|
| 1443 |
+
super(BasicDecBlk, self).__init__()
|
| 1444 |
+
inter_channels = in_channels // 4 if config.dec_channels_inter == 'adap' else 64
|
| 1445 |
+
self.conv_in = nn.Conv2d(in_channels, inter_channels, 3, 1, padding=1)
|
| 1446 |
+
self.relu_in = nn.ReLU(inplace=True)
|
| 1447 |
+
if config.dec_att == 'ASPP':
|
| 1448 |
+
self.dec_att = ASPP(in_channels=inter_channels)
|
| 1449 |
+
elif config.dec_att == 'ASPPDeformable':
|
| 1450 |
+
self.dec_att = ASPPDeformable(in_channels=inter_channels)
|
| 1451 |
+
self.conv_out = nn.Conv2d(inter_channels, out_channels, 3, 1, padding=1)
|
| 1452 |
+
self.bn_in = nn.BatchNorm2d(inter_channels) if config.batch_size > 1 else nn.Identity()
|
| 1453 |
+
self.bn_out = nn.BatchNorm2d(out_channels) if config.batch_size > 1 else nn.Identity()
|
| 1454 |
+
|
| 1455 |
+
def forward(self, x):
|
| 1456 |
+
x = self.conv_in(x)
|
| 1457 |
+
x = self.bn_in(x)
|
| 1458 |
+
x = self.relu_in(x)
|
| 1459 |
+
if hasattr(self, 'dec_att'):
|
| 1460 |
+
x = self.dec_att(x)
|
| 1461 |
+
x = self.conv_out(x)
|
| 1462 |
+
x = self.bn_out(x)
|
| 1463 |
+
return x
|
| 1464 |
+
|
| 1465 |
+
|
| 1466 |
+
class ResBlk(nn.Module):
|
| 1467 |
+
def __init__(self, in_channels=64, out_channels=None, inter_channels=64):
|
| 1468 |
+
super(ResBlk, self).__init__()
|
| 1469 |
+
if out_channels is None:
|
| 1470 |
+
out_channels = in_channels
|
| 1471 |
+
inter_channels = in_channels // 4 if config.dec_channels_inter == 'adap' else 64
|
| 1472 |
+
|
| 1473 |
+
self.conv_in = nn.Conv2d(in_channels, inter_channels, 3, 1, padding=1)
|
| 1474 |
+
self.bn_in = nn.BatchNorm2d(inter_channels) if config.batch_size > 1 else nn.Identity()
|
| 1475 |
+
self.relu_in = nn.ReLU(inplace=True)
|
| 1476 |
+
|
| 1477 |
+
if config.dec_att == 'ASPP':
|
| 1478 |
+
self.dec_att = ASPP(in_channels=inter_channels)
|
| 1479 |
+
elif config.dec_att == 'ASPPDeformable':
|
| 1480 |
+
self.dec_att = ASPPDeformable(in_channels=inter_channels)
|
| 1481 |
+
|
| 1482 |
+
self.conv_out = nn.Conv2d(inter_channels, out_channels, 3, 1, padding=1)
|
| 1483 |
+
self.bn_out = nn.BatchNorm2d(out_channels) if config.batch_size > 1 else nn.Identity()
|
| 1484 |
+
|
| 1485 |
+
self.conv_resi = nn.Conv2d(in_channels, out_channels, 1, 1, 0)
|
| 1486 |
+
|
| 1487 |
+
def forward(self, x):
|
| 1488 |
+
_x = self.conv_resi(x)
|
| 1489 |
+
x = self.conv_in(x)
|
| 1490 |
+
x = self.bn_in(x)
|
| 1491 |
+
x = self.relu_in(x)
|
| 1492 |
+
if hasattr(self, 'dec_att'):
|
| 1493 |
+
x = self.dec_att(x)
|
| 1494 |
+
x = self.conv_out(x)
|
| 1495 |
+
x = self.bn_out(x)
|
| 1496 |
+
return x + _x
|
| 1497 |
+
|
| 1498 |
+
|
| 1499 |
+
|
| 1500 |
+
### models/modules/lateral_blocks.py
|
| 1501 |
+
|
| 1502 |
+
import numpy as np
|
| 1503 |
+
import torch
|
| 1504 |
+
import torch.nn as nn
|
| 1505 |
+
import torch.nn.functional as F
|
| 1506 |
+
from functools import partial
|
| 1507 |
+
|
| 1508 |
+
# from config import Config
|
| 1509 |
+
|
| 1510 |
+
|
| 1511 |
+
# config = Config()
|
| 1512 |
+
|
| 1513 |
+
|
| 1514 |
+
class BasicLatBlk(nn.Module):
|
| 1515 |
+
def __init__(self, in_channels=64, out_channels=64, inter_channels=64):
|
| 1516 |
+
super(BasicLatBlk, self).__init__()
|
| 1517 |
+
inter_channels = in_channels // 4 if config.dec_channels_inter == 'adap' else 64
|
| 1518 |
+
self.conv = nn.Conv2d(in_channels, out_channels, 1, 1, 0)
|
| 1519 |
+
|
| 1520 |
+
def forward(self, x):
|
| 1521 |
+
x = self.conv(x)
|
| 1522 |
+
return x
|
| 1523 |
+
|
| 1524 |
+
|
| 1525 |
+
|
| 1526 |
+
### models/modules/aspp.py
|
| 1527 |
+
|
| 1528 |
+
import torch
|
| 1529 |
+
import torch.nn as nn
|
| 1530 |
+
import torch.nn.functional as F
|
| 1531 |
+
# from models.deform_conv import DeformableConv2d
|
| 1532 |
+
# from config import Config
|
| 1533 |
+
|
| 1534 |
+
|
| 1535 |
+
# config = Config()
|
| 1536 |
+
|
| 1537 |
+
|
| 1538 |
+
class _ASPPModule(nn.Module):
|
| 1539 |
+
def __init__(self, in_channels, planes, kernel_size, padding, dilation):
|
| 1540 |
+
super(_ASPPModule, self).__init__()
|
| 1541 |
+
self.atrous_conv = nn.Conv2d(in_channels, planes, kernel_size=kernel_size,
|
| 1542 |
+
stride=1, padding=padding, dilation=dilation, bias=False)
|
| 1543 |
+
self.bn = nn.BatchNorm2d(planes) if config.batch_size > 1 else nn.Identity()
|
| 1544 |
+
self.relu = nn.ReLU(inplace=True)
|
| 1545 |
+
|
| 1546 |
+
def forward(self, x):
|
| 1547 |
+
x = self.atrous_conv(x)
|
| 1548 |
+
x = self.bn(x)
|
| 1549 |
+
|
| 1550 |
+
return self.relu(x)
|
| 1551 |
+
|
| 1552 |
+
|
| 1553 |
+
class ASPP(nn.Module):
|
| 1554 |
+
def __init__(self, in_channels=64, out_channels=None, output_stride=16):
|
| 1555 |
+
super(ASPP, self).__init__()
|
| 1556 |
+
self.down_scale = 1
|
| 1557 |
+
if out_channels is None:
|
| 1558 |
+
out_channels = in_channels
|
| 1559 |
+
self.in_channelster = 256 // self.down_scale
|
| 1560 |
+
if output_stride == 16:
|
| 1561 |
+
dilations = [1, 6, 12, 18]
|
| 1562 |
+
elif output_stride == 8:
|
| 1563 |
+
dilations = [1, 12, 24, 36]
|
| 1564 |
+
else:
|
| 1565 |
+
raise NotImplementedError
|
| 1566 |
+
|
| 1567 |
+
self.aspp1 = _ASPPModule(in_channels, self.in_channelster, 1, padding=0, dilation=dilations[0])
|
| 1568 |
+
self.aspp2 = _ASPPModule(in_channels, self.in_channelster, 3, padding=dilations[1], dilation=dilations[1])
|
| 1569 |
+
self.aspp3 = _ASPPModule(in_channels, self.in_channelster, 3, padding=dilations[2], dilation=dilations[2])
|
| 1570 |
+
self.aspp4 = _ASPPModule(in_channels, self.in_channelster, 3, padding=dilations[3], dilation=dilations[3])
|
| 1571 |
+
|
| 1572 |
+
self.global_avg_pool = nn.Sequential(nn.AdaptiveAvgPool2d((1, 1)),
|
| 1573 |
+
nn.Conv2d(in_channels, self.in_channelster, 1, stride=1, bias=False),
|
| 1574 |
+
nn.BatchNorm2d(self.in_channelster) if config.batch_size > 1 else nn.Identity(),
|
| 1575 |
+
nn.ReLU(inplace=True))
|
| 1576 |
+
self.conv1 = nn.Conv2d(self.in_channelster * 5, out_channels, 1, bias=False)
|
| 1577 |
+
self.bn1 = nn.BatchNorm2d(out_channels) if config.batch_size > 1 else nn.Identity()
|
| 1578 |
+
self.relu = nn.ReLU(inplace=True)
|
| 1579 |
+
self.dropout = nn.Dropout(0.5)
|
| 1580 |
+
|
| 1581 |
+
def forward(self, x):
|
| 1582 |
+
x1 = self.aspp1(x)
|
| 1583 |
+
x2 = self.aspp2(x)
|
| 1584 |
+
x3 = self.aspp3(x)
|
| 1585 |
+
x4 = self.aspp4(x)
|
| 1586 |
+
x5 = self.global_avg_pool(x)
|
| 1587 |
+
x5 = F.interpolate(x5, size=x1.size()[2:], mode='bilinear', align_corners=True)
|
| 1588 |
+
x = torch.cat((x1, x2, x3, x4, x5), dim=1)
|
| 1589 |
+
|
| 1590 |
+
x = self.conv1(x)
|
| 1591 |
+
x = self.bn1(x)
|
| 1592 |
+
x = self.relu(x)
|
| 1593 |
+
|
| 1594 |
+
return self.dropout(x)
|
| 1595 |
+
|
| 1596 |
+
|
| 1597 |
+
##################### Deformable
|
| 1598 |
+
class _ASPPModuleDeformable(nn.Module):
|
| 1599 |
+
def __init__(self, in_channels, planes, kernel_size, padding):
|
| 1600 |
+
super(_ASPPModuleDeformable, self).__init__()
|
| 1601 |
+
self.atrous_conv = DeformableConv2d(in_channels, planes, kernel_size=kernel_size,
|
| 1602 |
+
stride=1, padding=padding, bias=False)
|
| 1603 |
+
self.bn = nn.BatchNorm2d(planes) if config.batch_size > 1 else nn.Identity()
|
| 1604 |
+
self.relu = nn.ReLU(inplace=True)
|
| 1605 |
+
|
| 1606 |
+
def forward(self, x):
|
| 1607 |
+
x = self.atrous_conv(x)
|
| 1608 |
+
x = self.bn(x)
|
| 1609 |
+
|
| 1610 |
+
return self.relu(x)
|
| 1611 |
+
|
| 1612 |
+
|
| 1613 |
+
class ASPPDeformable(nn.Module):
|
| 1614 |
+
def __init__(self, in_channels, out_channels=None, parallel_block_sizes=[1, 3, 7]):
|
| 1615 |
+
super(ASPPDeformable, self).__init__()
|
| 1616 |
+
self.down_scale = 1
|
| 1617 |
+
if out_channels is None:
|
| 1618 |
+
out_channels = in_channels
|
| 1619 |
+
self.in_channelster = 256 // self.down_scale
|
| 1620 |
+
|
| 1621 |
+
self.aspp1 = _ASPPModuleDeformable(in_channels, self.in_channelster, 1, padding=0)
|
| 1622 |
+
self.aspp_deforms = nn.ModuleList([
|
| 1623 |
+
_ASPPModuleDeformable(in_channels, self.in_channelster, conv_size, padding=int(conv_size//2)) for conv_size in parallel_block_sizes
|
| 1624 |
+
])
|
| 1625 |
+
|
| 1626 |
+
self.global_avg_pool = nn.Sequential(nn.AdaptiveAvgPool2d((1, 1)),
|
| 1627 |
+
nn.Conv2d(in_channels, self.in_channelster, 1, stride=1, bias=False),
|
| 1628 |
+
nn.BatchNorm2d(self.in_channelster) if config.batch_size > 1 else nn.Identity(),
|
| 1629 |
+
nn.ReLU(inplace=True))
|
| 1630 |
+
self.conv1 = nn.Conv2d(self.in_channelster * (2 + len(self.aspp_deforms)), out_channels, 1, bias=False)
|
| 1631 |
+
self.bn1 = nn.BatchNorm2d(out_channels) if config.batch_size > 1 else nn.Identity()
|
| 1632 |
+
self.relu = nn.ReLU(inplace=True)
|
| 1633 |
+
self.dropout = nn.Dropout(0.5)
|
| 1634 |
+
|
| 1635 |
+
def forward(self, x):
|
| 1636 |
+
x1 = self.aspp1(x)
|
| 1637 |
+
x_aspp_deforms = [aspp_deform(x) for aspp_deform in self.aspp_deforms]
|
| 1638 |
+
x5 = self.global_avg_pool(x)
|
| 1639 |
+
x5 = F.interpolate(x5, size=x1.size()[2:], mode='bilinear', align_corners=True)
|
| 1640 |
+
x = torch.cat((x1, *x_aspp_deforms, x5), dim=1)
|
| 1641 |
+
|
| 1642 |
+
x = self.conv1(x)
|
| 1643 |
+
x = self.bn1(x)
|
| 1644 |
+
x = self.relu(x)
|
| 1645 |
+
|
| 1646 |
+
return self.dropout(x)
|
| 1647 |
+
|
| 1648 |
+
|
| 1649 |
+
|
| 1650 |
+
### models/refinement/refiner.py
|
| 1651 |
+
|
| 1652 |
+
import torch
|
| 1653 |
+
import torch.nn as nn
|
| 1654 |
+
from collections import OrderedDict
|
| 1655 |
+
import torch
|
| 1656 |
+
import torch.nn as nn
|
| 1657 |
+
import torch.nn.functional as F
|
| 1658 |
+
from torchvision.models import vgg16, vgg16_bn
|
| 1659 |
+
from torchvision.models import resnet50
|
| 1660 |
+
|
| 1661 |
+
# from config import Config
|
| 1662 |
+
# from dataset import class_labels_TR_sorted
|
| 1663 |
+
# from models.build_backbone import build_backbone
|
| 1664 |
+
# from models.decoder_blocks import BasicDecBlk
|
| 1665 |
+
# from models.lateral_blocks import BasicLatBlk
|
| 1666 |
+
# from models.ing import *
|
| 1667 |
+
# from models.stem_layer import StemLayer
|
| 1668 |
+
|
| 1669 |
+
|
| 1670 |
+
class RefinerPVTInChannels4(nn.Module):
|
| 1671 |
+
def __init__(self, in_channels=3+1):
|
| 1672 |
+
super(RefinerPVTInChannels4, self).__init__()
|
| 1673 |
+
self.config = Config()
|
| 1674 |
+
self.epoch = 1
|
| 1675 |
+
self.bb = build_backbone(self.config.bb, params_settings='in_channels=4')
|
| 1676 |
+
|
| 1677 |
+
lateral_channels_in_collection = {
|
| 1678 |
+
'vgg16': [512, 256, 128, 64], 'vgg16bn': [512, 256, 128, 64], 'resnet50': [1024, 512, 256, 64],
|
| 1679 |
+
'pvt_v2_b2': [512, 320, 128, 64], 'pvt_v2_b5': [512, 320, 128, 64],
|
| 1680 |
+
'swin_v1_b': [1024, 512, 256, 128], 'swin_v1_l': [1536, 768, 384, 192],
|
| 1681 |
+
}
|
| 1682 |
+
channels = lateral_channels_in_collection[self.config.bb]
|
| 1683 |
+
self.squeeze_module = BasicDecBlk(channels[0], channels[0])
|
| 1684 |
+
|
| 1685 |
+
self.decoder = Decoder(channels)
|
| 1686 |
+
|
| 1687 |
+
if 0:
|
| 1688 |
+
for key, value in self.named_parameters():
|
| 1689 |
+
if 'bb.' in key:
|
| 1690 |
+
value.requires_grad = False
|
| 1691 |
+
|
| 1692 |
+
def forward(self, x):
|
| 1693 |
+
if isinstance(x, list):
|
| 1694 |
+
x = torch.cat(x, dim=1)
|
| 1695 |
+
########## Encoder ##########
|
| 1696 |
+
if self.config.bb in ['vgg16', 'vgg16bn', 'resnet50']:
|
| 1697 |
+
x1 = self.bb.conv1(x)
|
| 1698 |
+
x2 = self.bb.conv2(x1)
|
| 1699 |
+
x3 = self.bb.conv3(x2)
|
| 1700 |
+
x4 = self.bb.conv4(x3)
|
| 1701 |
+
else:
|
| 1702 |
+
x1, x2, x3, x4 = self.bb(x)
|
| 1703 |
+
|
| 1704 |
+
x4 = self.squeeze_module(x4)
|
| 1705 |
+
|
| 1706 |
+
########## Decoder ##########
|
| 1707 |
+
|
| 1708 |
+
features = [x, x1, x2, x3, x4]
|
| 1709 |
+
scaled_preds = self.decoder(features)
|
| 1710 |
+
|
| 1711 |
+
return scaled_preds
|
| 1712 |
+
|
| 1713 |
+
|
| 1714 |
+
class Refiner(nn.Module):
|
| 1715 |
+
def __init__(self, in_channels=3+1):
|
| 1716 |
+
super(Refiner, self).__init__()
|
| 1717 |
+
self.config = Config()
|
| 1718 |
+
self.epoch = 1
|
| 1719 |
+
self.stem_layer = StemLayer(in_channels=in_channels, inter_channels=48, out_channels=3, norm_layer='BN' if self.config.batch_size > 1 else 'LN')
|
| 1720 |
+
self.bb = build_backbone(self.config.bb)
|
| 1721 |
+
|
| 1722 |
+
lateral_channels_in_collection = {
|
| 1723 |
+
'vgg16': [512, 256, 128, 64], 'vgg16bn': [512, 256, 128, 64], 'resnet50': [1024, 512, 256, 64],
|
| 1724 |
+
'pvt_v2_b2': [512, 320, 128, 64], 'pvt_v2_b5': [512, 320, 128, 64],
|
| 1725 |
+
'swin_v1_b': [1024, 512, 256, 128], 'swin_v1_l': [1536, 768, 384, 192],
|
| 1726 |
+
}
|
| 1727 |
+
channels = lateral_channels_in_collection[self.config.bb]
|
| 1728 |
+
self.squeeze_module = BasicDecBlk(channels[0], channels[0])
|
| 1729 |
+
|
| 1730 |
+
self.decoder = Decoder(channels)
|
| 1731 |
+
|
| 1732 |
+
if 0:
|
| 1733 |
+
for key, value in self.named_parameters():
|
| 1734 |
+
if 'bb.' in key:
|
| 1735 |
+
value.requires_grad = False
|
| 1736 |
+
|
| 1737 |
+
def forward(self, x):
|
| 1738 |
+
if isinstance(x, list):
|
| 1739 |
+
x = torch.cat(x, dim=1)
|
| 1740 |
+
x = self.stem_layer(x)
|
| 1741 |
+
########## Encoder ##########
|
| 1742 |
+
if self.config.bb in ['vgg16', 'vgg16bn', 'resnet50']:
|
| 1743 |
+
x1 = self.bb.conv1(x)
|
| 1744 |
+
x2 = self.bb.conv2(x1)
|
| 1745 |
+
x3 = self.bb.conv3(x2)
|
| 1746 |
+
x4 = self.bb.conv4(x3)
|
| 1747 |
+
else:
|
| 1748 |
+
x1, x2, x3, x4 = self.bb(x)
|
| 1749 |
+
|
| 1750 |
+
x4 = self.squeeze_module(x4)
|
| 1751 |
+
|
| 1752 |
+
########## Decoder ##########
|
| 1753 |
+
|
| 1754 |
+
features = [x, x1, x2, x3, x4]
|
| 1755 |
+
scaled_preds = self.decoder(features)
|
| 1756 |
+
|
| 1757 |
+
return scaled_preds
|
| 1758 |
+
|
| 1759 |
+
|
| 1760 |
+
class Decoder(nn.Module):
|
| 1761 |
+
def __init__(self, channels):
|
| 1762 |
+
super(Decoder, self).__init__()
|
| 1763 |
+
self.config = Config()
|
| 1764 |
+
DecoderBlock = eval('BasicDecBlk')
|
| 1765 |
+
LateralBlock = eval('BasicLatBlk')
|
| 1766 |
+
|
| 1767 |
+
self.decoder_block4 = DecoderBlock(channels[0], channels[1])
|
| 1768 |
+
self.decoder_block3 = DecoderBlock(channels[1], channels[2])
|
| 1769 |
+
self.decoder_block2 = DecoderBlock(channels[2], channels[3])
|
| 1770 |
+
self.decoder_block1 = DecoderBlock(channels[3], channels[3]//2)
|
| 1771 |
+
|
| 1772 |
+
self.lateral_block4 = LateralBlock(channels[1], channels[1])
|
| 1773 |
+
self.lateral_block3 = LateralBlock(channels[2], channels[2])
|
| 1774 |
+
self.lateral_block2 = LateralBlock(channels[3], channels[3])
|
| 1775 |
+
|
| 1776 |
+
if self.config.ms_supervision:
|
| 1777 |
+
self.conv_ms_spvn_4 = nn.Conv2d(channels[1], 1, 1, 1, 0)
|
| 1778 |
+
self.conv_ms_spvn_3 = nn.Conv2d(channels[2], 1, 1, 1, 0)
|
| 1779 |
+
self.conv_ms_spvn_2 = nn.Conv2d(channels[3], 1, 1, 1, 0)
|
| 1780 |
+
self.conv_out1 = nn.Sequential(nn.Conv2d(channels[3]//2, 1, 1, 1, 0))
|
| 1781 |
+
|
| 1782 |
+
def forward(self, features):
|
| 1783 |
+
x, x1, x2, x3, x4 = features
|
| 1784 |
+
outs = []
|
| 1785 |
+
p4 = self.decoder_block4(x4)
|
| 1786 |
+
_p4 = F.interpolate(p4, size=x3.shape[2:], mode='bilinear', align_corners=True)
|
| 1787 |
+
_p3 = _p4 + self.lateral_block4(x3)
|
| 1788 |
+
|
| 1789 |
+
p3 = self.decoder_block3(_p3)
|
| 1790 |
+
_p3 = F.interpolate(p3, size=x2.shape[2:], mode='bilinear', align_corners=True)
|
| 1791 |
+
_p2 = _p3 + self.lateral_block3(x2)
|
| 1792 |
+
|
| 1793 |
+
p2 = self.decoder_block2(_p2)
|
| 1794 |
+
_p2 = F.interpolate(p2, size=x1.shape[2:], mode='bilinear', align_corners=True)
|
| 1795 |
+
_p1 = _p2 + self.lateral_block2(x1)
|
| 1796 |
+
|
| 1797 |
+
_p1 = self.decoder_block1(_p1)
|
| 1798 |
+
_p1 = F.interpolate(_p1, size=x.shape[2:], mode='bilinear', align_corners=True)
|
| 1799 |
+
p1_out = self.conv_out1(_p1)
|
| 1800 |
+
|
| 1801 |
+
if self.config.ms_supervision:
|
| 1802 |
+
outs.append(self.conv_ms_spvn_4(p4))
|
| 1803 |
+
outs.append(self.conv_ms_spvn_3(p3))
|
| 1804 |
+
outs.append(self.conv_ms_spvn_2(p2))
|
| 1805 |
+
outs.append(p1_out)
|
| 1806 |
+
return outs
|
| 1807 |
+
|
| 1808 |
+
|
| 1809 |
+
class RefUNet(nn.Module):
|
| 1810 |
+
# Refinement
|
| 1811 |
+
def __init__(self, in_channels=3+1):
|
| 1812 |
+
super(RefUNet, self).__init__()
|
| 1813 |
+
self.encoder_1 = nn.Sequential(
|
| 1814 |
+
nn.Conv2d(in_channels, 64, 3, 1, 1),
|
| 1815 |
+
nn.Conv2d(64, 64, 3, 1, 1),
|
| 1816 |
+
nn.BatchNorm2d(64),
|
| 1817 |
+
nn.ReLU(inplace=True)
|
| 1818 |
+
)
|
| 1819 |
+
|
| 1820 |
+
self.encoder_2 = nn.Sequential(
|
| 1821 |
+
nn.MaxPool2d(2, 2, ceil_mode=True),
|
| 1822 |
+
nn.Conv2d(64, 64, 3, 1, 1),
|
| 1823 |
+
nn.BatchNorm2d(64),
|
| 1824 |
+
nn.ReLU(inplace=True)
|
| 1825 |
+
)
|
| 1826 |
+
|
| 1827 |
+
self.encoder_3 = nn.Sequential(
|
| 1828 |
+
nn.MaxPool2d(2, 2, ceil_mode=True),
|
| 1829 |
+
nn.Conv2d(64, 64, 3, 1, 1),
|
| 1830 |
+
nn.BatchNorm2d(64),
|
| 1831 |
+
nn.ReLU(inplace=True)
|
| 1832 |
+
)
|
| 1833 |
+
|
| 1834 |
+
self.encoder_4 = nn.Sequential(
|
| 1835 |
+
nn.MaxPool2d(2, 2, ceil_mode=True),
|
| 1836 |
+
nn.Conv2d(64, 64, 3, 1, 1),
|
| 1837 |
+
nn.BatchNorm2d(64),
|
| 1838 |
+
nn.ReLU(inplace=True)
|
| 1839 |
+
)
|
| 1840 |
+
|
| 1841 |
+
self.pool4 = nn.MaxPool2d(2, 2, ceil_mode=True)
|
| 1842 |
+
#####
|
| 1843 |
+
self.decoder_5 = nn.Sequential(
|
| 1844 |
+
nn.Conv2d(64, 64, 3, 1, 1),
|
| 1845 |
+
nn.BatchNorm2d(64),
|
| 1846 |
+
nn.ReLU(inplace=True)
|
| 1847 |
+
)
|
| 1848 |
+
#####
|
| 1849 |
+
self.decoder_4 = nn.Sequential(
|
| 1850 |
+
nn.Conv2d(128, 64, 3, 1, 1),
|
| 1851 |
+
nn.BatchNorm2d(64),
|
| 1852 |
+
nn.ReLU(inplace=True)
|
| 1853 |
+
)
|
| 1854 |
+
|
| 1855 |
+
self.decoder_3 = nn.Sequential(
|
| 1856 |
+
nn.Conv2d(128, 64, 3, 1, 1),
|
| 1857 |
+
nn.BatchNorm2d(64),
|
| 1858 |
+
nn.ReLU(inplace=True)
|
| 1859 |
+
)
|
| 1860 |
+
|
| 1861 |
+
self.decoder_2 = nn.Sequential(
|
| 1862 |
+
nn.Conv2d(128, 64, 3, 1, 1),
|
| 1863 |
+
nn.BatchNorm2d(64),
|
| 1864 |
+
nn.ReLU(inplace=True)
|
| 1865 |
+
)
|
| 1866 |
+
|
| 1867 |
+
self.decoder_1 = nn.Sequential(
|
| 1868 |
+
nn.Conv2d(128, 64, 3, 1, 1),
|
| 1869 |
+
nn.BatchNorm2d(64),
|
| 1870 |
+
nn.ReLU(inplace=True)
|
| 1871 |
+
)
|
| 1872 |
+
|
| 1873 |
+
self.conv_d0 = nn.Conv2d(64, 1, 3, 1, 1)
|
| 1874 |
+
|
| 1875 |
+
self.upscore2 = nn.Upsample(scale_factor=2, mode='bilinear', align_corners=True)
|
| 1876 |
+
|
| 1877 |
+
def forward(self, x):
|
| 1878 |
+
outs = []
|
| 1879 |
+
if isinstance(x, list):
|
| 1880 |
+
x = torch.cat(x, dim=1)
|
| 1881 |
+
hx = x
|
| 1882 |
+
|
| 1883 |
+
hx1 = self.encoder_1(hx)
|
| 1884 |
+
hx2 = self.encoder_2(hx1)
|
| 1885 |
+
hx3 = self.encoder_3(hx2)
|
| 1886 |
+
hx4 = self.encoder_4(hx3)
|
| 1887 |
+
|
| 1888 |
+
hx = self.decoder_5(self.pool4(hx4))
|
| 1889 |
+
hx = torch.cat((self.upscore2(hx), hx4), 1)
|
| 1890 |
+
|
| 1891 |
+
d4 = self.decoder_4(hx)
|
| 1892 |
+
hx = torch.cat((self.upscore2(d4), hx3), 1)
|
| 1893 |
+
|
| 1894 |
+
d3 = self.decoder_3(hx)
|
| 1895 |
+
hx = torch.cat((self.upscore2(d3), hx2), 1)
|
| 1896 |
+
|
| 1897 |
+
d2 = self.decoder_2(hx)
|
| 1898 |
+
hx = torch.cat((self.upscore2(d2), hx1), 1)
|
| 1899 |
+
|
| 1900 |
+
d1 = self.decoder_1(hx)
|
| 1901 |
+
|
| 1902 |
+
x = self.conv_d0(d1)
|
| 1903 |
+
outs.append(x)
|
| 1904 |
+
return outs
|
| 1905 |
+
|
| 1906 |
+
|
| 1907 |
+
|
| 1908 |
+
### models/stem_layer.py
|
| 1909 |
+
|
| 1910 |
+
import torch.nn as nn
|
| 1911 |
+
# from utils import build_act_layer, build_norm_layer
|
| 1912 |
+
|
| 1913 |
+
|
| 1914 |
+
class StemLayer(nn.Module):
|
| 1915 |
+
r""" Stem layer of InternImage
|
| 1916 |
+
Args:
|
| 1917 |
+
in_channels (int): number of input channels
|
| 1918 |
+
out_channels (int): number of output channels
|
| 1919 |
+
act_layer (str): activation layer
|
| 1920 |
+
norm_layer (str): normalization layer
|
| 1921 |
+
"""
|
| 1922 |
+
|
| 1923 |
+
def __init__(self,
|
| 1924 |
+
in_channels=3+1,
|
| 1925 |
+
inter_channels=48,
|
| 1926 |
+
out_channels=96,
|
| 1927 |
+
act_layer='GELU',
|
| 1928 |
+
norm_layer='BN'):
|
| 1929 |
+
super().__init__()
|
| 1930 |
+
self.conv1 = nn.Conv2d(in_channels,
|
| 1931 |
+
inter_channels,
|
| 1932 |
+
kernel_size=3,
|
| 1933 |
+
stride=1,
|
| 1934 |
+
padding=1)
|
| 1935 |
+
self.norm1 = build_norm_layer(
|
| 1936 |
+
inter_channels, norm_layer, 'channels_first', 'channels_first'
|
| 1937 |
+
)
|
| 1938 |
+
self.act = build_act_layer(act_layer)
|
| 1939 |
+
self.conv2 = nn.Conv2d(inter_channels,
|
| 1940 |
+
out_channels,
|
| 1941 |
+
kernel_size=3,
|
| 1942 |
+
stride=1,
|
| 1943 |
+
padding=1)
|
| 1944 |
+
self.norm2 = build_norm_layer(
|
| 1945 |
+
out_channels, norm_layer, 'channels_first', 'channels_first'
|
| 1946 |
+
)
|
| 1947 |
+
|
| 1948 |
+
def forward(self, x):
|
| 1949 |
+
x = self.conv1(x)
|
| 1950 |
+
x = self.norm1(x)
|
| 1951 |
+
x = self.act(x)
|
| 1952 |
+
x = self.conv2(x)
|
| 1953 |
+
x = self.norm2(x)
|
| 1954 |
+
return x
|
| 1955 |
+
|
| 1956 |
+
|
| 1957 |
+
### models/birefnet.py
|
| 1958 |
+
|
| 1959 |
+
import torch
|
| 1960 |
+
import torch.nn as nn
|
| 1961 |
+
import torch.nn.functional as F
|
| 1962 |
+
from kornia.filters import laplacian
|
| 1963 |
+
from transformers import PreTrainedModel
|
| 1964 |
+
|
| 1965 |
+
# from config import Config
|
| 1966 |
+
# from dataset import class_labels_TR_sorted
|
| 1967 |
+
# from models.build_backbone import build_backbone
|
| 1968 |
+
# from models.decoder_blocks import BasicDecBlk, ResBlk, HierarAttDecBlk
|
| 1969 |
+
# from models.lateral_blocks import BasicLatBlk
|
| 1970 |
+
# from models.aspp import ASPP, ASPPDeformable
|
| 1971 |
+
# from models.ing import *
|
| 1972 |
+
# from models.refiner import Refiner, RefinerPVTInChannels4, RefUNet
|
| 1973 |
+
# from models.stem_layer import StemLayer
|
| 1974 |
+
from .BiRefNet_config import BiRefNetConfig
|
| 1975 |
+
|
| 1976 |
+
|
| 1977 |
+
class BiRefNet(
|
| 1978 |
+
PreTrainedModel
|
| 1979 |
+
):
|
| 1980 |
+
config_class = BiRefNetConfig
|
| 1981 |
+
def __init__(self, bb_pretrained=True, config=BiRefNetConfig()):
|
| 1982 |
+
super(BiRefNet, self).__init__(config)
|
| 1983 |
+
bb_pretrained = config.bb_pretrained
|
| 1984 |
+
self.config = Config()
|
| 1985 |
+
self.epoch = 1
|
| 1986 |
+
self.bb = build_backbone(self.config.bb, pretrained=bb_pretrained)
|
| 1987 |
+
|
| 1988 |
+
channels = self.config.lateral_channels_in_collection
|
| 1989 |
+
|
| 1990 |
+
if self.config.auxiliary_classification:
|
| 1991 |
+
self.avgpool = nn.AdaptiveAvgPool2d((1, 1))
|
| 1992 |
+
self.cls_head = nn.Sequential(
|
| 1993 |
+
nn.Linear(channels[0], len(class_labels_TR_sorted))
|
| 1994 |
+
)
|
| 1995 |
+
|
| 1996 |
+
if self.config.squeeze_block:
|
| 1997 |
+
self.squeeze_module = nn.Sequential(*[
|
| 1998 |
+
eval(self.config.squeeze_block.split('_x')[0])(channels[0]+sum(self.config.cxt), channels[0])
|
| 1999 |
+
for _ in range(eval(self.config.squeeze_block.split('_x')[1]))
|
| 2000 |
+
])
|
| 2001 |
+
|
| 2002 |
+
self.decoder = Decoder(channels)
|
| 2003 |
+
|
| 2004 |
+
if self.config.ender:
|
| 2005 |
+
self.dec_end = nn.Sequential(
|
| 2006 |
+
nn.Conv2d(1, 16, 3, 1, 1),
|
| 2007 |
+
nn.Conv2d(16, 1, 3, 1, 1),
|
| 2008 |
+
nn.ReLU(inplace=True),
|
| 2009 |
+
)
|
| 2010 |
+
|
| 2011 |
+
# refine patch-level segmentation
|
| 2012 |
+
if self.config.refine:
|
| 2013 |
+
if self.config.refine == 'itself':
|
| 2014 |
+
self.stem_layer = StemLayer(in_channels=3+1, inter_channels=48, out_channels=3, norm_layer='BN' if self.config.batch_size > 1 else 'LN')
|
| 2015 |
+
else:
|
| 2016 |
+
self.refiner = eval('{}({})'.format(self.config.refine, 'in_channels=3+1'))
|
| 2017 |
+
|
| 2018 |
+
if self.config.freeze_bb:
|
| 2019 |
+
# Freeze the backbone...
|
| 2020 |
+
print(self.named_parameters())
|
| 2021 |
+
for key, value in self.named_parameters():
|
| 2022 |
+
if 'bb.' in key and 'refiner.' not in key:
|
| 2023 |
+
value.requires_grad = False
|
| 2024 |
+
|
| 2025 |
+
def forward_enc(self, x):
|
| 2026 |
+
if self.config.bb in ['vgg16', 'vgg16bn', 'resnet50']:
|
| 2027 |
+
x1 = self.bb.conv1(x); x2 = self.bb.conv2(x1); x3 = self.bb.conv3(x2); x4 = self.bb.conv4(x3)
|
| 2028 |
+
else:
|
| 2029 |
+
x1, x2, x3, x4 = self.bb(x)
|
| 2030 |
+
if self.config.mul_scl_ipt == 'cat':
|
| 2031 |
+
B, C, H, W = x.shape
|
| 2032 |
+
x1_, x2_, x3_, x4_ = self.bb(F.interpolate(x, size=(H//2, W//2), mode='bilinear', align_corners=True))
|
| 2033 |
+
x1 = torch.cat([x1, F.interpolate(x1_, size=x1.shape[2:], mode='bilinear', align_corners=True)], dim=1)
|
| 2034 |
+
x2 = torch.cat([x2, F.interpolate(x2_, size=x2.shape[2:], mode='bilinear', align_corners=True)], dim=1)
|
| 2035 |
+
x3 = torch.cat([x3, F.interpolate(x3_, size=x3.shape[2:], mode='bilinear', align_corners=True)], dim=1)
|
| 2036 |
+
x4 = torch.cat([x4, F.interpolate(x4_, size=x4.shape[2:], mode='bilinear', align_corners=True)], dim=1)
|
| 2037 |
+
elif self.config.mul_scl_ipt == 'add':
|
| 2038 |
+
B, C, H, W = x.shape
|
| 2039 |
+
x1_, x2_, x3_, x4_ = self.bb(F.interpolate(x, size=(H//2, W//2), mode='bilinear', align_corners=True))
|
| 2040 |
+
x1 = x1 + F.interpolate(x1_, size=x1.shape[2:], mode='bilinear', align_corners=True)
|
| 2041 |
+
x2 = x2 + F.interpolate(x2_, size=x2.shape[2:], mode='bilinear', align_corners=True)
|
| 2042 |
+
x3 = x3 + F.interpolate(x3_, size=x3.shape[2:], mode='bilinear', align_corners=True)
|
| 2043 |
+
x4 = x4 + F.interpolate(x4_, size=x4.shape[2:], mode='bilinear', align_corners=True)
|
| 2044 |
+
class_preds = self.cls_head(self.avgpool(x4).view(x4.shape[0], -1)) if self.training and self.config.auxiliary_classification else None
|
| 2045 |
+
if self.config.cxt:
|
| 2046 |
+
x4 = torch.cat(
|
| 2047 |
+
(
|
| 2048 |
+
*[
|
| 2049 |
+
F.interpolate(x1, size=x4.shape[2:], mode='bilinear', align_corners=True),
|
| 2050 |
+
F.interpolate(x2, size=x4.shape[2:], mode='bilinear', align_corners=True),
|
| 2051 |
+
F.interpolate(x3, size=x4.shape[2:], mode='bilinear', align_corners=True),
|
| 2052 |
+
][-len(self.config.cxt):],
|
| 2053 |
+
x4
|
| 2054 |
+
),
|
| 2055 |
+
dim=1
|
| 2056 |
+
)
|
| 2057 |
+
return (x1, x2, x3, x4), class_preds
|
| 2058 |
+
|
| 2059 |
+
def forward_ori(self, x):
|
| 2060 |
+
########## Encoder ##########
|
| 2061 |
+
(x1, x2, x3, x4), class_preds = self.forward_enc(x)
|
| 2062 |
+
if self.config.squeeze_block:
|
| 2063 |
+
x4 = self.squeeze_module(x4)
|
| 2064 |
+
########## Decoder ##########
|
| 2065 |
+
features = [x, x1, x2, x3, x4]
|
| 2066 |
+
if self.training and self.config.out_ref:
|
| 2067 |
+
features.append(laplacian(torch.mean(x, dim=1).unsqueeze(1), kernel_size=5))
|
| 2068 |
+
scaled_preds = self.decoder(features)
|
| 2069 |
+
return scaled_preds, class_preds
|
| 2070 |
+
|
| 2071 |
+
def forward(self, x):
|
| 2072 |
+
scaled_preds, class_preds = self.forward_ori(x)
|
| 2073 |
+
class_preds_lst = [class_preds]
|
| 2074 |
+
return [scaled_preds, class_preds_lst] if self.training else scaled_preds
|
| 2075 |
+
|
| 2076 |
+
|
| 2077 |
+
class Decoder(nn.Module):
|
| 2078 |
+
def __init__(self, channels):
|
| 2079 |
+
super(Decoder, self).__init__()
|
| 2080 |
+
self.config = Config()
|
| 2081 |
+
DecoderBlock = eval(self.config.dec_blk)
|
| 2082 |
+
LateralBlock = eval(self.config.lat_blk)
|
| 2083 |
+
|
| 2084 |
+
if self.config.dec_ipt:
|
| 2085 |
+
self.split = self.config.dec_ipt_split
|
| 2086 |
+
N_dec_ipt = 64
|
| 2087 |
+
DBlock = SimpleConvs
|
| 2088 |
+
ic = 64
|
| 2089 |
+
ipt_cha_opt = 1
|
| 2090 |
+
self.ipt_blk5 = DBlock(2**10*3 if self.split else 3, [N_dec_ipt, channels[0]//8][ipt_cha_opt], inter_channels=ic)
|
| 2091 |
+
self.ipt_blk4 = DBlock(2**8*3 if self.split else 3, [N_dec_ipt, channels[0]//8][ipt_cha_opt], inter_channels=ic)
|
| 2092 |
+
self.ipt_blk3 = DBlock(2**6*3 if self.split else 3, [N_dec_ipt, channels[1]//8][ipt_cha_opt], inter_channels=ic)
|
| 2093 |
+
self.ipt_blk2 = DBlock(2**4*3 if self.split else 3, [N_dec_ipt, channels[2]//8][ipt_cha_opt], inter_channels=ic)
|
| 2094 |
+
self.ipt_blk1 = DBlock(2**0*3 if self.split else 3, [N_dec_ipt, channels[3]//8][ipt_cha_opt], inter_channels=ic)
|
| 2095 |
+
else:
|
| 2096 |
+
self.split = None
|
| 2097 |
+
|
| 2098 |
+
self.decoder_block4 = DecoderBlock(channels[0]+([N_dec_ipt, channels[0]//8][ipt_cha_opt] if self.config.dec_ipt else 0), channels[1])
|
| 2099 |
+
self.decoder_block3 = DecoderBlock(channels[1]+([N_dec_ipt, channels[0]//8][ipt_cha_opt] if self.config.dec_ipt else 0), channels[2])
|
| 2100 |
+
self.decoder_block2 = DecoderBlock(channels[2]+([N_dec_ipt, channels[1]//8][ipt_cha_opt] if self.config.dec_ipt else 0), channels[3])
|
| 2101 |
+
self.decoder_block1 = DecoderBlock(channels[3]+([N_dec_ipt, channels[2]//8][ipt_cha_opt] if self.config.dec_ipt else 0), channels[3]//2)
|
| 2102 |
+
self.conv_out1 = nn.Sequential(nn.Conv2d(channels[3]//2+([N_dec_ipt, channels[3]//8][ipt_cha_opt] if self.config.dec_ipt else 0), 1, 1, 1, 0))
|
| 2103 |
+
|
| 2104 |
+
self.lateral_block4 = LateralBlock(channels[1], channels[1])
|
| 2105 |
+
self.lateral_block3 = LateralBlock(channels[2], channels[2])
|
| 2106 |
+
self.lateral_block2 = LateralBlock(channels[3], channels[3])
|
| 2107 |
+
|
| 2108 |
+
if self.config.ms_supervision:
|
| 2109 |
+
self.conv_ms_spvn_4 = nn.Conv2d(channels[1], 1, 1, 1, 0)
|
| 2110 |
+
self.conv_ms_spvn_3 = nn.Conv2d(channels[2], 1, 1, 1, 0)
|
| 2111 |
+
self.conv_ms_spvn_2 = nn.Conv2d(channels[3], 1, 1, 1, 0)
|
| 2112 |
+
|
| 2113 |
+
if self.config.out_ref:
|
| 2114 |
+
_N = 16
|
| 2115 |
+
self.gdt_convs_4 = nn.Sequential(nn.Conv2d(channels[1], _N, 3, 1, 1), nn.BatchNorm2d(_N) if self.config.batch_size > 1 else nn.Identity(), nn.ReLU(inplace=True))
|
| 2116 |
+
self.gdt_convs_3 = nn.Sequential(nn.Conv2d(channels[2], _N, 3, 1, 1), nn.BatchNorm2d(_N) if self.config.batch_size > 1 else nn.Identity(), nn.ReLU(inplace=True))
|
| 2117 |
+
self.gdt_convs_2 = nn.Sequential(nn.Conv2d(channels[3], _N, 3, 1, 1), nn.BatchNorm2d(_N) if self.config.batch_size > 1 else nn.Identity(), nn.ReLU(inplace=True))
|
| 2118 |
+
|
| 2119 |
+
self.gdt_convs_pred_4 = nn.Sequential(nn.Conv2d(_N, 1, 1, 1, 0))
|
| 2120 |
+
self.gdt_convs_pred_3 = nn.Sequential(nn.Conv2d(_N, 1, 1, 1, 0))
|
| 2121 |
+
self.gdt_convs_pred_2 = nn.Sequential(nn.Conv2d(_N, 1, 1, 1, 0))
|
| 2122 |
+
|
| 2123 |
+
self.gdt_convs_attn_4 = nn.Sequential(nn.Conv2d(_N, 1, 1, 1, 0))
|
| 2124 |
+
self.gdt_convs_attn_3 = nn.Sequential(nn.Conv2d(_N, 1, 1, 1, 0))
|
| 2125 |
+
self.gdt_convs_attn_2 = nn.Sequential(nn.Conv2d(_N, 1, 1, 1, 0))
|
| 2126 |
+
|
| 2127 |
+
def get_patches_batch(self, x, p):
|
| 2128 |
+
_size_h, _size_w = p.shape[2:]
|
| 2129 |
+
patches_batch = []
|
| 2130 |
+
for idx in range(x.shape[0]):
|
| 2131 |
+
columns_x = torch.split(x[idx], split_size_or_sections=_size_w, dim=-1)
|
| 2132 |
+
patches_x = []
|
| 2133 |
+
for column_x in columns_x:
|
| 2134 |
+
patches_x += [p.unsqueeze(0) for p in torch.split(column_x, split_size_or_sections=_size_h, dim=-2)]
|
| 2135 |
+
patch_sample = torch.cat(patches_x, dim=1)
|
| 2136 |
+
patches_batch.append(patch_sample)
|
| 2137 |
+
return torch.cat(patches_batch, dim=0)
|
| 2138 |
+
|
| 2139 |
+
def forward(self, features):
|
| 2140 |
+
if self.training and self.config.out_ref:
|
| 2141 |
+
outs_gdt_pred = []
|
| 2142 |
+
outs_gdt_label = []
|
| 2143 |
+
x, x1, x2, x3, x4, gdt_gt = features
|
| 2144 |
+
else:
|
| 2145 |
+
x, x1, x2, x3, x4 = features
|
| 2146 |
+
outs = []
|
| 2147 |
+
|
| 2148 |
+
if self.config.dec_ipt:
|
| 2149 |
+
patches_batch = self.get_patches_batch(x, x4) if self.split else x
|
| 2150 |
+
x4 = torch.cat((x4, self.ipt_blk5(F.interpolate(patches_batch, size=x4.shape[2:], mode='bilinear', align_corners=True))), 1)
|
| 2151 |
+
p4 = self.decoder_block4(x4)
|
| 2152 |
+
m4 = self.conv_ms_spvn_4(p4) if self.config.ms_supervision else None
|
| 2153 |
+
if self.config.out_ref:
|
| 2154 |
+
p4_gdt = self.gdt_convs_4(p4)
|
| 2155 |
+
if self.training:
|
| 2156 |
+
# >> GT:
|
| 2157 |
+
m4_dia = m4
|
| 2158 |
+
gdt_label_main_4 = gdt_gt * F.interpolate(m4_dia, size=gdt_gt.shape[2:], mode='bilinear', align_corners=True)
|
| 2159 |
+
outs_gdt_label.append(gdt_label_main_4)
|
| 2160 |
+
# >> Pred:
|
| 2161 |
+
gdt_pred_4 = self.gdt_convs_pred_4(p4_gdt)
|
| 2162 |
+
outs_gdt_pred.append(gdt_pred_4)
|
| 2163 |
+
gdt_attn_4 = self.gdt_convs_attn_4(p4_gdt).sigmoid()
|
| 2164 |
+
# >> Finally:
|
| 2165 |
+
p4 = p4 * gdt_attn_4
|
| 2166 |
+
_p4 = F.interpolate(p4, size=x3.shape[2:], mode='bilinear', align_corners=True)
|
| 2167 |
+
_p3 = _p4 + self.lateral_block4(x3)
|
| 2168 |
+
|
| 2169 |
+
if self.config.dec_ipt:
|
| 2170 |
+
patches_batch = self.get_patches_batch(x, _p3) if self.split else x
|
| 2171 |
+
_p3 = torch.cat((_p3, self.ipt_blk4(F.interpolate(patches_batch, size=x3.shape[2:], mode='bilinear', align_corners=True))), 1)
|
| 2172 |
+
p3 = self.decoder_block3(_p3)
|
| 2173 |
+
m3 = self.conv_ms_spvn_3(p3) if self.config.ms_supervision else None
|
| 2174 |
+
if self.config.out_ref:
|
| 2175 |
+
p3_gdt = self.gdt_convs_3(p3)
|
| 2176 |
+
if self.training:
|
| 2177 |
+
# >> GT:
|
| 2178 |
+
# m3 --dilation--> m3_dia
|
| 2179 |
+
# G_3^gt * m3_dia --> G_3^m, which is the label of gradient
|
| 2180 |
+
m3_dia = m3
|
| 2181 |
+
gdt_label_main_3 = gdt_gt * F.interpolate(m3_dia, size=gdt_gt.shape[2:], mode='bilinear', align_corners=True)
|
| 2182 |
+
outs_gdt_label.append(gdt_label_main_3)
|
| 2183 |
+
# >> Pred:
|
| 2184 |
+
# p3 --conv--BN--> F_3^G, where F_3^G predicts the \hat{G_3} with xx
|
| 2185 |
+
# F_3^G --sigmoid--> A_3^G
|
| 2186 |
+
gdt_pred_3 = self.gdt_convs_pred_3(p3_gdt)
|
| 2187 |
+
outs_gdt_pred.append(gdt_pred_3)
|
| 2188 |
+
gdt_attn_3 = self.gdt_convs_attn_3(p3_gdt).sigmoid()
|
| 2189 |
+
# >> Finally:
|
| 2190 |
+
# p3 = p3 * A_3^G
|
| 2191 |
+
p3 = p3 * gdt_attn_3
|
| 2192 |
+
_p3 = F.interpolate(p3, size=x2.shape[2:], mode='bilinear', align_corners=True)
|
| 2193 |
+
_p2 = _p3 + self.lateral_block3(x2)
|
| 2194 |
+
|
| 2195 |
+
if self.config.dec_ipt:
|
| 2196 |
+
patches_batch = self.get_patches_batch(x, _p2) if self.split else x
|
| 2197 |
+
_p2 = torch.cat((_p2, self.ipt_blk3(F.interpolate(patches_batch, size=x2.shape[2:], mode='bilinear', align_corners=True))), 1)
|
| 2198 |
+
p2 = self.decoder_block2(_p2)
|
| 2199 |
+
m2 = self.conv_ms_spvn_2(p2) if self.config.ms_supervision else None
|
| 2200 |
+
if self.config.out_ref:
|
| 2201 |
+
p2_gdt = self.gdt_convs_2(p2)
|
| 2202 |
+
if self.training:
|
| 2203 |
+
# >> GT:
|
| 2204 |
+
m2_dia = m2
|
| 2205 |
+
gdt_label_main_2 = gdt_gt * F.interpolate(m2_dia, size=gdt_gt.shape[2:], mode='bilinear', align_corners=True)
|
| 2206 |
+
outs_gdt_label.append(gdt_label_main_2)
|
| 2207 |
+
# >> Pred:
|
| 2208 |
+
gdt_pred_2 = self.gdt_convs_pred_2(p2_gdt)
|
| 2209 |
+
outs_gdt_pred.append(gdt_pred_2)
|
| 2210 |
+
gdt_attn_2 = self.gdt_convs_attn_2(p2_gdt).sigmoid()
|
| 2211 |
+
# >> Finally:
|
| 2212 |
+
p2 = p2 * gdt_attn_2
|
| 2213 |
+
_p2 = F.interpolate(p2, size=x1.shape[2:], mode='bilinear', align_corners=True)
|
| 2214 |
+
_p1 = _p2 + self.lateral_block2(x1)
|
| 2215 |
+
|
| 2216 |
+
if self.config.dec_ipt:
|
| 2217 |
+
patches_batch = self.get_patches_batch(x, _p1) if self.split else x
|
| 2218 |
+
_p1 = torch.cat((_p1, self.ipt_blk2(F.interpolate(patches_batch, size=x1.shape[2:], mode='bilinear', align_corners=True))), 1)
|
| 2219 |
+
_p1 = self.decoder_block1(_p1)
|
| 2220 |
+
_p1 = F.interpolate(_p1, size=x.shape[2:], mode='bilinear', align_corners=True)
|
| 2221 |
+
|
| 2222 |
+
if self.config.dec_ipt:
|
| 2223 |
+
patches_batch = self.get_patches_batch(x, _p1) if self.split else x
|
| 2224 |
+
_p1 = torch.cat((_p1, self.ipt_blk1(F.interpolate(patches_batch, size=x.shape[2:], mode='bilinear', align_corners=True))), 1)
|
| 2225 |
+
p1_out = self.conv_out1(_p1)
|
| 2226 |
+
|
| 2227 |
+
if self.config.ms_supervision:
|
| 2228 |
+
outs.append(m4)
|
| 2229 |
+
outs.append(m3)
|
| 2230 |
+
outs.append(m2)
|
| 2231 |
+
outs.append(p1_out)
|
| 2232 |
+
return outs if not (self.config.out_ref and self.training) else ([outs_gdt_pred, outs_gdt_label], outs)
|
| 2233 |
+
|
| 2234 |
+
|
| 2235 |
+
class SimpleConvs(nn.Module):
|
| 2236 |
+
def __init__(
|
| 2237 |
+
self, in_channels: int, out_channels: int, inter_channels=64
|
| 2238 |
+
) -> None:
|
| 2239 |
+
super().__init__()
|
| 2240 |
+
self.conv1 = nn.Conv2d(in_channels, inter_channels, 3, 1, 1)
|
| 2241 |
+
self.conv_out = nn.Conv2d(inter_channels, out_channels, 3, 1, 1)
|
| 2242 |
+
|
| 2243 |
+
def forward(self, x):
|
| 2244 |
+
return self.conv_out(self.conv1(x))
|
ComfyUI/models/BiRefNet/RMBG-2.0/collage5.png
ADDED
|
Git LFS Details
|
ComfyUI/models/BiRefNet/RMBG-2.0/config.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_name_or_path": "ZhengPeng7/BiRefNet",
|
| 3 |
+
"architectures": [
|
| 4 |
+
"BiRefNet"
|
| 5 |
+
],
|
| 6 |
+
"auto_map": {
|
| 7 |
+
"AutoConfig": "BiRefNet_config.BiRefNetConfig",
|
| 8 |
+
"AutoModelForImageSegmentation": "birefnet.BiRefNet"
|
| 9 |
+
},
|
| 10 |
+
"custom_pipelines": {
|
| 11 |
+
"image-segmentation": {
|
| 12 |
+
"pt": [
|
| 13 |
+
"AutoModelForImageSegmentation"
|
| 14 |
+
],
|
| 15 |
+
"tf": [],
|
| 16 |
+
"type": "image"
|
| 17 |
+
}
|
| 18 |
+
},
|
| 19 |
+
"bb_pretrained": false
|
| 20 |
+
}
|
ComfyUI/models/BiRefNet/RMBG-2.0/diagram1.png
ADDED
|
ComfyUI/models/BiRefNet/RMBG-2.0/model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:566ed80c3d95f87ada6864d4cbe2290a1c5eb1c7bb0b123e984f60f76b02c3a7
|
| 3 |
+
size 884878856
|
ComfyUI/models/BiRefNet/RMBG-2.0/preprocessor_config.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"do_normalize": true,
|
| 3 |
+
"do_rescale": true,
|
| 4 |
+
"do_resize": true,
|
| 5 |
+
"feature_extractor_type": "ViTFeatureExtractor",
|
| 6 |
+
"image_mean": [
|
| 7 |
+
0.485,
|
| 8 |
+
0.456,
|
| 9 |
+
0.406
|
| 10 |
+
],
|
| 11 |
+
"image_processor_type": "ViTFeatureExtractor",
|
| 12 |
+
"image_std": [
|
| 13 |
+
0.229,
|
| 14 |
+
0.224,
|
| 15 |
+
0.225
|
| 16 |
+
],
|
| 17 |
+
"resample": 2,
|
| 18 |
+
"rescale_factor": 0.00392156862745098,
|
| 19 |
+
"size": {
|
| 20 |
+
"height": 1024,
|
| 21 |
+
"width": 1024
|
| 22 |
+
}
|
| 23 |
+
}
|
ComfyUI/models/BiRefNet/RMBG-2.0/t4.png
ADDED
|
Git LFS Details
|
ComfyUI/models/BiRefNet/pth/BiRefNet-general-epoch_244.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:11341a6a1c12646627e8d28da025bfec8aad027929d377cbe8fd4759636cc77c
|
| 3 |
+
size 885082437
|
ComfyUI/models/BiRefNet/pvt_v2_b2.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:80711cd1b37ffba12bec6c7a2a7c54efe2315ed635e6d2055fd51c3e909ede4d
|
| 3 |
+
size 101501299
|
ComfyUI/models/BiRefNet/pvt_v2_b5.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d5c381730c305a9b9d411c2ec9768fb40e922298ecdb4bfe0a606ccd12af0225
|
| 3 |
+
size 327985673
|
ComfyUI/models/BiRefNet/swin_base_patch4_window12_384_22kto1k.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0f6f7d28cb1ddf43af5583163310b29cb3805a32044f226025352494702c606e
|
| 3 |
+
size 365361851
|
ComfyUI/models/BiRefNet/swin_large_patch4_window12_384_22kto1k.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:30762928cd6ee9229e24e26e200951b8fe635799b67db016ba747fa653b64db9
|
| 3 |
+
size 800688955
|
ComfyUI/models/EVF-SAM/evf-sam/.gitattributes
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
| 13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
ComfyUI/models/EVF-SAM/evf-sam/README.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
---
|
| 4 |
+
## EVF-SAM
|
| 5 |
+
|
| 6 |
+
[EVF-SAM: Early Vision-Language Fusion for Text-Prompted Segment Anything Model](https://huggingface.co/papers/2406.20076)
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
## Usage:
|
| 10 |
+
This is the checkpoint holder of [EVF-SAM](https://github.com/hustvl/EVF-SAM.git).
|
| 11 |
+
Please refer to `"inference.py"` in the source code for detailed usage.
|
| 12 |
+
We haven't supported `"AutoModel.from_pretrained(...)"` yet, please import the model script from source code.
|
ComfyUI/models/EVF-SAM/evf-sam/config.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"EvfSamModel"
|
| 4 |
+
],
|
| 5 |
+
"bos_token_id": 0,
|
| 6 |
+
"eos_token_id": 2,
|
| 7 |
+
"hidden_size": 1024,
|
| 8 |
+
"mm_extractor_scale": "large",
|
| 9 |
+
"sam_scale": "huge",
|
| 10 |
+
"model_type": "evf",
|
| 11 |
+
"out_dim": 256,
|
| 12 |
+
"pad_token_id": 1,
|
| 13 |
+
"tie_word_embeddings": false,
|
| 14 |
+
"torch_dtype": "float16",
|
| 15 |
+
"transformers_version": "4.31.0"
|
| 16 |
+
}
|
ComfyUI/models/EVF-SAM/evf-sam/pytorch_model.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8d57771174d1ad276c7abbc2a18218cae54ac95efbc882f178bfd84565a0555e
|
| 3 |
+
size 2630742858
|
ComfyUI/models/EVF-SAM/evf-sam/sentencepiece.bpe.model
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6f5e2fefcf793761a76a6bfb8ad35489f9c203b25557673284b6d032f41043f4
|
| 3 |
+
size 1356293
|
ComfyUI/models/EVF-SAM/evf-sam/special_tokens_map.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"bos_token": "<s>",
|
| 3 |
+
"cls_token": "<s>",
|
| 4 |
+
"eos_token": "</s>",
|
| 5 |
+
"mask_token": {
|
| 6 |
+
"content": "<mask>",
|
| 7 |
+
"lstrip": true,
|
| 8 |
+
"normalized": true,
|
| 9 |
+
"rstrip": false,
|
| 10 |
+
"single_word": false
|
| 11 |
+
},
|
| 12 |
+
"pad_token": "<pad>",
|
| 13 |
+
"sep_token": "</s>",
|
| 14 |
+
"unk_token": "<unk>"
|
| 15 |
+
}
|
ComfyUI/models/EVF-SAM/evf-sam/tokenizer_config.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"bos_token": "<s>",
|
| 3 |
+
"clean_up_tokenization_spaces": true,
|
| 4 |
+
"cls_token": "<s>",
|
| 5 |
+
"eos_token": "</s>",
|
| 6 |
+
"mask_token": {
|
| 7 |
+
"__type": "AddedToken",
|
| 8 |
+
"content": "<mask>",
|
| 9 |
+
"lstrip": true,
|
| 10 |
+
"normalized": true,
|
| 11 |
+
"rstrip": false,
|
| 12 |
+
"single_word": false
|
| 13 |
+
},
|
| 14 |
+
"model_max_length": 1000000000000000019884624838656,
|
| 15 |
+
"pad_token": "<pad>",
|
| 16 |
+
"padding_side": "right",
|
| 17 |
+
"sep_token": "</s>",
|
| 18 |
+
"sp_model_kwargs": {},
|
| 19 |
+
"tokenizer_class": "XLMRobertaTokenizer",
|
| 20 |
+
"unk_token": "<unk>",
|
| 21 |
+
"use_fast": false
|
| 22 |
+
}
|
ComfyUI/models/EVF-SAM/evf-sam2/.gitattributes
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
| 13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
ComfyUI/models/EVF-SAM/evf-sam2/README.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
---
|
| 4 |
+
## EVF-SAM
|
| 5 |
+
|
| 6 |
+
[EVF-SAM: Early Vision-Language Fusion for Text-Prompted Segment Anything Model](https://huggingface.co/papers/2406.20076)
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
## Usage:
|
| 10 |
+
This is the checkpoint holder of [EVF-SAM](https://github.com/hustvl/EVF-SAM.git).
|
| 11 |
+
Please refer to `"inference.py"` and `"inference_video.py"` in the source code for detailed usage.
|
| 12 |
+
We haven't supported `"AutoModel.from_pretrained(...)"` yet, please import the model script from source code.
|
ComfyUI/models/EVF-SAM/evf-sam2/config.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"EvfSam2Model"
|
| 4 |
+
],
|
| 5 |
+
"bos_token_id": 0,
|
| 6 |
+
"eos_token_id": 2,
|
| 7 |
+
"hidden_size": 1024,
|
| 8 |
+
"mm_extractor_scale": "large",
|
| 9 |
+
"model_type": "evf",
|
| 10 |
+
"out_dim": 256,
|
| 11 |
+
"pad_token_id": 1,
|
| 12 |
+
"sam_scale": "large",
|
| 13 |
+
"tie_word_embeddings": false,
|
| 14 |
+
"torch_dtype": "float16",
|
| 15 |
+
"transformers_version": "4.43.3"
|
| 16 |
+
}
|
ComfyUI/models/EVF-SAM/evf-sam2/model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:de5ea4da5236e386ca1c7f5eba51d008f10082d433d9bb354050721701f2e5db
|
| 3 |
+
size 3145168996
|
ComfyUI/models/EVF-SAM/evf-sam2/sentencepiece.bpe.model
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6f5e2fefcf793761a76a6bfb8ad35489f9c203b25557673284b6d032f41043f4
|
| 3 |
+
size 1356293
|
ComfyUI/models/EVF-SAM/evf-sam2/special_tokens_map.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"bos_token": "<s>",
|
| 3 |
+
"cls_token": "<s>",
|
| 4 |
+
"eos_token": "</s>",
|
| 5 |
+
"mask_token": {
|
| 6 |
+
"content": "<mask>",
|
| 7 |
+
"lstrip": true,
|
| 8 |
+
"normalized": false,
|
| 9 |
+
"rstrip": false,
|
| 10 |
+
"single_word": false
|
| 11 |
+
},
|
| 12 |
+
"pad_token": "<pad>",
|
| 13 |
+
"sep_token": "</s>",
|
| 14 |
+
"unk_token": "<unk>"
|
| 15 |
+
}
|
ComfyUI/models/EVF-SAM/evf-sam2/tokenizer_config.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"added_tokens_decoder": {
|
| 3 |
+
"0": {
|
| 4 |
+
"content": "<s>",
|
| 5 |
+
"lstrip": false,
|
| 6 |
+
"normalized": false,
|
| 7 |
+
"rstrip": false,
|
| 8 |
+
"single_word": false,
|
| 9 |
+
"special": true
|
| 10 |
+
},
|
| 11 |
+
"1": {
|
| 12 |
+
"content": "<pad>",
|
| 13 |
+
"lstrip": false,
|
| 14 |
+
"normalized": false,
|
| 15 |
+
"rstrip": false,
|
| 16 |
+
"single_word": false,
|
| 17 |
+
"special": true
|
| 18 |
+
},
|
| 19 |
+
"2": {
|
| 20 |
+
"content": "</s>",
|
| 21 |
+
"lstrip": false,
|
| 22 |
+
"normalized": false,
|
| 23 |
+
"rstrip": false,
|
| 24 |
+
"single_word": false,
|
| 25 |
+
"special": true
|
| 26 |
+
},
|
| 27 |
+
"3": {
|
| 28 |
+
"content": "<unk>",
|
| 29 |
+
"lstrip": false,
|
| 30 |
+
"normalized": false,
|
| 31 |
+
"rstrip": false,
|
| 32 |
+
"single_word": false,
|
| 33 |
+
"special": true
|
| 34 |
+
},
|
| 35 |
+
"64001": {
|
| 36 |
+
"content": "<mask>",
|
| 37 |
+
"lstrip": true,
|
| 38 |
+
"normalized": false,
|
| 39 |
+
"rstrip": false,
|
| 40 |
+
"single_word": false,
|
| 41 |
+
"special": true
|
| 42 |
+
}
|
| 43 |
+
},
|
| 44 |
+
"bos_token": "<s>",
|
| 45 |
+
"clean_up_tokenization_spaces": true,
|
| 46 |
+
"cls_token": "<s>",
|
| 47 |
+
"eos_token": "</s>",
|
| 48 |
+
"mask_token": "<mask>",
|
| 49 |
+
"model_max_length": 1000000000000000019884624838656,
|
| 50 |
+
"pad_token": "<pad>",
|
| 51 |
+
"padding_side": "right",
|
| 52 |
+
"sep_token": "</s>",
|
| 53 |
+
"sp_model_kwargs": {},
|
| 54 |
+
"tokenizer_class": "XLMRobertaTokenizer",
|
| 55 |
+
"unk_token": "<unk>",
|
| 56 |
+
"use_fast": false
|
| 57 |
+
}
|
ComfyUI/models/Joy_caption/cgrkzexw-599808/clip_model.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9277e041aab3e7f20a8e6ecf7248b663aac1c281daf4472c12a6e5013cf9f0cc
|
| 3 |
+
size 1713067838
|
ComfyUI/models/Joy_caption/cgrkzexw-599808/clip_model.pt.baiduyun.uploading.cfg
ADDED
|
Binary file (42.9 kB). View file
|
|
|
ComfyUI/models/Joy_caption/cgrkzexw-599808/config.yaml
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
wandb_project: joy-caption-1
|
| 2 |
+
device_batch_size: 2
|
| 3 |
+
batch_size: 256
|
| 4 |
+
learning_rate: 0.0002
|
| 5 |
+
warmup_samples: 18000
|
| 6 |
+
max_samples: 600000
|
| 7 |
+
save_every: 50000
|
| 8 |
+
test_every: 50000
|
| 9 |
+
use_amp: true
|
| 10 |
+
grad_scaler: true
|
| 11 |
+
lr_scheduler_type: cosine
|
| 12 |
+
min_lr_ratio: 0.0
|
| 13 |
+
allow_tf32: true
|
| 14 |
+
seed: 69
|
| 15 |
+
num_workers: 8
|
| 16 |
+
optimizer_type: adamw
|
| 17 |
+
adam_beta1: 0.9
|
| 18 |
+
adam_beta2: 0.999
|
| 19 |
+
adam_eps: 1.0e-08
|
| 20 |
+
adam_weight_decay: 0.0
|
| 21 |
+
clip_grad_norm: 1.0
|
| 22 |
+
dataset: fancyfeast/joy-captioning-20240924a
|
| 23 |
+
clip_model: google/siglip-so400m-patch14-384
|
| 24 |
+
text_model: ../lora-train/lora_model_vwbzycxh
|
| 25 |
+
resume: null
|
| 26 |
+
gradient_checkpointing: false
|
| 27 |
+
test_size: 2048
|
| 28 |
+
grad_scaler_init: 65536.0
|
| 29 |
+
max_caption_length: 257
|
| 30 |
+
num_image_tokens: 32
|
| 31 |
+
adapter_type: mlp
|
| 32 |
+
text_model_dtype: bfloat16
|
| 33 |
+
pre_test: false
|
| 34 |
+
train_image_model: true
|
| 35 |
+
image_model_lr: null
|
| 36 |
+
train_lora: true
|
| 37 |
+
lora_r: 64
|
| 38 |
+
lora_alpha: 16
|
| 39 |
+
lora_dropout: 0.1
|
ComfyUI/models/Joy_caption/cgrkzexw-599808/image_adapter.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:38db2fe263be2d494a50be4a7bbfd7b23b76f9d03e4008a1b7df97d6b27894ef
|
| 3 |
+
size 86067714
|
ComfyUI/models/Joy_caption/cgrkzexw-599808/text_model/README.md
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
base_model: unsloth/Meta-Llama-3.1-8B-Instruct
|
| 3 |
+
library_name: peft
|
| 4 |
+
---
|
| 5 |
+
|
| 6 |
+
# Model Card for Model ID
|
| 7 |
+
|
| 8 |
+
<!-- Provide a quick summary of what the model is/does. -->
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
## Model Details
|
| 13 |
+
|
| 14 |
+
### Model Description
|
| 15 |
+
|
| 16 |
+
<!-- Provide a longer summary of what this model is. -->
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
- **Developed by:** [More Information Needed]
|
| 21 |
+
- **Funded by [optional]:** [More Information Needed]
|
| 22 |
+
- **Shared by [optional]:** [More Information Needed]
|
| 23 |
+
- **Model type:** [More Information Needed]
|
| 24 |
+
- **Language(s) (NLP):** [More Information Needed]
|
| 25 |
+
- **License:** [More Information Needed]
|
| 26 |
+
- **Finetuned from model [optional]:** [More Information Needed]
|
| 27 |
+
|
| 28 |
+
### Model Sources [optional]
|
| 29 |
+
|
| 30 |
+
<!-- Provide the basic links for the model. -->
|
| 31 |
+
|
| 32 |
+
- **Repository:** [More Information Needed]
|
| 33 |
+
- **Paper [optional]:** [More Information Needed]
|
| 34 |
+
- **Demo [optional]:** [More Information Needed]
|
| 35 |
+
|
| 36 |
+
## Uses
|
| 37 |
+
|
| 38 |
+
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
| 39 |
+
|
| 40 |
+
### Direct Use
|
| 41 |
+
|
| 42 |
+
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
|
| 43 |
+
|
| 44 |
+
[More Information Needed]
|
| 45 |
+
|
| 46 |
+
### Downstream Use [optional]
|
| 47 |
+
|
| 48 |
+
<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
|
| 49 |
+
|
| 50 |
+
[More Information Needed]
|
| 51 |
+
|
| 52 |
+
### Out-of-Scope Use
|
| 53 |
+
|
| 54 |
+
<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
|
| 55 |
+
|
| 56 |
+
[More Information Needed]
|
| 57 |
+
|
| 58 |
+
## Bias, Risks, and Limitations
|
| 59 |
+
|
| 60 |
+
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
| 61 |
+
|
| 62 |
+
[More Information Needed]
|
| 63 |
+
|
| 64 |
+
### Recommendations
|
| 65 |
+
|
| 66 |
+
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
| 67 |
+
|
| 68 |
+
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
| 69 |
+
|
| 70 |
+
## How to Get Started with the Model
|
| 71 |
+
|
| 72 |
+
Use the code below to get started with the model.
|
| 73 |
+
|
| 74 |
+
[More Information Needed]
|
| 75 |
+
|
| 76 |
+
## Training Details
|
| 77 |
+
|
| 78 |
+
### Training Data
|
| 79 |
+
|
| 80 |
+
<!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
|
| 81 |
+
|
| 82 |
+
[More Information Needed]
|
| 83 |
+
|
| 84 |
+
### Training Procedure
|
| 85 |
+
|
| 86 |
+
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
| 87 |
+
|
| 88 |
+
#### Preprocessing [optional]
|
| 89 |
+
|
| 90 |
+
[More Information Needed]
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
#### Training Hyperparameters
|
| 94 |
+
|
| 95 |
+
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
| 96 |
+
|
| 97 |
+
#### Speeds, Sizes, Times [optional]
|
| 98 |
+
|
| 99 |
+
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
| 100 |
+
|
| 101 |
+
[More Information Needed]
|
| 102 |
+
|
| 103 |
+
## Evaluation
|
| 104 |
+
|
| 105 |
+
<!-- This section describes the evaluation protocols and provides the results. -->
|
| 106 |
+
|
| 107 |
+
### Testing Data, Factors & Metrics
|
| 108 |
+
|
| 109 |
+
#### Testing Data
|
| 110 |
+
|
| 111 |
+
<!-- This should link to a Dataset Card if possible. -->
|
| 112 |
+
|
| 113 |
+
[More Information Needed]
|
| 114 |
+
|
| 115 |
+
#### Factors
|
| 116 |
+
|
| 117 |
+
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
| 118 |
+
|
| 119 |
+
[More Information Needed]
|
| 120 |
+
|
| 121 |
+
#### Metrics
|
| 122 |
+
|
| 123 |
+
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
| 124 |
+
|
| 125 |
+
[More Information Needed]
|
| 126 |
+
|
| 127 |
+
### Results
|
| 128 |
+
|
| 129 |
+
[More Information Needed]
|
| 130 |
+
|
| 131 |
+
#### Summary
|
| 132 |
+
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
## Model Examination [optional]
|
| 136 |
+
|
| 137 |
+
<!-- Relevant interpretability work for the model goes here -->
|
| 138 |
+
|
| 139 |
+
[More Information Needed]
|
| 140 |
+
|
| 141 |
+
## Environmental Impact
|
| 142 |
+
|
| 143 |
+
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
| 144 |
+
|
| 145 |
+
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
| 146 |
+
|
| 147 |
+
- **Hardware Type:** [More Information Needed]
|
| 148 |
+
- **Hours used:** [More Information Needed]
|
| 149 |
+
- **Cloud Provider:** [More Information Needed]
|
| 150 |
+
- **Compute Region:** [More Information Needed]
|
| 151 |
+
- **Carbon Emitted:** [More Information Needed]
|
| 152 |
+
|
| 153 |
+
## Technical Specifications [optional]
|
| 154 |
+
|
| 155 |
+
### Model Architecture and Objective
|
| 156 |
+
|
| 157 |
+
[More Information Needed]
|
| 158 |
+
|
| 159 |
+
### Compute Infrastructure
|
| 160 |
+
|
| 161 |
+
[More Information Needed]
|
| 162 |
+
|
| 163 |
+
#### Hardware
|
| 164 |
+
|
| 165 |
+
[More Information Needed]
|
| 166 |
+
|
| 167 |
+
#### Software
|
| 168 |
+
|
| 169 |
+
[More Information Needed]
|
| 170 |
+
|
| 171 |
+
## Citation [optional]
|
| 172 |
+
|
| 173 |
+
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
| 174 |
+
|
| 175 |
+
**BibTeX:**
|
| 176 |
+
|
| 177 |
+
[More Information Needed]
|
| 178 |
+
|
| 179 |
+
**APA:**
|
| 180 |
+
|
| 181 |
+
[More Information Needed]
|
| 182 |
+
|
| 183 |
+
## Glossary [optional]
|
| 184 |
+
|
| 185 |
+
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
| 186 |
+
|
| 187 |
+
[More Information Needed]
|
| 188 |
+
|
| 189 |
+
## More Information [optional]
|
| 190 |
+
|
| 191 |
+
[More Information Needed]
|
| 192 |
+
|
| 193 |
+
## Model Card Authors [optional]
|
| 194 |
+
|
| 195 |
+
[More Information Needed]
|
| 196 |
+
|
| 197 |
+
## Model Card Contact
|
| 198 |
+
|
| 199 |
+
[More Information Needed]
|
| 200 |
+
### Framework versions
|
| 201 |
+
|
| 202 |
+
- PEFT 0.12.0
|
ComfyUI/models/Joy_caption/cgrkzexw-599808/text_model/adapter_config.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"alpha_pattern": {},
|
| 3 |
+
"auto_mapping": null,
|
| 4 |
+
"base_model_name_or_path": "unsloth/Meta-Llama-3.1-8B-Instruct",
|
| 5 |
+
"bias": "none",
|
| 6 |
+
"fan_in_fan_out": false,
|
| 7 |
+
"inference_mode": true,
|
| 8 |
+
"init_lora_weights": true,
|
| 9 |
+
"layer_replication": null,
|
| 10 |
+
"layers_pattern": null,
|
| 11 |
+
"layers_to_transform": null,
|
| 12 |
+
"loftq_config": {},
|
| 13 |
+
"lora_alpha": 16,
|
| 14 |
+
"lora_dropout": 0,
|
| 15 |
+
"megatron_config": null,
|
| 16 |
+
"megatron_core": "megatron.core",
|
| 17 |
+
"modules_to_save": null,
|
| 18 |
+
"peft_type": "LORA",
|
| 19 |
+
"r": 64,
|
| 20 |
+
"rank_pattern": {},
|
| 21 |
+
"revision": null,
|
| 22 |
+
"target_modules": [
|
| 23 |
+
"q_proj",
|
| 24 |
+
"v_proj",
|
| 25 |
+
"gate_proj",
|
| 26 |
+
"down_proj",
|
| 27 |
+
"o_proj",
|
| 28 |
+
"k_proj",
|
| 29 |
+
"up_proj"
|
| 30 |
+
],
|
| 31 |
+
"task_type": "CAUSAL_LM",
|
| 32 |
+
"use_dora": false,
|
| 33 |
+
"use_rslora": false
|
| 34 |
+
}
|
ComfyUI/models/Joy_caption/cgrkzexw-599808/text_model/adapter_model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:dd883ebd089f87e0fab7f17960c5f4451ceae43aecead44a9984b3369018dbdb
|
| 3 |
+
size 671149168
|
ComfyUI/models/Joy_caption/cgrkzexw-599808/text_model/special_tokens_map.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"bos_token": {
|
| 3 |
+
"content": "<|begin_of_text|>",
|
| 4 |
+
"lstrip": false,
|
| 5 |
+
"normalized": false,
|
| 6 |
+
"rstrip": false,
|
| 7 |
+
"single_word": false
|
| 8 |
+
},
|
| 9 |
+
"eos_token": {
|
| 10 |
+
"content": "<|eot_id|>",
|
| 11 |
+
"lstrip": false,
|
| 12 |
+
"normalized": false,
|
| 13 |
+
"rstrip": false,
|
| 14 |
+
"single_word": false
|
| 15 |
+
},
|
| 16 |
+
"pad_token": {
|
| 17 |
+
"content": "<|finetune_right_pad_id|>",
|
| 18 |
+
"lstrip": false,
|
| 19 |
+
"normalized": false,
|
| 20 |
+
"rstrip": false,
|
| 21 |
+
"single_word": false
|
| 22 |
+
}
|
| 23 |
+
}
|
ComfyUI/models/Joy_caption/cgrkzexw-599808/text_model/tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
ComfyUI/models/Joy_caption/cgrkzexw-599808/text_model/tokenizer_config.json
ADDED
|
@@ -0,0 +1,2064 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"added_tokens_decoder": {
|
| 3 |
+
"128000": {
|
| 4 |
+
"content": "<|begin_of_text|>",
|
| 5 |
+
"lstrip": false,
|
| 6 |
+
"normalized": false,
|
| 7 |
+
"rstrip": false,
|
| 8 |
+
"single_word": false,
|
| 9 |
+
"special": true
|
| 10 |
+
},
|
| 11 |
+
"128001": {
|
| 12 |
+
"content": "<|end_of_text|>",
|
| 13 |
+
"lstrip": false,
|
| 14 |
+
"normalized": false,
|
| 15 |
+
"rstrip": false,
|
| 16 |
+
"single_word": false,
|
| 17 |
+
"special": true
|
| 18 |
+
},
|
| 19 |
+
"128002": {
|
| 20 |
+
"content": "<|reserved_special_token_0|>",
|
| 21 |
+
"lstrip": false,
|
| 22 |
+
"normalized": false,
|
| 23 |
+
"rstrip": false,
|
| 24 |
+
"single_word": false,
|
| 25 |
+
"special": true
|
| 26 |
+
},
|
| 27 |
+
"128003": {
|
| 28 |
+
"content": "<|reserved_special_token_1|>",
|
| 29 |
+
"lstrip": false,
|
| 30 |
+
"normalized": false,
|
| 31 |
+
"rstrip": false,
|
| 32 |
+
"single_word": false,
|
| 33 |
+
"special": true
|
| 34 |
+
},
|
| 35 |
+
"128004": {
|
| 36 |
+
"content": "<|finetune_right_pad_id|>",
|
| 37 |
+
"lstrip": false,
|
| 38 |
+
"normalized": false,
|
| 39 |
+
"rstrip": false,
|
| 40 |
+
"single_word": false,
|
| 41 |
+
"special": true
|
| 42 |
+
},
|
| 43 |
+
"128005": {
|
| 44 |
+
"content": "<|reserved_special_token_2|>",
|
| 45 |
+
"lstrip": false,
|
| 46 |
+
"normalized": false,
|
| 47 |
+
"rstrip": false,
|
| 48 |
+
"single_word": false,
|
| 49 |
+
"special": true
|
| 50 |
+
},
|
| 51 |
+
"128006": {
|
| 52 |
+
"content": "<|start_header_id|>",
|
| 53 |
+
"lstrip": false,
|
| 54 |
+
"normalized": false,
|
| 55 |
+
"rstrip": false,
|
| 56 |
+
"single_word": false,
|
| 57 |
+
"special": true
|
| 58 |
+
},
|
| 59 |
+
"128007": {
|
| 60 |
+
"content": "<|end_header_id|>",
|
| 61 |
+
"lstrip": false,
|
| 62 |
+
"normalized": false,
|
| 63 |
+
"rstrip": false,
|
| 64 |
+
"single_word": false,
|
| 65 |
+
"special": true
|
| 66 |
+
},
|
| 67 |
+
"128008": {
|
| 68 |
+
"content": "<|eom_id|>",
|
| 69 |
+
"lstrip": false,
|
| 70 |
+
"normalized": false,
|
| 71 |
+
"rstrip": false,
|
| 72 |
+
"single_word": false,
|
| 73 |
+
"special": true
|
| 74 |
+
},
|
| 75 |
+
"128009": {
|
| 76 |
+
"content": "<|eot_id|>",
|
| 77 |
+
"lstrip": false,
|
| 78 |
+
"normalized": false,
|
| 79 |
+
"rstrip": false,
|
| 80 |
+
"single_word": false,
|
| 81 |
+
"special": true
|
| 82 |
+
},
|
| 83 |
+
"128010": {
|
| 84 |
+
"content": "<|python_tag|>",
|
| 85 |
+
"lstrip": false,
|
| 86 |
+
"normalized": false,
|
| 87 |
+
"rstrip": false,
|
| 88 |
+
"single_word": false,
|
| 89 |
+
"special": true
|
| 90 |
+
},
|
| 91 |
+
"128011": {
|
| 92 |
+
"content": "<|reserved_special_token_3|>",
|
| 93 |
+
"lstrip": false,
|
| 94 |
+
"normalized": false,
|
| 95 |
+
"rstrip": false,
|
| 96 |
+
"single_word": false,
|
| 97 |
+
"special": true
|
| 98 |
+
},
|
| 99 |
+
"128012": {
|
| 100 |
+
"content": "<|reserved_special_token_4|>",
|
| 101 |
+
"lstrip": false,
|
| 102 |
+
"normalized": false,
|
| 103 |
+
"rstrip": false,
|
| 104 |
+
"single_word": false,
|
| 105 |
+
"special": true
|
| 106 |
+
},
|
| 107 |
+
"128013": {
|
| 108 |
+
"content": "<|reserved_special_token_5|>",
|
| 109 |
+
"lstrip": false,
|
| 110 |
+
"normalized": false,
|
| 111 |
+
"rstrip": false,
|
| 112 |
+
"single_word": false,
|
| 113 |
+
"special": true
|
| 114 |
+
},
|
| 115 |
+
"128014": {
|
| 116 |
+
"content": "<|reserved_special_token_6|>",
|
| 117 |
+
"lstrip": false,
|
| 118 |
+
"normalized": false,
|
| 119 |
+
"rstrip": false,
|
| 120 |
+
"single_word": false,
|
| 121 |
+
"special": true
|
| 122 |
+
},
|
| 123 |
+
"128015": {
|
| 124 |
+
"content": "<|reserved_special_token_7|>",
|
| 125 |
+
"lstrip": false,
|
| 126 |
+
"normalized": false,
|
| 127 |
+
"rstrip": false,
|
| 128 |
+
"single_word": false,
|
| 129 |
+
"special": true
|
| 130 |
+
},
|
| 131 |
+
"128016": {
|
| 132 |
+
"content": "<|reserved_special_token_8|>",
|
| 133 |
+
"lstrip": false,
|
| 134 |
+
"normalized": false,
|
| 135 |
+
"rstrip": false,
|
| 136 |
+
"single_word": false,
|
| 137 |
+
"special": true
|
| 138 |
+
},
|
| 139 |
+
"128017": {
|
| 140 |
+
"content": "<|reserved_special_token_9|>",
|
| 141 |
+
"lstrip": false,
|
| 142 |
+
"normalized": false,
|
| 143 |
+
"rstrip": false,
|
| 144 |
+
"single_word": false,
|
| 145 |
+
"special": true
|
| 146 |
+
},
|
| 147 |
+
"128018": {
|
| 148 |
+
"content": "<|reserved_special_token_10|>",
|
| 149 |
+
"lstrip": false,
|
| 150 |
+
"normalized": false,
|
| 151 |
+
"rstrip": false,
|
| 152 |
+
"single_word": false,
|
| 153 |
+
"special": true
|
| 154 |
+
},
|
| 155 |
+
"128019": {
|
| 156 |
+
"content": "<|reserved_special_token_11|>",
|
| 157 |
+
"lstrip": false,
|
| 158 |
+
"normalized": false,
|
| 159 |
+
"rstrip": false,
|
| 160 |
+
"single_word": false,
|
| 161 |
+
"special": true
|
| 162 |
+
},
|
| 163 |
+
"128020": {
|
| 164 |
+
"content": "<|reserved_special_token_12|>",
|
| 165 |
+
"lstrip": false,
|
| 166 |
+
"normalized": false,
|
| 167 |
+
"rstrip": false,
|
| 168 |
+
"single_word": false,
|
| 169 |
+
"special": true
|
| 170 |
+
},
|
| 171 |
+
"128021": {
|
| 172 |
+
"content": "<|reserved_special_token_13|>",
|
| 173 |
+
"lstrip": false,
|
| 174 |
+
"normalized": false,
|
| 175 |
+
"rstrip": false,
|
| 176 |
+
"single_word": false,
|
| 177 |
+
"special": true
|
| 178 |
+
},
|
| 179 |
+
"128022": {
|
| 180 |
+
"content": "<|reserved_special_token_14|>",
|
| 181 |
+
"lstrip": false,
|
| 182 |
+
"normalized": false,
|
| 183 |
+
"rstrip": false,
|
| 184 |
+
"single_word": false,
|
| 185 |
+
"special": true
|
| 186 |
+
},
|
| 187 |
+
"128023": {
|
| 188 |
+
"content": "<|reserved_special_token_15|>",
|
| 189 |
+
"lstrip": false,
|
| 190 |
+
"normalized": false,
|
| 191 |
+
"rstrip": false,
|
| 192 |
+
"single_word": false,
|
| 193 |
+
"special": true
|
| 194 |
+
},
|
| 195 |
+
"128024": {
|
| 196 |
+
"content": "<|reserved_special_token_16|>",
|
| 197 |
+
"lstrip": false,
|
| 198 |
+
"normalized": false,
|
| 199 |
+
"rstrip": false,
|
| 200 |
+
"single_word": false,
|
| 201 |
+
"special": true
|
| 202 |
+
},
|
| 203 |
+
"128025": {
|
| 204 |
+
"content": "<|reserved_special_token_17|>",
|
| 205 |
+
"lstrip": false,
|
| 206 |
+
"normalized": false,
|
| 207 |
+
"rstrip": false,
|
| 208 |
+
"single_word": false,
|
| 209 |
+
"special": true
|
| 210 |
+
},
|
| 211 |
+
"128026": {
|
| 212 |
+
"content": "<|reserved_special_token_18|>",
|
| 213 |
+
"lstrip": false,
|
| 214 |
+
"normalized": false,
|
| 215 |
+
"rstrip": false,
|
| 216 |
+
"single_word": false,
|
| 217 |
+
"special": true
|
| 218 |
+
},
|
| 219 |
+
"128027": {
|
| 220 |
+
"content": "<|reserved_special_token_19|>",
|
| 221 |
+
"lstrip": false,
|
| 222 |
+
"normalized": false,
|
| 223 |
+
"rstrip": false,
|
| 224 |
+
"single_word": false,
|
| 225 |
+
"special": true
|
| 226 |
+
},
|
| 227 |
+
"128028": {
|
| 228 |
+
"content": "<|reserved_special_token_20|>",
|
| 229 |
+
"lstrip": false,
|
| 230 |
+
"normalized": false,
|
| 231 |
+
"rstrip": false,
|
| 232 |
+
"single_word": false,
|
| 233 |
+
"special": true
|
| 234 |
+
},
|
| 235 |
+
"128029": {
|
| 236 |
+
"content": "<|reserved_special_token_21|>",
|
| 237 |
+
"lstrip": false,
|
| 238 |
+
"normalized": false,
|
| 239 |
+
"rstrip": false,
|
| 240 |
+
"single_word": false,
|
| 241 |
+
"special": true
|
| 242 |
+
},
|
| 243 |
+
"128030": {
|
| 244 |
+
"content": "<|reserved_special_token_22|>",
|
| 245 |
+
"lstrip": false,
|
| 246 |
+
"normalized": false,
|
| 247 |
+
"rstrip": false,
|
| 248 |
+
"single_word": false,
|
| 249 |
+
"special": true
|
| 250 |
+
},
|
| 251 |
+
"128031": {
|
| 252 |
+
"content": "<|reserved_special_token_23|>",
|
| 253 |
+
"lstrip": false,
|
| 254 |
+
"normalized": false,
|
| 255 |
+
"rstrip": false,
|
| 256 |
+
"single_word": false,
|
| 257 |
+
"special": true
|
| 258 |
+
},
|
| 259 |
+
"128032": {
|
| 260 |
+
"content": "<|reserved_special_token_24|>",
|
| 261 |
+
"lstrip": false,
|
| 262 |
+
"normalized": false,
|
| 263 |
+
"rstrip": false,
|
| 264 |
+
"single_word": false,
|
| 265 |
+
"special": true
|
| 266 |
+
},
|
| 267 |
+
"128033": {
|
| 268 |
+
"content": "<|reserved_special_token_25|>",
|
| 269 |
+
"lstrip": false,
|
| 270 |
+
"normalized": false,
|
| 271 |
+
"rstrip": false,
|
| 272 |
+
"single_word": false,
|
| 273 |
+
"special": true
|
| 274 |
+
},
|
| 275 |
+
"128034": {
|
| 276 |
+
"content": "<|reserved_special_token_26|>",
|
| 277 |
+
"lstrip": false,
|
| 278 |
+
"normalized": false,
|
| 279 |
+
"rstrip": false,
|
| 280 |
+
"single_word": false,
|
| 281 |
+
"special": true
|
| 282 |
+
},
|
| 283 |
+
"128035": {
|
| 284 |
+
"content": "<|reserved_special_token_27|>",
|
| 285 |
+
"lstrip": false,
|
| 286 |
+
"normalized": false,
|
| 287 |
+
"rstrip": false,
|
| 288 |
+
"single_word": false,
|
| 289 |
+
"special": true
|
| 290 |
+
},
|
| 291 |
+
"128036": {
|
| 292 |
+
"content": "<|reserved_special_token_28|>",
|
| 293 |
+
"lstrip": false,
|
| 294 |
+
"normalized": false,
|
| 295 |
+
"rstrip": false,
|
| 296 |
+
"single_word": false,
|
| 297 |
+
"special": true
|
| 298 |
+
},
|
| 299 |
+
"128037": {
|
| 300 |
+
"content": "<|reserved_special_token_29|>",
|
| 301 |
+
"lstrip": false,
|
| 302 |
+
"normalized": false,
|
| 303 |
+
"rstrip": false,
|
| 304 |
+
"single_word": false,
|
| 305 |
+
"special": true
|
| 306 |
+
},
|
| 307 |
+
"128038": {
|
| 308 |
+
"content": "<|reserved_special_token_30|>",
|
| 309 |
+
"lstrip": false,
|
| 310 |
+
"normalized": false,
|
| 311 |
+
"rstrip": false,
|
| 312 |
+
"single_word": false,
|
| 313 |
+
"special": true
|
| 314 |
+
},
|
| 315 |
+
"128039": {
|
| 316 |
+
"content": "<|reserved_special_token_31|>",
|
| 317 |
+
"lstrip": false,
|
| 318 |
+
"normalized": false,
|
| 319 |
+
"rstrip": false,
|
| 320 |
+
"single_word": false,
|
| 321 |
+
"special": true
|
| 322 |
+
},
|
| 323 |
+
"128040": {
|
| 324 |
+
"content": "<|reserved_special_token_32|>",
|
| 325 |
+
"lstrip": false,
|
| 326 |
+
"normalized": false,
|
| 327 |
+
"rstrip": false,
|
| 328 |
+
"single_word": false,
|
| 329 |
+
"special": true
|
| 330 |
+
},
|
| 331 |
+
"128041": {
|
| 332 |
+
"content": "<|reserved_special_token_33|>",
|
| 333 |
+
"lstrip": false,
|
| 334 |
+
"normalized": false,
|
| 335 |
+
"rstrip": false,
|
| 336 |
+
"single_word": false,
|
| 337 |
+
"special": true
|
| 338 |
+
},
|
| 339 |
+
"128042": {
|
| 340 |
+
"content": "<|reserved_special_token_34|>",
|
| 341 |
+
"lstrip": false,
|
| 342 |
+
"normalized": false,
|
| 343 |
+
"rstrip": false,
|
| 344 |
+
"single_word": false,
|
| 345 |
+
"special": true
|
| 346 |
+
},
|
| 347 |
+
"128043": {
|
| 348 |
+
"content": "<|reserved_special_token_35|>",
|
| 349 |
+
"lstrip": false,
|
| 350 |
+
"normalized": false,
|
| 351 |
+
"rstrip": false,
|
| 352 |
+
"single_word": false,
|
| 353 |
+
"special": true
|
| 354 |
+
},
|
| 355 |
+
"128044": {
|
| 356 |
+
"content": "<|reserved_special_token_36|>",
|
| 357 |
+
"lstrip": false,
|
| 358 |
+
"normalized": false,
|
| 359 |
+
"rstrip": false,
|
| 360 |
+
"single_word": false,
|
| 361 |
+
"special": true
|
| 362 |
+
},
|
| 363 |
+
"128045": {
|
| 364 |
+
"content": "<|reserved_special_token_37|>",
|
| 365 |
+
"lstrip": false,
|
| 366 |
+
"normalized": false,
|
| 367 |
+
"rstrip": false,
|
| 368 |
+
"single_word": false,
|
| 369 |
+
"special": true
|
| 370 |
+
},
|
| 371 |
+
"128046": {
|
| 372 |
+
"content": "<|reserved_special_token_38|>",
|
| 373 |
+
"lstrip": false,
|
| 374 |
+
"normalized": false,
|
| 375 |
+
"rstrip": false,
|
| 376 |
+
"single_word": false,
|
| 377 |
+
"special": true
|
| 378 |
+
},
|
| 379 |
+
"128047": {
|
| 380 |
+
"content": "<|reserved_special_token_39|>",
|
| 381 |
+
"lstrip": false,
|
| 382 |
+
"normalized": false,
|
| 383 |
+
"rstrip": false,
|
| 384 |
+
"single_word": false,
|
| 385 |
+
"special": true
|
| 386 |
+
},
|
| 387 |
+
"128048": {
|
| 388 |
+
"content": "<|reserved_special_token_40|>",
|
| 389 |
+
"lstrip": false,
|
| 390 |
+
"normalized": false,
|
| 391 |
+
"rstrip": false,
|
| 392 |
+
"single_word": false,
|
| 393 |
+
"special": true
|
| 394 |
+
},
|
| 395 |
+
"128049": {
|
| 396 |
+
"content": "<|reserved_special_token_41|>",
|
| 397 |
+
"lstrip": false,
|
| 398 |
+
"normalized": false,
|
| 399 |
+
"rstrip": false,
|
| 400 |
+
"single_word": false,
|
| 401 |
+
"special": true
|
| 402 |
+
},
|
| 403 |
+
"128050": {
|
| 404 |
+
"content": "<|reserved_special_token_42|>",
|
| 405 |
+
"lstrip": false,
|
| 406 |
+
"normalized": false,
|
| 407 |
+
"rstrip": false,
|
| 408 |
+
"single_word": false,
|
| 409 |
+
"special": true
|
| 410 |
+
},
|
| 411 |
+
"128051": {
|
| 412 |
+
"content": "<|reserved_special_token_43|>",
|
| 413 |
+
"lstrip": false,
|
| 414 |
+
"normalized": false,
|
| 415 |
+
"rstrip": false,
|
| 416 |
+
"single_word": false,
|
| 417 |
+
"special": true
|
| 418 |
+
},
|
| 419 |
+
"128052": {
|
| 420 |
+
"content": "<|reserved_special_token_44|>",
|
| 421 |
+
"lstrip": false,
|
| 422 |
+
"normalized": false,
|
| 423 |
+
"rstrip": false,
|
| 424 |
+
"single_word": false,
|
| 425 |
+
"special": true
|
| 426 |
+
},
|
| 427 |
+
"128053": {
|
| 428 |
+
"content": "<|reserved_special_token_45|>",
|
| 429 |
+
"lstrip": false,
|
| 430 |
+
"normalized": false,
|
| 431 |
+
"rstrip": false,
|
| 432 |
+
"single_word": false,
|
| 433 |
+
"special": true
|
| 434 |
+
},
|
| 435 |
+
"128054": {
|
| 436 |
+
"content": "<|reserved_special_token_46|>",
|
| 437 |
+
"lstrip": false,
|
| 438 |
+
"normalized": false,
|
| 439 |
+
"rstrip": false,
|
| 440 |
+
"single_word": false,
|
| 441 |
+
"special": true
|
| 442 |
+
},
|
| 443 |
+
"128055": {
|
| 444 |
+
"content": "<|reserved_special_token_47|>",
|
| 445 |
+
"lstrip": false,
|
| 446 |
+
"normalized": false,
|
| 447 |
+
"rstrip": false,
|
| 448 |
+
"single_word": false,
|
| 449 |
+
"special": true
|
| 450 |
+
},
|
| 451 |
+
"128056": {
|
| 452 |
+
"content": "<|reserved_special_token_48|>",
|
| 453 |
+
"lstrip": false,
|
| 454 |
+
"normalized": false,
|
| 455 |
+
"rstrip": false,
|
| 456 |
+
"single_word": false,
|
| 457 |
+
"special": true
|
| 458 |
+
},
|
| 459 |
+
"128057": {
|
| 460 |
+
"content": "<|reserved_special_token_49|>",
|
| 461 |
+
"lstrip": false,
|
| 462 |
+
"normalized": false,
|
| 463 |
+
"rstrip": false,
|
| 464 |
+
"single_word": false,
|
| 465 |
+
"special": true
|
| 466 |
+
},
|
| 467 |
+
"128058": {
|
| 468 |
+
"content": "<|reserved_special_token_50|>",
|
| 469 |
+
"lstrip": false,
|
| 470 |
+
"normalized": false,
|
| 471 |
+
"rstrip": false,
|
| 472 |
+
"single_word": false,
|
| 473 |
+
"special": true
|
| 474 |
+
},
|
| 475 |
+
"128059": {
|
| 476 |
+
"content": "<|reserved_special_token_51|>",
|
| 477 |
+
"lstrip": false,
|
| 478 |
+
"normalized": false,
|
| 479 |
+
"rstrip": false,
|
| 480 |
+
"single_word": false,
|
| 481 |
+
"special": true
|
| 482 |
+
},
|
| 483 |
+
"128060": {
|
| 484 |
+
"content": "<|reserved_special_token_52|>",
|
| 485 |
+
"lstrip": false,
|
| 486 |
+
"normalized": false,
|
| 487 |
+
"rstrip": false,
|
| 488 |
+
"single_word": false,
|
| 489 |
+
"special": true
|
| 490 |
+
},
|
| 491 |
+
"128061": {
|
| 492 |
+
"content": "<|reserved_special_token_53|>",
|
| 493 |
+
"lstrip": false,
|
| 494 |
+
"normalized": false,
|
| 495 |
+
"rstrip": false,
|
| 496 |
+
"single_word": false,
|
| 497 |
+
"special": true
|
| 498 |
+
},
|
| 499 |
+
"128062": {
|
| 500 |
+
"content": "<|reserved_special_token_54|>",
|
| 501 |
+
"lstrip": false,
|
| 502 |
+
"normalized": false,
|
| 503 |
+
"rstrip": false,
|
| 504 |
+
"single_word": false,
|
| 505 |
+
"special": true
|
| 506 |
+
},
|
| 507 |
+
"128063": {
|
| 508 |
+
"content": "<|reserved_special_token_55|>",
|
| 509 |
+
"lstrip": false,
|
| 510 |
+
"normalized": false,
|
| 511 |
+
"rstrip": false,
|
| 512 |
+
"single_word": false,
|
| 513 |
+
"special": true
|
| 514 |
+
},
|
| 515 |
+
"128064": {
|
| 516 |
+
"content": "<|reserved_special_token_56|>",
|
| 517 |
+
"lstrip": false,
|
| 518 |
+
"normalized": false,
|
| 519 |
+
"rstrip": false,
|
| 520 |
+
"single_word": false,
|
| 521 |
+
"special": true
|
| 522 |
+
},
|
| 523 |
+
"128065": {
|
| 524 |
+
"content": "<|reserved_special_token_57|>",
|
| 525 |
+
"lstrip": false,
|
| 526 |
+
"normalized": false,
|
| 527 |
+
"rstrip": false,
|
| 528 |
+
"single_word": false,
|
| 529 |
+
"special": true
|
| 530 |
+
},
|
| 531 |
+
"128066": {
|
| 532 |
+
"content": "<|reserved_special_token_58|>",
|
| 533 |
+
"lstrip": false,
|
| 534 |
+
"normalized": false,
|
| 535 |
+
"rstrip": false,
|
| 536 |
+
"single_word": false,
|
| 537 |
+
"special": true
|
| 538 |
+
},
|
| 539 |
+
"128067": {
|
| 540 |
+
"content": "<|reserved_special_token_59|>",
|
| 541 |
+
"lstrip": false,
|
| 542 |
+
"normalized": false,
|
| 543 |
+
"rstrip": false,
|
| 544 |
+
"single_word": false,
|
| 545 |
+
"special": true
|
| 546 |
+
},
|
| 547 |
+
"128068": {
|
| 548 |
+
"content": "<|reserved_special_token_60|>",
|
| 549 |
+
"lstrip": false,
|
| 550 |
+
"normalized": false,
|
| 551 |
+
"rstrip": false,
|
| 552 |
+
"single_word": false,
|
| 553 |
+
"special": true
|
| 554 |
+
},
|
| 555 |
+
"128069": {
|
| 556 |
+
"content": "<|reserved_special_token_61|>",
|
| 557 |
+
"lstrip": false,
|
| 558 |
+
"normalized": false,
|
| 559 |
+
"rstrip": false,
|
| 560 |
+
"single_word": false,
|
| 561 |
+
"special": true
|
| 562 |
+
},
|
| 563 |
+
"128070": {
|
| 564 |
+
"content": "<|reserved_special_token_62|>",
|
| 565 |
+
"lstrip": false,
|
| 566 |
+
"normalized": false,
|
| 567 |
+
"rstrip": false,
|
| 568 |
+
"single_word": false,
|
| 569 |
+
"special": true
|
| 570 |
+
},
|
| 571 |
+
"128071": {
|
| 572 |
+
"content": "<|reserved_special_token_63|>",
|
| 573 |
+
"lstrip": false,
|
| 574 |
+
"normalized": false,
|
| 575 |
+
"rstrip": false,
|
| 576 |
+
"single_word": false,
|
| 577 |
+
"special": true
|
| 578 |
+
},
|
| 579 |
+
"128072": {
|
| 580 |
+
"content": "<|reserved_special_token_64|>",
|
| 581 |
+
"lstrip": false,
|
| 582 |
+
"normalized": false,
|
| 583 |
+
"rstrip": false,
|
| 584 |
+
"single_word": false,
|
| 585 |
+
"special": true
|
| 586 |
+
},
|
| 587 |
+
"128073": {
|
| 588 |
+
"content": "<|reserved_special_token_65|>",
|
| 589 |
+
"lstrip": false,
|
| 590 |
+
"normalized": false,
|
| 591 |
+
"rstrip": false,
|
| 592 |
+
"single_word": false,
|
| 593 |
+
"special": true
|
| 594 |
+
},
|
| 595 |
+
"128074": {
|
| 596 |
+
"content": "<|reserved_special_token_66|>",
|
| 597 |
+
"lstrip": false,
|
| 598 |
+
"normalized": false,
|
| 599 |
+
"rstrip": false,
|
| 600 |
+
"single_word": false,
|
| 601 |
+
"special": true
|
| 602 |
+
},
|
| 603 |
+
"128075": {
|
| 604 |
+
"content": "<|reserved_special_token_67|>",
|
| 605 |
+
"lstrip": false,
|
| 606 |
+
"normalized": false,
|
| 607 |
+
"rstrip": false,
|
| 608 |
+
"single_word": false,
|
| 609 |
+
"special": true
|
| 610 |
+
},
|
| 611 |
+
"128076": {
|
| 612 |
+
"content": "<|reserved_special_token_68|>",
|
| 613 |
+
"lstrip": false,
|
| 614 |
+
"normalized": false,
|
| 615 |
+
"rstrip": false,
|
| 616 |
+
"single_word": false,
|
| 617 |
+
"special": true
|
| 618 |
+
},
|
| 619 |
+
"128077": {
|
| 620 |
+
"content": "<|reserved_special_token_69|>",
|
| 621 |
+
"lstrip": false,
|
| 622 |
+
"normalized": false,
|
| 623 |
+
"rstrip": false,
|
| 624 |
+
"single_word": false,
|
| 625 |
+
"special": true
|
| 626 |
+
},
|
| 627 |
+
"128078": {
|
| 628 |
+
"content": "<|reserved_special_token_70|>",
|
| 629 |
+
"lstrip": false,
|
| 630 |
+
"normalized": false,
|
| 631 |
+
"rstrip": false,
|
| 632 |
+
"single_word": false,
|
| 633 |
+
"special": true
|
| 634 |
+
},
|
| 635 |
+
"128079": {
|
| 636 |
+
"content": "<|reserved_special_token_71|>",
|
| 637 |
+
"lstrip": false,
|
| 638 |
+
"normalized": false,
|
| 639 |
+
"rstrip": false,
|
| 640 |
+
"single_word": false,
|
| 641 |
+
"special": true
|
| 642 |
+
},
|
| 643 |
+
"128080": {
|
| 644 |
+
"content": "<|reserved_special_token_72|>",
|
| 645 |
+
"lstrip": false,
|
| 646 |
+
"normalized": false,
|
| 647 |
+
"rstrip": false,
|
| 648 |
+
"single_word": false,
|
| 649 |
+
"special": true
|
| 650 |
+
},
|
| 651 |
+
"128081": {
|
| 652 |
+
"content": "<|reserved_special_token_73|>",
|
| 653 |
+
"lstrip": false,
|
| 654 |
+
"normalized": false,
|
| 655 |
+
"rstrip": false,
|
| 656 |
+
"single_word": false,
|
| 657 |
+
"special": true
|
| 658 |
+
},
|
| 659 |
+
"128082": {
|
| 660 |
+
"content": "<|reserved_special_token_74|>",
|
| 661 |
+
"lstrip": false,
|
| 662 |
+
"normalized": false,
|
| 663 |
+
"rstrip": false,
|
| 664 |
+
"single_word": false,
|
| 665 |
+
"special": true
|
| 666 |
+
},
|
| 667 |
+
"128083": {
|
| 668 |
+
"content": "<|reserved_special_token_75|>",
|
| 669 |
+
"lstrip": false,
|
| 670 |
+
"normalized": false,
|
| 671 |
+
"rstrip": false,
|
| 672 |
+
"single_word": false,
|
| 673 |
+
"special": true
|
| 674 |
+
},
|
| 675 |
+
"128084": {
|
| 676 |
+
"content": "<|reserved_special_token_76|>",
|
| 677 |
+
"lstrip": false,
|
| 678 |
+
"normalized": false,
|
| 679 |
+
"rstrip": false,
|
| 680 |
+
"single_word": false,
|
| 681 |
+
"special": true
|
| 682 |
+
},
|
| 683 |
+
"128085": {
|
| 684 |
+
"content": "<|reserved_special_token_77|>",
|
| 685 |
+
"lstrip": false,
|
| 686 |
+
"normalized": false,
|
| 687 |
+
"rstrip": false,
|
| 688 |
+
"single_word": false,
|
| 689 |
+
"special": true
|
| 690 |
+
},
|
| 691 |
+
"128086": {
|
| 692 |
+
"content": "<|reserved_special_token_78|>",
|
| 693 |
+
"lstrip": false,
|
| 694 |
+
"normalized": false,
|
| 695 |
+
"rstrip": false,
|
| 696 |
+
"single_word": false,
|
| 697 |
+
"special": true
|
| 698 |
+
},
|
| 699 |
+
"128087": {
|
| 700 |
+
"content": "<|reserved_special_token_79|>",
|
| 701 |
+
"lstrip": false,
|
| 702 |
+
"normalized": false,
|
| 703 |
+
"rstrip": false,
|
| 704 |
+
"single_word": false,
|
| 705 |
+
"special": true
|
| 706 |
+
},
|
| 707 |
+
"128088": {
|
| 708 |
+
"content": "<|reserved_special_token_80|>",
|
| 709 |
+
"lstrip": false,
|
| 710 |
+
"normalized": false,
|
| 711 |
+
"rstrip": false,
|
| 712 |
+
"single_word": false,
|
| 713 |
+
"special": true
|
| 714 |
+
},
|
| 715 |
+
"128089": {
|
| 716 |
+
"content": "<|reserved_special_token_81|>",
|
| 717 |
+
"lstrip": false,
|
| 718 |
+
"normalized": false,
|
| 719 |
+
"rstrip": false,
|
| 720 |
+
"single_word": false,
|
| 721 |
+
"special": true
|
| 722 |
+
},
|
| 723 |
+
"128090": {
|
| 724 |
+
"content": "<|reserved_special_token_82|>",
|
| 725 |
+
"lstrip": false,
|
| 726 |
+
"normalized": false,
|
| 727 |
+
"rstrip": false,
|
| 728 |
+
"single_word": false,
|
| 729 |
+
"special": true
|
| 730 |
+
},
|
| 731 |
+
"128091": {
|
| 732 |
+
"content": "<|reserved_special_token_83|>",
|
| 733 |
+
"lstrip": false,
|
| 734 |
+
"normalized": false,
|
| 735 |
+
"rstrip": false,
|
| 736 |
+
"single_word": false,
|
| 737 |
+
"special": true
|
| 738 |
+
},
|
| 739 |
+
"128092": {
|
| 740 |
+
"content": "<|reserved_special_token_84|>",
|
| 741 |
+
"lstrip": false,
|
| 742 |
+
"normalized": false,
|
| 743 |
+
"rstrip": false,
|
| 744 |
+
"single_word": false,
|
| 745 |
+
"special": true
|
| 746 |
+
},
|
| 747 |
+
"128093": {
|
| 748 |
+
"content": "<|reserved_special_token_85|>",
|
| 749 |
+
"lstrip": false,
|
| 750 |
+
"normalized": false,
|
| 751 |
+
"rstrip": false,
|
| 752 |
+
"single_word": false,
|
| 753 |
+
"special": true
|
| 754 |
+
},
|
| 755 |
+
"128094": {
|
| 756 |
+
"content": "<|reserved_special_token_86|>",
|
| 757 |
+
"lstrip": false,
|
| 758 |
+
"normalized": false,
|
| 759 |
+
"rstrip": false,
|
| 760 |
+
"single_word": false,
|
| 761 |
+
"special": true
|
| 762 |
+
},
|
| 763 |
+
"128095": {
|
| 764 |
+
"content": "<|reserved_special_token_87|>",
|
| 765 |
+
"lstrip": false,
|
| 766 |
+
"normalized": false,
|
| 767 |
+
"rstrip": false,
|
| 768 |
+
"single_word": false,
|
| 769 |
+
"special": true
|
| 770 |
+
},
|
| 771 |
+
"128096": {
|
| 772 |
+
"content": "<|reserved_special_token_88|>",
|
| 773 |
+
"lstrip": false,
|
| 774 |
+
"normalized": false,
|
| 775 |
+
"rstrip": false,
|
| 776 |
+
"single_word": false,
|
| 777 |
+
"special": true
|
| 778 |
+
},
|
| 779 |
+
"128097": {
|
| 780 |
+
"content": "<|reserved_special_token_89|>",
|
| 781 |
+
"lstrip": false,
|
| 782 |
+
"normalized": false,
|
| 783 |
+
"rstrip": false,
|
| 784 |
+
"single_word": false,
|
| 785 |
+
"special": true
|
| 786 |
+
},
|
| 787 |
+
"128098": {
|
| 788 |
+
"content": "<|reserved_special_token_90|>",
|
| 789 |
+
"lstrip": false,
|
| 790 |
+
"normalized": false,
|
| 791 |
+
"rstrip": false,
|
| 792 |
+
"single_word": false,
|
| 793 |
+
"special": true
|
| 794 |
+
},
|
| 795 |
+
"128099": {
|
| 796 |
+
"content": "<|reserved_special_token_91|>",
|
| 797 |
+
"lstrip": false,
|
| 798 |
+
"normalized": false,
|
| 799 |
+
"rstrip": false,
|
| 800 |
+
"single_word": false,
|
| 801 |
+
"special": true
|
| 802 |
+
},
|
| 803 |
+
"128100": {
|
| 804 |
+
"content": "<|reserved_special_token_92|>",
|
| 805 |
+
"lstrip": false,
|
| 806 |
+
"normalized": false,
|
| 807 |
+
"rstrip": false,
|
| 808 |
+
"single_word": false,
|
| 809 |
+
"special": true
|
| 810 |
+
},
|
| 811 |
+
"128101": {
|
| 812 |
+
"content": "<|reserved_special_token_93|>",
|
| 813 |
+
"lstrip": false,
|
| 814 |
+
"normalized": false,
|
| 815 |
+
"rstrip": false,
|
| 816 |
+
"single_word": false,
|
| 817 |
+
"special": true
|
| 818 |
+
},
|
| 819 |
+
"128102": {
|
| 820 |
+
"content": "<|reserved_special_token_94|>",
|
| 821 |
+
"lstrip": false,
|
| 822 |
+
"normalized": false,
|
| 823 |
+
"rstrip": false,
|
| 824 |
+
"single_word": false,
|
| 825 |
+
"special": true
|
| 826 |
+
},
|
| 827 |
+
"128103": {
|
| 828 |
+
"content": "<|reserved_special_token_95|>",
|
| 829 |
+
"lstrip": false,
|
| 830 |
+
"normalized": false,
|
| 831 |
+
"rstrip": false,
|
| 832 |
+
"single_word": false,
|
| 833 |
+
"special": true
|
| 834 |
+
},
|
| 835 |
+
"128104": {
|
| 836 |
+
"content": "<|reserved_special_token_96|>",
|
| 837 |
+
"lstrip": false,
|
| 838 |
+
"normalized": false,
|
| 839 |
+
"rstrip": false,
|
| 840 |
+
"single_word": false,
|
| 841 |
+
"special": true
|
| 842 |
+
},
|
| 843 |
+
"128105": {
|
| 844 |
+
"content": "<|reserved_special_token_97|>",
|
| 845 |
+
"lstrip": false,
|
| 846 |
+
"normalized": false,
|
| 847 |
+
"rstrip": false,
|
| 848 |
+
"single_word": false,
|
| 849 |
+
"special": true
|
| 850 |
+
},
|
| 851 |
+
"128106": {
|
| 852 |
+
"content": "<|reserved_special_token_98|>",
|
| 853 |
+
"lstrip": false,
|
| 854 |
+
"normalized": false,
|
| 855 |
+
"rstrip": false,
|
| 856 |
+
"single_word": false,
|
| 857 |
+
"special": true
|
| 858 |
+
},
|
| 859 |
+
"128107": {
|
| 860 |
+
"content": "<|reserved_special_token_99|>",
|
| 861 |
+
"lstrip": false,
|
| 862 |
+
"normalized": false,
|
| 863 |
+
"rstrip": false,
|
| 864 |
+
"single_word": false,
|
| 865 |
+
"special": true
|
| 866 |
+
},
|
| 867 |
+
"128108": {
|
| 868 |
+
"content": "<|reserved_special_token_100|>",
|
| 869 |
+
"lstrip": false,
|
| 870 |
+
"normalized": false,
|
| 871 |
+
"rstrip": false,
|
| 872 |
+
"single_word": false,
|
| 873 |
+
"special": true
|
| 874 |
+
},
|
| 875 |
+
"128109": {
|
| 876 |
+
"content": "<|reserved_special_token_101|>",
|
| 877 |
+
"lstrip": false,
|
| 878 |
+
"normalized": false,
|
| 879 |
+
"rstrip": false,
|
| 880 |
+
"single_word": false,
|
| 881 |
+
"special": true
|
| 882 |
+
},
|
| 883 |
+
"128110": {
|
| 884 |
+
"content": "<|reserved_special_token_102|>",
|
| 885 |
+
"lstrip": false,
|
| 886 |
+
"normalized": false,
|
| 887 |
+
"rstrip": false,
|
| 888 |
+
"single_word": false,
|
| 889 |
+
"special": true
|
| 890 |
+
},
|
| 891 |
+
"128111": {
|
| 892 |
+
"content": "<|reserved_special_token_103|>",
|
| 893 |
+
"lstrip": false,
|
| 894 |
+
"normalized": false,
|
| 895 |
+
"rstrip": false,
|
| 896 |
+
"single_word": false,
|
| 897 |
+
"special": true
|
| 898 |
+
},
|
| 899 |
+
"128112": {
|
| 900 |
+
"content": "<|reserved_special_token_104|>",
|
| 901 |
+
"lstrip": false,
|
| 902 |
+
"normalized": false,
|
| 903 |
+
"rstrip": false,
|
| 904 |
+
"single_word": false,
|
| 905 |
+
"special": true
|
| 906 |
+
},
|
| 907 |
+
"128113": {
|
| 908 |
+
"content": "<|reserved_special_token_105|>",
|
| 909 |
+
"lstrip": false,
|
| 910 |
+
"normalized": false,
|
| 911 |
+
"rstrip": false,
|
| 912 |
+
"single_word": false,
|
| 913 |
+
"special": true
|
| 914 |
+
},
|
| 915 |
+
"128114": {
|
| 916 |
+
"content": "<|reserved_special_token_106|>",
|
| 917 |
+
"lstrip": false,
|
| 918 |
+
"normalized": false,
|
| 919 |
+
"rstrip": false,
|
| 920 |
+
"single_word": false,
|
| 921 |
+
"special": true
|
| 922 |
+
},
|
| 923 |
+
"128115": {
|
| 924 |
+
"content": "<|reserved_special_token_107|>",
|
| 925 |
+
"lstrip": false,
|
| 926 |
+
"normalized": false,
|
| 927 |
+
"rstrip": false,
|
| 928 |
+
"single_word": false,
|
| 929 |
+
"special": true
|
| 930 |
+
},
|
| 931 |
+
"128116": {
|
| 932 |
+
"content": "<|reserved_special_token_108|>",
|
| 933 |
+
"lstrip": false,
|
| 934 |
+
"normalized": false,
|
| 935 |
+
"rstrip": false,
|
| 936 |
+
"single_word": false,
|
| 937 |
+
"special": true
|
| 938 |
+
},
|
| 939 |
+
"128117": {
|
| 940 |
+
"content": "<|reserved_special_token_109|>",
|
| 941 |
+
"lstrip": false,
|
| 942 |
+
"normalized": false,
|
| 943 |
+
"rstrip": false,
|
| 944 |
+
"single_word": false,
|
| 945 |
+
"special": true
|
| 946 |
+
},
|
| 947 |
+
"128118": {
|
| 948 |
+
"content": "<|reserved_special_token_110|>",
|
| 949 |
+
"lstrip": false,
|
| 950 |
+
"normalized": false,
|
| 951 |
+
"rstrip": false,
|
| 952 |
+
"single_word": false,
|
| 953 |
+
"special": true
|
| 954 |
+
},
|
| 955 |
+
"128119": {
|
| 956 |
+
"content": "<|reserved_special_token_111|>",
|
| 957 |
+
"lstrip": false,
|
| 958 |
+
"normalized": false,
|
| 959 |
+
"rstrip": false,
|
| 960 |
+
"single_word": false,
|
| 961 |
+
"special": true
|
| 962 |
+
},
|
| 963 |
+
"128120": {
|
| 964 |
+
"content": "<|reserved_special_token_112|>",
|
| 965 |
+
"lstrip": false,
|
| 966 |
+
"normalized": false,
|
| 967 |
+
"rstrip": false,
|
| 968 |
+
"single_word": false,
|
| 969 |
+
"special": true
|
| 970 |
+
},
|
| 971 |
+
"128121": {
|
| 972 |
+
"content": "<|reserved_special_token_113|>",
|
| 973 |
+
"lstrip": false,
|
| 974 |
+
"normalized": false,
|
| 975 |
+
"rstrip": false,
|
| 976 |
+
"single_word": false,
|
| 977 |
+
"special": true
|
| 978 |
+
},
|
| 979 |
+
"128122": {
|
| 980 |
+
"content": "<|reserved_special_token_114|>",
|
| 981 |
+
"lstrip": false,
|
| 982 |
+
"normalized": false,
|
| 983 |
+
"rstrip": false,
|
| 984 |
+
"single_word": false,
|
| 985 |
+
"special": true
|
| 986 |
+
},
|
| 987 |
+
"128123": {
|
| 988 |
+
"content": "<|reserved_special_token_115|>",
|
| 989 |
+
"lstrip": false,
|
| 990 |
+
"normalized": false,
|
| 991 |
+
"rstrip": false,
|
| 992 |
+
"single_word": false,
|
| 993 |
+
"special": true
|
| 994 |
+
},
|
| 995 |
+
"128124": {
|
| 996 |
+
"content": "<|reserved_special_token_116|>",
|
| 997 |
+
"lstrip": false,
|
| 998 |
+
"normalized": false,
|
| 999 |
+
"rstrip": false,
|
| 1000 |
+
"single_word": false,
|
| 1001 |
+
"special": true
|
| 1002 |
+
},
|
| 1003 |
+
"128125": {
|
| 1004 |
+
"content": "<|reserved_special_token_117|>",
|
| 1005 |
+
"lstrip": false,
|
| 1006 |
+
"normalized": false,
|
| 1007 |
+
"rstrip": false,
|
| 1008 |
+
"single_word": false,
|
| 1009 |
+
"special": true
|
| 1010 |
+
},
|
| 1011 |
+
"128126": {
|
| 1012 |
+
"content": "<|reserved_special_token_118|>",
|
| 1013 |
+
"lstrip": false,
|
| 1014 |
+
"normalized": false,
|
| 1015 |
+
"rstrip": false,
|
| 1016 |
+
"single_word": false,
|
| 1017 |
+
"special": true
|
| 1018 |
+
},
|
| 1019 |
+
"128127": {
|
| 1020 |
+
"content": "<|reserved_special_token_119|>",
|
| 1021 |
+
"lstrip": false,
|
| 1022 |
+
"normalized": false,
|
| 1023 |
+
"rstrip": false,
|
| 1024 |
+
"single_word": false,
|
| 1025 |
+
"special": true
|
| 1026 |
+
},
|
| 1027 |
+
"128128": {
|
| 1028 |
+
"content": "<|reserved_special_token_120|>",
|
| 1029 |
+
"lstrip": false,
|
| 1030 |
+
"normalized": false,
|
| 1031 |
+
"rstrip": false,
|
| 1032 |
+
"single_word": false,
|
| 1033 |
+
"special": true
|
| 1034 |
+
},
|
| 1035 |
+
"128129": {
|
| 1036 |
+
"content": "<|reserved_special_token_121|>",
|
| 1037 |
+
"lstrip": false,
|
| 1038 |
+
"normalized": false,
|
| 1039 |
+
"rstrip": false,
|
| 1040 |
+
"single_word": false,
|
| 1041 |
+
"special": true
|
| 1042 |
+
},
|
| 1043 |
+
"128130": {
|
| 1044 |
+
"content": "<|reserved_special_token_122|>",
|
| 1045 |
+
"lstrip": false,
|
| 1046 |
+
"normalized": false,
|
| 1047 |
+
"rstrip": false,
|
| 1048 |
+
"single_word": false,
|
| 1049 |
+
"special": true
|
| 1050 |
+
},
|
| 1051 |
+
"128131": {
|
| 1052 |
+
"content": "<|reserved_special_token_123|>",
|
| 1053 |
+
"lstrip": false,
|
| 1054 |
+
"normalized": false,
|
| 1055 |
+
"rstrip": false,
|
| 1056 |
+
"single_word": false,
|
| 1057 |
+
"special": true
|
| 1058 |
+
},
|
| 1059 |
+
"128132": {
|
| 1060 |
+
"content": "<|reserved_special_token_124|>",
|
| 1061 |
+
"lstrip": false,
|
| 1062 |
+
"normalized": false,
|
| 1063 |
+
"rstrip": false,
|
| 1064 |
+
"single_word": false,
|
| 1065 |
+
"special": true
|
| 1066 |
+
},
|
| 1067 |
+
"128133": {
|
| 1068 |
+
"content": "<|reserved_special_token_125|>",
|
| 1069 |
+
"lstrip": false,
|
| 1070 |
+
"normalized": false,
|
| 1071 |
+
"rstrip": false,
|
| 1072 |
+
"single_word": false,
|
| 1073 |
+
"special": true
|
| 1074 |
+
},
|
| 1075 |
+
"128134": {
|
| 1076 |
+
"content": "<|reserved_special_token_126|>",
|
| 1077 |
+
"lstrip": false,
|
| 1078 |
+
"normalized": false,
|
| 1079 |
+
"rstrip": false,
|
| 1080 |
+
"single_word": false,
|
| 1081 |
+
"special": true
|
| 1082 |
+
},
|
| 1083 |
+
"128135": {
|
| 1084 |
+
"content": "<|reserved_special_token_127|>",
|
| 1085 |
+
"lstrip": false,
|
| 1086 |
+
"normalized": false,
|
| 1087 |
+
"rstrip": false,
|
| 1088 |
+
"single_word": false,
|
| 1089 |
+
"special": true
|
| 1090 |
+
},
|
| 1091 |
+
"128136": {
|
| 1092 |
+
"content": "<|reserved_special_token_128|>",
|
| 1093 |
+
"lstrip": false,
|
| 1094 |
+
"normalized": false,
|
| 1095 |
+
"rstrip": false,
|
| 1096 |
+
"single_word": false,
|
| 1097 |
+
"special": true
|
| 1098 |
+
},
|
| 1099 |
+
"128137": {
|
| 1100 |
+
"content": "<|reserved_special_token_129|>",
|
| 1101 |
+
"lstrip": false,
|
| 1102 |
+
"normalized": false,
|
| 1103 |
+
"rstrip": false,
|
| 1104 |
+
"single_word": false,
|
| 1105 |
+
"special": true
|
| 1106 |
+
},
|
| 1107 |
+
"128138": {
|
| 1108 |
+
"content": "<|reserved_special_token_130|>",
|
| 1109 |
+
"lstrip": false,
|
| 1110 |
+
"normalized": false,
|
| 1111 |
+
"rstrip": false,
|
| 1112 |
+
"single_word": false,
|
| 1113 |
+
"special": true
|
| 1114 |
+
},
|
| 1115 |
+
"128139": {
|
| 1116 |
+
"content": "<|reserved_special_token_131|>",
|
| 1117 |
+
"lstrip": false,
|
| 1118 |
+
"normalized": false,
|
| 1119 |
+
"rstrip": false,
|
| 1120 |
+
"single_word": false,
|
| 1121 |
+
"special": true
|
| 1122 |
+
},
|
| 1123 |
+
"128140": {
|
| 1124 |
+
"content": "<|reserved_special_token_132|>",
|
| 1125 |
+
"lstrip": false,
|
| 1126 |
+
"normalized": false,
|
| 1127 |
+
"rstrip": false,
|
| 1128 |
+
"single_word": false,
|
| 1129 |
+
"special": true
|
| 1130 |
+
},
|
| 1131 |
+
"128141": {
|
| 1132 |
+
"content": "<|reserved_special_token_133|>",
|
| 1133 |
+
"lstrip": false,
|
| 1134 |
+
"normalized": false,
|
| 1135 |
+
"rstrip": false,
|
| 1136 |
+
"single_word": false,
|
| 1137 |
+
"special": true
|
| 1138 |
+
},
|
| 1139 |
+
"128142": {
|
| 1140 |
+
"content": "<|reserved_special_token_134|>",
|
| 1141 |
+
"lstrip": false,
|
| 1142 |
+
"normalized": false,
|
| 1143 |
+
"rstrip": false,
|
| 1144 |
+
"single_word": false,
|
| 1145 |
+
"special": true
|
| 1146 |
+
},
|
| 1147 |
+
"128143": {
|
| 1148 |
+
"content": "<|reserved_special_token_135|>",
|
| 1149 |
+
"lstrip": false,
|
| 1150 |
+
"normalized": false,
|
| 1151 |
+
"rstrip": false,
|
| 1152 |
+
"single_word": false,
|
| 1153 |
+
"special": true
|
| 1154 |
+
},
|
| 1155 |
+
"128144": {
|
| 1156 |
+
"content": "<|reserved_special_token_136|>",
|
| 1157 |
+
"lstrip": false,
|
| 1158 |
+
"normalized": false,
|
| 1159 |
+
"rstrip": false,
|
| 1160 |
+
"single_word": false,
|
| 1161 |
+
"special": true
|
| 1162 |
+
},
|
| 1163 |
+
"128145": {
|
| 1164 |
+
"content": "<|reserved_special_token_137|>",
|
| 1165 |
+
"lstrip": false,
|
| 1166 |
+
"normalized": false,
|
| 1167 |
+
"rstrip": false,
|
| 1168 |
+
"single_word": false,
|
| 1169 |
+
"special": true
|
| 1170 |
+
},
|
| 1171 |
+
"128146": {
|
| 1172 |
+
"content": "<|reserved_special_token_138|>",
|
| 1173 |
+
"lstrip": false,
|
| 1174 |
+
"normalized": false,
|
| 1175 |
+
"rstrip": false,
|
| 1176 |
+
"single_word": false,
|
| 1177 |
+
"special": true
|
| 1178 |
+
},
|
| 1179 |
+
"128147": {
|
| 1180 |
+
"content": "<|reserved_special_token_139|>",
|
| 1181 |
+
"lstrip": false,
|
| 1182 |
+
"normalized": false,
|
| 1183 |
+
"rstrip": false,
|
| 1184 |
+
"single_word": false,
|
| 1185 |
+
"special": true
|
| 1186 |
+
},
|
| 1187 |
+
"128148": {
|
| 1188 |
+
"content": "<|reserved_special_token_140|>",
|
| 1189 |
+
"lstrip": false,
|
| 1190 |
+
"normalized": false,
|
| 1191 |
+
"rstrip": false,
|
| 1192 |
+
"single_word": false,
|
| 1193 |
+
"special": true
|
| 1194 |
+
},
|
| 1195 |
+
"128149": {
|
| 1196 |
+
"content": "<|reserved_special_token_141|>",
|
| 1197 |
+
"lstrip": false,
|
| 1198 |
+
"normalized": false,
|
| 1199 |
+
"rstrip": false,
|
| 1200 |
+
"single_word": false,
|
| 1201 |
+
"special": true
|
| 1202 |
+
},
|
| 1203 |
+
"128150": {
|
| 1204 |
+
"content": "<|reserved_special_token_142|>",
|
| 1205 |
+
"lstrip": false,
|
| 1206 |
+
"normalized": false,
|
| 1207 |
+
"rstrip": false,
|
| 1208 |
+
"single_word": false,
|
| 1209 |
+
"special": true
|
| 1210 |
+
},
|
| 1211 |
+
"128151": {
|
| 1212 |
+
"content": "<|reserved_special_token_143|>",
|
| 1213 |
+
"lstrip": false,
|
| 1214 |
+
"normalized": false,
|
| 1215 |
+
"rstrip": false,
|
| 1216 |
+
"single_word": false,
|
| 1217 |
+
"special": true
|
| 1218 |
+
},
|
| 1219 |
+
"128152": {
|
| 1220 |
+
"content": "<|reserved_special_token_144|>",
|
| 1221 |
+
"lstrip": false,
|
| 1222 |
+
"normalized": false,
|
| 1223 |
+
"rstrip": false,
|
| 1224 |
+
"single_word": false,
|
| 1225 |
+
"special": true
|
| 1226 |
+
},
|
| 1227 |
+
"128153": {
|
| 1228 |
+
"content": "<|reserved_special_token_145|>",
|
| 1229 |
+
"lstrip": false,
|
| 1230 |
+
"normalized": false,
|
| 1231 |
+
"rstrip": false,
|
| 1232 |
+
"single_word": false,
|
| 1233 |
+
"special": true
|
| 1234 |
+
},
|
| 1235 |
+
"128154": {
|
| 1236 |
+
"content": "<|reserved_special_token_146|>",
|
| 1237 |
+
"lstrip": false,
|
| 1238 |
+
"normalized": false,
|
| 1239 |
+
"rstrip": false,
|
| 1240 |
+
"single_word": false,
|
| 1241 |
+
"special": true
|
| 1242 |
+
},
|
| 1243 |
+
"128155": {
|
| 1244 |
+
"content": "<|reserved_special_token_147|>",
|
| 1245 |
+
"lstrip": false,
|
| 1246 |
+
"normalized": false,
|
| 1247 |
+
"rstrip": false,
|
| 1248 |
+
"single_word": false,
|
| 1249 |
+
"special": true
|
| 1250 |
+
},
|
| 1251 |
+
"128156": {
|
| 1252 |
+
"content": "<|reserved_special_token_148|>",
|
| 1253 |
+
"lstrip": false,
|
| 1254 |
+
"normalized": false,
|
| 1255 |
+
"rstrip": false,
|
| 1256 |
+
"single_word": false,
|
| 1257 |
+
"special": true
|
| 1258 |
+
},
|
| 1259 |
+
"128157": {
|
| 1260 |
+
"content": "<|reserved_special_token_149|>",
|
| 1261 |
+
"lstrip": false,
|
| 1262 |
+
"normalized": false,
|
| 1263 |
+
"rstrip": false,
|
| 1264 |
+
"single_word": false,
|
| 1265 |
+
"special": true
|
| 1266 |
+
},
|
| 1267 |
+
"128158": {
|
| 1268 |
+
"content": "<|reserved_special_token_150|>",
|
| 1269 |
+
"lstrip": false,
|
| 1270 |
+
"normalized": false,
|
| 1271 |
+
"rstrip": false,
|
| 1272 |
+
"single_word": false,
|
| 1273 |
+
"special": true
|
| 1274 |
+
},
|
| 1275 |
+
"128159": {
|
| 1276 |
+
"content": "<|reserved_special_token_151|>",
|
| 1277 |
+
"lstrip": false,
|
| 1278 |
+
"normalized": false,
|
| 1279 |
+
"rstrip": false,
|
| 1280 |
+
"single_word": false,
|
| 1281 |
+
"special": true
|
| 1282 |
+
},
|
| 1283 |
+
"128160": {
|
| 1284 |
+
"content": "<|reserved_special_token_152|>",
|
| 1285 |
+
"lstrip": false,
|
| 1286 |
+
"normalized": false,
|
| 1287 |
+
"rstrip": false,
|
| 1288 |
+
"single_word": false,
|
| 1289 |
+
"special": true
|
| 1290 |
+
},
|
| 1291 |
+
"128161": {
|
| 1292 |
+
"content": "<|reserved_special_token_153|>",
|
| 1293 |
+
"lstrip": false,
|
| 1294 |
+
"normalized": false,
|
| 1295 |
+
"rstrip": false,
|
| 1296 |
+
"single_word": false,
|
| 1297 |
+
"special": true
|
| 1298 |
+
},
|
| 1299 |
+
"128162": {
|
| 1300 |
+
"content": "<|reserved_special_token_154|>",
|
| 1301 |
+
"lstrip": false,
|
| 1302 |
+
"normalized": false,
|
| 1303 |
+
"rstrip": false,
|
| 1304 |
+
"single_word": false,
|
| 1305 |
+
"special": true
|
| 1306 |
+
},
|
| 1307 |
+
"128163": {
|
| 1308 |
+
"content": "<|reserved_special_token_155|>",
|
| 1309 |
+
"lstrip": false,
|
| 1310 |
+
"normalized": false,
|
| 1311 |
+
"rstrip": false,
|
| 1312 |
+
"single_word": false,
|
| 1313 |
+
"special": true
|
| 1314 |
+
},
|
| 1315 |
+
"128164": {
|
| 1316 |
+
"content": "<|reserved_special_token_156|>",
|
| 1317 |
+
"lstrip": false,
|
| 1318 |
+
"normalized": false,
|
| 1319 |
+
"rstrip": false,
|
| 1320 |
+
"single_word": false,
|
| 1321 |
+
"special": true
|
| 1322 |
+
},
|
| 1323 |
+
"128165": {
|
| 1324 |
+
"content": "<|reserved_special_token_157|>",
|
| 1325 |
+
"lstrip": false,
|
| 1326 |
+
"normalized": false,
|
| 1327 |
+
"rstrip": false,
|
| 1328 |
+
"single_word": false,
|
| 1329 |
+
"special": true
|
| 1330 |
+
},
|
| 1331 |
+
"128166": {
|
| 1332 |
+
"content": "<|reserved_special_token_158|>",
|
| 1333 |
+
"lstrip": false,
|
| 1334 |
+
"normalized": false,
|
| 1335 |
+
"rstrip": false,
|
| 1336 |
+
"single_word": false,
|
| 1337 |
+
"special": true
|
| 1338 |
+
},
|
| 1339 |
+
"128167": {
|
| 1340 |
+
"content": "<|reserved_special_token_159|>",
|
| 1341 |
+
"lstrip": false,
|
| 1342 |
+
"normalized": false,
|
| 1343 |
+
"rstrip": false,
|
| 1344 |
+
"single_word": false,
|
| 1345 |
+
"special": true
|
| 1346 |
+
},
|
| 1347 |
+
"128168": {
|
| 1348 |
+
"content": "<|reserved_special_token_160|>",
|
| 1349 |
+
"lstrip": false,
|
| 1350 |
+
"normalized": false,
|
| 1351 |
+
"rstrip": false,
|
| 1352 |
+
"single_word": false,
|
| 1353 |
+
"special": true
|
| 1354 |
+
},
|
| 1355 |
+
"128169": {
|
| 1356 |
+
"content": "<|reserved_special_token_161|>",
|
| 1357 |
+
"lstrip": false,
|
| 1358 |
+
"normalized": false,
|
| 1359 |
+
"rstrip": false,
|
| 1360 |
+
"single_word": false,
|
| 1361 |
+
"special": true
|
| 1362 |
+
},
|
| 1363 |
+
"128170": {
|
| 1364 |
+
"content": "<|reserved_special_token_162|>",
|
| 1365 |
+
"lstrip": false,
|
| 1366 |
+
"normalized": false,
|
| 1367 |
+
"rstrip": false,
|
| 1368 |
+
"single_word": false,
|
| 1369 |
+
"special": true
|
| 1370 |
+
},
|
| 1371 |
+
"128171": {
|
| 1372 |
+
"content": "<|reserved_special_token_163|>",
|
| 1373 |
+
"lstrip": false,
|
| 1374 |
+
"normalized": false,
|
| 1375 |
+
"rstrip": false,
|
| 1376 |
+
"single_word": false,
|
| 1377 |
+
"special": true
|
| 1378 |
+
},
|
| 1379 |
+
"128172": {
|
| 1380 |
+
"content": "<|reserved_special_token_164|>",
|
| 1381 |
+
"lstrip": false,
|
| 1382 |
+
"normalized": false,
|
| 1383 |
+
"rstrip": false,
|
| 1384 |
+
"single_word": false,
|
| 1385 |
+
"special": true
|
| 1386 |
+
},
|
| 1387 |
+
"128173": {
|
| 1388 |
+
"content": "<|reserved_special_token_165|>",
|
| 1389 |
+
"lstrip": false,
|
| 1390 |
+
"normalized": false,
|
| 1391 |
+
"rstrip": false,
|
| 1392 |
+
"single_word": false,
|
| 1393 |
+
"special": true
|
| 1394 |
+
},
|
| 1395 |
+
"128174": {
|
| 1396 |
+
"content": "<|reserved_special_token_166|>",
|
| 1397 |
+
"lstrip": false,
|
| 1398 |
+
"normalized": false,
|
| 1399 |
+
"rstrip": false,
|
| 1400 |
+
"single_word": false,
|
| 1401 |
+
"special": true
|
| 1402 |
+
},
|
| 1403 |
+
"128175": {
|
| 1404 |
+
"content": "<|reserved_special_token_167|>",
|
| 1405 |
+
"lstrip": false,
|
| 1406 |
+
"normalized": false,
|
| 1407 |
+
"rstrip": false,
|
| 1408 |
+
"single_word": false,
|
| 1409 |
+
"special": true
|
| 1410 |
+
},
|
| 1411 |
+
"128176": {
|
| 1412 |
+
"content": "<|reserved_special_token_168|>",
|
| 1413 |
+
"lstrip": false,
|
| 1414 |
+
"normalized": false,
|
| 1415 |
+
"rstrip": false,
|
| 1416 |
+
"single_word": false,
|
| 1417 |
+
"special": true
|
| 1418 |
+
},
|
| 1419 |
+
"128177": {
|
| 1420 |
+
"content": "<|reserved_special_token_169|>",
|
| 1421 |
+
"lstrip": false,
|
| 1422 |
+
"normalized": false,
|
| 1423 |
+
"rstrip": false,
|
| 1424 |
+
"single_word": false,
|
| 1425 |
+
"special": true
|
| 1426 |
+
},
|
| 1427 |
+
"128178": {
|
| 1428 |
+
"content": "<|reserved_special_token_170|>",
|
| 1429 |
+
"lstrip": false,
|
| 1430 |
+
"normalized": false,
|
| 1431 |
+
"rstrip": false,
|
| 1432 |
+
"single_word": false,
|
| 1433 |
+
"special": true
|
| 1434 |
+
},
|
| 1435 |
+
"128179": {
|
| 1436 |
+
"content": "<|reserved_special_token_171|>",
|
| 1437 |
+
"lstrip": false,
|
| 1438 |
+
"normalized": false,
|
| 1439 |
+
"rstrip": false,
|
| 1440 |
+
"single_word": false,
|
| 1441 |
+
"special": true
|
| 1442 |
+
},
|
| 1443 |
+
"128180": {
|
| 1444 |
+
"content": "<|reserved_special_token_172|>",
|
| 1445 |
+
"lstrip": false,
|
| 1446 |
+
"normalized": false,
|
| 1447 |
+
"rstrip": false,
|
| 1448 |
+
"single_word": false,
|
| 1449 |
+
"special": true
|
| 1450 |
+
},
|
| 1451 |
+
"128181": {
|
| 1452 |
+
"content": "<|reserved_special_token_173|>",
|
| 1453 |
+
"lstrip": false,
|
| 1454 |
+
"normalized": false,
|
| 1455 |
+
"rstrip": false,
|
| 1456 |
+
"single_word": false,
|
| 1457 |
+
"special": true
|
| 1458 |
+
},
|
| 1459 |
+
"128182": {
|
| 1460 |
+
"content": "<|reserved_special_token_174|>",
|
| 1461 |
+
"lstrip": false,
|
| 1462 |
+
"normalized": false,
|
| 1463 |
+
"rstrip": false,
|
| 1464 |
+
"single_word": false,
|
| 1465 |
+
"special": true
|
| 1466 |
+
},
|
| 1467 |
+
"128183": {
|
| 1468 |
+
"content": "<|reserved_special_token_175|>",
|
| 1469 |
+
"lstrip": false,
|
| 1470 |
+
"normalized": false,
|
| 1471 |
+
"rstrip": false,
|
| 1472 |
+
"single_word": false,
|
| 1473 |
+
"special": true
|
| 1474 |
+
},
|
| 1475 |
+
"128184": {
|
| 1476 |
+
"content": "<|reserved_special_token_176|>",
|
| 1477 |
+
"lstrip": false,
|
| 1478 |
+
"normalized": false,
|
| 1479 |
+
"rstrip": false,
|
| 1480 |
+
"single_word": false,
|
| 1481 |
+
"special": true
|
| 1482 |
+
},
|
| 1483 |
+
"128185": {
|
| 1484 |
+
"content": "<|reserved_special_token_177|>",
|
| 1485 |
+
"lstrip": false,
|
| 1486 |
+
"normalized": false,
|
| 1487 |
+
"rstrip": false,
|
| 1488 |
+
"single_word": false,
|
| 1489 |
+
"special": true
|
| 1490 |
+
},
|
| 1491 |
+
"128186": {
|
| 1492 |
+
"content": "<|reserved_special_token_178|>",
|
| 1493 |
+
"lstrip": false,
|
| 1494 |
+
"normalized": false,
|
| 1495 |
+
"rstrip": false,
|
| 1496 |
+
"single_word": false,
|
| 1497 |
+
"special": true
|
| 1498 |
+
},
|
| 1499 |
+
"128187": {
|
| 1500 |
+
"content": "<|reserved_special_token_179|>",
|
| 1501 |
+
"lstrip": false,
|
| 1502 |
+
"normalized": false,
|
| 1503 |
+
"rstrip": false,
|
| 1504 |
+
"single_word": false,
|
| 1505 |
+
"special": true
|
| 1506 |
+
},
|
| 1507 |
+
"128188": {
|
| 1508 |
+
"content": "<|reserved_special_token_180|>",
|
| 1509 |
+
"lstrip": false,
|
| 1510 |
+
"normalized": false,
|
| 1511 |
+
"rstrip": false,
|
| 1512 |
+
"single_word": false,
|
| 1513 |
+
"special": true
|
| 1514 |
+
},
|
| 1515 |
+
"128189": {
|
| 1516 |
+
"content": "<|reserved_special_token_181|>",
|
| 1517 |
+
"lstrip": false,
|
| 1518 |
+
"normalized": false,
|
| 1519 |
+
"rstrip": false,
|
| 1520 |
+
"single_word": false,
|
| 1521 |
+
"special": true
|
| 1522 |
+
},
|
| 1523 |
+
"128190": {
|
| 1524 |
+
"content": "<|reserved_special_token_182|>",
|
| 1525 |
+
"lstrip": false,
|
| 1526 |
+
"normalized": false,
|
| 1527 |
+
"rstrip": false,
|
| 1528 |
+
"single_word": false,
|
| 1529 |
+
"special": true
|
| 1530 |
+
},
|
| 1531 |
+
"128191": {
|
| 1532 |
+
"content": "<|reserved_special_token_183|>",
|
| 1533 |
+
"lstrip": false,
|
| 1534 |
+
"normalized": false,
|
| 1535 |
+
"rstrip": false,
|
| 1536 |
+
"single_word": false,
|
| 1537 |
+
"special": true
|
| 1538 |
+
},
|
| 1539 |
+
"128192": {
|
| 1540 |
+
"content": "<|reserved_special_token_184|>",
|
| 1541 |
+
"lstrip": false,
|
| 1542 |
+
"normalized": false,
|
| 1543 |
+
"rstrip": false,
|
| 1544 |
+
"single_word": false,
|
| 1545 |
+
"special": true
|
| 1546 |
+
},
|
| 1547 |
+
"128193": {
|
| 1548 |
+
"content": "<|reserved_special_token_185|>",
|
| 1549 |
+
"lstrip": false,
|
| 1550 |
+
"normalized": false,
|
| 1551 |
+
"rstrip": false,
|
| 1552 |
+
"single_word": false,
|
| 1553 |
+
"special": true
|
| 1554 |
+
},
|
| 1555 |
+
"128194": {
|
| 1556 |
+
"content": "<|reserved_special_token_186|>",
|
| 1557 |
+
"lstrip": false,
|
| 1558 |
+
"normalized": false,
|
| 1559 |
+
"rstrip": false,
|
| 1560 |
+
"single_word": false,
|
| 1561 |
+
"special": true
|
| 1562 |
+
},
|
| 1563 |
+
"128195": {
|
| 1564 |
+
"content": "<|reserved_special_token_187|>",
|
| 1565 |
+
"lstrip": false,
|
| 1566 |
+
"normalized": false,
|
| 1567 |
+
"rstrip": false,
|
| 1568 |
+
"single_word": false,
|
| 1569 |
+
"special": true
|
| 1570 |
+
},
|
| 1571 |
+
"128196": {
|
| 1572 |
+
"content": "<|reserved_special_token_188|>",
|
| 1573 |
+
"lstrip": false,
|
| 1574 |
+
"normalized": false,
|
| 1575 |
+
"rstrip": false,
|
| 1576 |
+
"single_word": false,
|
| 1577 |
+
"special": true
|
| 1578 |
+
},
|
| 1579 |
+
"128197": {
|
| 1580 |
+
"content": "<|reserved_special_token_189|>",
|
| 1581 |
+
"lstrip": false,
|
| 1582 |
+
"normalized": false,
|
| 1583 |
+
"rstrip": false,
|
| 1584 |
+
"single_word": false,
|
| 1585 |
+
"special": true
|
| 1586 |
+
},
|
| 1587 |
+
"128198": {
|
| 1588 |
+
"content": "<|reserved_special_token_190|>",
|
| 1589 |
+
"lstrip": false,
|
| 1590 |
+
"normalized": false,
|
| 1591 |
+
"rstrip": false,
|
| 1592 |
+
"single_word": false,
|
| 1593 |
+
"special": true
|
| 1594 |
+
},
|
| 1595 |
+
"128199": {
|
| 1596 |
+
"content": "<|reserved_special_token_191|>",
|
| 1597 |
+
"lstrip": false,
|
| 1598 |
+
"normalized": false,
|
| 1599 |
+
"rstrip": false,
|
| 1600 |
+
"single_word": false,
|
| 1601 |
+
"special": true
|
| 1602 |
+
},
|
| 1603 |
+
"128200": {
|
| 1604 |
+
"content": "<|reserved_special_token_192|>",
|
| 1605 |
+
"lstrip": false,
|
| 1606 |
+
"normalized": false,
|
| 1607 |
+
"rstrip": false,
|
| 1608 |
+
"single_word": false,
|
| 1609 |
+
"special": true
|
| 1610 |
+
},
|
| 1611 |
+
"128201": {
|
| 1612 |
+
"content": "<|reserved_special_token_193|>",
|
| 1613 |
+
"lstrip": false,
|
| 1614 |
+
"normalized": false,
|
| 1615 |
+
"rstrip": false,
|
| 1616 |
+
"single_word": false,
|
| 1617 |
+
"special": true
|
| 1618 |
+
},
|
| 1619 |
+
"128202": {
|
| 1620 |
+
"content": "<|reserved_special_token_194|>",
|
| 1621 |
+
"lstrip": false,
|
| 1622 |
+
"normalized": false,
|
| 1623 |
+
"rstrip": false,
|
| 1624 |
+
"single_word": false,
|
| 1625 |
+
"special": true
|
| 1626 |
+
},
|
| 1627 |
+
"128203": {
|
| 1628 |
+
"content": "<|reserved_special_token_195|>",
|
| 1629 |
+
"lstrip": false,
|
| 1630 |
+
"normalized": false,
|
| 1631 |
+
"rstrip": false,
|
| 1632 |
+
"single_word": false,
|
| 1633 |
+
"special": true
|
| 1634 |
+
},
|
| 1635 |
+
"128204": {
|
| 1636 |
+
"content": "<|reserved_special_token_196|>",
|
| 1637 |
+
"lstrip": false,
|
| 1638 |
+
"normalized": false,
|
| 1639 |
+
"rstrip": false,
|
| 1640 |
+
"single_word": false,
|
| 1641 |
+
"special": true
|
| 1642 |
+
},
|
| 1643 |
+
"128205": {
|
| 1644 |
+
"content": "<|reserved_special_token_197|>",
|
| 1645 |
+
"lstrip": false,
|
| 1646 |
+
"normalized": false,
|
| 1647 |
+
"rstrip": false,
|
| 1648 |
+
"single_word": false,
|
| 1649 |
+
"special": true
|
| 1650 |
+
},
|
| 1651 |
+
"128206": {
|
| 1652 |
+
"content": "<|reserved_special_token_198|>",
|
| 1653 |
+
"lstrip": false,
|
| 1654 |
+
"normalized": false,
|
| 1655 |
+
"rstrip": false,
|
| 1656 |
+
"single_word": false,
|
| 1657 |
+
"special": true
|
| 1658 |
+
},
|
| 1659 |
+
"128207": {
|
| 1660 |
+
"content": "<|reserved_special_token_199|>",
|
| 1661 |
+
"lstrip": false,
|
| 1662 |
+
"normalized": false,
|
| 1663 |
+
"rstrip": false,
|
| 1664 |
+
"single_word": false,
|
| 1665 |
+
"special": true
|
| 1666 |
+
},
|
| 1667 |
+
"128208": {
|
| 1668 |
+
"content": "<|reserved_special_token_200|>",
|
| 1669 |
+
"lstrip": false,
|
| 1670 |
+
"normalized": false,
|
| 1671 |
+
"rstrip": false,
|
| 1672 |
+
"single_word": false,
|
| 1673 |
+
"special": true
|
| 1674 |
+
},
|
| 1675 |
+
"128209": {
|
| 1676 |
+
"content": "<|reserved_special_token_201|>",
|
| 1677 |
+
"lstrip": false,
|
| 1678 |
+
"normalized": false,
|
| 1679 |
+
"rstrip": false,
|
| 1680 |
+
"single_word": false,
|
| 1681 |
+
"special": true
|
| 1682 |
+
},
|
| 1683 |
+
"128210": {
|
| 1684 |
+
"content": "<|reserved_special_token_202|>",
|
| 1685 |
+
"lstrip": false,
|
| 1686 |
+
"normalized": false,
|
| 1687 |
+
"rstrip": false,
|
| 1688 |
+
"single_word": false,
|
| 1689 |
+
"special": true
|
| 1690 |
+
},
|
| 1691 |
+
"128211": {
|
| 1692 |
+
"content": "<|reserved_special_token_203|>",
|
| 1693 |
+
"lstrip": false,
|
| 1694 |
+
"normalized": false,
|
| 1695 |
+
"rstrip": false,
|
| 1696 |
+
"single_word": false,
|
| 1697 |
+
"special": true
|
| 1698 |
+
},
|
| 1699 |
+
"128212": {
|
| 1700 |
+
"content": "<|reserved_special_token_204|>",
|
| 1701 |
+
"lstrip": false,
|
| 1702 |
+
"normalized": false,
|
| 1703 |
+
"rstrip": false,
|
| 1704 |
+
"single_word": false,
|
| 1705 |
+
"special": true
|
| 1706 |
+
},
|
| 1707 |
+
"128213": {
|
| 1708 |
+
"content": "<|reserved_special_token_205|>",
|
| 1709 |
+
"lstrip": false,
|
| 1710 |
+
"normalized": false,
|
| 1711 |
+
"rstrip": false,
|
| 1712 |
+
"single_word": false,
|
| 1713 |
+
"special": true
|
| 1714 |
+
},
|
| 1715 |
+
"128214": {
|
| 1716 |
+
"content": "<|reserved_special_token_206|>",
|
| 1717 |
+
"lstrip": false,
|
| 1718 |
+
"normalized": false,
|
| 1719 |
+
"rstrip": false,
|
| 1720 |
+
"single_word": false,
|
| 1721 |
+
"special": true
|
| 1722 |
+
},
|
| 1723 |
+
"128215": {
|
| 1724 |
+
"content": "<|reserved_special_token_207|>",
|
| 1725 |
+
"lstrip": false,
|
| 1726 |
+
"normalized": false,
|
| 1727 |
+
"rstrip": false,
|
| 1728 |
+
"single_word": false,
|
| 1729 |
+
"special": true
|
| 1730 |
+
},
|
| 1731 |
+
"128216": {
|
| 1732 |
+
"content": "<|reserved_special_token_208|>",
|
| 1733 |
+
"lstrip": false,
|
| 1734 |
+
"normalized": false,
|
| 1735 |
+
"rstrip": false,
|
| 1736 |
+
"single_word": false,
|
| 1737 |
+
"special": true
|
| 1738 |
+
},
|
| 1739 |
+
"128217": {
|
| 1740 |
+
"content": "<|reserved_special_token_209|>",
|
| 1741 |
+
"lstrip": false,
|
| 1742 |
+
"normalized": false,
|
| 1743 |
+
"rstrip": false,
|
| 1744 |
+
"single_word": false,
|
| 1745 |
+
"special": true
|
| 1746 |
+
},
|
| 1747 |
+
"128218": {
|
| 1748 |
+
"content": "<|reserved_special_token_210|>",
|
| 1749 |
+
"lstrip": false,
|
| 1750 |
+
"normalized": false,
|
| 1751 |
+
"rstrip": false,
|
| 1752 |
+
"single_word": false,
|
| 1753 |
+
"special": true
|
| 1754 |
+
},
|
| 1755 |
+
"128219": {
|
| 1756 |
+
"content": "<|reserved_special_token_211|>",
|
| 1757 |
+
"lstrip": false,
|
| 1758 |
+
"normalized": false,
|
| 1759 |
+
"rstrip": false,
|
| 1760 |
+
"single_word": false,
|
| 1761 |
+
"special": true
|
| 1762 |
+
},
|
| 1763 |
+
"128220": {
|
| 1764 |
+
"content": "<|reserved_special_token_212|>",
|
| 1765 |
+
"lstrip": false,
|
| 1766 |
+
"normalized": false,
|
| 1767 |
+
"rstrip": false,
|
| 1768 |
+
"single_word": false,
|
| 1769 |
+
"special": true
|
| 1770 |
+
},
|
| 1771 |
+
"128221": {
|
| 1772 |
+
"content": "<|reserved_special_token_213|>",
|
| 1773 |
+
"lstrip": false,
|
| 1774 |
+
"normalized": false,
|
| 1775 |
+
"rstrip": false,
|
| 1776 |
+
"single_word": false,
|
| 1777 |
+
"special": true
|
| 1778 |
+
},
|
| 1779 |
+
"128222": {
|
| 1780 |
+
"content": "<|reserved_special_token_214|>",
|
| 1781 |
+
"lstrip": false,
|
| 1782 |
+
"normalized": false,
|
| 1783 |
+
"rstrip": false,
|
| 1784 |
+
"single_word": false,
|
| 1785 |
+
"special": true
|
| 1786 |
+
},
|
| 1787 |
+
"128223": {
|
| 1788 |
+
"content": "<|reserved_special_token_215|>",
|
| 1789 |
+
"lstrip": false,
|
| 1790 |
+
"normalized": false,
|
| 1791 |
+
"rstrip": false,
|
| 1792 |
+
"single_word": false,
|
| 1793 |
+
"special": true
|
| 1794 |
+
},
|
| 1795 |
+
"128224": {
|
| 1796 |
+
"content": "<|reserved_special_token_216|>",
|
| 1797 |
+
"lstrip": false,
|
| 1798 |
+
"normalized": false,
|
| 1799 |
+
"rstrip": false,
|
| 1800 |
+
"single_word": false,
|
| 1801 |
+
"special": true
|
| 1802 |
+
},
|
| 1803 |
+
"128225": {
|
| 1804 |
+
"content": "<|reserved_special_token_217|>",
|
| 1805 |
+
"lstrip": false,
|
| 1806 |
+
"normalized": false,
|
| 1807 |
+
"rstrip": false,
|
| 1808 |
+
"single_word": false,
|
| 1809 |
+
"special": true
|
| 1810 |
+
},
|
| 1811 |
+
"128226": {
|
| 1812 |
+
"content": "<|reserved_special_token_218|>",
|
| 1813 |
+
"lstrip": false,
|
| 1814 |
+
"normalized": false,
|
| 1815 |
+
"rstrip": false,
|
| 1816 |
+
"single_word": false,
|
| 1817 |
+
"special": true
|
| 1818 |
+
},
|
| 1819 |
+
"128227": {
|
| 1820 |
+
"content": "<|reserved_special_token_219|>",
|
| 1821 |
+
"lstrip": false,
|
| 1822 |
+
"normalized": false,
|
| 1823 |
+
"rstrip": false,
|
| 1824 |
+
"single_word": false,
|
| 1825 |
+
"special": true
|
| 1826 |
+
},
|
| 1827 |
+
"128228": {
|
| 1828 |
+
"content": "<|reserved_special_token_220|>",
|
| 1829 |
+
"lstrip": false,
|
| 1830 |
+
"normalized": false,
|
| 1831 |
+
"rstrip": false,
|
| 1832 |
+
"single_word": false,
|
| 1833 |
+
"special": true
|
| 1834 |
+
},
|
| 1835 |
+
"128229": {
|
| 1836 |
+
"content": "<|reserved_special_token_221|>",
|
| 1837 |
+
"lstrip": false,
|
| 1838 |
+
"normalized": false,
|
| 1839 |
+
"rstrip": false,
|
| 1840 |
+
"single_word": false,
|
| 1841 |
+
"special": true
|
| 1842 |
+
},
|
| 1843 |
+
"128230": {
|
| 1844 |
+
"content": "<|reserved_special_token_222|>",
|
| 1845 |
+
"lstrip": false,
|
| 1846 |
+
"normalized": false,
|
| 1847 |
+
"rstrip": false,
|
| 1848 |
+
"single_word": false,
|
| 1849 |
+
"special": true
|
| 1850 |
+
},
|
| 1851 |
+
"128231": {
|
| 1852 |
+
"content": "<|reserved_special_token_223|>",
|
| 1853 |
+
"lstrip": false,
|
| 1854 |
+
"normalized": false,
|
| 1855 |
+
"rstrip": false,
|
| 1856 |
+
"single_word": false,
|
| 1857 |
+
"special": true
|
| 1858 |
+
},
|
| 1859 |
+
"128232": {
|
| 1860 |
+
"content": "<|reserved_special_token_224|>",
|
| 1861 |
+
"lstrip": false,
|
| 1862 |
+
"normalized": false,
|
| 1863 |
+
"rstrip": false,
|
| 1864 |
+
"single_word": false,
|
| 1865 |
+
"special": true
|
| 1866 |
+
},
|
| 1867 |
+
"128233": {
|
| 1868 |
+
"content": "<|reserved_special_token_225|>",
|
| 1869 |
+
"lstrip": false,
|
| 1870 |
+
"normalized": false,
|
| 1871 |
+
"rstrip": false,
|
| 1872 |
+
"single_word": false,
|
| 1873 |
+
"special": true
|
| 1874 |
+
},
|
| 1875 |
+
"128234": {
|
| 1876 |
+
"content": "<|reserved_special_token_226|>",
|
| 1877 |
+
"lstrip": false,
|
| 1878 |
+
"normalized": false,
|
| 1879 |
+
"rstrip": false,
|
| 1880 |
+
"single_word": false,
|
| 1881 |
+
"special": true
|
| 1882 |
+
},
|
| 1883 |
+
"128235": {
|
| 1884 |
+
"content": "<|reserved_special_token_227|>",
|
| 1885 |
+
"lstrip": false,
|
| 1886 |
+
"normalized": false,
|
| 1887 |
+
"rstrip": false,
|
| 1888 |
+
"single_word": false,
|
| 1889 |
+
"special": true
|
| 1890 |
+
},
|
| 1891 |
+
"128236": {
|
| 1892 |
+
"content": "<|reserved_special_token_228|>",
|
| 1893 |
+
"lstrip": false,
|
| 1894 |
+
"normalized": false,
|
| 1895 |
+
"rstrip": false,
|
| 1896 |
+
"single_word": false,
|
| 1897 |
+
"special": true
|
| 1898 |
+
},
|
| 1899 |
+
"128237": {
|
| 1900 |
+
"content": "<|reserved_special_token_229|>",
|
| 1901 |
+
"lstrip": false,
|
| 1902 |
+
"normalized": false,
|
| 1903 |
+
"rstrip": false,
|
| 1904 |
+
"single_word": false,
|
| 1905 |
+
"special": true
|
| 1906 |
+
},
|
| 1907 |
+
"128238": {
|
| 1908 |
+
"content": "<|reserved_special_token_230|>",
|
| 1909 |
+
"lstrip": false,
|
| 1910 |
+
"normalized": false,
|
| 1911 |
+
"rstrip": false,
|
| 1912 |
+
"single_word": false,
|
| 1913 |
+
"special": true
|
| 1914 |
+
},
|
| 1915 |
+
"128239": {
|
| 1916 |
+
"content": "<|reserved_special_token_231|>",
|
| 1917 |
+
"lstrip": false,
|
| 1918 |
+
"normalized": false,
|
| 1919 |
+
"rstrip": false,
|
| 1920 |
+
"single_word": false,
|
| 1921 |
+
"special": true
|
| 1922 |
+
},
|
| 1923 |
+
"128240": {
|
| 1924 |
+
"content": "<|reserved_special_token_232|>",
|
| 1925 |
+
"lstrip": false,
|
| 1926 |
+
"normalized": false,
|
| 1927 |
+
"rstrip": false,
|
| 1928 |
+
"single_word": false,
|
| 1929 |
+
"special": true
|
| 1930 |
+
},
|
| 1931 |
+
"128241": {
|
| 1932 |
+
"content": "<|reserved_special_token_233|>",
|
| 1933 |
+
"lstrip": false,
|
| 1934 |
+
"normalized": false,
|
| 1935 |
+
"rstrip": false,
|
| 1936 |
+
"single_word": false,
|
| 1937 |
+
"special": true
|
| 1938 |
+
},
|
| 1939 |
+
"128242": {
|
| 1940 |
+
"content": "<|reserved_special_token_234|>",
|
| 1941 |
+
"lstrip": false,
|
| 1942 |
+
"normalized": false,
|
| 1943 |
+
"rstrip": false,
|
| 1944 |
+
"single_word": false,
|
| 1945 |
+
"special": true
|
| 1946 |
+
},
|
| 1947 |
+
"128243": {
|
| 1948 |
+
"content": "<|reserved_special_token_235|>",
|
| 1949 |
+
"lstrip": false,
|
| 1950 |
+
"normalized": false,
|
| 1951 |
+
"rstrip": false,
|
| 1952 |
+
"single_word": false,
|
| 1953 |
+
"special": true
|
| 1954 |
+
},
|
| 1955 |
+
"128244": {
|
| 1956 |
+
"content": "<|reserved_special_token_236|>",
|
| 1957 |
+
"lstrip": false,
|
| 1958 |
+
"normalized": false,
|
| 1959 |
+
"rstrip": false,
|
| 1960 |
+
"single_word": false,
|
| 1961 |
+
"special": true
|
| 1962 |
+
},
|
| 1963 |
+
"128245": {
|
| 1964 |
+
"content": "<|reserved_special_token_237|>",
|
| 1965 |
+
"lstrip": false,
|
| 1966 |
+
"normalized": false,
|
| 1967 |
+
"rstrip": false,
|
| 1968 |
+
"single_word": false,
|
| 1969 |
+
"special": true
|
| 1970 |
+
},
|
| 1971 |
+
"128246": {
|
| 1972 |
+
"content": "<|reserved_special_token_238|>",
|
| 1973 |
+
"lstrip": false,
|
| 1974 |
+
"normalized": false,
|
| 1975 |
+
"rstrip": false,
|
| 1976 |
+
"single_word": false,
|
| 1977 |
+
"special": true
|
| 1978 |
+
},
|
| 1979 |
+
"128247": {
|
| 1980 |
+
"content": "<|reserved_special_token_239|>",
|
| 1981 |
+
"lstrip": false,
|
| 1982 |
+
"normalized": false,
|
| 1983 |
+
"rstrip": false,
|
| 1984 |
+
"single_word": false,
|
| 1985 |
+
"special": true
|
| 1986 |
+
},
|
| 1987 |
+
"128248": {
|
| 1988 |
+
"content": "<|reserved_special_token_240|>",
|
| 1989 |
+
"lstrip": false,
|
| 1990 |
+
"normalized": false,
|
| 1991 |
+
"rstrip": false,
|
| 1992 |
+
"single_word": false,
|
| 1993 |
+
"special": true
|
| 1994 |
+
},
|
| 1995 |
+
"128249": {
|
| 1996 |
+
"content": "<|reserved_special_token_241|>",
|
| 1997 |
+
"lstrip": false,
|
| 1998 |
+
"normalized": false,
|
| 1999 |
+
"rstrip": false,
|
| 2000 |
+
"single_word": false,
|
| 2001 |
+
"special": true
|
| 2002 |
+
},
|
| 2003 |
+
"128250": {
|
| 2004 |
+
"content": "<|reserved_special_token_242|>",
|
| 2005 |
+
"lstrip": false,
|
| 2006 |
+
"normalized": false,
|
| 2007 |
+
"rstrip": false,
|
| 2008 |
+
"single_word": false,
|
| 2009 |
+
"special": true
|
| 2010 |
+
},
|
| 2011 |
+
"128251": {
|
| 2012 |
+
"content": "<|reserved_special_token_243|>",
|
| 2013 |
+
"lstrip": false,
|
| 2014 |
+
"normalized": false,
|
| 2015 |
+
"rstrip": false,
|
| 2016 |
+
"single_word": false,
|
| 2017 |
+
"special": true
|
| 2018 |
+
},
|
| 2019 |
+
"128252": {
|
| 2020 |
+
"content": "<|reserved_special_token_244|>",
|
| 2021 |
+
"lstrip": false,
|
| 2022 |
+
"normalized": false,
|
| 2023 |
+
"rstrip": false,
|
| 2024 |
+
"single_word": false,
|
| 2025 |
+
"special": true
|
| 2026 |
+
},
|
| 2027 |
+
"128253": {
|
| 2028 |
+
"content": "<|reserved_special_token_245|>",
|
| 2029 |
+
"lstrip": false,
|
| 2030 |
+
"normalized": false,
|
| 2031 |
+
"rstrip": false,
|
| 2032 |
+
"single_word": false,
|
| 2033 |
+
"special": true
|
| 2034 |
+
},
|
| 2035 |
+
"128254": {
|
| 2036 |
+
"content": "<|reserved_special_token_246|>",
|
| 2037 |
+
"lstrip": false,
|
| 2038 |
+
"normalized": false,
|
| 2039 |
+
"rstrip": false,
|
| 2040 |
+
"single_word": false,
|
| 2041 |
+
"special": true
|
| 2042 |
+
},
|
| 2043 |
+
"128255": {
|
| 2044 |
+
"content": "<|reserved_special_token_247|>",
|
| 2045 |
+
"lstrip": false,
|
| 2046 |
+
"normalized": false,
|
| 2047 |
+
"rstrip": false,
|
| 2048 |
+
"single_word": false,
|
| 2049 |
+
"special": true
|
| 2050 |
+
}
|
| 2051 |
+
},
|
| 2052 |
+
"bos_token": "<|begin_of_text|>",
|
| 2053 |
+
"chat_template": "{{- bos_token }}\n{%- if custom_tools is defined %}\n {%- set tools = custom_tools %}\n{%- endif %}\n{%- if not tools_in_user_message is defined %}\n {%- set tools_in_user_message = true %}\n{%- endif %}\n{%- if not date_string is defined %}\n {%- set date_string = \"26 July 2024\" %}\n{%- endif %}\n{%- if not tools is defined %}\n {%- set tools = none %}\n{%- endif %}\n\n{#- This block extracts the system message, so we can slot it into the right place. #}\n{%- if messages[0]['role'] == 'system' %}\n {%- set system_message = messages[0]['content'] %}\n {%- set messages = messages[1:] %}\n{%- else %}\n {%- set system_message = \"\" %}\n{%- endif %}\n\n{#- System message + builtin tools #}\n{{- \"<|start_header_id|>system<|end_header_id|>\n\n\" }}\n{%- if builtin_tools is defined or tools is not none %}\n {{- \"Environment: ipython\n\" }}\n{%- endif %}\n{%- if builtin_tools is defined %}\n {{- \"Tools: \" + builtin_tools | reject('equalto', 'code_interpreter') | join(\", \") + \"\n\n\"}}\n{%- endif %}\n{{- \"Cutting Knowledge Date: December 2023\n\" }}\n{{- \"Today Date: \" + date_string + \"\n\n\" }}\n{%- if tools is not none and not tools_in_user_message %}\n {{- \"You have access to the following functions. To call a function, please respond with JSON for a function call.\" }}\n {{- 'Respond in the format {\"name\": function name, \"parameters\": dictionary of argument name and its value}.' }}\n {{- \"Do not use variables.\n\n\" }}\n {%- for t in tools %}\n {{- t | tojson(indent=4) }}\n {{- \"\n\n\" }}\n {%- endfor %}\n{%- endif %}\n{{- system_message }}\n{{- \"<|eot_id|>\" }}\n\n{#- Custom tools are passed in a user message with some extra guidance #}\n{%- if tools_in_user_message and not tools is none %}\n {#- Extract the first user message so we can plug it in here #}\n {%- if messages | length != 0 %}\n {%- set first_user_message = messages[0]['content'] %}\n {%- set messages = messages[1:] %}\n {%- else %}\n {{- raise_exception(\"Cannot put tools in the first user message when there's no first user message!\") }}\n{%- endif %}\n {{- '<|start_header_id|>user<|end_header_id|>\n\n' -}}\n {{- \"Given the following functions, please respond with a JSON for a function call \" }}\n {{- \"with its proper arguments that best answers the given prompt.\n\n\" }}\n {{- 'Respond in the format {\"name\": function name, \"parameters\": dictionary of argument name and its value}.' }}\n {{- \"Do not use variables.\n\n\" }}\n {%- for t in tools %}\n {{- t | tojson(indent=4) }}\n {{- \"\n\n\" }}\n {%- endfor %}\n {{- first_user_message + \"<|eot_id|>\"}}\n{%- endif %}\n\n{%- for message in messages %}\n {%- if not (message.role == 'ipython' or message.role == 'tool' or 'tool_calls' in message) %}\n {{- '<|start_header_id|>' + message['role'] + '<|end_header_id|>\n\n'+ message['content'] + '<|eot_id|>' }}\n {%- elif 'tool_calls' in message %}\n {%- if not message.tool_calls|length == 1 %}\n {{- raise_exception(\"This model only supports single tool-calls at once!\") }}\n {%- endif %}\n {%- set tool_call = message.tool_calls[0].function %}\n {%- if builtin_tools is defined and tool_call.name in builtin_tools %}\n {{- '<|start_header_id|>assistant<|end_header_id|>\n\n' -}}\n {{- \"<|python_tag|>\" + tool_call.name + \".call(\" }}\n {%- for arg_name, arg_val in tool_call.arguments | items %}\n {{- arg_name + '=\"' + arg_val + '\"' }}\n {%- if not loop.last %}\n {{- \", \" }}\n {%- endif %}\n {%- endfor %}\n {{- \")\" }}\n {%- else %}\n {{- '<|start_header_id|>assistant<|end_header_id|>\n\n' -}}\n {{- '{\"name\": \"' + tool_call.name + '\", ' }}\n {{- '\"parameters\": ' }}\n {{- tool_call.arguments | tojson }}\n {{- \"}\" }}\n {%- endif %}\n {%- if builtin_tools is defined %}\n {#- This means we're in ipython mode #}\n {{- \"<|eom_id|>\" }}\n {%- else %}\n {{- \"<|eot_id|>\" }}\n {%- endif %}\n {%- elif message.role == \"tool\" or message.role == \"ipython\" %}\n {{- \"<|start_header_id|>ipython<|end_header_id|>\n\n\" }}\n {%- if message.content is mapping or message.content is iterable %}\n {{- message.content | tojson }}\n {%- else %}\n {{- message.content }}\n {%- endif %}\n {{- \"<|eot_id|>\" }}\n {%- endif %}\n{%- endfor %}\n{%- if add_generation_prompt %}\n {{- '<|start_header_id|>assistant<|end_header_id|>\n\n' }}\n{%- endif %}\n",
|
| 2054 |
+
"clean_up_tokenization_spaces": true,
|
| 2055 |
+
"eos_token": "<|eot_id|>",
|
| 2056 |
+
"model_input_names": [
|
| 2057 |
+
"input_ids",
|
| 2058 |
+
"attention_mask"
|
| 2059 |
+
],
|
| 2060 |
+
"model_max_length": 131072,
|
| 2061 |
+
"pad_token": "<|finetune_right_pad_id|>",
|
| 2062 |
+
"padding_side": "right",
|
| 2063 |
+
"tokenizer_class": "PreTrainedTokenizerFast"
|
| 2064 |
+
}
|
ComfyUI/models/LLM/Phi-3.5-mini-instruct/.gitattributes
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
| 13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
ComfyUI/models/LLM/Phi-3.5-mini-instruct/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Microsoft Open Source Code of Conduct
|
| 2 |
+
|
| 3 |
+
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
|
| 4 |
+
|
| 5 |
+
Resources:
|
| 6 |
+
|
| 7 |
+
- [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/)
|
| 8 |
+
- [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
|
| 9 |
+
- Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns
|
ComfyUI/models/LLM/Phi-3.5-mini-instruct/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Microsoft.
|
| 2 |
+
Copyright (c) Microsoft Corporation.
|
| 3 |
+
|
| 4 |
+
MIT License
|
| 5 |
+
|
| 6 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 7 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 8 |
+
in the Software without restriction, including without limitation the rights
|
| 9 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 10 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 11 |
+
furnished to do so, subject to the following conditions:
|
| 12 |
+
|
| 13 |
+
The above copyright notice and this permission notice shall be included in all
|
| 14 |
+
copies or substantial portions of the Software.
|
| 15 |
+
|
| 16 |
+
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 17 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 18 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 19 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 20 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 21 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 22 |
+
SOFTWARE.
|
ComfyUI/models/LLM/Phi-3.5-mini-instruct/NOTICE.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
NOTICES AND INFORMATION
|
| 2 |
+
Do Not Translate or Localize
|
| 3 |
+
|
| 4 |
+
This software incorporates material from third parties.
|
| 5 |
+
|
| 6 |
+
**Component.** https://github.com/Dao-AILab/flash-attention
|
| 7 |
+
|
| 8 |
+
**Open Source License/Copyright Notice.**
|
| 9 |
+
|
| 10 |
+
BSD 3-Clause License
|
| 11 |
+
|
| 12 |
+
Copyright (c) 2022, the respective contributors, as shown by the AUTHORS file.
|
| 13 |
+
All rights reserved.
|
| 14 |
+
|
| 15 |
+
Redistribution and use in source and binary forms, with or without
|
| 16 |
+
modification, are permitted provided that the following conditions are met:
|
| 17 |
+
|
| 18 |
+
* Redistributions of source code must retain the above copyright notice, this
|
| 19 |
+
list of conditions and the following disclaimer.
|
| 20 |
+
|
| 21 |
+
* Redistributions in binary form must reproduce the above copyright notice,
|
| 22 |
+
this list of conditions and the following disclaimer in the documentation
|
| 23 |
+
and/or other materials provided with the distribution.
|
| 24 |
+
|
| 25 |
+
* Neither the name of the copyright holder nor the names of its
|
| 26 |
+
contributors may be used to endorse or promote products derived from
|
| 27 |
+
this software without specific prior written permission.
|
| 28 |
+
|
| 29 |
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
| 30 |
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
| 31 |
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
| 32 |
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
| 33 |
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
| 34 |
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
| 35 |
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
| 36 |
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
| 37 |
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 38 |
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
ComfyUI/models/LLM/Phi-3.5-mini-instruct/README.md
ADDED
|
@@ -0,0 +1,474 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
license_link: https://huggingface.co/microsoft/Phi-3.5-mini-instruct/resolve/main/LICENSE
|
| 4 |
+
language:
|
| 5 |
+
- multilingual
|
| 6 |
+
pipeline_tag: text-generation
|
| 7 |
+
tags:
|
| 8 |
+
- nlp
|
| 9 |
+
- code
|
| 10 |
+
widget:
|
| 11 |
+
- messages:
|
| 12 |
+
- role: user
|
| 13 |
+
content: Can you provide ways to eat combinations of bananas and dragonfruits?
|
| 14 |
+
library_name: transformers
|
| 15 |
+
---
|
| 16 |
+
|
| 17 |
+
## Model Summary
|
| 18 |
+
|
| 19 |
+
Phi-3.5-mini is a lightweight, state-of-the-art open model built upon datasets used for Phi-3 - synthetic data and filtered publicly available websites - with a focus on very high-quality, reasoning dense data. The model belongs to the Phi-3 model family and supports 128K token context length. The model underwent a rigorous enhancement process, incorporating both supervised fine-tuning, proximal policy optimization, and direct preference optimization to ensure precise instruction adherence and robust safety measures.
|
| 20 |
+
|
| 21 |
+
🏡 [Phi-3 Portal](https://azure.microsoft.com/en-us/products/phi-3) <br>
|
| 22 |
+
📰 [Phi-3 Microsoft Blog](https://aka.ms/phi3.5-techblog) <br>
|
| 23 |
+
📖 [Phi-3 Technical Report](https://arxiv.org/abs/2404.14219) <br>
|
| 24 |
+
👩🍳 [Phi-3 Cookbook](https://github.com/microsoft/Phi-3CookBook) <br>
|
| 25 |
+
🖥️ [Try It](https://aka.ms/try-phi3.5mini) <br>
|
| 26 |
+
|
| 27 |
+
**Phi-3.5**: [[mini-instruct]](https://huggingface.co/microsoft/Phi-3.5-mini-instruct); [[MoE-instruct]](https://huggingface.co/microsoft/Phi-3.5-MoE-instruct) ; [[vision-instruct]](https://huggingface.co/microsoft/Phi-3.5-vision-instruct)
|
| 28 |
+
|
| 29 |
+
## Intended Uses
|
| 30 |
+
|
| 31 |
+
### Primary Use Cases
|
| 32 |
+
|
| 33 |
+
The model is intended for commercial and research use in multiple languages. The model provides uses for general purpose AI systems and applications which require:
|
| 34 |
+
|
| 35 |
+
1) Memory/compute constrained environments
|
| 36 |
+
2) Latency bound scenarios
|
| 37 |
+
3) Strong reasoning (especially code, math and logic)
|
| 38 |
+
|
| 39 |
+
Our model is designed to accelerate research on language and multimodal models, for use as a building block for generative AI powered features.
|
| 40 |
+
|
| 41 |
+
### Use Case Considerations
|
| 42 |
+
|
| 43 |
+
Our models are not specifically designed or evaluated for all downstream purposes. Developers should consider common limitations of language models as they select use cases, and evaluate and mitigate for accuracy, safety, and fariness before using within a specific downstream use case, particularly for high risk scenarios. Developers should be aware of and adhere to applicable laws or regulations (including privacy, trade compliance laws, etc.) that are relevant to their use case.
|
| 44 |
+
|
| 45 |
+
***Nothing contained in this Model Card should be interpreted as or deemed a restriction or modification to the license the model is released under.***
|
| 46 |
+
|
| 47 |
+
## Release Notes
|
| 48 |
+
|
| 49 |
+
This is an update over the June 2024 instruction-tuned Phi-3 Mini release based on valuable user feedback. The model used additional post-training data leading to substantial gains on multilingual, multi-turn conversation quality, and reasoning capability. We believe most use cases will benefit from this release, but we encourage users to test in their particular AI applications. We appreciate the enthusiastic adoption of the Phi-3 model family, and continue to welcome all feedback from the community.
|
| 50 |
+
|
| 51 |
+
### Multilingual
|
| 52 |
+
|
| 53 |
+
The table below highlights multilingual capability of the Phi-3.5 Mini on multilingual MMLU, MEGA, and multilingual MMLU-pro datasets. Overall, we observed that even with just 3.8B active parameters, the model is competitive on multilingual tasks in comparison to other models with a much bigger active parameters.
|
| 54 |
+
|
| 55 |
+
| Benchmark | Phi-3.5 Mini-Ins | Phi-3.0-Mini-128k-Instruct (June2024) | Mistral-7B-Instruct-v0.3 | Mistral-Nemo-12B-Ins-2407 | Llama-3.1-8B-Ins | Gemma-2-9B-Ins | Gemini 1.5 Flash | GPT-4o-mini-2024-07-18 (Chat) |
|
| 56 |
+
|----------------------------|------------------|-----------------------|--------------------------|---------------------------|------------------|----------------|------------------|-------------------------------|
|
| 57 |
+
| Multilingual MMLU | 55.4 | 51.08 | 47.4 | 58.9 | 56.2 | 63.8 | 77.2 | 72.9 |
|
| 58 |
+
| Multilingual MMLU-Pro | 30.9 | 30.21 | 15.0 | 34.0 | 21.4 | 43.0 | 57.9 | 53.2 |
|
| 59 |
+
| MGSM | 47.9 | 41.56 | 31.8 | 63.3 | 56.7 | 75.1 | 75.8 | 81.7 |
|
| 60 |
+
| MEGA MLQA | 61.7 | 55.5 | 43.9 | 61.2 | 45.2 | 54.4 | 61.6 | 70.0 |
|
| 61 |
+
| MEGA TyDi QA | 62.2 | 55.9 | 54.0 | 63.7 | 54.5 | 65.6 | 63.6 | 81.8 |
|
| 62 |
+
| MEGA UDPOS | 46.5 | 48.1 | 57.2 | 58.2 | 54.1 | 56.6 | 62.4 | 66.0 |
|
| 63 |
+
| MEGA XCOPA | 63.1 | 62.4 | 58.8 | 10.8 | 21.1 | 31.2 | 95.0 | 90.3 |
|
| 64 |
+
| MEGA XStoryCloze | 73.5 | 73.6 | 75.5 | 92.3 | 71.0 | 87.0 | 20.7 | 96.6 |
|
| 65 |
+
| **Average** | **55.2** | **52.3** | **47.9** | **55.3** | **47.5** | **59.6** | **64.3** | **76.6** |
|
| 66 |
+
|
| 67 |
+
The table below shows Multilingual MMLU scores in some of the supported languages. For more multi-lingual benchmarks and details, see [Appendix A](#appendix-a).
|
| 68 |
+
|
| 69 |
+
| Benchmark | Phi-3.5 Mini-Ins | Phi-3.0-Mini-128k-Instruct (June2024) | Mistral-7B-Instruct-v0.3 | Mistral-Nemo-12B-Ins-2407 | Llama-3.1-8B-Ins | Gemma-2-9B-Ins | Gemini 1.5 Flash | GPT-4o-mini-2024-07-18 (Chat) |
|
| 70 |
+
|-----------|------------------|-----------------------|--------------------------|---------------------------|------------------|----------------|------------------|-------------------------------|
|
| 71 |
+
| Arabic | 44.2 | 35.4 | 33.7 | 45.3 | 49.1 | 56.3 | 73.6 | 67.1 |
|
| 72 |
+
| Chinese | 52.6 | 46.9 | 45.9 | 58.2 | 54.4 | 62.7 | 66.7 | 70.8 |
|
| 73 |
+
| Dutch | 57.7 | 48.0 | 51.3 | 60.1 | 55.9 | 66.7 | 80.6 | 74.2 |
|
| 74 |
+
| French | 61.1 | 61.7 | 53.0 | 63.8 | 62.8 | 67.0 | 82.9 | 75.6 |
|
| 75 |
+
| German | 62.4 | 61.3 | 50.1 | 64.5 | 59.9 | 65.7 | 79.5 | 74.3 |
|
| 76 |
+
| Italian | 62.8 | 63.1 | 52.5 | 64.1 | 55.9 | 65.7 | 82.6 | 75.9 |
|
| 77 |
+
| Russian | 50.4 | 45.3 | 48.9 | 59.0 | 57.4 | 63.2 | 78.7 | 72.6 |
|
| 78 |
+
| Spanish | 62.6 | 61.3 | 53.9 | 64.3 | 62.6 | 66.0 | 80.0 | 75.5 |
|
| 79 |
+
| Ukrainian | 45.2 | 36.7 | 46.9 | 56.6 | 52.9 | 62.0 | 77.4 | 72.6 |
|
| 80 |
+
|
| 81 |
+
### Long Context
|
| 82 |
+
|
| 83 |
+
Phi-3.5-mini supports 128K context length, therefore the model is capable of several long context tasks including long document/meeting summarization, long document QA, long document information retrieval. We see that Phi-3.5-mini is clearly better than Gemma-2 family which only supports 8K context length. Phi-3.5-mini is competitive with other much larger open-weight models such as Llama-3.1-8B-instruct, Mistral-7B-instruct-v0.3, and Mistral-Nemo-12B-instruct-2407.
|
| 84 |
+
|
| 85 |
+
| Benchmark | Phi-3.5-mini-instruct | Llama-3.1-8B-instruct | Mistral-7B-instruct-v0.3 | Mistral-Nemo-12B-instruct-2407 | Gemini-1.5-Flash | GPT-4o-mini-2024-07-18 (Chat) |
|
| 86 |
+
|--|--|--|--|--|--|--|
|
| 87 |
+
| GovReport | 25.9 | 25.1 | 26.0 | 25.6 | 27.8 | 24.8 |
|
| 88 |
+
| QMSum | 21.3 | 21.6 | 21.3 | 22.1 | 24.0 | 21.7 |
|
| 89 |
+
| Qasper | 41.9 | 37.2 | 31.4 | 30.7 | 43.5 | 39.8 |
|
| 90 |
+
| SQuALITY | 25.3 | 26.2 | 25.9 | 25.8 | 23.5 | 23.8 |
|
| 91 |
+
| SummScreenFD | 16.0 | 17.6 | 17.5 | 18.2 | 16.3 | 17.0 |
|
| 92 |
+
| **Average** | **26.1** | **25.5** | **24.4** | **24.5** | **27.0** | **25.4** |
|
| 93 |
+
|
| 94 |
+
RULER: a retrieval-based benchmark for long context understanding
|
| 95 |
+
| Model | 4K | 8K | 16K | 32K | 64K | 128K | Average |
|
| 96 |
+
|--|--|--|--|--|--|--|--|
|
| 97 |
+
| **Phi-3.5-mini-instruct** | 94.3 | 91.1 | 90.7 | 87.1 | 78.0 | 63.6 | **84.1** |
|
| 98 |
+
| **Llama-3.1-8B-instruct** | 95.5 | 93.8 | 91.6 | 87.4 | 84.7 | 77.0 | **88.3** |
|
| 99 |
+
| **Mistral-Nemo-12B-instruct-2407** | 87.8 | 87.2 | 87.7 | 69.0 | 46.8 | 19.0 | **66.2** |
|
| 100 |
+
|
| 101 |
+
RepoQA: a benchmark for long context code understanding
|
| 102 |
+
| Model | Python | C++ | Rust | Java | TypeScript | Average |
|
| 103 |
+
|--|--|--|--|--|--|--|
|
| 104 |
+
| **Phi-3.5-mini-instruct** | 86 | 67 | 73 | 77 | 82 | **77** |
|
| 105 |
+
| **Llama-3.1-8B-instruct** | 80 | 65 | 73 | 76 | 63 | **71** |
|
| 106 |
+
| **Mistral-7B-instruct-v0.3** | 61 | 57 | 51 | 61 | 80 | **62** |
|
| 107 |
+
|
| 108 |
+
## Usage
|
| 109 |
+
|
| 110 |
+
### Requirements
|
| 111 |
+
Phi-3 family has been integrated in the `4.43.0` version of `transformers`. The current `transformers` version can be verified with: `pip list | grep transformers`.
|
| 112 |
+
|
| 113 |
+
Examples of required packages:
|
| 114 |
+
```
|
| 115 |
+
flash_attn==2.5.8
|
| 116 |
+
torch==2.3.1
|
| 117 |
+
accelerate==0.31.0
|
| 118 |
+
transformers==4.43.0
|
| 119 |
+
```
|
| 120 |
+
|
| 121 |
+
Phi-3.5-mini-instruct is also available in [Azure AI Studio](https://aka.ms/try-phi3.5mini)
|
| 122 |
+
|
| 123 |
+
### Tokenizer
|
| 124 |
+
|
| 125 |
+
Phi-3.5-mini-Instruct supports a vocabulary size of up to `32064` tokens. The [tokenizer files](https://huggingface.co/microsoft/Phi-3.5-mini-instruct/blob/main/added_tokens.json) already provide placeholder tokens that can be used for downstream fine-tuning, but they can also be extended up to the model's vocabulary size.
|
| 126 |
+
|
| 127 |
+
### Input Formats
|
| 128 |
+
Given the nature of the training data, the Phi-3.5-mini-instruct model is best suited for prompts using the chat format as follows:
|
| 129 |
+
|
| 130 |
+
```
|
| 131 |
+
<|system|>
|
| 132 |
+
You are a helpful assistant.<|end|>
|
| 133 |
+
<|user|>
|
| 134 |
+
How to explain Internet for a medieval knight?<|end|>
|
| 135 |
+
<|assistant|>
|
| 136 |
+
```
|
| 137 |
+
|
| 138 |
+
### Loading the model locally
|
| 139 |
+
After obtaining the Phi-3.5-mini-instruct model checkpoint, users can use this sample code for inference.
|
| 140 |
+
|
| 141 |
+
```python
|
| 142 |
+
import torch
|
| 143 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
|
| 144 |
+
|
| 145 |
+
torch.random.manual_seed(0)
|
| 146 |
+
|
| 147 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 148 |
+
"microsoft/Phi-3.5-mini-instruct",
|
| 149 |
+
device_map="cuda",
|
| 150 |
+
torch_dtype="auto",
|
| 151 |
+
trust_remote_code=True,
|
| 152 |
+
)
|
| 153 |
+
tokenizer = AutoTokenizer.from_pretrained("microsoft/Phi-3.5-mini-instruct")
|
| 154 |
+
|
| 155 |
+
messages = [
|
| 156 |
+
{"role": "system", "content": "You are a helpful AI assistant."},
|
| 157 |
+
{"role": "user", "content": "Can you provide ways to eat combinations of bananas and dragonfruits?"},
|
| 158 |
+
{"role": "assistant", "content": "Sure! Here are some ways to eat bananas and dragonfruits together: 1. Banana and dragonfruit smoothie: Blend bananas and dragonfruits together with some milk and honey. 2. Banana and dragonfruit salad: Mix sliced bananas and dragonfruits together with some lemon juice and honey."},
|
| 159 |
+
{"role": "user", "content": "What about solving an 2x + 3 = 7 equation?"},
|
| 160 |
+
]
|
| 161 |
+
|
| 162 |
+
pipe = pipeline(
|
| 163 |
+
"text-generation",
|
| 164 |
+
model=model,
|
| 165 |
+
tokenizer=tokenizer,
|
| 166 |
+
)
|
| 167 |
+
|
| 168 |
+
generation_args = {
|
| 169 |
+
"max_new_tokens": 500,
|
| 170 |
+
"return_full_text": False,
|
| 171 |
+
"temperature": 0.0,
|
| 172 |
+
"do_sample": False,
|
| 173 |
+
}
|
| 174 |
+
|
| 175 |
+
output = pipe(messages, **generation_args)
|
| 176 |
+
print(output[0]['generated_text'])
|
| 177 |
+
```
|
| 178 |
+
|
| 179 |
+
Notes: If you want to use flash attention, call _AutoModelForCausalLM.from_pretrained()_ with _attn_implementation="flash_attention_2"_
|
| 180 |
+
|
| 181 |
+
## Responsible AI Considerations
|
| 182 |
+
|
| 183 |
+
Like other language models, the Phi family of models can potentially behave in ways that are unfair, unreliable, or offensive. Some of the limiting behaviors to be aware of include:
|
| 184 |
+
+ Quality of Service: The Phi models are trained primarily on English text and some additional multilingual text. Languages other than English will experience worse performance as well as performance disparities across non-English. English language varieties with less representation in the training data might experience worse performance than standard American English.
|
| 185 |
+
+ Multilingual performance and safety gaps: We believe it is important to make language models more widely available across different languages, but the Phi 3 models still exhibit challenges common across multilingual releases. As with any deployment of LLMs, developers will be better positioned to test for performance or safety gaps for their linguistic and cultural context and customize the model with additional fine-tuning and appropriate safeguards.
|
| 186 |
+
+ Representation of Harms & Perpetuation of Stereotypes: These models can over- or under-represent groups of people, erase representation of some groups, or reinforce demeaning or negative stereotypes. Despite safety post-training, these limitations may still be present due to differing levels of representation of different groups, cultural contexts, or prevalence of examples of negative stereotypes in training data that reflect real-world patterns and societal biases.
|
| 187 |
+
+ Inappropriate or Offensive Content: These models may produce other types of inappropriate or offensive content, which may make it inappropriate to deploy for sensitive contexts without additional mitigations that are specific to the case.
|
| 188 |
+
+ Information Reliability: Language models can generate nonsensical content or fabricate content that might sound reasonable but is inaccurate or outdated.
|
| 189 |
+
+ Limited Scope for Code: Majority of Phi-3 training data is based in Python and use common packages such as "typing, math, random, collections, datetime, itertools". If the model generates Python scripts that utilize other packages or scripts in other languages, we strongly recommend users manually verify all API uses.
|
| 190 |
+
+ Long Conversation: Phi-3 models, like other models, can in some cases generate responses that are repetitive, unhelpful, or inconsistent in very long chat sessions in both English and non-English languages. Developers are encouraged to place appropriate mitigations, like limiting conversation turns to account for the possible conversational drift
|
| 191 |
+
|
| 192 |
+
Developers should apply responsible AI best practices, including mapping, measuring, and mitigating risks associated with their specific use case and cultural, linguistic context. Phi-3 family of models are general purpose models. As developers plan to deploy these models for specific use cases, they are encouraged to fine-tune the models for their use case and leverage the models as part of broader AI systems with language-specific safeguards in place. Important areas for consideration include:
|
| 193 |
+
|
| 194 |
+
+ Allocation: Models may not be suitable for scenarios that could have consequential impact on legal status or the allocation of resources or life opportunities (ex: housing, employment, credit, etc.) without further assessments and additional debiasing techniques.
|
| 195 |
+
+ High-Risk Scenarios: Developers should assess the suitability of using models in high-risk scenarios where unfair, unreliable or offensive outputs might be extremely costly or lead to harm. This includes providing advice in sensitive or expert domains where accuracy and reliability are critical (ex: legal or health advice). Additional safeguards should be implemented at the application level according to the deployment context.
|
| 196 |
+
+ Misinformation: Models may produce inaccurate information. Developers should follow transparency best practices and inform end-users they are interacting with an AI system. At the application level, developers can build feedback mechanisms and pipelines to ground responses in use-case specific, contextual information, a technique known as Retrieval Augmented Generation (RAG).
|
| 197 |
+
+ Generation of Harmful Content: Developers should assess outputs for their context and use available safety classifiers or custom solutions appropriate for their use case.
|
| 198 |
+
+ Misuse: Other forms of misuse such as fraud, spam, or malware production may be possible, and developers should ensure that their applications do not violate applicable laws and regulations.
|
| 199 |
+
|
| 200 |
+
## Training
|
| 201 |
+
|
| 202 |
+
### Model
|
| 203 |
+
|
| 204 |
+
**Architecture:** Phi-3.5-mini has 3.8B parameters and is a dense decoder-only Transformer model using the same tokenizer as Phi-3 Mini.<br>
|
| 205 |
+
**Inputs:** Text. It is best suited for prompts using chat format.<br>
|
| 206 |
+
**Context length:** 128K tokens<br>
|
| 207 |
+
**GPUs:** 512 H100-80G<br>
|
| 208 |
+
**Training time:** 10 days<br>
|
| 209 |
+
**Training data:** 3.4T tokens<br>
|
| 210 |
+
**Outputs:** Generated text in response to the input<br>
|
| 211 |
+
**Dates:** Trained between June and August 2024<br>
|
| 212 |
+
**Status:** This is a static model trained on an offline dataset with cutoff date October 2023 for publicly available data. Future versions of the tuned models may be released as we improve models.<br>
|
| 213 |
+
**Supported languages:** Arabic, Chinese, Czech, Danish, Dutch, English, Finnish, French, German, Hebrew, Hungarian, Italian, Japanese, Korean, Norwegian, Polish, Portuguese, Russian, Spanish, Swedish, Thai, Turkish, Ukrainian<br>
|
| 214 |
+
**Release date:** August 2024<br>
|
| 215 |
+
|
| 216 |
+
### Training Datasets
|
| 217 |
+
Our training data includes a wide variety of sources, totaling 3.4 trillion tokens, and is a combination of
|
| 218 |
+
1) publicly available documents filtered rigorously for quality, selected high-quality educational data, and code;
|
| 219 |
+
2) newly created synthetic, “textbook-like” data for the purpose of teaching math, coding, common sense reasoning, general knowledge of the world (science, daily activities, theory of mind, etc.);
|
| 220 |
+
3) high quality chat format supervised data covering various topics to reflect human preferences on different aspects such as instruct-following, truthfulness, honesty and helpfulness.
|
| 221 |
+
|
| 222 |
+
We are focusing on the quality of data that could potentially improve the reasoning ability for the model, and we filter the publicly available documents to contain the correct level of knowledge. As an example, the result of a game in premier league in a particular day might be good training data for frontier models, but we need to remove such information to leave more model capacity for reasoning for the small size models. More details about data can be found in the [Phi-3 Technical Report](https://arxiv.org/pdf/2404.14219).
|
| 223 |
+
|
| 224 |
+
### Fine-tuning
|
| 225 |
+
|
| 226 |
+
A basic example of multi-GPUs supervised fine-tuning (SFT) with TRL and Accelerate modules is provided [here](https://huggingface.co/microsoft/Phi-3.5-mini-instruct/resolve/main/sample_finetune.py).
|
| 227 |
+
|
| 228 |
+
## Benchmarks
|
| 229 |
+
|
| 230 |
+
We report the results under completion format for Phi-3.5-mini on standard open-source benchmarks measuring the model's reasoning ability (both common sense reasoning and logical reasoning). We compare to Mistral-7B-Instruct-v0.3, Mistral-Nemo-12B-Ins-2407, Llama-3.1-8B-Ins, Gemma-2-9B-Ins, Gemini 1.5 Flash, and GPT-4o-mini-2024-07-18 (Chat).
|
| 231 |
+
|
| 232 |
+
All the reported numbers are produced with the exact same pipeline to ensure that the numbers are comparable. These numbers might differ from other published numbers due to slightly different choices in the evaluation.
|
| 233 |
+
|
| 234 |
+
As is now standard, we use few-shot prompts to evaluate the models, at temperature 0.
|
| 235 |
+
The prompts and number of shots are part of a Microsoft internal tool to evaluate language models, and in particular we did no optimization to the pipeline for Phi-3.
|
| 236 |
+
More specifically, we do not change prompts, pick different few-shot examples, change prompt format, or do any other form of optimization for the model.
|
| 237 |
+
|
| 238 |
+
The number of k–shot examples is listed per-benchmark. At the high-level overview of the model quality on representative benchmarks:
|
| 239 |
+
|
| 240 |
+
| Category | Benchmark | Phi-3.5 Mini-Ins | Mistral-7B-Instruct-v0.3 | Mistral-Nemo-12B-Ins-2407 | Llama-3.1-8B-Ins | Gemma-2-9B-Ins | Gemini 1.5 Flash | GPT-4o-mini-2024-07-18 (Chat) |
|
| 241 |
+
|----------------|--------------------------|------------------|--------------------------|---------------------------|------------------|----------------|------------------|------------------------------|
|
| 242 |
+
| Popular aggregated benchmark | Arena Hard | 37 | 18.1 | 39.4 | 25.7 | 42 | 55.2 | 75 |
|
| 243 |
+
| | BigBench Hard CoT (0-shot) | 69 | 33.4 | 60.2 | 63.4 | 63.5 | 66.7 | 80.4 |
|
| 244 |
+
| | MMLU (5-shot) | 69 | 60.3 | 67.2 | 68.1 | 71.3 | 78.7 | 77.2 |
|
| 245 |
+
| | MMLU-Pro (0-shot, CoT) | 47.4 | 18 | 40.7 | 44 | 50.1 | 57.2 | 62.8 |
|
| 246 |
+
| Reasoning | ARC Challenge (10-shot) | 84.6 | 77.9 | 84.8 | 83.1 | 89.8 | 92.8 | 93.5 |
|
| 247 |
+
| | BoolQ (2-shot) | 78 | 80.5 | 82.5 | 82.8 | 85.7 | 85.8 | 88.7 |
|
| 248 |
+
| | GPQA (0-shot, CoT) | 30.4 | 15.6 | 28.6 | 26.3 | 29.2 | 37.5 | 41.1 |
|
| 249 |
+
| | HellaSwag (5-shot) | 69.4 | 71.6 | 76.7 | 73.5 | 80.9 | 67.5 | 87.1 |
|
| 250 |
+
| | OpenBookQA (10-shot) | 79.2 | 78 | 84.4 | 84.8 | 89.6 | 89 | 90 |
|
| 251 |
+
| | PIQA (5-shot) | 81 | 73.4 | 83.5 | 81.2 | 83.7 | 87.5 | 88.7 |
|
| 252 |
+
| | Social IQA (5-shot) | 74.7 | 73 | 75.3 | 71.8 | 74.7 | 77.8 | 82.9 |
|
| 253 |
+
| | TruthfulQA (MC2) (10-shot) | 64 | 64.7 | 68.1 | 69.2 | 76.6 | 76.6 | 78.2 |
|
| 254 |
+
| | WinoGrande (5-shot) | 68.5 | 58.1 | 70.4 | 64.7 | 74 | 74.7 | 76.9 |
|
| 255 |
+
| Multilingual | Multilingual MMLU (5-shot) | 55.4 | 47.4 | 58.9 | 56.2 | 63.8 | 77.2 | 72.9 |
|
| 256 |
+
| | MGSM (0-shot CoT) | 47.9 | 31.8 | 63.3 | 56.7 | 76.4 | 75.8 | 81.7 |
|
| 257 |
+
| Math | GSM8K (8-shot, CoT) | 86.2 | 54.4 | 84.2 | 82.4 | 84.9 | 82.4 | 91.3 |
|
| 258 |
+
| | MATH (0-shot, CoT) | 48.5 | 19 | 31.2 | 47.6 | 50.9 | 38 | 70.2 |
|
| 259 |
+
| Long context | Qasper | 41.9 | 31.4 | 30.7 | 37.2 | 13.9 | 43.5 | 39.8 |
|
| 260 |
+
| | SQuALITY | 24.3 | 25.9 | 25.8 | 26.2 | 0 | 23.5 | 23.8 |
|
| 261 |
+
| Code Generation| HumanEval (0-shot) | 62.8 | 35.4 | 63.4 | 66.5 | 61 | 74.4 | 86.6 |
|
| 262 |
+
| | MBPP (3-shot) | 69.6 | 50.4 | 68.1 | 69.4 | 69.3 | 77.5 | 84.1 |
|
| 263 |
+
| **Average** | | **61.4** | **48.5** | **61.3** | **61.0** | **63.3** | **68.5** | **74.9** |
|
| 264 |
+
|
| 265 |
+
We take a closer look at different categories across public benchmark datasets at the table below:
|
| 266 |
+
|
| 267 |
+
| Category | Phi-3.5 Mini-Ins | Mistral-7B-Instruct-v0.3 | Mistral-Nemo-12B-Ins-2407 | Llama-3.1-8B-Ins | Gemma-2-9B-Ins | Gemini 1.5 Flash | GPT-4o-mini-2024-07-18 (Chat) |
|
| 268 |
+
|----------------------------|------------------|--------------------------|---------------------------|------------------|----------------|------------------|------------------------------|
|
| 269 |
+
| Popular aggregated benchmark | 55.6 | 32.5 | 51.9 | 50.3 | 56.7 | 64.5 | 73.9 |
|
| 270 |
+
| Reasoning | 70.1 | 65.2 | 72.2 | 70.5 | 75.4 | 77.7 | 80 |
|
| 271 |
+
| Language understanding | 62.6 | 62.8 | 67 | 62.9 | 72.8 | 66.6 | 76.8 |
|
| 272 |
+
| Robustness | 59.7 | 53.4 | 65.2 | 59.8 | 64.7 | 68.9 | 77.5 |
|
| 273 |
+
| Long context | 26.1 | 25.5 | 24.4 | 24.5 | 0 | 27 | 25.4 |
|
| 274 |
+
| Math | 67.4 | 36.7 | 57.7 | 65 | 67.9 | 60.2 | 80.8 |
|
| 275 |
+
| Code generation | 62 | 43.1 | 56.9 | 65.8 | 58.3 | 66.8 | 69.9 |
|
| 276 |
+
| Multilingual | 55.2 | 47.9 | 55.3 | 47.5 | 59.6 | 64.3 | 76.6 |
|
| 277 |
+
|
| 278 |
+
Overall, the model with only 3.8B-param achieves a similar level of multilingual language understanding and reasoning ability as much larger models.
|
| 279 |
+
However, it is still fundamentally limited by its size for certain tasks.
|
| 280 |
+
The model simply does not have the capacity to store too much factual knowledge, therefore, users may experience factual incorrectness.
|
| 281 |
+
However, we believe such weakness can be resolved by augmenting Phi-3.5 with a search engine, particularly when using the model under RAG settings.
|
| 282 |
+
|
| 283 |
+
## Safety Evaluation and Red-Teaming
|
| 284 |
+
|
| 285 |
+
We leveraged various evaluation techniques including red teaming, adversarial conversation simulations, and multilingual safety evaluation benchmark datasets to
|
| 286 |
+
evaluate Phi-3.5 models' propensity to produce undesirable outputs across multiple languages and risk categories.
|
| 287 |
+
Several approaches were used to compensate for the limitations of one approach alone. Findings across the various evaluation methods indicate that safety
|
| 288 |
+
post-training that was done as detailed in the [Phi-3 Safety Post-Training paper](https://arxiv.org/pdf/2407.13833) had a positive impact across multiple languages and risk categories as observed by
|
| 289 |
+
refusal rates (refusal to output undesirable outputs) and robustness to jailbreak techniques. Note, however, while comprehensive red team evaluations were conducted
|
| 290 |
+
across all models in the prior release of Phi models, red teaming was largely focused on Phi-3.5 MOE across multiple languages and risk categories for this release as
|
| 291 |
+
it is the largest and more capable model of the three models. Details on prior red team evaluations across Phi models can be found in the [Phi-3 Safety Post-Training paper](https://arxiv.org/pdf/2407.13833).
|
| 292 |
+
For this release, insights from red teaming indicate that the models may refuse to generate undesirable outputs in English, even when the request for undesirable output
|
| 293 |
+
is in another language. Models may also be more susceptible to longer multi-turn jailbreak techniques across both English and non-English languages. These findings
|
| 294 |
+
highlight the need for industry-wide investment in the development of high-quality safety evaluation datasets across multiple languages, including low resource languages,
|
| 295 |
+
and risk areas that account for cultural nuances where those languages are spoken.
|
| 296 |
+
|
| 297 |
+
|
| 298 |
+
## Software
|
| 299 |
+
* [PyTorch](https://github.com/pytorch/pytorch)
|
| 300 |
+
* [Transformers](https://github.com/huggingface/transformers)
|
| 301 |
+
* [Flash-Attention](https://github.com/HazyResearch/flash-attention)
|
| 302 |
+
|
| 303 |
+
## Hardware
|
| 304 |
+
Note that by default, the Phi-3.5-mini-instruct model uses flash attention, which requires certain types of GPU hardware to run. We have tested on the following GPU types:
|
| 305 |
+
* NVIDIA A100
|
| 306 |
+
* NVIDIA A6000
|
| 307 |
+
* NVIDIA H100
|
| 308 |
+
|
| 309 |
+
If you want to run the model on:
|
| 310 |
+
* NVIDIA V100 or earlier generation GPUs: call AutoModelForCausalLM.from_pretrained() with attn_implementation="eager"
|
| 311 |
+
|
| 312 |
+
## License
|
| 313 |
+
The model is licensed under the [MIT license](./LICENSE).
|
| 314 |
+
|
| 315 |
+
## Trademarks
|
| 316 |
+
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow [Microsoft’s Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks). Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party’s policies.
|
| 317 |
+
|
| 318 |
+
|
| 319 |
+
## Appendix A
|
| 320 |
+
|
| 321 |
+
#### MGSM
|
| 322 |
+
|
| 323 |
+
| Languages | Phi-3.5-Mini-Instruct | Phi-3.0-Mini-128k-Instruct (June2024) | Mistral-7B-Instruct-v0.3 | Mistral-Nemo-12B-Ins-2407 | Llama-3.1-8B-Ins | Gemma-2-9B-Ins | Gemini 1.5 Flash | GPT-4o-mini-2024-07-18 (Chat) |
|
| 324 |
+
|-----------|------------------------|---------------------------------------|--------------------------|---------------------------|------------------|----------------|------------------|-------------------------------|
|
| 325 |
+
| German | 69.6 | 65.2 | 42.4 | 74.4 | 68.4 | 76.8 | 81.6 | 82.8 |
|
| 326 |
+
| English | 85.2 | 83.2 | 60.0 | 86.0 | 81.2 | 88.8 | 90.8 | 90.8 |
|
| 327 |
+
| Spanish | 79.2 | 77.6 | 46.4 | 75.6 | 66.4 | 82.4 | 84.8 | 86.8 |
|
| 328 |
+
| French | 71.6 | 72.8 | 47.2 | 70.4 | 66.8 | 74.4 | 77.2 | 81.6 |
|
| 329 |
+
| Japanese | 50.0 | 35.2 | 22.8 | 62.4 | 49.2 | 67.6 | 77.6 | 80.4 |
|
| 330 |
+
| Russian | 67.2 | 51.6 | 43.2 | 73.6 | 67.2 | 78.4 | 84.8 | 86.4 |
|
| 331 |
+
| Thai | 29.6 | 6.4 | 18.4 | 53.2 | 56.0 | 76.8 | 87.6 | 81.6 |
|
| 332 |
+
| Chinese | 60.0 | 52.8 | 42.4 | 66.4 | 68.0 | 72.8 | 82.0 | 82.0 |
|
| 333 |
+
|
| 334 |
+
#### Multilingual MMLU-pro
|
| 335 |
+
|
| 336 |
+
| Languages | Phi-3.5-Mini-Instruct | Phi-3.0-Mini-128k-Instruct (June2024) | Mistral-7B-Instruct-v0.3 | Mistral-Nemo-12B-Ins-2407 | Llama-3.1-8B-Ins | Gemma-2-9B-Ins | Gemini 1.5 Flash | GPT-4o-mini-2024-07-18 (Chat) |
|
| 337 |
+
|------------|-----------------------|---------------------------------------|--------------------------|---------------------------|------------------|----------------|------------------|-------------------------------|
|
| 338 |
+
| Czech | 24.9 | 26.3 | 14.6 | 30.6 | 23.0 | 40.5 | 59.0 | 40.9 |
|
| 339 |
+
| English | 47.7 | 46.2 | 17.7 | 39.8 | 43.1 | 49.0 | 66.1 | 62.7 |
|
| 340 |
+
| Finnish | 22.3 | 20.5 | 11.5 | 30.4 | 9.7 | 37.5 | 54.5 | 50.1 |
|
| 341 |
+
| Norwegian | 29.9 | 27.8 | 14.4 | 33.2 | 22.2 | 44.4 | 60.7 | 59.1 |
|
| 342 |
+
| Polish | 25.7 | 26.4 | 16.3 | 33.6 | 9.2 | 41.7 | 53.9 | 42.8 |
|
| 343 |
+
| Portuguese | 38.7 | 37.6 | 15.3 | 36.0 | 29.3 | 43.5 | 54.0 | 56.9 |
|
| 344 |
+
| Swedish | 30.7 | 28.1 | 15.5 | 34.3 | 16.9 | 42.6 | 57.7 | 55.5 |
|
| 345 |
+
|
| 346 |
+
#### MEGA
|
| 347 |
+
|
| 348 |
+
##### MLQA
|
| 349 |
+
|
| 350 |
+
| Languages | Phi-3.5-Mini-Instruct | Phi-3.0-Mini-128k-Instruct (June2024) | Mistral-7B-Instruct-v0.3 | Mistral-Nemo-12B-Ins-2407 | Llama-3.1-8B-Ins | Gemma-2-9B-Ins | Gemini 1.5 Flash | GPT-4o-mini-2024-07-18 (Chat) |
|
| 351 |
+
|-----------|-----------------------|---------------------------------------|--------------------------|---------------------------|------------------|----------------|------------------|-------------------------------|
|
| 352 |
+
| Arabic | 54.3 | 32.7 | 23.5 | 31.4 | 31.5 | 57.4 | 63.8 | 64.0 |
|
| 353 |
+
| Chinese | 36.1 | 31.8 | 22.4 | 27.4 | 18.6 | 45.4 | 38.1 | 38.9 |
|
| 354 |
+
| English | 80.3 | 78.9 | 68.2 | 75.5 | 67.2 | 82.9 | 69.5 | 82.2 |
|
| 355 |
+
| German | 61.8 | 59.1 | 49.0 | 57.8 | 38.9 | 63.8 | 55.9 | 64.1 |
|
| 356 |
+
| Spanish | 68.8 | 67.0 | 50.3 | 63.6 | 52.7 | 72.8 | 59.6 | 70.1 |
|
| 357 |
+
|
| 358 |
+
##### TyDi QA
|
| 359 |
+
|
| 360 |
+
| Languages | Phi-3.5-Mini-Instruct | Phi-3.0-Mini-128k-Instruct (June2024) | Mistral-7B-Instruct-v0.3 | Mistral-Nemo-12B-Ins-2407 | Llama-3.1-8B-Ins | Gemma-2-9B-Ins | Gemini 1.5 Flash | GPT-4o-mini-2024-07-18 (Chat) |
|
| 361 |
+
|-----------|-----------------------|---------------------------------------|--------------------------|---------------------------|------------------|----------------|------------------|-------------------------------|
|
| 362 |
+
| Arabic | 69.7 | 54.4 | 52.5 | 49.8 | 33.7 | 81.1 | 78.8 | 84.9 |
|
| 363 |
+
| English | 82.0 | 82.0 | 60.5 | 77.3 | 65.1 | 82.4 | 60.9 | 81.8 |
|
| 364 |
+
| Finnish | 70.3 | 64.3 | 68.6 | 57.1 | 74.4 | 85.7 | 73.5 | 84.8 |
|
| 365 |
+
| Japanese | 65.4 | 56.7 | 45.3 | 54.8 | 34.1 | 74.6 | 59.7 | 73.3 |
|
| 366 |
+
| Korean | 74.0 | 60.4 | 54.5 | 54.2 | 54.9 | 83.8 | 60.7 | 82.3 |
|
| 367 |
+
| Russian | 63.5 | 62.7 | 52.3 | 55.7 | 27.4 | 69.8 | 60.1 | 72.5 |
|
| 368 |
+
| Thai | 64.4 | 49.0 | 51.8 | 43.5 | 48.5 | 81.4 | 71.6 | 78.2 |
|
| 369 |
+
|
| 370 |
+
##### XCOPA
|
| 371 |
+
|
| 372 |
+
| Languages | Phi-3.5-Mini-Instruct | Phi-3.0-Mini-128k-Instruct (June2024) | Mistral-7B-Instruct-v0.3 | Mistral-Nemo-12B-Ins-2407 | Llama-3.1-8B-Ins | Gemma-2-9B-Ins | Gemini 1.5 Flash | GPT-4o-mini-2024-07-18 (Chat) |
|
| 373 |
+
|-----------|-----------------------|---------------------------------------|--------------------------|---------------------------|------------------|----------------|------------------|-------------------------------|
|
| 374 |
+
| English | 94.6 | 94.6 | 85.6 | 94.4 | 37.6 | 63.8 | 92.0 | 98.2 |
|
| 375 |
+
| Italian | 86.8 | 84.8 | 76.8 | 83.2 | 16.2 | 37.2 | 85.6 | 97.6 |
|
| 376 |
+
| Turkish | 58.6 | 57.2 | 61.6 | 56.6 | 38.4 | 60.2 | 91.4 | 94.6 |
|
| 377 |
+
|
| 378 |
+
|
| 379 |
+
## Appendix B: Korean benchmarks
|
| 380 |
+
|
| 381 |
+
The prompt is the same as the [CLIcK paper](https://arxiv.org/abs/2403.06412) prompt. The experimental results below were given with max_tokens=512 (zero-shot), max_tokens=1024 (5-shot), temperature=0.01. No system prompt used.
|
| 382 |
+
|
| 383 |
+
- GPT-4o: 2024-05-13 version
|
| 384 |
+
- GPT-4o-mini: 2024-07-18 version
|
| 385 |
+
- GPT-4-turbo: 2024-04-09 version
|
| 386 |
+
- GPT-3.5-turbo: 2023-06-13 version
|
| 387 |
+
|
| 388 |
+
The overall Korean benchmarks show that the Phi-3.5-Mini-Instruct with only 3.8B params outperforms Llama-3.1-8B-Instruct.
|
| 389 |
+
|
| 390 |
+
| Benchmarks | Phi-3.5-Mini-Instruct | Phi-3.0-Mini-128k-Instruct (June2024) | Llama-3.1-8B-Instruct | GPT-4o | GPT-4o-mini | GPT-4-turbo | GPT-3.5-turbo |
|
| 391 |
+
|:-------------------------|------------------------:|--------------------------------:|------------------------:|---------:|--------------:|--------------:|----------------:|
|
| 392 |
+
| CLIcK | 42.99 | 29.12 | 47.82 | 80.46 | 68.5 | 72.82 | 50.98 |
|
| 393 |
+
| HAERAE 1.0 | 44.21 | 36.41 | 53.9 | 85.7 | 76.4 | 77.76 | 52.67 |
|
| 394 |
+
| KMMLU (0-shot, CoT) | 35.87 | 30.82 | 38.54 | 64.26 | 52.63 | 58.75 | 40.3 |
|
| 395 |
+
| KMMLU (5-shot) | 37.35 | 29.98 | 20.21 | 64.28 | 51.62 | 59.29 | 42.28 |
|
| 396 |
+
| KMMLU-HARD (0-shot, CoT) | 24 | 25.68 | 24.03 | 39.62 | 24.56 | 30.56 | 20.97 |
|
| 397 |
+
| KMMLU-HARD (5-shot) | 24.76 | 25.73 | 15.81 | 40.94 | 24.63 | 31.12 | 21.19 |
|
| 398 |
+
| **Average** | **35.62** | **29.99** | **29.29** | **62.54** | **50.08** | **56.74** | **39.61** |
|
| 399 |
+
|
| 400 |
+
#### CLIcK (Cultural and Linguistic Intelligence in Korean)
|
| 401 |
+
|
| 402 |
+
##### Accuracy by supercategory
|
| 403 |
+
| supercategory | Phi-3.5-Mini-Instruct | Phi-3.0-Mini-128k-Instruct (June2024) | Llama-3.1-8B-Instruct | GPT-4o | GPT-4o-mini | GPT-4-turbo | GPT-3.5-turbo |
|
| 404 |
+
|:----------------|------------------------:|--------------------------------:|------------------------:|---------:|--------------:|--------------:|----------------:|
|
| 405 |
+
| Culture | 43.77 | 29.74 | 51.15 | 81.89 | 70.95 | 73.61 | 53.38 |
|
| 406 |
+
| Language | 41.38 | 27.85 | 40.92 | 77.54 | 63.54 | 71.23 | 46 |
|
| 407 |
+
| **Overall** | 42.99 | 29.12 | 47.82 | 80.46 | 68.5 | 72.82 | 50.98 |
|
| 408 |
+
|
| 409 |
+
##### Accuracy by category
|
| 410 |
+
| supercategory | category | Phi-3.5-Mini-Instruct | Phi-3.0-Mini-128k-Instruct (June2024) | Llama-3.1-8B-Instruct | GPT-4o | GPT-4o-mini | GPT-4-turbo | GPT-3.5-turbo |
|
| 411 |
+
|:----------------|:------------|------------------------:|--------------------------------:|------------------------:|---------:|--------------:|--------------:|----------------:|
|
| 412 |
+
| Culture | Economy | 61.02 | 28.81 | 66.1 | 94.92 | 83.05 | 89.83 | 64.41 |
|
| 413 |
+
| Culture | Geography | 45.8 | 29.01 | 54.2 | 80.15 | 77.86 | 82.44 | 53.44 |
|
| 414 |
+
| Culture | History | 26.15 | 30 | 29.64 | 66.92 | 48.4 | 46.4 | 31.79 |
|
| 415 |
+
| Culture | Law | 32.42 | 22.83 | 44.29 | 70.78 | 57.53 | 61.19 | 41.55 |
|
| 416 |
+
| Culture | Politics | 54.76 | 33.33 | 59.52 | 88.1 | 83.33 | 89.29 | 65.48 |
|
| 417 |
+
| Culture | Pop Culture | 60.98 | 34.15 | 60.98 | 97.56 | 85.37 | 92.68 | 75.61 |
|
| 418 |
+
| Culture | Society | 54.37 | 31.72 | 65.05 | 92.88 | 85.44 | 86.73 | 71.2 |
|
| 419 |
+
| Culture | Tradition | 47.75 | 31.98 | 54.95 | 87.39 | 74.77 | 79.28 | 55.86 |
|
| 420 |
+
| Language | Functional | 37.6 | 24 | 32.8 | 84.8 | 64.8 | 80 | 40 |
|
| 421 |
+
| Language | Grammar | 27.5 | 23.33 | 22.92 | 57.08 | 42.5 | 47.5 | 30 |
|
| 422 |
+
| Language | Textual | 54.74 | 33.33 | 59.65 | 91.58 | 80.7 | 87.37 | 62.11 |
|
| 423 |
+
|
| 424 |
+
#### HAERAE
|
| 425 |
+
|
| 426 |
+
| category | Phi-3.5-Mini-Instruct | Phi-3.0-Mini-128k-Instruct (June2024) | Llama-3.1-8B-Instruct | GPT-4o | GPT-4o-mini | GPT-4-turbo | GPT-3.5-turbo |
|
| 427 |
+
|:----------------------|------------------------:|--------------------------------:|------------------------:|---------:|--------------:|--------------:|----------------:|
|
| 428 |
+
| General Knowledge | 31.25 | 28.41 | 34.66 | 77.27 | 53.41 | 66.48 | 40.91 |
|
| 429 |
+
| History | 32.45 | 22.34 | 44.15 | 92.02 | 84.57 | 78.72 | 30.32 |
|
| 430 |
+
| Loan Words | 47.93 | 35.5 | 63.31 | 79.88 | 76.33 | 78.11 | 59.17 |
|
| 431 |
+
| Rare Words | 55.06 | 42.96 | 63.21 | 87.9 | 81.98 | 79.01 | 61.23 |
|
| 432 |
+
| Reading Comprehension | 42.95 | 41.16 | 51.9 | 85.46 | 77.18 | 80.09 | 56.15 |
|
| 433 |
+
| Standard Nomenclature | 44.44 | 32.68 | 58.82 | 88.89 | 75.82 | 79.08 | 53.59 |
|
| 434 |
+
| **Overall** | 44.21 | 36.41 | 53.9 | 85.7 | 76.4 | 77.76 | 52.67 |
|
| 435 |
+
|
| 436 |
+
#### KMMLU (0-shot, CoT)
|
| 437 |
+
|
| 438 |
+
| supercategory | Phi-3.5-Mini-Instruct | Phi-3.0-Mini-128k-Instruct (June2024) | Llama-3.1-8B-Instruct | GPT-4o | GPT-4o-mini | GPT-4-turbo | GPT-3.5-turbo |
|
| 439 |
+
|:----------------|------------------------:|--------------------------------:|------------------------:|---------:|--------------:|--------------:|----------------:|
|
| 440 |
+
| Applied Science | 35.8 | 31.68 | 37.03 | 61.52 | 49.29 | 55.98 | 38.47 |
|
| 441 |
+
| HUMSS | 31.56 | 26.47 | 37.29 | 69.45 | 56.59 | 63 | 40.9 |
|
| 442 |
+
| Other | 35.45 | 31.01 | 39.15 | 63.79 | 52.35 | 57.53 | 40.19 |
|
| 443 |
+
| STEM | 38.54 | 31.9 | 40.42 | 65.16 | 54.74 | 60.84 | 42.24 |
|
| 444 |
+
| **Overall** | 35.87 | 30.82 | 38.54 | 64.26 | 52.63 | 58.75 | 40.3 |
|
| 445 |
+
|
| 446 |
+
#### KMMLU (5-shot)
|
| 447 |
+
|
| 448 |
+
| supercategory | Phi-3.5-Mini-Instruct | Phi-3.0-Mini-128k-Instruct (June2024) | Llama-3.1-8B-Instruct | GPT-4o | GPT-4o-mini | GPT-4-turbo | GPT-3.5-turbo |
|
| 449 |
+
|:----------------|------------------------:|--------------------------------:|------------------------:|---------:|--------------:|--------------:|----------------:|
|
| 450 |
+
| Applied Science | 37.42 | 29.98 | 19.24 | 61.47 | 48.66 | 56.85 | 40.22 |
|
| 451 |
+
| HUMSS | 34.72 | 27.27 | 22.5 | 68.79 | 55.95 | 63.68 | 43.35 |
|
| 452 |
+
| Other | 37.04 | 30.76 | 20.95 | 64.21 | 51.1 | 57.85 | 41.92 |
|
| 453 |
+
| STEM | 38.9 | 30.73 | 19.55 | 65.28 | 53.29 | 61.08 | 44.43 |
|
| 454 |
+
| **Overall** | 37.35 | 29.98 | 20.21 | 64.28 | 51.62 | 59.29 | 42.28 |
|
| 455 |
+
|
| 456 |
+
#### KMMLU-HARD (0-shot, CoT)
|
| 457 |
+
|
| 458 |
+
| supercategory | Phi-3.5-Mini-Instruct | Phi-3.0-Mini-128k-Instruct (June2024) | Llama-3.1-8B-Instruct | GPT-4o | GPT-4o-mini | GPT-4-turbo | GPT-3.5-turbo |
|
| 459 |
+
|:----------------|------------------------:|--------------------------------:|------------------------:|---------:|--------------:|--------------:|----------------:|
|
| 460 |
+
| Applied Science | 27.08 | 26.17 | 26.25 | 37.12 | 22.25 | 29.17 | 21.07 |
|
| 461 |
+
| HUMSS | 20.21 | 24.38 | 20.21 | 41.97 | 23.31 | 31.51 | 19.44 |
|
| 462 |
+
| Other | 23.05 | 24.82 | 23.88 | 40.39 | 26.48 | 29.59 | 22.22 |
|
| 463 |
+
| STEM | 24.36 | 26.91 | 24.64 | 39.82 | 26.36 | 32.18 | 20.91 |
|
| 464 |
+
| **Overall** | 24 | 25.68 | 24.03 | 39.62 | 24.56 | 30.56 | 20.97 |
|
| 465 |
+
|
| 466 |
+
#### KMMLU-HARD (5-shot)
|
| 467 |
+
|
| 468 |
+
| supercategory | Phi-3.5-Mini-Instruct | Phi-3.0-Mini-128k-Instruct (June2024) | Llama-3.1-8B-Instruct | GPT-4o | GPT-4o-mini | GPT-4-turbo | GPT-3.5-turbo |
|
| 469 |
+
|:----------------|------------------------:|--------------------------------:|------------------------:|---------:|--------------:|--------------:|----------------:|
|
| 470 |
+
| Applied Science | 25 | 29 | 12 | 31 | 21 | 25 | 20 |
|
| 471 |
+
| HUMSS | 21.89 | 19.92 | 14 | 43.98 | 23.47 | 33.53 | 19.53 |
|
| 472 |
+
| Other | 23.26 | 27.27 | 12.83 | 39.84 | 28.34 | 29.68 | 23.22 |
|
| 473 |
+
| STEM | 20.5 | 25.25 | 12.75 | 40.25 | 23.25 | 27.25 | 19.75 |
|
| 474 |
+
| **Overall** | 24.76 | 25.73 | 15.81 | 40.94 | 24.63 | 31.12 | 21.19 |
|
ComfyUI/models/LLM/Phi-3.5-mini-instruct/SECURITY.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!-- BEGIN MICROSOFT SECURITY.MD V0.0.9 BLOCK -->
|
| 2 |
+
|
| 3 |
+
## Security
|
| 4 |
+
|
| 5 |
+
Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet) and [Xamarin](https://github.com/xamarin).
|
| 6 |
+
|
| 7 |
+
If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/security.md/definition), please report it to us as described below.
|
| 8 |
+
|
| 9 |
+
## Reporting Security Issues
|
| 10 |
+
|
| 11 |
+
**Please do not report security vulnerabilities through public GitHub issues.**
|
| 12 |
+
|
| 13 |
+
Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/security.md/msrc/create-report).
|
| 14 |
+
|
| 15 |
+
If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/security.md/msrc/pgp).
|
| 16 |
+
|
| 17 |
+
You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc).
|
| 18 |
+
|
| 19 |
+
Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:
|
| 20 |
+
|
| 21 |
+
* Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
|
| 22 |
+
* Full paths of source file(s) related to the manifestation of the issue
|
| 23 |
+
* The location of the affected source code (tag/branch/commit or direct URL)
|
| 24 |
+
* Any special configuration required to reproduce the issue
|
| 25 |
+
* Step-by-step instructions to reproduce the issue
|
| 26 |
+
* Proof-of-concept or exploit code (if possible)
|
| 27 |
+
* Impact of the issue, including how an attacker might exploit the issue
|
| 28 |
+
|
| 29 |
+
This information will help us triage your report more quickly.
|
| 30 |
+
|
| 31 |
+
If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/security.md/msrc/bounty) page for more details about our active programs.
|
| 32 |
+
|
| 33 |
+
## Preferred Languages
|
| 34 |
+
|
| 35 |
+
We prefer all communications to be in English.
|
| 36 |
+
|
| 37 |
+
## Policy
|
| 38 |
+
|
| 39 |
+
Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/security.md/cvd).
|
| 40 |
+
|
| 41 |
+
<!-- END MICROSOFT SECURITY.MD BLOCK -->
|
ComfyUI/models/LLM/Phi-3.5-mini-instruct/added_tokens.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"<|endoftext|>": 32000,
|
| 3 |
+
"<|assistant|>": 32001,
|
| 4 |
+
"<|placeholder1|>": 32002,
|
| 5 |
+
"<|placeholder2|>": 32003,
|
| 6 |
+
"<|placeholder3|>": 32004,
|
| 7 |
+
"<|placeholder4|>": 32005,
|
| 8 |
+
"<|system|>": 32006,
|
| 9 |
+
"<|end|>": 32007,
|
| 10 |
+
"<|placeholder5|>": 32008,
|
| 11 |
+
"<|placeholder6|>": 32009,
|
| 12 |
+
"<|user|>": 32010
|
| 13 |
+
}
|