upload first
Browse files- .gitattributes +1 -0
- README.md +201 -0
- config.json +43 -0
- configuration_fgclip2.py +274 -0
- model.safetensors +3 -0
- modeling_fgclip2.py +1400 -0
- preprocessor_config.json +22 -0
- special_tokens_map.json +34 -0
- tokenizer.json +3 -0
- tokenizer.model +3 -0
- tokenizer_config.json +1763 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* 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
|
|
|
|
|
|
| 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 |
+
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- en
|
| 4 |
+
library_name: transformers
|
| 5 |
+
license: apache-2.0
|
| 6 |
+
pipeline_tag: zero-shot-image-classification
|
| 7 |
+
tags:
|
| 8 |
+
- clip
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
# FG-CLIP 2: A BILINGUAL FINE-GRAINED VISION LANGUAGE ALIGNMENT MODEL
|
| 12 |
+
Code: https://github.com/360CVGroup/FG-CLIP
|
| 13 |
+
|
| 14 |
+
FG-CLIP 2 is the foundation model for fine-grained vision-language understanding in both English and Chinese.
|
| 15 |
+
Across 29 datasets and 8 diverse tasks, it consistently surpasses recent strong baselines such as SigLIP 2 and MetaCLIP 2, achieving the best reported performance to date in both languages.
|
| 16 |
+
|
| 17 |
+
**[FG-CLIP 2: A BILINGUAL FINE-GRAINED VISION LANGUAGE ALIGNMENT MODEL](https://arxiv.org/abs/2510.10921)**
|
| 18 |
+
</br>
|
| 19 |
+
Chunyu Xie*, Bin Wang*, Fanjing Kong, Jincheng Li, Dawei Liang, Ji Ao, Dawei Leng†, Yuhui Yin(*Equal Contribution, ✝Corresponding Author)
|
| 20 |
+
[](https://arxiv.org/abs/2510.10921)
|
| 21 |
+
[](https://huggingface.co/collections/qihoo360/fg-clip-2-68ecbf9c548623bb78bc7913)
|
| 22 |
+
[](https://huggingface.co/collections/qihoo360/fg-clip-2-68ecbf9c548623bb78bc7913)
|
| 23 |
+
[](https://research.360.cn/sass/index)
|
| 24 |
+
</br>
|
| 25 |
+
|
| 26 |
+
## Quick Start 🤗
|
| 27 |
+
|
| 28 |
+
### Load Model
|
| 29 |
+
```Shell
|
| 30 |
+
import torch
|
| 31 |
+
from PIL import Image
|
| 32 |
+
from transformers import (
|
| 33 |
+
AutoImageProcessor,
|
| 34 |
+
AutoTokenizer,
|
| 35 |
+
AutoModelForCausalLM,
|
| 36 |
+
)
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
model_root = "fgclip2-base-patch16"
|
| 40 |
+
model = AutoModelForCausalLM.from_pretrained(model_root,trust_remote_code=True).cuda()
|
| 41 |
+
|
| 42 |
+
device = model.device
|
| 43 |
+
|
| 44 |
+
tokenizer = AutoTokenizer.from_pretrained(model_root)
|
| 45 |
+
image_processor = AutoImageProcessor.from_pretrained(model_root)
|
| 46 |
+
|
| 47 |
+
```
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
### Retrieval
|
| 51 |
+
|
| 52 |
+
```Shell
|
| 53 |
+
def determine_max_value(image):
|
| 54 |
+
|
| 55 |
+
w,h = image.size
|
| 56 |
+
max_val = (w//16)*(h//16)
|
| 57 |
+
|
| 58 |
+
if max_val > 784:
|
| 59 |
+
return 1024
|
| 60 |
+
elif max_val > 576:
|
| 61 |
+
return 784
|
| 62 |
+
elif max_val > 256:
|
| 63 |
+
return 576
|
| 64 |
+
elif max_val > 128:
|
| 65 |
+
return 256
|
| 66 |
+
else:
|
| 67 |
+
return 128
|
| 68 |
+
|
| 69 |
+
img_root = "cat_dfclor.jpg"
|
| 70 |
+
image = Image.open(img_root).convert("RGB")
|
| 71 |
+
|
| 72 |
+
image_input = image_processor(images=image, max_num_patches=determine_max_value(image), return_tensors="pt").to(device)
|
| 73 |
+
|
| 74 |
+
# NOTE Short captions: max_length=64
|
| 75 |
+
|
| 76 |
+
captions = ["a photo of two cats", "a photo of a cat"]
|
| 77 |
+
captions = [caption.lower() for caption in captions]
|
| 78 |
+
|
| 79 |
+
caption_input = tokenizer(captions, padding="max_length", max_length=64, truncation=True, return_tensors="pt").to(device)
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
with torch.no_grad():
|
| 83 |
+
image_feature = model.get_image_features(**image_input)
|
| 84 |
+
text_feature = model.get_text_features(**caption_input)
|
| 85 |
+
image_feature = image_feature / image_feature.norm(p=2, dim=-1, keepdim=True)
|
| 86 |
+
text_feature = text_feature / text_feature.norm(p=2, dim=-1, keepdim=True)
|
| 87 |
+
|
| 88 |
+
logits_per_image = image_feature @ text_feature.T
|
| 89 |
+
logit_scale, logit_bias = model.logit_scale.to(text_feature.device), model.logit_bias.to(text_feature.device)
|
| 90 |
+
logits_per_image = logits_per_image * logit_scale.exp() + logit_bias
|
| 91 |
+
probs = torch.sigmoid(logits_per_image)
|
| 92 |
+
# [[0.5322, 0.0048]]
|
| 93 |
+
print(probs)
|
| 94 |
+
|
| 95 |
+
```
|
| 96 |
+
|
| 97 |
+
### Dense feature effect display
|
| 98 |
+
|
| 99 |
+
```Shell
|
| 100 |
+
|
| 101 |
+
import math
|
| 102 |
+
import matplotlib
|
| 103 |
+
matplotlib.use('Agg')
|
| 104 |
+
import matplotlib.pyplot as plt
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
img_root = "cat_dfclor.jpg"
|
| 108 |
+
image = Image.open(img_root).convert("RGB")
|
| 109 |
+
image = resize_short_edge(image,target_size=2048)
|
| 110 |
+
|
| 111 |
+
image_input = image_processor(images=image, max_num_patches=16384, return_tensors="pt").to(device)
|
| 112 |
+
captions = ["电脑","黑猫","窗户","window","white cat","book"]
|
| 113 |
+
|
| 114 |
+
with torch.no_grad():
|
| 115 |
+
dense_image_feature = model.get_image_dense_feature(**image_input)
|
| 116 |
+
|
| 117 |
+
spatial_values = image_input["spatial_shapes"][0]
|
| 118 |
+
real_h = spatial_values[0].item()
|
| 119 |
+
real_w = spatial_values[1].item()
|
| 120 |
+
real_pixel_tokens_num = real_w*real_h
|
| 121 |
+
dense_image_feature = dense_image_feature[0][:real_pixel_tokens_num]
|
| 122 |
+
|
| 123 |
+
|
| 124 |
+
captions = [caption.lower() for caption in captions]
|
| 125 |
+
caption_input = tokenizer(captions, padding="max_length", max_length=64, truncation=True, return_tensors="pt").to(device)
|
| 126 |
+
|
| 127 |
+
text_feature = model.get_text_features(**caption_input, walk_type="box")
|
| 128 |
+
text_feature = text_feature / text_feature.norm(p=2, dim=-1, keepdim=True)
|
| 129 |
+
dense_image_feature = dense_image_feature / dense_image_feature.norm(p=2, dim=-1, keepdim=True)
|
| 130 |
+
|
| 131 |
+
similarity = dense_image_feature @ text_feature.T
|
| 132 |
+
similarity = similarity.cpu()
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
num_classes = len(captions)
|
| 136 |
+
cols = 3
|
| 137 |
+
rows = (num_classes + cols - 1) // cols
|
| 138 |
+
|
| 139 |
+
|
| 140 |
+
aspect_ratio = real_w / real_h
|
| 141 |
+
|
| 142 |
+
fig_width_inch = 3 * cols
|
| 143 |
+
fig_height_inch = fig_width_inch / aspect_ratio * rows / cols
|
| 144 |
+
|
| 145 |
+
fig, axes = plt.subplots(rows, cols, figsize=(fig_width_inch, fig_height_inch))
|
| 146 |
+
fig.subplots_adjust(wspace=0.01, hspace=0.01)
|
| 147 |
+
|
| 148 |
+
if num_classes == 1:
|
| 149 |
+
axes = [axes]
|
| 150 |
+
else:
|
| 151 |
+
axes = axes.flatten()
|
| 152 |
+
|
| 153 |
+
for cls_index in range(num_classes):
|
| 154 |
+
similarity_map = similarity[:, cls_index].cpu().numpy()
|
| 155 |
+
show_image = similarity_map.reshape((real_h, real_w))
|
| 156 |
+
|
| 157 |
+
ax = axes[cls_index]
|
| 158 |
+
ax.imshow(show_image, cmap='viridis', aspect='equal')
|
| 159 |
+
ax.set_xticks([])
|
| 160 |
+
ax.set_yticks([])
|
| 161 |
+
ax.axis('off')
|
| 162 |
+
|
| 163 |
+
|
| 164 |
+
for idx in range(num_classes, len(axes)):
|
| 165 |
+
axes[idx].axis('off')
|
| 166 |
+
|
| 167 |
+
savename = "FGCLIP2_dfcolor_cat_all_2K.png"
|
| 168 |
+
plt.savefig(savename, dpi=150, bbox_inches='tight', pad_inches=0.05)
|
| 169 |
+
plt.close()
|
| 170 |
+
```
|
| 171 |
+
|
| 172 |
+
<p align="left">
|
| 173 |
+
<img src="FGCLIP2_dfcolor_cat_all_2K.png" width=50%/>
|
| 174 |
+
</p>
|
| 175 |
+
|
| 176 |
+
## Citation
|
| 177 |
+
If you find FG-CLIP 2 useful for your research and applications, please cite using this BibTeX:
|
| 178 |
+
|
| 179 |
+
```
|
| 180 |
+
@article{xie2025fg2,
|
| 181 |
+
title={FG-CLIP 2: A Bilingual Fine-grained Vision-language Alignment Model},
|
| 182 |
+
author={Xie, Chunyu and Wang, Bin and Kong, Fanjing and Li, Jincheng and Liang, Dawei and Ao, Ji and Leng, Dawei and Yin, Yuhui},
|
| 183 |
+
journal={arXiv preprint arXiv:2510.10921},
|
| 184 |
+
year={2025}
|
| 185 |
+
}
|
| 186 |
+
```
|
| 187 |
+
```
|
| 188 |
+
@article{xie2025fg,
|
| 189 |
+
title={FG-CLIP: Fine-Grained Visual and Textual Alignment},
|
| 190 |
+
author={Xie, Chunyu and Wang, Bin and Kong, Fanjing and Li, Jincheng and Liang, Dawei and Zhang, Gengshen and Leng, Dawei and Yin, Yuhui},
|
| 191 |
+
journal={arXiv preprint arXiv:2505.05071},
|
| 192 |
+
year={2025}
|
| 193 |
+
}
|
| 194 |
+
```
|
| 195 |
+
|
| 196 |
+
|
| 197 |
+
|
| 198 |
+
## License
|
| 199 |
+
|
| 200 |
+
This project utilizes certain datasets and checkpoints that are subject to their respective original licenses. Users must comply with all terms and conditions of these original licenses.
|
| 201 |
+
The content of this project itself is licensed under the [Apache license 2.0](./LICENSE).
|
config.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"Fgclip2Model"
|
| 4 |
+
],
|
| 5 |
+
"auto_map": {
|
| 6 |
+
"AutoConfig": "modeling_fgclip2.Fgclip2Config",
|
| 7 |
+
"AutoModelForCausalLM": "modeling_fgclip2.Fgclip2Model"
|
| 8 |
+
},
|
| 9 |
+
"dtype": "float32",
|
| 10 |
+
"initializer_factor": 1.0,
|
| 11 |
+
"model_type": "fgclip2",
|
| 12 |
+
"text_config": {
|
| 13 |
+
"attention_dropout": 0.0,
|
| 14 |
+
"dtype": "float32",
|
| 15 |
+
"hidden_act": "gelu_pytorch_tanh",
|
| 16 |
+
"hidden_size": 768,
|
| 17 |
+
"intermediate_size": 3072,
|
| 18 |
+
"keep_len": 20,
|
| 19 |
+
"layer_norm_eps": 1e-06,
|
| 20 |
+
"longtext_len": 196,
|
| 21 |
+
"max_position_embeddings": 64,
|
| 22 |
+
"model_type": "fgclip2_text_model",
|
| 23 |
+
"num_attention_heads": 12,
|
| 24 |
+
"num_hidden_layers": 12,
|
| 25 |
+
"projection_size": 768,
|
| 26 |
+
"vocab_size": 256000
|
| 27 |
+
},
|
| 28 |
+
"transformers_version": "4.57.0.dev0",
|
| 29 |
+
"vision_config": {
|
| 30 |
+
"attention_dropout": 0.0,
|
| 31 |
+
"dtype": "float32",
|
| 32 |
+
"hidden_act": "gelu_pytorch_tanh",
|
| 33 |
+
"hidden_size": 768,
|
| 34 |
+
"intermediate_size": 3072,
|
| 35 |
+
"layer_norm_eps": 1e-06,
|
| 36 |
+
"model_type": "fgclip2_vision_model",
|
| 37 |
+
"num_attention_heads": 12,
|
| 38 |
+
"num_channels": 3,
|
| 39 |
+
"num_hidden_layers": 12,
|
| 40 |
+
"num_patches": 256,
|
| 41 |
+
"patch_size": 16
|
| 42 |
+
}
|
| 43 |
+
}
|
configuration_fgclip2.py
ADDED
|
@@ -0,0 +1,274 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
|
| 2 |
+
# This file was automatically generated from src/transformers/models/fgclip2/modular_fgclip2.py.
|
| 3 |
+
# Do NOT edit this file manually as any edits will be overwritten by the generation of
|
| 4 |
+
# the file from the modular. If any change should be done, please apply the change to the
|
| 5 |
+
# modular_fgclip2.py file directly. One of our CI enforces this.
|
| 6 |
+
# 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
|
| 7 |
+
# coding=utf-8
|
| 8 |
+
# Copyright 2025 The HuggingFace Inc. team.
|
| 9 |
+
#
|
| 10 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 11 |
+
# you may not use this file except in compliance with the License.
|
| 12 |
+
# You may obtain a copy of the License at
|
| 13 |
+
#
|
| 14 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 15 |
+
#
|
| 16 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 17 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 18 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 19 |
+
# See the License for the specific language governing permissions and
|
| 20 |
+
# limitations under the License.
|
| 21 |
+
from transformers.configuration_utils import PretrainedConfig
|
| 22 |
+
from transformers.utils import logging
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
logger = logging.get_logger(__name__)
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
class Fgclip2TextConfig(PretrainedConfig):
|
| 29 |
+
r"""
|
| 30 |
+
This is the configuration class to store the configuration of a [`Fgclip2TextModel`]. It is used to instantiate a
|
| 31 |
+
Fgclip2 text encoder according to the specified arguments, defining the model architecture. Instantiating a
|
| 32 |
+
configuration with the defaults will yield a similar configuration to that of the text encoder of the Fgclip2
|
| 33 |
+
[qihoo360/fg-clip2-base](https://huggingface.co/qihoo360/fg-clip2-base) architecture.
|
| 34 |
+
|
| 35 |
+
Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
|
| 36 |
+
documentation from [`PretrainedConfig`] for more information.
|
| 37 |
+
|
| 38 |
+
Args:
|
| 39 |
+
vocab_size (`int`, *optional*, defaults to 32000):
|
| 40 |
+
Vocabulary size of the Fgclip2 text model. Defines the number of different tokens that can be represented by
|
| 41 |
+
the `inputs_ids` passed when calling [`Fgclip2Model`].
|
| 42 |
+
hidden_size (`int`, *optional*, defaults to 768):
|
| 43 |
+
Dimensionality of the encoder layers and the pooler layer.
|
| 44 |
+
intermediate_size (`int`, *optional*, defaults to 3072):
|
| 45 |
+
Dimensionality of the "intermediate" (i.e., feed-forward) layer in the Transformer encoder.
|
| 46 |
+
num_hidden_layers (`int`, *optional*, defaults to 12):
|
| 47 |
+
Number of hidden layers in the Transformer encoder.
|
| 48 |
+
num_attention_heads (`int`, *optional*, defaults to 12):
|
| 49 |
+
Number of attention heads for each attention layer in the Transformer encoder.
|
| 50 |
+
max_position_embeddings (`int`, *optional*, defaults to 64):
|
| 51 |
+
The maximum sequence length that this model might ever be used with. Typically set this to something large
|
| 52 |
+
just in case (e.g., 512 or 1024 or 2048).
|
| 53 |
+
hidden_act (`str` or `function`, *optional*, defaults to `"gelu_pytorch_tanh"`):
|
| 54 |
+
The non-linear activation function (function or string) in the encoder and pooler. If string, `"gelu"`,
|
| 55 |
+
`"relu"`, `"selu"` and `"gelu_new"` `"quick_gelu"` are supported.
|
| 56 |
+
layer_norm_eps (`float`, *optional*, defaults to 1e-06):
|
| 57 |
+
The epsilon used by the layer normalization layers.
|
| 58 |
+
attention_dropout (`float`, *optional*, defaults to 0.0):
|
| 59 |
+
The dropout ratio for the attention probabilities.
|
| 60 |
+
pad_token_id (`int`, *optional*, defaults to 1):
|
| 61 |
+
The id of the padding token in the vocabulary.
|
| 62 |
+
bos_token_id (`int`, *optional*, defaults to 49406):
|
| 63 |
+
The id of the beginning-of-sequence token in the vocabulary.
|
| 64 |
+
eos_token_id (`int`, *optional*, defaults to 49407):
|
| 65 |
+
The id of the end-of-sequence token in the vocabulary.
|
| 66 |
+
projection_size (`int`, *optional*, defaults to `hidden_size`):
|
| 67 |
+
The size of the projection head.
|
| 68 |
+
keep_len (`int`, *optional*, defaults to 20):
|
| 69 |
+
When processing long texts, the retained tokens are used for handling short text lengths.
|
| 70 |
+
For details, please refer to the FG-CLIP 'https://arxiv.org/abs/2505.05071' paper.
|
| 71 |
+
longtext_len (`int`, *optional*, defaults to 196):
|
| 72 |
+
The maximum number of tokens in long texts that can be processed
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
Example:
|
| 76 |
+
|
| 77 |
+
```python
|
| 78 |
+
>>> from transformers import Fgclip2TextConfig, Fgclip2TextModel
|
| 79 |
+
|
| 80 |
+
>>> # Initializing a Fgclip2TextConfig with qihoo/fgclip2-base-patch16 style configuration
|
| 81 |
+
>>> configuration = Fgclip2TextConfig()
|
| 82 |
+
|
| 83 |
+
>>> # Initializing a Fgclip2TextModel (with random weights) from the qihoo/fgclip2-base-patch16 style configuration
|
| 84 |
+
>>> model = Fgclip2TextModel(configuration)
|
| 85 |
+
|
| 86 |
+
>>> # Accessing the model configuration
|
| 87 |
+
>>> configuration = model.config
|
| 88 |
+
```"""
|
| 89 |
+
|
| 90 |
+
model_type = "fgclip2_text_model"
|
| 91 |
+
base_config_key = "text_config"
|
| 92 |
+
|
| 93 |
+
def __init__(
|
| 94 |
+
self,
|
| 95 |
+
vocab_size=32000,
|
| 96 |
+
hidden_size=768,
|
| 97 |
+
intermediate_size=3072,
|
| 98 |
+
num_hidden_layers=12,
|
| 99 |
+
num_attention_heads=12,
|
| 100 |
+
max_position_embeddings=64,
|
| 101 |
+
hidden_act="gelu_pytorch_tanh",
|
| 102 |
+
layer_norm_eps=1e-6,
|
| 103 |
+
attention_dropout=0.0,
|
| 104 |
+
# This differs from `CLIPTokenizer`'s default and from openai/fgclip2
|
| 105 |
+
# See https://github.com/huggingface/transformers/pull/24773#issuecomment-1632287538
|
| 106 |
+
pad_token_id=1,
|
| 107 |
+
bos_token_id=49406,
|
| 108 |
+
eos_token_id=49407,
|
| 109 |
+
projection_size=None,
|
| 110 |
+
keep_len=20,
|
| 111 |
+
longtext_len=196,
|
| 112 |
+
**kwargs,
|
| 113 |
+
):
|
| 114 |
+
super().__init__(pad_token_id=pad_token_id, bos_token_id=bos_token_id, eos_token_id=eos_token_id, **kwargs)
|
| 115 |
+
|
| 116 |
+
self.vocab_size = vocab_size
|
| 117 |
+
self.hidden_size = hidden_size
|
| 118 |
+
self.intermediate_size = intermediate_size
|
| 119 |
+
self.num_hidden_layers = num_hidden_layers
|
| 120 |
+
self.num_attention_heads = num_attention_heads
|
| 121 |
+
self.max_position_embeddings = max_position_embeddings
|
| 122 |
+
self.layer_norm_eps = layer_norm_eps
|
| 123 |
+
self.hidden_act = hidden_act
|
| 124 |
+
self.attention_dropout = attention_dropout
|
| 125 |
+
self.projection_size = projection_size if projection_size is not None else hidden_size
|
| 126 |
+
self.keep_len = keep_len
|
| 127 |
+
self.longtext_len = longtext_len
|
| 128 |
+
|
| 129 |
+
|
| 130 |
+
class Fgclip2VisionConfig(PretrainedConfig):
|
| 131 |
+
r"""
|
| 132 |
+
This is the configuration class to store the configuration of a [`Fgclip2VisionModel`]. It is used to instantiate a
|
| 133 |
+
Fgclip2 vision encoder according to the specified arguments, defining the model architecture. Instantiating a
|
| 134 |
+
configuration with the defaults will yield a similar configuration to that of the vision encoder of the Fgclip2
|
| 135 |
+
[qihoo/fgclip2-base-patch16](https://huggingface.co/qihoo/fgclip2-base-patch16) architecture.
|
| 136 |
+
|
| 137 |
+
Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
|
| 138 |
+
documentation from [`PretrainedConfig`] for more information.
|
| 139 |
+
|
| 140 |
+
Args:
|
| 141 |
+
hidden_size (`int`, *optional*, defaults to 768):
|
| 142 |
+
Dimensionality of the encoder layers and the pooler layer.
|
| 143 |
+
intermediate_size (`int`, *optional*, defaults to 3072):
|
| 144 |
+
Dimensionality of the "intermediate" (i.e., feed-forward) layer in the Transformer encoder.
|
| 145 |
+
num_hidden_layers (`int`, *optional*, defaults to 12):
|
| 146 |
+
Number of hidden layers in the Transformer encoder.
|
| 147 |
+
num_attention_heads (`int`, *optional*, defaults to 12):
|
| 148 |
+
Number of attention heads for each attention layer in the Transformer encoder.
|
| 149 |
+
num_channels (`int`, *optional*, defaults to 3):
|
| 150 |
+
Number of channels in the input images.
|
| 151 |
+
num_patches (`int`, *optional*, defaults to 256):
|
| 152 |
+
The number of patches in the image with the size of (`patch_size`, `patch_size`).
|
| 153 |
+
The image is resized to fill maximum of this number of patches, and to preserve
|
| 154 |
+
the aspect ratio. In case the resulted number of patches is lower, the image is
|
| 155 |
+
padded in "patch" dimension.
|
| 156 |
+
patch_size (`int`, *optional*, defaults to 16):
|
| 157 |
+
The size (resolution) of each patch.
|
| 158 |
+
hidden_act (`str` or `function`, *optional*, defaults to `"gelu_pytorch_tanh"`):
|
| 159 |
+
The non-linear activation function (function or string) in the encoder and pooler. If string, `"gelu"`,
|
| 160 |
+
`"relu"`, `"selu"` and `"gelu_new"` `"quick_gelu"` are supported.
|
| 161 |
+
layer_norm_eps (`float`, *optional*, defaults to 1e-06):
|
| 162 |
+
The epsilon used by the layer normalization layers.
|
| 163 |
+
attention_dropout (`float`, *optional*, defaults to 0.0):
|
| 164 |
+
The dropout ratio for the attention probabilities.
|
| 165 |
+
|
| 166 |
+
Example:
|
| 167 |
+
|
| 168 |
+
```python
|
| 169 |
+
>>> from transformers import Fgclip2VisionConfig, Fgclip2VisionModel
|
| 170 |
+
|
| 171 |
+
>>> # Initializing a Fgclip2VisionConfig with qihoo/fgclip2-base-patch16 style configuration
|
| 172 |
+
>>> configuration = Fgclip2VisionConfig()
|
| 173 |
+
|
| 174 |
+
>>> # Initializing a Fgclip2VisionModel (with random weights) from the qihoo/fgclip2-base-patch16 style configuration
|
| 175 |
+
>>> model = Fgclip2VisionModel(configuration)
|
| 176 |
+
|
| 177 |
+
>>> # Accessing the model configuration
|
| 178 |
+
>>> configuration = model.config
|
| 179 |
+
```"""
|
| 180 |
+
|
| 181 |
+
model_type = "fgclip2_vision_model"
|
| 182 |
+
base_config_key = "vision_config"
|
| 183 |
+
|
| 184 |
+
def __init__(
|
| 185 |
+
self,
|
| 186 |
+
hidden_size=768,
|
| 187 |
+
intermediate_size=3072,
|
| 188 |
+
num_hidden_layers=12,
|
| 189 |
+
num_attention_heads=12,
|
| 190 |
+
num_channels=3,
|
| 191 |
+
num_patches=256,
|
| 192 |
+
patch_size=16,
|
| 193 |
+
hidden_act="gelu_pytorch_tanh",
|
| 194 |
+
layer_norm_eps=1e-6,
|
| 195 |
+
attention_dropout=0.0,
|
| 196 |
+
**kwargs,
|
| 197 |
+
):
|
| 198 |
+
super().__init__(**kwargs)
|
| 199 |
+
|
| 200 |
+
self.hidden_size = hidden_size
|
| 201 |
+
self.intermediate_size = intermediate_size
|
| 202 |
+
self.num_hidden_layers = num_hidden_layers
|
| 203 |
+
self.num_attention_heads = num_attention_heads
|
| 204 |
+
self.num_channels = num_channels
|
| 205 |
+
self.patch_size = patch_size
|
| 206 |
+
self.attention_dropout = attention_dropout
|
| 207 |
+
self.layer_norm_eps = layer_norm_eps
|
| 208 |
+
self.hidden_act = hidden_act
|
| 209 |
+
self.num_patches = num_patches
|
| 210 |
+
|
| 211 |
+
|
| 212 |
+
class Fgclip2Config(PretrainedConfig):
|
| 213 |
+
r"""
|
| 214 |
+
[`Fgclip2Config`] is the configuration class to store the configuration of a [`Fgclip2Model`]. It is used to
|
| 215 |
+
instantiate a Fgclip2 model according to the specified arguments, defining the text model and vision model configs.
|
| 216 |
+
Instantiating a configuration with the defaults will yield a similar configuration to that of the Fgclip2
|
| 217 |
+
[qihoo/fgclip2-base-patch16](https://huggingface.co/qihoo/fgclip2-base-patch16) architecture.
|
| 218 |
+
|
| 219 |
+
Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
|
| 220 |
+
documentation from [`PretrainedConfig`] for more information.
|
| 221 |
+
|
| 222 |
+
Args:
|
| 223 |
+
text_config (`dict`, *optional*):
|
| 224 |
+
Dictionary of configuration options used to initialize [`Fgclip2TextConfig`].
|
| 225 |
+
vision_config (`dict`, *optional*):
|
| 226 |
+
Dictionary of configuration options used to initialize [`Fgclip2VisionConfig`].
|
| 227 |
+
kwargs (*optional*):
|
| 228 |
+
Dictionary of keyword arguments.
|
| 229 |
+
|
| 230 |
+
Example:
|
| 231 |
+
|
| 232 |
+
```python
|
| 233 |
+
>>> from transformers import Fgclip2Config, Fgclip2Model
|
| 234 |
+
|
| 235 |
+
>>> # Initializing a Fgclip2Config with qihoo/fgclip2-base-patch16 style configuration
|
| 236 |
+
>>> configuration = Fgclip2Config()
|
| 237 |
+
|
| 238 |
+
>>> # Initializing a Fgclip2Model (with random weights) from the qihoo/fgclip2-base-patch16 style configuration
|
| 239 |
+
>>> model = Fgclip2Model(configuration)
|
| 240 |
+
|
| 241 |
+
>>> # Accessing the model configuration
|
| 242 |
+
>>> configuration = model.config
|
| 243 |
+
|
| 244 |
+
>>> # We can also initialize a Fgclip2Config from a Fgclip2TextConfig and a Fgclip2VisionConfig
|
| 245 |
+
>>> from transformers import Fgclip2TextConfig, Fgclip2VisionConfig
|
| 246 |
+
|
| 247 |
+
>>> # Initializing a Fgclip2Text and Fgclip2Vision configuration
|
| 248 |
+
>>> config_text = Fgclip2TextConfig()
|
| 249 |
+
>>> config_vision = Fgclip2VisionConfig()
|
| 250 |
+
|
| 251 |
+
>>> config = Fgclip2Config.from_text_vision_configs(config_text, config_vision)
|
| 252 |
+
```"""
|
| 253 |
+
|
| 254 |
+
model_type = "fgclip2"
|
| 255 |
+
sub_configs = {"text_config": Fgclip2TextConfig, "vision_config": Fgclip2VisionConfig}
|
| 256 |
+
|
| 257 |
+
def __init__(self, text_config=None, vision_config=None, **kwargs):
|
| 258 |
+
super().__init__(**kwargs)
|
| 259 |
+
|
| 260 |
+
if text_config is None:
|
| 261 |
+
text_config = {}
|
| 262 |
+
logger.info("`text_config` is `None`. Initializing the `Fgclip2TextConfig` with default values.")
|
| 263 |
+
|
| 264 |
+
if vision_config is None:
|
| 265 |
+
vision_config = {}
|
| 266 |
+
logger.info("`vision_config` is `None`. initializing the `Fgclip2VisionConfig` with default values.")
|
| 267 |
+
|
| 268 |
+
self.text_config = Fgclip2TextConfig(**text_config)
|
| 269 |
+
self.vision_config = Fgclip2VisionConfig(**vision_config)
|
| 270 |
+
|
| 271 |
+
self.initializer_factor = 1.0
|
| 272 |
+
|
| 273 |
+
|
| 274 |
+
__all__ = ["Fgclip2Config", "Fgclip2TextConfig", "Fgclip2VisionConfig"]
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5328bf1538afb4b7f4aa844f749655285d0d79490f31a25aeefc5603d9b173fe
|
| 3 |
+
size 1535264416
|
modeling_fgclip2.py
ADDED
|
@@ -0,0 +1,1400 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
|
| 2 |
+
# This file was automatically generated from src/transformers/models/fgclip2/modular_fgclip2.py.
|
| 3 |
+
# Do NOT edit this file manually as any edits will be overwritten by the generation of
|
| 4 |
+
# the file from the modular. If any change should be done, please apply the change to the
|
| 5 |
+
# modular_fgclip2.py file directly. One of our CI enforces this.
|
| 6 |
+
# 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
|
| 7 |
+
# coding=utf-8
|
| 8 |
+
# Copyright 2025 The HuggingFace Inc. team.
|
| 9 |
+
#
|
| 10 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 11 |
+
# you may not use this file except in compliance with the License.
|
| 12 |
+
# You may obtain a copy of the License at
|
| 13 |
+
#
|
| 14 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 15 |
+
#
|
| 16 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 17 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 18 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 19 |
+
# See the License for the specific language governing permissions and
|
| 20 |
+
# limitations under the License.
|
| 21 |
+
import math
|
| 22 |
+
import warnings
|
| 23 |
+
from dataclasses import dataclass
|
| 24 |
+
from typing import Any, Callable, Optional, Union, List
|
| 25 |
+
|
| 26 |
+
import numpy as np
|
| 27 |
+
import torch
|
| 28 |
+
import torch.nn as nn
|
| 29 |
+
import torch.nn.functional as F
|
| 30 |
+
from torch.nn.init import _calculate_fan_in_and_fan_out
|
| 31 |
+
from torchvision.ops import roi_align
|
| 32 |
+
|
| 33 |
+
from transformers.activations import ACT2FN
|
| 34 |
+
from transformers.modeling_attn_mask_utils import _prepare_4d_attention_mask
|
| 35 |
+
from transformers.modeling_layers import GradientCheckpointingLayer
|
| 36 |
+
from transformers.modeling_outputs import BaseModelOutput, BaseModelOutputWithPooling
|
| 37 |
+
from transformers.modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel
|
| 38 |
+
from transformers.processing_utils import Unpack
|
| 39 |
+
from transformers.utils import ModelOutput, TransformersKwargs, auto_docstring, can_return_tuple, filter_out_non_signature_kwargs
|
| 40 |
+
from transformers.utils.generic import check_model_inputs
|
| 41 |
+
from .configuration_fgclip2 import Fgclip2Config, Fgclip2TextConfig, Fgclip2VisionConfig
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
@dataclass
|
| 45 |
+
@auto_docstring(
|
| 46 |
+
custom_intro="""
|
| 47 |
+
Base class for vision model's outputs that also contains image embeddings of the pooling of the last hidden states.
|
| 48 |
+
"""
|
| 49 |
+
)
|
| 50 |
+
class Fgclip2VisionOutput(ModelOutput):
|
| 51 |
+
r"""
|
| 52 |
+
image_embeds (`torch.FloatTensor` of shape `(batch_size, output_dim)` *optional* returned when model is initialized with `with_projection=True`):
|
| 53 |
+
The image embeddings obtained by applying the projection layer to the pooler_output.
|
| 54 |
+
"""
|
| 55 |
+
|
| 56 |
+
image_embeds: Optional[torch.FloatTensor] = None
|
| 57 |
+
last_hidden_state: Optional[torch.FloatTensor] = None
|
| 58 |
+
hidden_states: Optional[tuple[torch.FloatTensor, ...]] = None
|
| 59 |
+
attentions: Optional[tuple[torch.FloatTensor, ...]] = None
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
@dataclass
|
| 63 |
+
@auto_docstring(
|
| 64 |
+
custom_intro="""
|
| 65 |
+
Base class for text model's outputs that also contains a pooling of the last hidden states.
|
| 66 |
+
"""
|
| 67 |
+
)
|
| 68 |
+
class Fgclip2TextOutput(ModelOutput):
|
| 69 |
+
r"""
|
| 70 |
+
text_embeds (`torch.FloatTensor` of shape `(batch_size, output_dim)` *optional* returned when model is initialized with `with_projection=True`):
|
| 71 |
+
The text embeddings obtained by applying the projection layer to the pooler_output.
|
| 72 |
+
"""
|
| 73 |
+
|
| 74 |
+
text_embeds: Optional[torch.FloatTensor] = None
|
| 75 |
+
last_hidden_state: Optional[torch.FloatTensor] = None
|
| 76 |
+
hidden_states: Optional[tuple[torch.FloatTensor, ...]] = None
|
| 77 |
+
attentions: Optional[tuple[torch.FloatTensor, ...]] = None
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
@dataclass
|
| 81 |
+
@auto_docstring
|
| 82 |
+
class Fgclip2Output(ModelOutput):
|
| 83 |
+
r"""
|
| 84 |
+
loss (`torch.FloatTensor` of shape `(1,)`, *optional*, returned when `return_loss` is `True`):
|
| 85 |
+
Contrastive loss for image-text similarity.
|
| 86 |
+
logits_per_image (`torch.FloatTensor` of shape `(image_batch_size, text_batch_size)`):
|
| 87 |
+
The scaled dot product scores between `image_embeds` and `text_embeds`. This represents the image-text
|
| 88 |
+
similarity scores.
|
| 89 |
+
logits_per_text (`torch.FloatTensor` of shape `(text_batch_size, image_batch_size)`):
|
| 90 |
+
The scaled dot product scores between `text_embeds` and `image_embeds`. This represents the text-image
|
| 91 |
+
similarity scores.
|
| 92 |
+
text_embeds (`torch.FloatTensor` of shape `(batch_size, output_dim`):
|
| 93 |
+
The text embeddings obtained by applying the projection layer to the pooled output of [`Fgclip2TextModel`].
|
| 94 |
+
image_embeds (`torch.FloatTensor` of shape `(batch_size, output_dim`):
|
| 95 |
+
The image embeddings obtained by applying the projection layer to the pooled output of [`Fgclip2VisionModel`].
|
| 96 |
+
text_model_output (`BaseModelOutputWithPooling`):
|
| 97 |
+
The output of the [`Fgclip2TextModel`].
|
| 98 |
+
vision_model_output (`BaseModelOutputWithPooling`):
|
| 99 |
+
The output of the [`Fgclip2VisionModel`].
|
| 100 |
+
"""
|
| 101 |
+
|
| 102 |
+
loss: Optional[torch.FloatTensor] = None
|
| 103 |
+
logits_per_image: Optional[torch.FloatTensor] = None
|
| 104 |
+
logits_per_text: Optional[torch.FloatTensor] = None
|
| 105 |
+
text_embeds: Optional[torch.FloatTensor] = None
|
| 106 |
+
image_embeds: Optional[torch.FloatTensor] = None
|
| 107 |
+
text_model_output: BaseModelOutputWithPooling = None
|
| 108 |
+
vision_model_output: BaseModelOutputWithPooling = None
|
| 109 |
+
|
| 110 |
+
def to_tuple(self) -> tuple[Any]:
|
| 111 |
+
return tuple(
|
| 112 |
+
self[k] if k not in ["text_model_output", "vision_model_output"] else getattr(self, k).to_tuple()
|
| 113 |
+
for k in self.keys()
|
| 114 |
+
)
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
class Fgclip2VisionEmbeddings(nn.Module):
|
| 118 |
+
def __init__(self, config: Fgclip2VisionConfig):
|
| 119 |
+
super().__init__()
|
| 120 |
+
self.config = config
|
| 121 |
+
self.embed_dim = config.hidden_size
|
| 122 |
+
self.patch_size = config.patch_size
|
| 123 |
+
|
| 124 |
+
self.patch_embedding = nn.Linear(
|
| 125 |
+
in_features=config.num_channels * self.patch_size * self.patch_size,
|
| 126 |
+
out_features=self.embed_dim,
|
| 127 |
+
)
|
| 128 |
+
|
| 129 |
+
self.num_patches = config.num_patches
|
| 130 |
+
self.position_embedding_size = int(self.num_patches**0.5)
|
| 131 |
+
self.position_embedding = nn.Embedding(self.num_patches, self.embed_dim)
|
| 132 |
+
|
| 133 |
+
@staticmethod
|
| 134 |
+
def resize_positional_embeddings(
|
| 135 |
+
positional_embeddings: torch.Tensor,
|
| 136 |
+
spatial_shapes: torch.LongTensor,
|
| 137 |
+
max_length: int,
|
| 138 |
+
) -> torch.Tensor:
|
| 139 |
+
"""
|
| 140 |
+
Resize positional embeddings to image-specific size and pad to a fixed size.
|
| 141 |
+
|
| 142 |
+
Args:
|
| 143 |
+
positional_embeddings (`torch.Tensor`):
|
| 144 |
+
Position embeddings of shape (height, width, embed_dim)
|
| 145 |
+
spatial_shapes (`torch.LongTensor`):
|
| 146 |
+
Spatial shapes of shape (batch_size, 2) to resize the positional embeddings to
|
| 147 |
+
max_length (`int`):
|
| 148 |
+
Maximum length of the positional embeddings to pad resized positional embeddings to
|
| 149 |
+
|
| 150 |
+
Returns:
|
| 151 |
+
`torch.Tensor`: Embeddings of shape (batch_size, max_length, embed_dim)
|
| 152 |
+
"""
|
| 153 |
+
batch_size = spatial_shapes.shape[0]
|
| 154 |
+
embed_dim = positional_embeddings.shape[-1]
|
| 155 |
+
source_dtype = positional_embeddings.dtype
|
| 156 |
+
|
| 157 |
+
resulted_positional_embeddings = torch.empty(
|
| 158 |
+
(batch_size, max_length, embed_dim),
|
| 159 |
+
device=positional_embeddings.device,
|
| 160 |
+
dtype=source_dtype,
|
| 161 |
+
)
|
| 162 |
+
|
| 163 |
+
# (height, width, embed_dim) -> (1, embed_dim, height, width) for interpolation
|
| 164 |
+
positional_embeddings = positional_embeddings.permute(2, 0, 1).unsqueeze(0)
|
| 165 |
+
|
| 166 |
+
# Upcast to float32 on CPU because antialias is not supported for bfloat16/float16 on CPU
|
| 167 |
+
if positional_embeddings.device.type == "cpu":
|
| 168 |
+
positional_embeddings = positional_embeddings.to(torch.float32)
|
| 169 |
+
|
| 170 |
+
for i in range(batch_size):
|
| 171 |
+
# (1, dim, height, width) -> (1, dim, target_height, target_width)
|
| 172 |
+
height, width = spatial_shapes[i]
|
| 173 |
+
resized_embeddings = F.interpolate(
|
| 174 |
+
positional_embeddings,
|
| 175 |
+
size=(height, width),
|
| 176 |
+
mode="bilinear",
|
| 177 |
+
align_corners=False,
|
| 178 |
+
antialias=True,
|
| 179 |
+
)
|
| 180 |
+
|
| 181 |
+
# (1, dim, target_height, target_width) -> (target_height * target_width, dim)
|
| 182 |
+
resized_embeddings = resized_embeddings.reshape(embed_dim, height * width).transpose(0, 1)
|
| 183 |
+
|
| 184 |
+
# Cast to original dtype
|
| 185 |
+
resized_embeddings = resized_embeddings.to(source_dtype)
|
| 186 |
+
|
| 187 |
+
resulted_positional_embeddings[i, : height * width] = resized_embeddings
|
| 188 |
+
resulted_positional_embeddings[i, height * width :] = resized_embeddings[0]
|
| 189 |
+
|
| 190 |
+
return resulted_positional_embeddings
|
| 191 |
+
|
| 192 |
+
def forward(self, pixel_values: torch.FloatTensor, spatial_shapes: torch.LongTensor) -> torch.Tensor:
|
| 193 |
+
"""
|
| 194 |
+
Args:
|
| 195 |
+
pixel_values (`torch.FloatTensor`):
|
| 196 |
+
Pixel values of shape (batch_size, max_num_patches, num_channels * patch_size * patch_size)
|
| 197 |
+
spatial_shapes (`list[tuple[int, int]]`):
|
| 198 |
+
Spatial shapes of shape (batch_size, 2) to resize the positional embeddings to
|
| 199 |
+
"""
|
| 200 |
+
|
| 201 |
+
# Apply patch embeddings to already patchified pixel values
|
| 202 |
+
target_dtype = self.patch_embedding.weight.dtype
|
| 203 |
+
patch_embeds = self.patch_embedding(pixel_values.to(dtype=target_dtype))
|
| 204 |
+
|
| 205 |
+
# Get positional resized and padded positional embeddings
|
| 206 |
+
positional_embeddings = self.position_embedding.weight.reshape(
|
| 207 |
+
self.position_embedding_size, self.position_embedding_size, -1
|
| 208 |
+
)
|
| 209 |
+
resized_positional_embeddings = self.resize_positional_embeddings(
|
| 210 |
+
positional_embeddings, spatial_shapes, max_length=pixel_values.shape[1]
|
| 211 |
+
)
|
| 212 |
+
|
| 213 |
+
# Add positional embeddings to patch embeddings
|
| 214 |
+
embeddings = patch_embeds + resized_positional_embeddings
|
| 215 |
+
return embeddings
|
| 216 |
+
|
| 217 |
+
|
| 218 |
+
def eager_attention_forward(
|
| 219 |
+
module: nn.Module,
|
| 220 |
+
query: torch.Tensor,
|
| 221 |
+
key: torch.Tensor,
|
| 222 |
+
value: torch.Tensor,
|
| 223 |
+
attention_mask: Optional[torch.Tensor],
|
| 224 |
+
scaling: float,
|
| 225 |
+
dropout: float = 0.0,
|
| 226 |
+
**kwargs,
|
| 227 |
+
):
|
| 228 |
+
attn_weights = torch.matmul(query, key.transpose(-1, -2)) * scaling
|
| 229 |
+
if attention_mask is not None:
|
| 230 |
+
attn_weights = attn_weights + attention_mask
|
| 231 |
+
|
| 232 |
+
attn_weights = nn.functional.softmax(attn_weights, dim=-1, dtype=torch.float32).to(query.dtype)
|
| 233 |
+
attn_weights = nn.functional.dropout(attn_weights, p=dropout, training=module.training)
|
| 234 |
+
|
| 235 |
+
attn_output = torch.matmul(attn_weights, value)
|
| 236 |
+
attn_output = attn_output.transpose(1, 2).contiguous()
|
| 237 |
+
|
| 238 |
+
return attn_output, attn_weights
|
| 239 |
+
|
| 240 |
+
|
| 241 |
+
class Fgclip2Attention(nn.Module):
|
| 242 |
+
"""Multi-headed attention from 'Attention Is All You Need' paper"""
|
| 243 |
+
|
| 244 |
+
def __init__(self, config):
|
| 245 |
+
super().__init__()
|
| 246 |
+
self.config = config
|
| 247 |
+
self.embed_dim = config.hidden_size
|
| 248 |
+
self.num_heads = config.num_attention_heads
|
| 249 |
+
self.head_dim = self.embed_dim // self.num_heads
|
| 250 |
+
if self.head_dim * self.num_heads != self.embed_dim:
|
| 251 |
+
raise ValueError(
|
| 252 |
+
f"embed_dim must be divisible by num_heads (got `embed_dim`: {self.embed_dim} and `num_heads`:"
|
| 253 |
+
f" {self.num_heads})."
|
| 254 |
+
)
|
| 255 |
+
self.scale = self.head_dim**-0.5
|
| 256 |
+
self.dropout = config.attention_dropout
|
| 257 |
+
self.is_causal = False
|
| 258 |
+
|
| 259 |
+
self.k_proj = nn.Linear(self.embed_dim, self.embed_dim)
|
| 260 |
+
self.v_proj = nn.Linear(self.embed_dim, self.embed_dim)
|
| 261 |
+
self.q_proj = nn.Linear(self.embed_dim, self.embed_dim)
|
| 262 |
+
self.out_proj = nn.Linear(self.embed_dim, self.embed_dim)
|
| 263 |
+
|
| 264 |
+
def forward(
|
| 265 |
+
self,
|
| 266 |
+
hidden_states: torch.Tensor,
|
| 267 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 268 |
+
**kwargs,
|
| 269 |
+
) -> tuple[torch.Tensor, Optional[torch.Tensor]]:
|
| 270 |
+
"""Input shape: Batch x Time x Channel"""
|
| 271 |
+
|
| 272 |
+
batch_size, seq_length, embed_dim = hidden_states.shape
|
| 273 |
+
|
| 274 |
+
queries = self.q_proj(hidden_states)
|
| 275 |
+
keys = self.k_proj(hidden_states)
|
| 276 |
+
values = self.v_proj(hidden_states)
|
| 277 |
+
|
| 278 |
+
queries = queries.view(batch_size, seq_length, self.num_heads, self.head_dim).transpose(1, 2)
|
| 279 |
+
keys = keys.view(batch_size, seq_length, self.num_heads, self.head_dim).transpose(1, 2)
|
| 280 |
+
values = values.view(batch_size, seq_length, self.num_heads, self.head_dim).transpose(1, 2)
|
| 281 |
+
|
| 282 |
+
attention_interface: Callable = eager_attention_forward
|
| 283 |
+
if self.config._attn_implementation != "eager":
|
| 284 |
+
attention_interface = ALL_ATTENTION_FUNCTIONS[self.config._attn_implementation]
|
| 285 |
+
|
| 286 |
+
attn_output, attn_weights = attention_interface(
|
| 287 |
+
self,
|
| 288 |
+
queries,
|
| 289 |
+
keys,
|
| 290 |
+
values,
|
| 291 |
+
attention_mask,
|
| 292 |
+
is_causal=self.is_causal,
|
| 293 |
+
scaling=self.scale,
|
| 294 |
+
dropout=0.0 if not self.training else self.dropout,
|
| 295 |
+
)
|
| 296 |
+
|
| 297 |
+
attn_output = attn_output.reshape(batch_size, seq_length, embed_dim).contiguous()
|
| 298 |
+
attn_output = self.out_proj(attn_output)
|
| 299 |
+
|
| 300 |
+
return attn_output, attn_weights
|
| 301 |
+
|
| 302 |
+
|
| 303 |
+
class Fgclip2MLP(nn.Module):
|
| 304 |
+
def __init__(self, config):
|
| 305 |
+
super().__init__()
|
| 306 |
+
self.config = config
|
| 307 |
+
self.activation_fn = ACT2FN[config.hidden_act]
|
| 308 |
+
self.fc1 = nn.Linear(config.hidden_size, config.intermediate_size)
|
| 309 |
+
self.fc2 = nn.Linear(config.intermediate_size, config.hidden_size)
|
| 310 |
+
|
| 311 |
+
def forward(self, hidden_states: torch.Tensor) -> torch.Tensor:
|
| 312 |
+
hidden_states = self.fc1(hidden_states)
|
| 313 |
+
hidden_states = self.activation_fn(hidden_states)
|
| 314 |
+
hidden_states = self.fc2(hidden_states)
|
| 315 |
+
return hidden_states
|
| 316 |
+
|
| 317 |
+
|
| 318 |
+
class Fgclip2EncoderLayer(GradientCheckpointingLayer):
|
| 319 |
+
def __init__(self, config: Union[Fgclip2VisionConfig, Fgclip2TextConfig]):
|
| 320 |
+
super().__init__()
|
| 321 |
+
self.embed_dim = config.hidden_size
|
| 322 |
+
self.layer_norm1 = nn.LayerNorm(self.embed_dim, eps=config.layer_norm_eps)
|
| 323 |
+
self.self_attn = Fgclip2Attention(config)
|
| 324 |
+
self.layer_norm2 = nn.LayerNorm(self.embed_dim, eps=config.layer_norm_eps)
|
| 325 |
+
self.mlp = Fgclip2MLP(config)
|
| 326 |
+
|
| 327 |
+
@auto_docstring
|
| 328 |
+
def forward(
|
| 329 |
+
self,
|
| 330 |
+
hidden_states: torch.Tensor,
|
| 331 |
+
attention_mask: torch.Tensor,
|
| 332 |
+
**kwargs: Unpack[TransformersKwargs],
|
| 333 |
+
) -> torch.FloatTensor:
|
| 334 |
+
residual = hidden_states
|
| 335 |
+
|
| 336 |
+
hidden_states = self.layer_norm1(hidden_states)
|
| 337 |
+
hidden_states, _ = self.self_attn(
|
| 338 |
+
hidden_states=hidden_states,
|
| 339 |
+
attention_mask=attention_mask,
|
| 340 |
+
**kwargs,
|
| 341 |
+
)
|
| 342 |
+
hidden_states = residual + hidden_states
|
| 343 |
+
|
| 344 |
+
residual = hidden_states
|
| 345 |
+
hidden_states = self.layer_norm2(hidden_states)
|
| 346 |
+
hidden_states = self.mlp(hidden_states)
|
| 347 |
+
hidden_states = residual + hidden_states
|
| 348 |
+
|
| 349 |
+
return hidden_states
|
| 350 |
+
|
| 351 |
+
|
| 352 |
+
class Fgclip2Encoder(nn.Module):
|
| 353 |
+
"""
|
| 354 |
+
Transformer encoder consisting of `config.num_hidden_layers` self attention layers. Each layer is a
|
| 355 |
+
[`Fgclip2EncoderLayer`].
|
| 356 |
+
|
| 357 |
+
Args:
|
| 358 |
+
config: Fgclip2Config
|
| 359 |
+
"""
|
| 360 |
+
|
| 361 |
+
def __init__(self, config: Fgclip2Config):
|
| 362 |
+
super().__init__()
|
| 363 |
+
self.config = config
|
| 364 |
+
self.layers = nn.ModuleList([Fgclip2EncoderLayer(config) for _ in range(config.num_hidden_layers)])
|
| 365 |
+
self.gradient_checkpointing = False
|
| 366 |
+
|
| 367 |
+
# Ignore copy
|
| 368 |
+
@auto_docstring
|
| 369 |
+
def forward(
|
| 370 |
+
self,
|
| 371 |
+
inputs_embeds,
|
| 372 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 373 |
+
**kwargs: Unpack[TransformersKwargs],
|
| 374 |
+
) -> BaseModelOutput:
|
| 375 |
+
hidden_states = inputs_embeds
|
| 376 |
+
for encoder_layer in self.layers:
|
| 377 |
+
hidden_states = encoder_layer(
|
| 378 |
+
hidden_states,
|
| 379 |
+
attention_mask,
|
| 380 |
+
**kwargs,
|
| 381 |
+
)
|
| 382 |
+
|
| 383 |
+
return BaseModelOutput(last_hidden_state=hidden_states)
|
| 384 |
+
|
| 385 |
+
|
| 386 |
+
class Fgclip2VisionTransformer(nn.Module):
|
| 387 |
+
def __init__(self, config: Fgclip2VisionConfig):
|
| 388 |
+
super().__init__()
|
| 389 |
+
self.config = config
|
| 390 |
+
embed_dim = config.hidden_size
|
| 391 |
+
|
| 392 |
+
self.embeddings = Fgclip2VisionEmbeddings(config)
|
| 393 |
+
self.encoder = Fgclip2Encoder(config)
|
| 394 |
+
self.post_layernorm = nn.LayerNorm(embed_dim, eps=config.layer_norm_eps)
|
| 395 |
+
self.use_head = True if not hasattr(config, "vision_use_head") else config.vision_use_head
|
| 396 |
+
if self.use_head:
|
| 397 |
+
self.head = Fgclip2MultiheadAttentionPoolingHead(config)
|
| 398 |
+
|
| 399 |
+
@can_return_tuple
|
| 400 |
+
@auto_docstring
|
| 401 |
+
def forward(
|
| 402 |
+
self,
|
| 403 |
+
pixel_values: torch.FloatTensor,
|
| 404 |
+
attention_mask: torch.Tensor,
|
| 405 |
+
spatial_shapes: torch.LongTensor,
|
| 406 |
+
output_attentions: Optional[bool] = None,
|
| 407 |
+
output_hidden_states: Optional[bool] = None,
|
| 408 |
+
) -> BaseModelOutputWithPooling:
|
| 409 |
+
r"""
|
| 410 |
+
spatial_shapes (`torch.LongTensor` of shape `(batch_size, 2)`):
|
| 411 |
+
Tensor containing the spatial dimensions (height, width) of the input images.
|
| 412 |
+
"""
|
| 413 |
+
output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
|
| 414 |
+
output_hidden_states = (
|
| 415 |
+
output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
|
| 416 |
+
)
|
| 417 |
+
|
| 418 |
+
hidden_states = self.embeddings(pixel_values, spatial_shapes)
|
| 419 |
+
|
| 420 |
+
if attention_mask is not None and self.config._attn_implementation != "flash_attention_2":
|
| 421 |
+
# [batch_size, seq_len] -> [batch_size, 1, tgt_seq_len, src_seq_len]
|
| 422 |
+
encoder_attention_mask = _prepare_4d_attention_mask(attention_mask, hidden_states.dtype)
|
| 423 |
+
else:
|
| 424 |
+
encoder_attention_mask = attention_mask
|
| 425 |
+
|
| 426 |
+
encoder_outputs: BaseModelOutput = self.encoder(
|
| 427 |
+
inputs_embeds=hidden_states,
|
| 428 |
+
attention_mask=encoder_attention_mask,
|
| 429 |
+
output_attentions=output_attentions,
|
| 430 |
+
output_hidden_states=output_hidden_states,
|
| 431 |
+
)
|
| 432 |
+
|
| 433 |
+
last_hidden_state = encoder_outputs.last_hidden_state
|
| 434 |
+
last_hidden_state = self.post_layernorm(last_hidden_state)
|
| 435 |
+
|
| 436 |
+
pooler_output = self.head(last_hidden_state, attention_mask) if self.use_head else None
|
| 437 |
+
|
| 438 |
+
return BaseModelOutputWithPooling(
|
| 439 |
+
last_hidden_state=last_hidden_state,
|
| 440 |
+
pooler_output=pooler_output,
|
| 441 |
+
hidden_states=encoder_outputs.hidden_states,
|
| 442 |
+
attentions=encoder_outputs.attentions,
|
| 443 |
+
)
|
| 444 |
+
|
| 445 |
+
|
| 446 |
+
def _trunc_normal_(tensor, mean, std, a, b):
|
| 447 |
+
# Cut & paste from PyTorch official master until it's in a few official releases - RW
|
| 448 |
+
# Method based on https://people.sc.fsu.edu/~jburkardt/presentations/truncated_normal.pdf
|
| 449 |
+
def norm_cdf(x):
|
| 450 |
+
# Computes standard normal cumulative distribution function
|
| 451 |
+
return (1.0 + math.erf(x / math.sqrt(2.0))) / 2.0
|
| 452 |
+
|
| 453 |
+
if (mean < a - 2 * std) or (mean > b + 2 * std):
|
| 454 |
+
warnings.warn(
|
| 455 |
+
"mean is more than 2 std from [a, b] in nn.init.trunc_normal_. "
|
| 456 |
+
"The distribution of values may be incorrect.",
|
| 457 |
+
stacklevel=2,
|
| 458 |
+
)
|
| 459 |
+
|
| 460 |
+
# Values are generated by using a truncated uniform distribution and
|
| 461 |
+
# then using the inverse CDF for the normal distribution.
|
| 462 |
+
# Get upper and lower cdf values
|
| 463 |
+
l = norm_cdf((a - mean) / std)
|
| 464 |
+
u = norm_cdf((b - mean) / std)
|
| 465 |
+
|
| 466 |
+
# Uniformly fill tensor with values from [l, u], then translate to
|
| 467 |
+
# [2l-1, 2u-1].
|
| 468 |
+
tensor.uniform_(2 * l - 1, 2 * u - 1)
|
| 469 |
+
|
| 470 |
+
# Use inverse cdf transform for normal distribution to get truncated
|
| 471 |
+
# standard normal
|
| 472 |
+
tensor.erfinv_()
|
| 473 |
+
|
| 474 |
+
# Transform to proper mean, std
|
| 475 |
+
tensor.mul_(std * math.sqrt(2.0))
|
| 476 |
+
tensor.add_(mean)
|
| 477 |
+
|
| 478 |
+
# Clamp to ensure it's in the proper range
|
| 479 |
+
tensor.clamp_(min=a, max=b)
|
| 480 |
+
|
| 481 |
+
|
| 482 |
+
def trunc_normal_tf_(
|
| 483 |
+
tensor: torch.Tensor, mean: float = 0.0, std: float = 1.0, a: float = -2.0, b: float = 2.0
|
| 484 |
+
) -> torch.Tensor:
|
| 485 |
+
"""Fills the input Tensor with values drawn from a truncated
|
| 486 |
+
normal distribution. The values are effectively drawn from the
|
| 487 |
+
normal distribution :math:`\\mathcal{N}(\text{mean}, \text{std}^2)`
|
| 488 |
+
with values outside :math:`[a, b]` redrawn until they are within
|
| 489 |
+
the bounds. The method used for generating the random values works
|
| 490 |
+
best when :math:`a \\leq \text{mean} \\leq b`.
|
| 491 |
+
|
| 492 |
+
NOTE: this 'tf' variant behaves closer to Tensorflow / JAX impl where the
|
| 493 |
+
bounds [a, b] are applied when sampling the normal distribution with mean=0, std=1.0
|
| 494 |
+
and the result is subsequently scaled and shifted by the mean and std args.
|
| 495 |
+
|
| 496 |
+
Args:
|
| 497 |
+
tensor: an n-dimensional `torch.Tensor`
|
| 498 |
+
mean: the mean of the normal distribution
|
| 499 |
+
std: the standard deviation of the normal distribution
|
| 500 |
+
a: the minimum cutoff value
|
| 501 |
+
b: the maximum cutoff value
|
| 502 |
+
"""
|
| 503 |
+
with torch.no_grad():
|
| 504 |
+
_trunc_normal_(tensor, 0, 1.0, a, b)
|
| 505 |
+
tensor.mul_(std).add_(mean)
|
| 506 |
+
|
| 507 |
+
|
| 508 |
+
def variance_scaling_(tensor, scale=1.0, mode="fan_in", distribution="normal"):
|
| 509 |
+
fan_in, fan_out = _calculate_fan_in_and_fan_out(tensor)
|
| 510 |
+
if mode == "fan_in":
|
| 511 |
+
denom = fan_in
|
| 512 |
+
elif mode == "fan_out":
|
| 513 |
+
denom = fan_out
|
| 514 |
+
elif mode == "fan_avg":
|
| 515 |
+
denom = (fan_in + fan_out) / 2
|
| 516 |
+
|
| 517 |
+
variance = scale / denom
|
| 518 |
+
|
| 519 |
+
if distribution == "truncated_normal":
|
| 520 |
+
# constant is stddev of standard normal truncated to (-2, 2)
|
| 521 |
+
trunc_normal_tf_(tensor, std=math.sqrt(variance) / 0.87962566103423978)
|
| 522 |
+
elif distribution == "normal":
|
| 523 |
+
with torch.no_grad():
|
| 524 |
+
tensor.normal_(std=math.sqrt(variance))
|
| 525 |
+
elif distribution == "uniform":
|
| 526 |
+
bound = math.sqrt(3 * variance)
|
| 527 |
+
with torch.no_grad():
|
| 528 |
+
tensor.uniform_(-bound, bound)
|
| 529 |
+
else:
|
| 530 |
+
raise ValueError(f"invalid distribution {distribution}")
|
| 531 |
+
|
| 532 |
+
|
| 533 |
+
def lecun_normal_(tensor):
|
| 534 |
+
variance_scaling_(tensor, mode="fan_in", distribution="truncated_normal")
|
| 535 |
+
|
| 536 |
+
|
| 537 |
+
def default_flax_embed_init(tensor):
|
| 538 |
+
variance_scaling_(tensor, mode="fan_in", distribution="normal")
|
| 539 |
+
|
| 540 |
+
|
| 541 |
+
@auto_docstring
|
| 542 |
+
class Fgclip2PreTrainedModel(PreTrainedModel):
|
| 543 |
+
config: Fgclip2Config
|
| 544 |
+
base_model_prefix = "fgclip2"
|
| 545 |
+
supports_gradient_checkpointing = True
|
| 546 |
+
|
| 547 |
+
_no_split_modules = [
|
| 548 |
+
"Fgclip2TextEmbeddings",
|
| 549 |
+
"Fgclip2VisionEmbeddings",
|
| 550 |
+
"Fgclip2EncoderLayer",
|
| 551 |
+
"Fgclip2MultiheadAttentionPoolingHead",
|
| 552 |
+
]
|
| 553 |
+
_supports_flash_attn = True
|
| 554 |
+
_supports_sdpa = True
|
| 555 |
+
_supports_flex_attn = True
|
| 556 |
+
_supports_attention_backend = True
|
| 557 |
+
|
| 558 |
+
_can_record_outputs = {
|
| 559 |
+
"hidden_states": Fgclip2EncoderLayer,
|
| 560 |
+
"attentions": Fgclip2Attention,
|
| 561 |
+
}
|
| 562 |
+
|
| 563 |
+
def _init_weights(self, module):
|
| 564 |
+
"""Initialize the weights"""
|
| 565 |
+
if isinstance(module, Fgclip2VisionEmbeddings):
|
| 566 |
+
width = (
|
| 567 |
+
self.config.vision_config.hidden_size
|
| 568 |
+
if isinstance(self.config, Fgclip2Config)
|
| 569 |
+
else self.config.hidden_size
|
| 570 |
+
)
|
| 571 |
+
nn.init.normal_(module.position_embedding.weight, std=1 / np.sqrt(width))
|
| 572 |
+
elif isinstance(module, nn.Embedding):
|
| 573 |
+
default_flax_embed_init(module.weight)
|
| 574 |
+
elif isinstance(module, Fgclip2Attention):
|
| 575 |
+
nn.init.xavier_uniform_(module.q_proj.weight)
|
| 576 |
+
nn.init.xavier_uniform_(module.k_proj.weight)
|
| 577 |
+
nn.init.xavier_uniform_(module.v_proj.weight)
|
| 578 |
+
nn.init.xavier_uniform_(module.out_proj.weight)
|
| 579 |
+
nn.init.zeros_(module.q_proj.bias)
|
| 580 |
+
nn.init.zeros_(module.k_proj.bias)
|
| 581 |
+
nn.init.zeros_(module.v_proj.bias)
|
| 582 |
+
nn.init.zeros_(module.out_proj.bias)
|
| 583 |
+
elif isinstance(module, Fgclip2MLP):
|
| 584 |
+
nn.init.xavier_uniform_(module.fc1.weight)
|
| 585 |
+
nn.init.xavier_uniform_(module.fc2.weight)
|
| 586 |
+
nn.init.normal_(module.fc1.bias, std=1e-6)
|
| 587 |
+
nn.init.normal_(module.fc2.bias, std=1e-6)
|
| 588 |
+
elif isinstance(module, Fgclip2MultiheadAttentionPoolingHead):
|
| 589 |
+
nn.init.xavier_uniform_(module.probe.data)
|
| 590 |
+
nn.init.xavier_uniform_(module.attention.in_proj_weight.data)
|
| 591 |
+
nn.init.zeros_(module.attention.in_proj_bias.data)
|
| 592 |
+
elif isinstance(module, Fgclip2Model):
|
| 593 |
+
logit_scale_init = torch.log(torch.tensor(1.0))
|
| 594 |
+
module.logit_scale.data.fill_(logit_scale_init)
|
| 595 |
+
module.logit_bias.data.zero_()
|
| 596 |
+
elif isinstance(module, (nn.Linear, nn.Conv2d)):
|
| 597 |
+
lecun_normal_(module.weight)
|
| 598 |
+
if module.bias is not None:
|
| 599 |
+
nn.init.zeros_(module.bias)
|
| 600 |
+
elif isinstance(module, nn.LayerNorm):
|
| 601 |
+
module.bias.data.zero_()
|
| 602 |
+
module.weight.data.fill_(1.0)
|
| 603 |
+
|
| 604 |
+
|
| 605 |
+
class Fgclip2TextEmbeddings(nn.Module):
|
| 606 |
+
def __init__(self, config: Fgclip2TextConfig):
|
| 607 |
+
super().__init__()
|
| 608 |
+
embed_dim = config.hidden_size
|
| 609 |
+
|
| 610 |
+
self.token_embedding = nn.Embedding(config.vocab_size, embed_dim)
|
| 611 |
+
self.position_embedding = nn.Embedding(config.max_position_embeddings, embed_dim)
|
| 612 |
+
|
| 613 |
+
# position_ids (1, len position emb) is contiguous in memory and exported when serialized
|
| 614 |
+
self.register_buffer(
|
| 615 |
+
"position_ids", torch.arange(config.max_position_embeddings).expand((1, -1)), persistent=False
|
| 616 |
+
)
|
| 617 |
+
|
| 618 |
+
keep_len = config.keep_len
|
| 619 |
+
longtext_len = config.longtext_len
|
| 620 |
+
|
| 621 |
+
self.position_embedding_res = nn.Embedding(longtext_len, embed_dim)
|
| 622 |
+
self.position_embedding_ori = nn.Embedding(longtext_len, embed_dim)
|
| 623 |
+
|
| 624 |
+
self.mask1 = torch.zeros([longtext_len, 1])
|
| 625 |
+
self.mask1[:keep_len, :] = 1
|
| 626 |
+
self.mask2 = torch.zeros([longtext_len, 1])
|
| 627 |
+
self.mask2[keep_len:, :] = 1
|
| 628 |
+
|
| 629 |
+
# position_ids (1, len position emb) is contiguous in memory and exported when serialized
|
| 630 |
+
self.register_buffer("position_ids", torch.arange(longtext_len).expand((1, -1)), persistent=False)
|
| 631 |
+
|
| 632 |
+
def forward(
|
| 633 |
+
self,
|
| 634 |
+
input_ids: Optional[torch.LongTensor] = None,
|
| 635 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 636 |
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
| 637 |
+
use_short_position_ids: Optional[bool] = True,
|
| 638 |
+
) -> torch.Tensor:
|
| 639 |
+
r"""
|
| 640 |
+
Args:
|
| 641 |
+
use_short_position_ids (`bool`, optional, defaults to `True`):
|
| 642 |
+
If `True`, applies a positional encoding scheme optimized for **short-text processing** and **local-region description processing**,
|
| 643 |
+
such as phrases or simple sentences. Corresponds to the `"short"` and `"box"` walk type.
|
| 644 |
+
Assumes compact semantic structure and local dependency dominance.
|
| 645 |
+
"""
|
| 646 |
+
|
| 647 |
+
seq_length = input_ids.shape[-1] if input_ids is not None else inputs_embeds.shape[-2]
|
| 648 |
+
|
| 649 |
+
if position_ids is None:
|
| 650 |
+
position_ids = self.position_ids[:, :seq_length]
|
| 651 |
+
|
| 652 |
+
if inputs_embeds is None:
|
| 653 |
+
inputs_embeds = self.token_embedding(input_ids)
|
| 654 |
+
|
| 655 |
+
if use_short_position_ids:
|
| 656 |
+
position_embeddings = self.position_embedding(position_ids)
|
| 657 |
+
embeddings = inputs_embeds + position_embeddings
|
| 658 |
+
else:
|
| 659 |
+
position_embeddings_res = self.position_embedding_res(position_ids)
|
| 660 |
+
position_embeddings_ori = self.position_embedding_ori(position_ids)
|
| 661 |
+
embeddings = (
|
| 662 |
+
inputs_embeds
|
| 663 |
+
+ (position_embeddings_ori * self.mask1.to(inputs_embeds.device))
|
| 664 |
+
.type(inputs_embeds.dtype)
|
| 665 |
+
.to(inputs_embeds.device)
|
| 666 |
+
+ (position_embeddings_res * self.mask2.to(inputs_embeds.device))
|
| 667 |
+
.type(inputs_embeds.dtype)
|
| 668 |
+
.to(inputs_embeds.device)
|
| 669 |
+
)
|
| 670 |
+
|
| 671 |
+
return embeddings
|
| 672 |
+
|
| 673 |
+
|
| 674 |
+
class Fgclip2TextTransformer(nn.Module):
|
| 675 |
+
def __init__(self, config: Fgclip2TextConfig):
|
| 676 |
+
super().__init__()
|
| 677 |
+
self.config = config
|
| 678 |
+
embed_dim = config.hidden_size
|
| 679 |
+
self.embeddings = Fgclip2TextEmbeddings(config)
|
| 680 |
+
self.encoder = Fgclip2Encoder(config)
|
| 681 |
+
self.final_layer_norm = nn.LayerNorm(embed_dim, eps=config.layer_norm_eps)
|
| 682 |
+
|
| 683 |
+
self.head = nn.Linear(embed_dim, config.projection_size)
|
| 684 |
+
|
| 685 |
+
@can_return_tuple
|
| 686 |
+
@auto_docstring
|
| 687 |
+
def forward(
|
| 688 |
+
self,
|
| 689 |
+
input_ids: Optional[torch.Tensor] = None,
|
| 690 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 691 |
+
position_ids: Optional[torch.Tensor] = None,
|
| 692 |
+
walk_type: str = "short", # Modified: Single parameter
|
| 693 |
+
**kwargs: Unpack[TransformersKwargs],
|
| 694 |
+
) -> BaseModelOutputWithPooling:
|
| 695 |
+
r"""
|
| 696 |
+
Args:
|
| 697 |
+
walk_type (`str`, optional, defaults to `"short"`):
|
| 698 |
+
The traversal strategy used during feature extraction. Must be one of
|
| 699 |
+
`"short"`, `"box"`, or `"long"`. This controls how contextual information
|
| 700 |
+
is aggregated across the input:
|
| 701 |
+
- `"short"`: Optimized for short-text understanding, focusing on tight semantic coherence
|
| 702 |
+
and direct word interactions. Suitable when the input is a phrase or brief sentence.
|
| 703 |
+
- `"box"`: Designed for local-region description processing, such as grounding in vision-language
|
| 704 |
+
models or processing localized textual descriptions (e.g., object regions or segments).
|
| 705 |
+
Emphasizes dense features within bounded semantic units.
|
| 706 |
+
- `"long"`: Tailored for long-form text processing, enabling modeling of extended dependencies
|
| 707 |
+
and discourse structure. Uses strategies like chunking or hierarchical attention to handle
|
| 708 |
+
longer sequences effectively.
|
| 709 |
+
"""
|
| 710 |
+
if input_ids is None:
|
| 711 |
+
raise ValueError("You have to specify input_ids")
|
| 712 |
+
|
| 713 |
+
# Validate walk_type
|
| 714 |
+
walk_type = walk_type.lower()
|
| 715 |
+
if walk_type not in ["short", "box", "long"]:
|
| 716 |
+
raise ValueError(f"Invalid `walk_type`: {walk_type}. Must be one of 'short', 'box', 'long'.")
|
| 717 |
+
|
| 718 |
+
# Convert walk_type to boolean flags for internal logic
|
| 719 |
+
walk_short = walk_type == "short"
|
| 720 |
+
walk_box = walk_type == "box"
|
| 721 |
+
walk_long = walk_type == "long"
|
| 722 |
+
|
| 723 |
+
input_shape = input_ids.size()
|
| 724 |
+
input_ids = input_ids.view(-1, input_shape[-1])
|
| 725 |
+
hidden_states = self.embeddings(
|
| 726 |
+
input_ids=input_ids, position_ids=position_ids, use_short_position_ids=(not walk_long)
|
| 727 |
+
)
|
| 728 |
+
# note: fgclip2's text model does not use a causal mask, unlike the original CLIP model.
|
| 729 |
+
# expand attention_mask
|
| 730 |
+
uses_flash_attention = "flash" in self.config._attn_implementation
|
| 731 |
+
if uses_flash_attention:
|
| 732 |
+
attention_mask = None
|
| 733 |
+
elif attention_mask is not None and not uses_flash_attention:
|
| 734 |
+
# [batch_size, seq_len] -> [batch_size, 1, tgt_seq_len, src_seq_len]
|
| 735 |
+
attention_mask = _prepare_4d_attention_mask(attention_mask, hidden_states.dtype)
|
| 736 |
+
encoder_outputs: BaseModelOutput = self.encoder(
|
| 737 |
+
inputs_embeds=hidden_states,
|
| 738 |
+
attention_mask=attention_mask,
|
| 739 |
+
**kwargs,
|
| 740 |
+
)
|
| 741 |
+
last_hidden_state = encoder_outputs.last_hidden_state
|
| 742 |
+
last_hidden_state = self.final_layer_norm(last_hidden_state)
|
| 743 |
+
# The model uses the last token's hidden state, which may be padding.
|
| 744 |
+
pooled_output = last_hidden_state[:, -1, :]
|
| 745 |
+
if walk_short == True:
|
| 746 |
+
assert walk_box == False
|
| 747 |
+
assert walk_long == False
|
| 748 |
+
temp_pool_out = []
|
| 749 |
+
for i in range(pooled_output.shape[0]):
|
| 750 |
+
temp_pool_out.append(self.head(pooled_output[i : i + 1]))
|
| 751 |
+
pooled_output = torch.cat(temp_pool_out, dim=0)
|
| 752 |
+
# pooled_output = self.head(pooled_output)
|
| 753 |
+
if walk_box == True:
|
| 754 |
+
assert walk_short == False
|
| 755 |
+
assert walk_long == False
|
| 756 |
+
pooled_output = pooled_output
|
| 757 |
+
if walk_long == True:
|
| 758 |
+
assert walk_short == False
|
| 759 |
+
assert walk_box == False
|
| 760 |
+
pooled_output = pooled_output
|
| 761 |
+
return BaseModelOutputWithPooling(
|
| 762 |
+
last_hidden_state=last_hidden_state,
|
| 763 |
+
pooler_output=pooled_output,
|
| 764 |
+
)
|
| 765 |
+
|
| 766 |
+
|
| 767 |
+
@auto_docstring(
|
| 768 |
+
custom_intro="""
|
| 769 |
+
The text model from Fgclip2 without any head or projection on top.
|
| 770 |
+
"""
|
| 771 |
+
)
|
| 772 |
+
class Fgclip2TextModel(Fgclip2PreTrainedModel):
|
| 773 |
+
config: Fgclip2TextConfig
|
| 774 |
+
|
| 775 |
+
def __init__(self, config: Fgclip2TextConfig):
|
| 776 |
+
super().__init__(config)
|
| 777 |
+
self.text_model = Fgclip2TextTransformer(config)
|
| 778 |
+
# Initialize weights and apply final processing
|
| 779 |
+
self.post_init()
|
| 780 |
+
|
| 781 |
+
def get_input_embeddings(self) -> nn.Module:
|
| 782 |
+
return self.text_model.embeddings.token_embedding
|
| 783 |
+
|
| 784 |
+
def set_input_embeddings(self, value):
|
| 785 |
+
self.text_model.embeddings.token_embedding = value
|
| 786 |
+
|
| 787 |
+
@check_model_inputs
|
| 788 |
+
@auto_docstring
|
| 789 |
+
def forward(
|
| 790 |
+
self,
|
| 791 |
+
input_ids: Optional[torch.Tensor] = None,
|
| 792 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 793 |
+
position_ids: Optional[torch.Tensor] = None,
|
| 794 |
+
walk_type: str = "short", # Modified: Single parameter
|
| 795 |
+
**kwargs: Unpack[TransformersKwargs],
|
| 796 |
+
) -> BaseModelOutputWithPooling:
|
| 797 |
+
r"""
|
| 798 |
+
Args:
|
| 799 |
+
walk_type (`str`, optional, defaults to `"short"`):
|
| 800 |
+
The traversal strategy used during feature extraction. Must be one of
|
| 801 |
+
`"short"`, `"box"`, or `"long"`. This controls how contextual information
|
| 802 |
+
is aggregated across the input:
|
| 803 |
+
- `"short"`: Optimized for short-text understanding, focusing on tight semantic coherence
|
| 804 |
+
and direct word interactions. Suitable when the input is a phrase or brief sentence.
|
| 805 |
+
- `"box"`: Designed for local-region description processing, such as grounding in vision-language
|
| 806 |
+
models or processing localized textual descriptions (e.g., object regions or segments).
|
| 807 |
+
Emphasizes dense features within bounded semantic units.
|
| 808 |
+
- `"long"`: Tailored for long-form text processing, enabling modeling of extended dependencies
|
| 809 |
+
and discourse structure. Uses strategies like chunking or hierarchical attention to handle
|
| 810 |
+
longer sequences effectively.
|
| 811 |
+
"""
|
| 812 |
+
return self.text_model(
|
| 813 |
+
input_ids=input_ids,
|
| 814 |
+
attention_mask=attention_mask,
|
| 815 |
+
position_ids=position_ids,
|
| 816 |
+
walk_type=walk_type, # Modified: Pass single parameter
|
| 817 |
+
**kwargs,
|
| 818 |
+
)
|
| 819 |
+
|
| 820 |
+
|
| 821 |
+
class Fgclip2MultiheadAttentionPoolingHead(nn.Module):
|
| 822 |
+
"""Multihead Attention Pooling."""
|
| 823 |
+
|
| 824 |
+
def __init__(self, config: Fgclip2VisionConfig):
|
| 825 |
+
super().__init__()
|
| 826 |
+
|
| 827 |
+
self.probe = nn.Parameter(torch.randn(1, 1, config.hidden_size))
|
| 828 |
+
self.attention = torch.nn.MultiheadAttention(config.hidden_size, config.num_attention_heads, batch_first=True)
|
| 829 |
+
self.layernorm = nn.LayerNorm(config.hidden_size, eps=config.layer_norm_eps)
|
| 830 |
+
self.mlp = Fgclip2MLP(config)
|
| 831 |
+
self.num_heads = config.num_attention_heads
|
| 832 |
+
|
| 833 |
+
def forward(self, hidden_state: torch.Tensor, attention_mask: Optional[torch.Tensor] = None) -> torch.Tensor:
|
| 834 |
+
batch_size = hidden_state.shape[0]
|
| 835 |
+
probe = self.probe.repeat(batch_size, 1, 1)
|
| 836 |
+
|
| 837 |
+
if attention_mask is not None:
|
| 838 |
+
target_len, source_len = probe.shape[1], hidden_state.shape[1]
|
| 839 |
+
attention_mask = _prepare_4d_attention_mask(attention_mask, hidden_state.dtype, target_len)
|
| 840 |
+
attention_mask = attention_mask.repeat(1, self.num_heads, target_len, 1)
|
| 841 |
+
attention_mask = attention_mask.reshape(-1, target_len, source_len)
|
| 842 |
+
|
| 843 |
+
group_size = self.num_heads
|
| 844 |
+
outputs = []
|
| 845 |
+
for i in range(batch_size):
|
| 846 |
+
start_idx = i * group_size
|
| 847 |
+
end_idx = start_idx + group_size
|
| 848 |
+
out_i = self.attention(
|
| 849 |
+
probe[i : i + 1],
|
| 850 |
+
hidden_state[i : i + 1],
|
| 851 |
+
hidden_state[i : i + 1],
|
| 852 |
+
attn_mask=attention_mask[start_idx:end_idx] if attention_mask is not None else None,
|
| 853 |
+
)[0]
|
| 854 |
+
outputs.append(out_i)
|
| 855 |
+
|
| 856 |
+
hidden_state = torch.cat(outputs, dim=0)
|
| 857 |
+
residual = hidden_state
|
| 858 |
+
hidden_state = self.layernorm(hidden_state)
|
| 859 |
+
|
| 860 |
+
temp_outs = []
|
| 861 |
+
for k in range(batch_size):
|
| 862 |
+
out_k = self.mlp(hidden_state[k : k + 1])
|
| 863 |
+
temp_outs.append(out_k)
|
| 864 |
+
hidden_state = residual + torch.cat(temp_outs, dim=0)
|
| 865 |
+
|
| 866 |
+
return hidden_state[:, 0]
|
| 867 |
+
|
| 868 |
+
|
| 869 |
+
@auto_docstring(
|
| 870 |
+
custom_intro="""
|
| 871 |
+
The vision model from Fgclip2 without any head or projection on top.
|
| 872 |
+
"""
|
| 873 |
+
)
|
| 874 |
+
class Fgclip2VisionModel(Fgclip2PreTrainedModel):
|
| 875 |
+
config: Fgclip2VisionConfig
|
| 876 |
+
main_input_name = "pixel_values"
|
| 877 |
+
|
| 878 |
+
def __init__(self, config: Fgclip2VisionConfig):
|
| 879 |
+
super().__init__(config)
|
| 880 |
+
|
| 881 |
+
self.vision_model = Fgclip2VisionTransformer(config)
|
| 882 |
+
|
| 883 |
+
# Initialize weights and apply final processing
|
| 884 |
+
self.post_init()
|
| 885 |
+
|
| 886 |
+
def get_input_embeddings(self) -> nn.Module:
|
| 887 |
+
return self.vision_model.embeddings.patch_embedding
|
| 888 |
+
|
| 889 |
+
@check_model_inputs
|
| 890 |
+
@auto_docstring
|
| 891 |
+
def forward(
|
| 892 |
+
self,
|
| 893 |
+
pixel_values: torch.FloatTensor,
|
| 894 |
+
pixel_attention_mask: torch.Tensor,
|
| 895 |
+
spatial_shapes: torch.LongTensor,
|
| 896 |
+
output_attentions: Optional[bool] = None,
|
| 897 |
+
output_hidden_states: Optional[bool] = None,
|
| 898 |
+
) -> BaseModelOutputWithPooling:
|
| 899 |
+
r"""
|
| 900 |
+
pixel_attention_mask (`torch.Tensor` of shape `(batch_size, image_size, image_size)`, *optional*):
|
| 901 |
+
Mask to avoid performing attention on padding pixel indices.
|
| 902 |
+
spatial_shapes (`torch.LongTensor` of shape `(batch_size, 2)`):
|
| 903 |
+
Tensor containing the spatial dimensions (height, width) of the input images.
|
| 904 |
+
|
| 905 |
+
Examples:
|
| 906 |
+
|
| 907 |
+
```python
|
| 908 |
+
>>> from PIL import Image
|
| 909 |
+
>>> import requests
|
| 910 |
+
>>> from transformers import AutoProcessor, Fgclip2VisionModel
|
| 911 |
+
|
| 912 |
+
>>> model = Fgclip2VisionModel.from_pretrained("qihoo360/fg-clip2-base")
|
| 913 |
+
>>> processor = AutoProcessor.from_pretrained("qihoo360/fg-clip2-base")
|
| 914 |
+
|
| 915 |
+
>>> url = "http://images.cocodataset.org/val2017/000000039769.jpg"
|
| 916 |
+
>>> image = Image.open(requests.get(url, stream=True).raw)
|
| 917 |
+
|
| 918 |
+
>>> inputs = processor(images=image, return_tensors="pt")
|
| 919 |
+
|
| 920 |
+
>>> outputs = model(**inputs)
|
| 921 |
+
>>> last_hidden_state = outputs.last_hidden_state
|
| 922 |
+
>>> pooled_output = outputs.pooler_output # pooled features
|
| 923 |
+
```"""
|
| 924 |
+
return self.vision_model(
|
| 925 |
+
pixel_values=pixel_values,
|
| 926 |
+
attention_mask=pixel_attention_mask,
|
| 927 |
+
spatial_shapes=spatial_shapes,
|
| 928 |
+
output_attentions=output_attentions,
|
| 929 |
+
output_hidden_states=output_hidden_states,
|
| 930 |
+
)
|
| 931 |
+
|
| 932 |
+
|
| 933 |
+
@auto_docstring
|
| 934 |
+
class Fgclip2Model(Fgclip2PreTrainedModel):
|
| 935 |
+
config: Fgclip2Config
|
| 936 |
+
|
| 937 |
+
def __init__(self, config: Fgclip2Config):
|
| 938 |
+
super().__init__(config)
|
| 939 |
+
|
| 940 |
+
if not isinstance(config.text_config, Fgclip2TextConfig):
|
| 941 |
+
raise TypeError(
|
| 942 |
+
"config.text_config is expected to be of type Fgclip2TextConfig but is of type"
|
| 943 |
+
f" {type(config.text_config)}."
|
| 944 |
+
)
|
| 945 |
+
|
| 946 |
+
if not isinstance(config.vision_config, Fgclip2VisionConfig):
|
| 947 |
+
raise TypeError(
|
| 948 |
+
"config.vision_config is expected to be of type Fgclip2VisionConfig but is of type"
|
| 949 |
+
f" {type(config.vision_config)}."
|
| 950 |
+
)
|
| 951 |
+
|
| 952 |
+
text_config = config.text_config
|
| 953 |
+
vision_config = config.vision_config
|
| 954 |
+
|
| 955 |
+
# First, initialize the text and vision models with proper attention implementation
|
| 956 |
+
text_model = Fgclip2TextModel._from_config(text_config)
|
| 957 |
+
vision_model = Fgclip2VisionModel._from_config(vision_config)
|
| 958 |
+
|
| 959 |
+
# Second, get the text and vision submodules (for backward compatibility)
|
| 960 |
+
self.text_model = text_model.text_model
|
| 961 |
+
self.vision_model = vision_model.vision_model
|
| 962 |
+
|
| 963 |
+
self.logit_scale = nn.Parameter(torch.randn(1))
|
| 964 |
+
self.logit_bias = nn.Parameter(torch.randn(1))
|
| 965 |
+
self.dense_feature_head = Fgclip2MultiheadAttentionPoolingHead(vision_config)
|
| 966 |
+
self.embed_dim = text_config.hidden_size
|
| 967 |
+
self.longtext_head = nn.Linear(self.embed_dim, self.embed_dim)
|
| 968 |
+
self.boxtext_head = nn.Linear(self.embed_dim, self.embed_dim)
|
| 969 |
+
|
| 970 |
+
# Initialize weights and apply final processing
|
| 971 |
+
self.post_init()
|
| 972 |
+
|
| 973 |
+
@filter_out_non_signature_kwargs()
|
| 974 |
+
@auto_docstring
|
| 975 |
+
def get_text_features(
|
| 976 |
+
self,
|
| 977 |
+
input_ids: torch.Tensor,
|
| 978 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 979 |
+
position_ids: Optional[torch.Tensor] = None,
|
| 980 |
+
walk_type: str = "short",
|
| 981 |
+
) -> torch.FloatTensor:
|
| 982 |
+
r"""
|
| 983 |
+
Extracts feature representations from the input text.
|
| 984 |
+
|
| 985 |
+
Args:
|
| 986 |
+
input_ids (`torch.Tensor` of shape `(batch_size, sequence_length)`):
|
| 987 |
+
The token IDs of the input sequence, as generated by the tokenizer.
|
| 988 |
+
attention_mask (`torch.Tensor`, optional, of shape `(batch_size, sequence_length)`):
|
| 989 |
+
A mask indicating which tokens are valid (1) and which are padding (0).
|
| 990 |
+
If not provided, all tokens are assumed to be valid.
|
| 991 |
+
position_ids (`torch.Tensor`, optional, of shape `(batch_size, sequence_length)`):
|
| 992 |
+
Position indices for each token in the sequence. If not provided,
|
| 993 |
+
positions are automatically constructed based on `input_ids`.
|
| 994 |
+
walk_type (`str`, optional, defaults to `"short"`):
|
| 995 |
+
The traversal strategy used during feature extraction. Must be one of
|
| 996 |
+
`"short"`, `"box"`, or `"long"`. This controls how contextual information
|
| 997 |
+
is aggregated across the input:
|
| 998 |
+
- `"short"`: Optimized for short-text understanding, focusing on tight semantic coherence
|
| 999 |
+
and direct word interactions. Suitable when the input is a phrase or brief sentence.
|
| 1000 |
+
- `"box"`: Designed for local-region description processing, such as grounding in vision-language
|
| 1001 |
+
models or processing localized textual descriptions (e.g., object regions or segments).
|
| 1002 |
+
Emphasizes dense features within bounded semantic units.
|
| 1003 |
+
- `"long"`: Tailored for long-form text processing, enabling modeling of extended dependencies
|
| 1004 |
+
and discourse structure. Uses strategies like chunking or hierarchical attention to handle
|
| 1005 |
+
longer sequences effectively.
|
| 1006 |
+
|
| 1007 |
+
Returns:
|
| 1008 |
+
`torch.FloatTensor` of shape `(batch_size, hidden_size)` or `(batch_size, sequence_length, hidden_size)`:
|
| 1009 |
+
The extracted feature tensor representing the input text. The output shape depends on
|
| 1010 |
+
whether a pooled representation or per-token embeddings are returned.
|
| 1011 |
+
|
| 1012 |
+
Examples:
|
| 1013 |
+
|
| 1014 |
+
```python
|
| 1015 |
+
>>> from transformers import AutoTokenizer, AutoModel
|
| 1016 |
+
>>> import torch
|
| 1017 |
+
|
| 1018 |
+
>>> model = AutoModel.from_pretrained("qihoo360/fg-clip2-base")
|
| 1019 |
+
>>> tokenizer = AutoTokenizer.from_pretrained("qihoo360/fg-clip2-base")
|
| 1020 |
+
|
| 1021 |
+
>>> # important: make sure to set padding="max_length" as that's how the model was trained
|
| 1022 |
+
>>> inputs = tokenizer(["a photo of a cat", "a photo of a dog"], padding="max_length", return_tensors="pt")
|
| 1023 |
+
>>> with torch.no_grad():
|
| 1024 |
+
... text_features = model.get_text_features(**inputs, walk_type="short")
|
| 1025 |
+
```"""
|
| 1026 |
+
|
| 1027 |
+
walk_type = walk_type.lower()
|
| 1028 |
+
|
| 1029 |
+
if walk_type not in ["short", "box", "long"]:
|
| 1030 |
+
raise ValueError(f"Invalid `walk_type`: {walk_type}. Must be one of 'short', 'box', 'long'.")
|
| 1031 |
+
|
| 1032 |
+
walk_short = walk_type == "short"
|
| 1033 |
+
walk_box = walk_type == "box"
|
| 1034 |
+
walk_long = walk_type == "long"
|
| 1035 |
+
|
| 1036 |
+
text_outputs: BaseModelOutputWithPooling = self.text_model(
|
| 1037 |
+
input_ids=input_ids,
|
| 1038 |
+
attention_mask=attention_mask,
|
| 1039 |
+
position_ids=position_ids,
|
| 1040 |
+
walk_type=walk_type,
|
| 1041 |
+
)
|
| 1042 |
+
|
| 1043 |
+
if walk_short:
|
| 1044 |
+
pooled_output = text_outputs.pooler_output
|
| 1045 |
+
|
| 1046 |
+
if walk_box:
|
| 1047 |
+
pooled_output = self.boxtext_head(text_outputs.pooler_output)
|
| 1048 |
+
|
| 1049 |
+
if walk_long:
|
| 1050 |
+
pooled_output = self.longtext_head(text_outputs.pooler_output)
|
| 1051 |
+
|
| 1052 |
+
return pooled_output
|
| 1053 |
+
|
| 1054 |
+
@filter_out_non_signature_kwargs()
|
| 1055 |
+
@auto_docstring
|
| 1056 |
+
def get_image_features(
|
| 1057 |
+
self,
|
| 1058 |
+
pixel_values: Optional[torch.FloatTensor] = None,
|
| 1059 |
+
pixel_attention_mask: Optional[torch.Tensor] = None,
|
| 1060 |
+
spatial_shapes: Optional[torch.LongTensor] = None,
|
| 1061 |
+
) -> torch.FloatTensor:
|
| 1062 |
+
r"""
|
| 1063 |
+
pixel_attention_mask (`torch.Tensor` of shape `(batch_size, image_size, image_size)`, *optional*):
|
| 1064 |
+
Mask to avoid performing attention on padding pixel indices.
|
| 1065 |
+
spatial_shapes (`torch.LongTensor` of shape `(batch_size, 2)`):
|
| 1066 |
+
Tensor containing the spatial dimensions (height, width) of the input images.
|
| 1067 |
+
|
| 1068 |
+
Returns:
|
| 1069 |
+
image_features (`torch.FloatTensor` of shape `(batch_size, output_dim`): The image embeddings obtained by
|
| 1070 |
+
applying the projection layer to the pooled output of [`Fgclip2VisionModel`].
|
| 1071 |
+
|
| 1072 |
+
Examples:
|
| 1073 |
+
|
| 1074 |
+
```python
|
| 1075 |
+
>>> import torch
|
| 1076 |
+
>>> from transformers import AutoProcessor, AutoModel
|
| 1077 |
+
>>> from transformers.image_utils import load_image
|
| 1078 |
+
|
| 1079 |
+
>>> url = "http://images.cocodataset.org/val2017/000000039769.jpg"
|
| 1080 |
+
>>> image = load_image(url)
|
| 1081 |
+
|
| 1082 |
+
>>> model = AutoModel.from_pretrained("qihoo360/fg-clip2-base")
|
| 1083 |
+
>>> processor = AutoProcessor.from_pretrained("qihoo360/fg-clip2-base")
|
| 1084 |
+
|
| 1085 |
+
>>> inputs = processor(images=image, return_tensors="pt")
|
| 1086 |
+
|
| 1087 |
+
>>> with torch.no_grad():
|
| 1088 |
+
... image_features = model.get_image_features(**inputs)
|
| 1089 |
+
```
|
| 1090 |
+
"""
|
| 1091 |
+
vision_outputs: BaseModelOutputWithPooling = self.vision_model(
|
| 1092 |
+
pixel_values=pixel_values,
|
| 1093 |
+
attention_mask=pixel_attention_mask,
|
| 1094 |
+
spatial_shapes=spatial_shapes,
|
| 1095 |
+
)
|
| 1096 |
+
pooled_output = vision_outputs.pooler_output
|
| 1097 |
+
|
| 1098 |
+
return pooled_output
|
| 1099 |
+
|
| 1100 |
+
# NOTE: Fgclip2Model uses Pretrained backbones, so we don't need to add `check_model_inputs` here
|
| 1101 |
+
@can_return_tuple
|
| 1102 |
+
@auto_docstring
|
| 1103 |
+
def forward(
|
| 1104 |
+
self,
|
| 1105 |
+
input_ids: Optional[torch.LongTensor] = None,
|
| 1106 |
+
pixel_values: Optional[torch.FloatTensor] = None,
|
| 1107 |
+
pixel_attention_mask: Optional[torch.Tensor] = None,
|
| 1108 |
+
spatial_shapes: Optional[torch.LongTensor] = None,
|
| 1109 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 1110 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 1111 |
+
return_loss: Optional[bool] = None,
|
| 1112 |
+
output_attentions: Optional[bool] = None,
|
| 1113 |
+
output_hidden_states: Optional[bool] = None,
|
| 1114 |
+
walk_type: str = "short",
|
| 1115 |
+
) -> Fgclip2Output:
|
| 1116 |
+
r"""
|
| 1117 |
+
pixel_attention_mask (`torch.Tensor` of shape `(batch_size, image_size, image_size)`, *optional*):
|
| 1118 |
+
Mask to avoid performing attention on padding pixel indices.
|
| 1119 |
+
spatial_shapes (`torch.LongTensor` of shape `(batch_size, 2)`):
|
| 1120 |
+
Tensor containing the spatial dimensions (height, width) of the input images.
|
| 1121 |
+
return_loss (`bool`, *optional*):
|
| 1122 |
+
Whether or not to return the contrastive loss.
|
| 1123 |
+
walk_type (`str`, optional, defaults to `"short"`):
|
| 1124 |
+
The traversal strategy used during feature extraction. Must be one of
|
| 1125 |
+
`"short"`, `"box"`, or `"long"`. This controls how contextual information
|
| 1126 |
+
is aggregated across the input:
|
| 1127 |
+
- `"short"`: Optimized for short-text understanding, focusing on tight semantic coherence
|
| 1128 |
+
and direct word interactions. Suitable when the input is a phrase or brief sentence.
|
| 1129 |
+
- `"box"`: Designed for local-region description processing, such as grounding in vision-language
|
| 1130 |
+
models or processing localized textual descriptions (e.g., object regions or segments).
|
| 1131 |
+
Emphasizes dense features within bounded semantic units.
|
| 1132 |
+
- `"long"`: Tailored for long-form text processing, enabling modeling of extended dependencies
|
| 1133 |
+
and discourse structure. Uses strategies like chunking or hierarchical attention to handle
|
| 1134 |
+
longer sequences effectively.
|
| 1135 |
+
|
| 1136 |
+
|
| 1137 |
+
Examples:
|
| 1138 |
+
|
| 1139 |
+
```python
|
| 1140 |
+
>>> from PIL import Image
|
| 1141 |
+
>>> import requests
|
| 1142 |
+
>>> from transformers import AutoProcessor, AutoModel
|
| 1143 |
+
>>> import torch
|
| 1144 |
+
|
| 1145 |
+
>>> model = AutoModel.from_pretrained("qihoo360/fg-clip2-base")
|
| 1146 |
+
>>> processor = AutoProcessor.from_pretrained("qihoo360/fg-clip2-base")
|
| 1147 |
+
|
| 1148 |
+
>>> url = "http://images.cocodataset.org/val2017/000000039769.jpg"
|
| 1149 |
+
>>> image = Image.open(requests.get(url, stream=True).raw)
|
| 1150 |
+
|
| 1151 |
+
>>> texts = ["a photo of 2 cats", "a photo of 2 dogs"]
|
| 1152 |
+
>>> # important: we pass `padding=max_length` since the model was trained with this
|
| 1153 |
+
>>> inputs = processor(text=texts, images=image, padding="max_length", return_tensors="pt")
|
| 1154 |
+
|
| 1155 |
+
>>> with torch.no_grad():
|
| 1156 |
+
... outputs = model(**inputs)
|
| 1157 |
+
|
| 1158 |
+
>>> logits_per_image = outputs.logits_per_image
|
| 1159 |
+
>>> probs = torch.sigmoid(logits_per_image) # these are the probabilities
|
| 1160 |
+
>>> print(f"{probs[0][0]:.1%} that image 0 is '{texts[0]}'")
|
| 1161 |
+
31.9% that image 0 is 'a photo of 2 cats'
|
| 1162 |
+
```
|
| 1163 |
+
"""
|
| 1164 |
+
walk_type = walk_type.lower()
|
| 1165 |
+
|
| 1166 |
+
if walk_type not in ["short", "box", "long"]:
|
| 1167 |
+
raise ValueError(f"Invalid `walk_type`: {walk_type}. Must be one of 'short', 'box', 'long'.")
|
| 1168 |
+
|
| 1169 |
+
walk_short = walk_type == "short"
|
| 1170 |
+
walk_box = walk_type == "box"
|
| 1171 |
+
walk_long = walk_type == "long"
|
| 1172 |
+
|
| 1173 |
+
# Use Fgclip2 model's config for some fields (if specified) instead of those of vision & text components.
|
| 1174 |
+
output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
|
| 1175 |
+
output_hidden_states = (
|
| 1176 |
+
output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
|
| 1177 |
+
)
|
| 1178 |
+
|
| 1179 |
+
vision_outputs: BaseModelOutputWithPooling = self.vision_model(
|
| 1180 |
+
pixel_values=pixel_values,
|
| 1181 |
+
attention_mask=pixel_attention_mask,
|
| 1182 |
+
spatial_shapes=spatial_shapes,
|
| 1183 |
+
output_attentions=output_attentions,
|
| 1184 |
+
output_hidden_states=output_hidden_states,
|
| 1185 |
+
)
|
| 1186 |
+
|
| 1187 |
+
text_outputs: BaseModelOutputWithPooling = self.text_model(
|
| 1188 |
+
input_ids=input_ids,
|
| 1189 |
+
attention_mask=attention_mask,
|
| 1190 |
+
position_ids=position_ids,
|
| 1191 |
+
output_attentions=output_attentions,
|
| 1192 |
+
output_hidden_states=output_hidden_states,
|
| 1193 |
+
walk_type=walk_type,
|
| 1194 |
+
)
|
| 1195 |
+
|
| 1196 |
+
image_embeds = vision_outputs.pooler_output
|
| 1197 |
+
|
| 1198 |
+
if walk_short:
|
| 1199 |
+
text_embeds = text_outputs.pooler_output
|
| 1200 |
+
|
| 1201 |
+
if walk_box:
|
| 1202 |
+
text_embeds = self.boxtext_head(text_outputs.pooler_output)
|
| 1203 |
+
|
| 1204 |
+
if walk_long:
|
| 1205 |
+
text_embeds = self.longtext_head(text_outputs.pooler_output)
|
| 1206 |
+
|
| 1207 |
+
# normalized features
|
| 1208 |
+
image_embeds = image_embeds / image_embeds.norm(p=2, dim=-1, keepdim=True)
|
| 1209 |
+
text_embeds = text_embeds / text_embeds.norm(p=2, dim=-1, keepdim=True)
|
| 1210 |
+
|
| 1211 |
+
# cosine similarity as logits
|
| 1212 |
+
logits_per_text = torch.matmul(text_embeds, image_embeds.t().to(text_embeds.device))
|
| 1213 |
+
|
| 1214 |
+
logit_scale, logit_bias = self.logit_scale.to(text_embeds.device), self.logit_bias.to(text_embeds.device)
|
| 1215 |
+
logits_per_text = logits_per_text * logit_scale.exp() + logit_bias
|
| 1216 |
+
|
| 1217 |
+
logits_per_image = logits_per_text.t()
|
| 1218 |
+
|
| 1219 |
+
loss = None
|
| 1220 |
+
if return_loss:
|
| 1221 |
+
# Adapted from https://github.com/google-research/big_vision/blob/01edb81a4716f93a48be43b3a4af14e29cdb3a7f/big_vision/trainers/proj/image_text/fgclip2.py#L287
|
| 1222 |
+
eye = torch.eye(logits_per_text.size(0), device=logits_per_text.device)
|
| 1223 |
+
m1_diag1 = -torch.ones_like(logits_per_text) + 2 * eye
|
| 1224 |
+
loglik = torch.nn.functional.logsigmoid(m1_diag1 * logits_per_text)
|
| 1225 |
+
nll = -torch.sum(loglik, dim=-1)
|
| 1226 |
+
loss = nll.mean()
|
| 1227 |
+
|
| 1228 |
+
return Fgclip2Output(
|
| 1229 |
+
loss=loss,
|
| 1230 |
+
logits_per_image=logits_per_image,
|
| 1231 |
+
logits_per_text=logits_per_text,
|
| 1232 |
+
text_embeds=text_embeds,
|
| 1233 |
+
image_embeds=image_embeds,
|
| 1234 |
+
text_model_output=text_outputs,
|
| 1235 |
+
vision_model_output=vision_outputs,
|
| 1236 |
+
)
|
| 1237 |
+
|
| 1238 |
+
# New function: Acquire dense visual features of images with support for dynamic resolution
|
| 1239 |
+
@filter_out_non_signature_kwargs()
|
| 1240 |
+
@auto_docstring
|
| 1241 |
+
def get_image_dense_feature(
|
| 1242 |
+
self,
|
| 1243 |
+
pixel_values: Optional[torch.FloatTensor] = None,
|
| 1244 |
+
pixel_attention_mask: Optional[torch.Tensor] = None,
|
| 1245 |
+
spatial_shapes: Optional[torch.LongTensor] = None,
|
| 1246 |
+
) -> torch.FloatTensor:
|
| 1247 |
+
r"""
|
| 1248 |
+
Extract dense visual features from input images by forwarding through the vision backbone.
|
| 1249 |
+
|
| 1250 |
+
Args:
|
| 1251 |
+
pixel_values (`torch.FloatTensor`):
|
| 1252 |
+
Pixel values of shape (batch_size, max_num_patches, num_channels * patch_size * patch_size)
|
| 1253 |
+
pixel_attention_mask (`torch.Tensor` of shape `(batch_size, image_size, image_size)`, *optional*):
|
| 1254 |
+
Mask to avoid performing attention on padding pixel indices.
|
| 1255 |
+
spatial_shapes (`torch.LongTensor` of shape `(batch_size, 2)`):
|
| 1256 |
+
Tensor containing the spatial dimensions (height, width) of the input images.
|
| 1257 |
+
|
| 1258 |
+
Returns:
|
| 1259 |
+
`torch.FloatTensor` of shape `(batch_size, max_num_patches, hidden_size)`:
|
| 1260 |
+
|
| 1261 |
+
"""
|
| 1262 |
+
|
| 1263 |
+
vision_outputs: BaseModelOutputWithPooling = self.vision_model(
|
| 1264 |
+
pixel_values=pixel_values,
|
| 1265 |
+
attention_mask=pixel_attention_mask,
|
| 1266 |
+
spatial_shapes=spatial_shapes,
|
| 1267 |
+
)
|
| 1268 |
+
|
| 1269 |
+
probe = vision_outputs.last_hidden_state
|
| 1270 |
+
hidden_state = vision_outputs.last_hidden_state
|
| 1271 |
+
attention_mask = pixel_attention_mask
|
| 1272 |
+
|
| 1273 |
+
if attention_mask is not None:
|
| 1274 |
+
target_len, source_len = probe.shape[1], hidden_state.shape[1]
|
| 1275 |
+
attention_mask = _prepare_4d_attention_mask(attention_mask, hidden_state.dtype, target_len)
|
| 1276 |
+
attention_mask = attention_mask.repeat(1, self.dense_feature_head.num_heads, 1, 1)
|
| 1277 |
+
attention_mask = attention_mask.reshape(-1, target_len, source_len)
|
| 1278 |
+
|
| 1279 |
+
hidden_state = self.dense_feature_head.attention(probe, hidden_state, hidden_state, attn_mask=attention_mask)[
|
| 1280 |
+
0
|
| 1281 |
+
]
|
| 1282 |
+
residual = hidden_state
|
| 1283 |
+
hidden_state = self.dense_feature_head.layernorm(hidden_state)
|
| 1284 |
+
hidden_state = residual + self.dense_feature_head.mlp(hidden_state)
|
| 1285 |
+
feature_map = hidden_state
|
| 1286 |
+
|
| 1287 |
+
return feature_map
|
| 1288 |
+
|
| 1289 |
+
# New function: Acquire local features of images, applicable to retrieval, classification, and localization, with support for dynamic resolution
|
| 1290 |
+
@filter_out_non_signature_kwargs()
|
| 1291 |
+
@auto_docstring
|
| 1292 |
+
def get_image_region_features(
|
| 1293 |
+
self,
|
| 1294 |
+
pixel_values: Optional[torch.FloatTensor] = None,
|
| 1295 |
+
pixel_attention_mask: Optional[torch.Tensor] = None,
|
| 1296 |
+
spatial_shapes: Optional[torch.LongTensor] = None,
|
| 1297 |
+
image_sizes: Optional[list[tuple]] = None,
|
| 1298 |
+
region_infos: Optional[list[list[list[float]]]] = None,
|
| 1299 |
+
) -> list[torch.FloatTensor]:
|
| 1300 |
+
r"""
|
| 1301 |
+
Extract region-of-interest (RoI) features from images using RoI Align.
|
| 1302 |
+
This method supports batched processing of variable-sized images and allows feature extraction
|
| 1303 |
+
from user-specified image regions.
|
| 1304 |
+
|
| 1305 |
+
The input can be either a full image with corresponding region coordinates.
|
| 1306 |
+
Features are extracted per region (e.g., bounding boxes), making this function suitable for tasks such as
|
| 1307 |
+
object detection, referring expression grounding, or vision-language alignment.
|
| 1308 |
+
|
| 1309 |
+
Args:
|
| 1310 |
+
pixel_values (`torch.FloatTensor`):
|
| 1311 |
+
Pixel values of shape (batch_size, max_num_patches, num_channels * patch_size * patch_size)
|
| 1312 |
+
pixel_attention_mask (`torch.Tensor` of shape `(batch_size, image_size, image_size)`, *optional*):
|
| 1313 |
+
Mask to avoid performing attention on padding pixel indices.
|
| 1314 |
+
spatial_shapes (`torch.LongTensor` of shape `(batch_size, 2)`):
|
| 1315 |
+
Tensor containing the spatial dimensions (height, width) of the input images.
|
| 1316 |
+
image_sizes (`List[tuple]`, optional, each tuple of form `(int, int)`):
|
| 1317 |
+
Original size (height, width) of each image in the batch before padding or resizing.
|
| 1318 |
+
Required for accurate coordinate projection when region_infos are defined in original image space.
|
| 1319 |
+
region_infos (`List[List[List[float]]]`, optional):
|
| 1320 |
+
Bounding box coordinates for regions of interest in each image. Format:
|
| 1321 |
+
- Outer list: length `batch_size`
|
| 1322 |
+
- Middle list: number of regions per image
|
| 1323 |
+
- Inner list: each contains `[x_min, y_min, x_max, y_max]` in **absolute pixel coordinates**
|
| 1324 |
+
relative to the original image size (as specified in `image_sizes`).
|
| 1325 |
+
These boxes are projected to feature map space using `image_sizes` and `spatial_shapes`,
|
| 1326 |
+
then used to pool features via RoI Align or equivalent.
|
| 1327 |
+
|
| 1328 |
+
Returns:
|
| 1329 |
+
`List[torch.FloatTensor]`:
|
| 1330 |
+
A list of length `batch_size`, where each element is a tensor of shape
|
| 1331 |
+
`(num_boxes, hidden_dim)` containing the extracted visual features for each region
|
| 1332 |
+
in the corresponding image.
|
| 1333 |
+
Example::
|
| 1334 |
+
>>> # For a batch of 2 images
|
| 1335 |
+
>>> region_features = model.get_image_region_features(
|
| 1336 |
+
>>> pixel_values=pixel_values,
|
| 1337 |
+
>>> image_sizes=[(640, 480), (480, 640)],
|
| 1338 |
+
>>> region_infos=[
|
| 1339 |
+
>>> [[100, 100, 200, 200], [300, 300, 400, 400]], # 2 boxes in first image
|
| 1340 |
+
>>> [[50, 50, 150, 150]] # 1 box in second image
|
| 1341 |
+
>>> ]
|
| 1342 |
+
>>> )
|
| 1343 |
+
>>> print(region_features[0].shape) # torch.Size([2, hidden_dim])
|
| 1344 |
+
>>> print(region_features[1].shape) # torch.Size([1, hidden_dim])
|
| 1345 |
+
|
| 1346 |
+
"""
|
| 1347 |
+
if region_infos is None or len(region_infos) == 0:
|
| 1348 |
+
return []
|
| 1349 |
+
|
| 1350 |
+
# Get dense feature maps: (B, N, D)
|
| 1351 |
+
dense_feature_map = self.get_image_dense_feature(
|
| 1352 |
+
pixel_values=pixel_values,
|
| 1353 |
+
pixel_attention_mask=pixel_attention_mask,
|
| 1354 |
+
spatial_shapes=spatial_shapes,
|
| 1355 |
+
)
|
| 1356 |
+
bs, _, hidden_dim = dense_feature_map.shape
|
| 1357 |
+
|
| 1358 |
+
all_region_features = []
|
| 1359 |
+
|
| 1360 |
+
for i in range(bs):
|
| 1361 |
+
h, w = spatial_shapes[i].tolist()
|
| 1362 |
+
img_h, img_w = image_sizes[i]
|
| 1363 |
+
bboxes = region_infos[i]
|
| 1364 |
+
|
| 1365 |
+
if not bboxes:
|
| 1366 |
+
all_region_features.append(torch.empty(0, hidden_dim, device=dense_feature_map.device))
|
| 1367 |
+
continue
|
| 1368 |
+
|
| 1369 |
+
# Reshape to (1, C, H', W')
|
| 1370 |
+
num_valid = h * w
|
| 1371 |
+
feat_seq = dense_feature_map[i, :num_valid] # (num_valid, D)
|
| 1372 |
+
feat_map = feat_seq.view(h, w, hidden_dim).permute(2, 0, 1).unsqueeze(0) # (1, D, H', W')
|
| 1373 |
+
|
| 1374 |
+
# Normalize bboxes to feature map coordinates
|
| 1375 |
+
rois = []
|
| 1376 |
+
for x1, y1, x2, y2 in bboxes:
|
| 1377 |
+
nx1 = (x1 / img_w) * w
|
| 1378 |
+
ny1 = (y1 / img_h) * h
|
| 1379 |
+
nx2 = (x2 / img_w) * w
|
| 1380 |
+
ny2 = (y2 / img_h) * h
|
| 1381 |
+
rois.append([0, nx1, ny1, nx2, ny2]) #
|
| 1382 |
+
rois_tensor = torch.tensor(rois, dtype=torch.float32, device=feat_map.device) # (N, 5)
|
| 1383 |
+
|
| 1384 |
+
# RoI Align on single image
|
| 1385 |
+
pooled = roi_align(
|
| 1386 |
+
input=feat_map,
|
| 1387 |
+
boxes=rois_tensor,
|
| 1388 |
+
output_size=(1, 1),
|
| 1389 |
+
spatial_scale=1.0,
|
| 1390 |
+
sampling_ratio=-1,
|
| 1391 |
+
aligned=True,
|
| 1392 |
+
) # (N, D, 1, 1)
|
| 1393 |
+
region_feats = pooled.squeeze(-1).squeeze(-1) # (N, D)
|
| 1394 |
+
|
| 1395 |
+
all_region_features.append(region_feats)
|
| 1396 |
+
|
| 1397 |
+
return all_region_features
|
| 1398 |
+
|
| 1399 |
+
|
| 1400 |
+
__all__ = ["Fgclip2Model", "Fgclip2PreTrainedModel", "Fgclip2TextModel", "Fgclip2VisionModel"]
|
preprocessor_config.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"do_convert_rgb": null,
|
| 3 |
+
"do_normalize": true,
|
| 4 |
+
"do_rescale": true,
|
| 5 |
+
"do_resize": true,
|
| 6 |
+
"image_mean": [
|
| 7 |
+
0.5,
|
| 8 |
+
0.5,
|
| 9 |
+
0.5
|
| 10 |
+
],
|
| 11 |
+
"image_processor_type": "Siglip2ImageProcessorFast",
|
| 12 |
+
"image_std": [
|
| 13 |
+
0.5,
|
| 14 |
+
0.5,
|
| 15 |
+
0.5
|
| 16 |
+
],
|
| 17 |
+
"max_num_patches": 256,
|
| 18 |
+
"patch_size": 16,
|
| 19 |
+
"processor_class": "Siglip2Processor",
|
| 20 |
+
"resample": 2,
|
| 21 |
+
"rescale_factor": 0.00392156862745098
|
| 22 |
+
}
|
special_tokens_map.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"additional_special_tokens": [
|
| 3 |
+
"<start_of_turn>",
|
| 4 |
+
"<end_of_turn>"
|
| 5 |
+
],
|
| 6 |
+
"bos_token": {
|
| 7 |
+
"content": "<bos>",
|
| 8 |
+
"lstrip": false,
|
| 9 |
+
"normalized": false,
|
| 10 |
+
"rstrip": false,
|
| 11 |
+
"single_word": false
|
| 12 |
+
},
|
| 13 |
+
"eos_token": {
|
| 14 |
+
"content": "<eos>",
|
| 15 |
+
"lstrip": false,
|
| 16 |
+
"normalized": false,
|
| 17 |
+
"rstrip": false,
|
| 18 |
+
"single_word": false
|
| 19 |
+
},
|
| 20 |
+
"pad_token": {
|
| 21 |
+
"content": "<pad>",
|
| 22 |
+
"lstrip": false,
|
| 23 |
+
"normalized": false,
|
| 24 |
+
"rstrip": false,
|
| 25 |
+
"single_word": false
|
| 26 |
+
},
|
| 27 |
+
"unk_token": {
|
| 28 |
+
"content": "<unk>",
|
| 29 |
+
"lstrip": false,
|
| 30 |
+
"normalized": false,
|
| 31 |
+
"rstrip": false,
|
| 32 |
+
"single_word": false
|
| 33 |
+
}
|
| 34 |
+
}
|
tokenizer.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:58a1696e79c9d97937389ed116f552a15c84811d7b8023918b86f4bc5775b1b0
|
| 3 |
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_bos_token": false,
|
| 3 |
+
"add_eos_token": true,
|
| 4 |
+
"added_tokens_decoder": {
|
| 5 |
+
"0": {
|
| 6 |
+
"content": "<pad>",
|
| 7 |
+
"lstrip": false,
|
| 8 |
+
"normalized": false,
|
| 9 |
+
"rstrip": false,
|
| 10 |
+
"single_word": false,
|
| 11 |
+
"special": true
|
| 12 |
+
},
|
| 13 |
+
"1": {
|
| 14 |
+
"content": "<eos>",
|
| 15 |
+
"lstrip": false,
|
| 16 |
+
"normalized": false,
|
| 17 |
+
"rstrip": false,
|
| 18 |
+
"single_word": false,
|
| 19 |
+
"special": true
|
| 20 |
+
},
|
| 21 |
+
"2": {
|
| 22 |
+
"content": "<bos>",
|
| 23 |
+
"lstrip": false,
|
| 24 |
+
"normalized": false,
|
| 25 |
+
"rstrip": false,
|
| 26 |
+
"single_word": false,
|
| 27 |
+
"special": true
|
| 28 |
+
},
|
| 29 |
+
"3": {
|
| 30 |
+
"content": "<unk>",
|
| 31 |
+
"lstrip": false,
|
| 32 |
+
"normalized": false,
|
| 33 |
+
"rstrip": false,
|
| 34 |
+
"single_word": false,
|
| 35 |
+
"special": true
|
| 36 |
+
},
|
| 37 |
+
"4": {
|
| 38 |
+
"content": "<mask>",
|
| 39 |
+
"lstrip": false,
|
| 40 |
+
"normalized": false,
|
| 41 |
+
"rstrip": false,
|
| 42 |
+
"single_word": false,
|
| 43 |
+
"special": false
|
| 44 |
+
},
|
| 45 |
+
"5": {
|
| 46 |
+
"content": "<2mass>",
|
| 47 |
+
"lstrip": false,
|
| 48 |
+
"normalized": false,
|
| 49 |
+
"rstrip": false,
|
| 50 |
+
"single_word": false,
|
| 51 |
+
"special": false
|
| 52 |
+
},
|
| 53 |
+
"6": {
|
| 54 |
+
"content": "[@BOS@]",
|
| 55 |
+
"lstrip": false,
|
| 56 |
+
"normalized": false,
|
| 57 |
+
"rstrip": false,
|
| 58 |
+
"single_word": false,
|
| 59 |
+
"special": false
|
| 60 |
+
},
|
| 61 |
+
"7": {
|
| 62 |
+
"content": "<unused0>",
|
| 63 |
+
"lstrip": false,
|
| 64 |
+
"normalized": false,
|
| 65 |
+
"rstrip": false,
|
| 66 |
+
"single_word": false,
|
| 67 |
+
"special": false
|
| 68 |
+
},
|
| 69 |
+
"8": {
|
| 70 |
+
"content": "<unused1>",
|
| 71 |
+
"lstrip": false,
|
| 72 |
+
"normalized": false,
|
| 73 |
+
"rstrip": false,
|
| 74 |
+
"single_word": false,
|
| 75 |
+
"special": false
|
| 76 |
+
},
|
| 77 |
+
"9": {
|
| 78 |
+
"content": "<unused2>",
|
| 79 |
+
"lstrip": false,
|
| 80 |
+
"normalized": false,
|
| 81 |
+
"rstrip": false,
|
| 82 |
+
"single_word": false,
|
| 83 |
+
"special": false
|
| 84 |
+
},
|
| 85 |
+
"10": {
|
| 86 |
+
"content": "<unused3>",
|
| 87 |
+
"lstrip": false,
|
| 88 |
+
"normalized": false,
|
| 89 |
+
"rstrip": false,
|
| 90 |
+
"single_word": false,
|
| 91 |
+
"special": false
|
| 92 |
+
},
|
| 93 |
+
"11": {
|
| 94 |
+
"content": "<unused4>",
|
| 95 |
+
"lstrip": false,
|
| 96 |
+
"normalized": false,
|
| 97 |
+
"rstrip": false,
|
| 98 |
+
"single_word": false,
|
| 99 |
+
"special": false
|
| 100 |
+
},
|
| 101 |
+
"12": {
|
| 102 |
+
"content": "<unused5>",
|
| 103 |
+
"lstrip": false,
|
| 104 |
+
"normalized": false,
|
| 105 |
+
"rstrip": false,
|
| 106 |
+
"single_word": false,
|
| 107 |
+
"special": false
|
| 108 |
+
},
|
| 109 |
+
"13": {
|
| 110 |
+
"content": "<unused6>",
|
| 111 |
+
"lstrip": false,
|
| 112 |
+
"normalized": false,
|
| 113 |
+
"rstrip": false,
|
| 114 |
+
"single_word": false,
|
| 115 |
+
"special": false
|
| 116 |
+
},
|
| 117 |
+
"14": {
|
| 118 |
+
"content": "<unused7>",
|
| 119 |
+
"lstrip": false,
|
| 120 |
+
"normalized": false,
|
| 121 |
+
"rstrip": false,
|
| 122 |
+
"single_word": false,
|
| 123 |
+
"special": false
|
| 124 |
+
},
|
| 125 |
+
"15": {
|
| 126 |
+
"content": "<unused8>",
|
| 127 |
+
"lstrip": false,
|
| 128 |
+
"normalized": false,
|
| 129 |
+
"rstrip": false,
|
| 130 |
+
"single_word": false,
|
| 131 |
+
"special": false
|
| 132 |
+
},
|
| 133 |
+
"16": {
|
| 134 |
+
"content": "<unused9>",
|
| 135 |
+
"lstrip": false,
|
| 136 |
+
"normalized": false,
|
| 137 |
+
"rstrip": false,
|
| 138 |
+
"single_word": false,
|
| 139 |
+
"special": false
|
| 140 |
+
},
|
| 141 |
+
"17": {
|
| 142 |
+
"content": "<unused10>",
|
| 143 |
+
"lstrip": false,
|
| 144 |
+
"normalized": false,
|
| 145 |
+
"rstrip": false,
|
| 146 |
+
"single_word": false,
|
| 147 |
+
"special": false
|
| 148 |
+
},
|
| 149 |
+
"18": {
|
| 150 |
+
"content": "<unused11>",
|
| 151 |
+
"lstrip": false,
|
| 152 |
+
"normalized": false,
|
| 153 |
+
"rstrip": false,
|
| 154 |
+
"single_word": false,
|
| 155 |
+
"special": false
|
| 156 |
+
},
|
| 157 |
+
"19": {
|
| 158 |
+
"content": "<unused12>",
|
| 159 |
+
"lstrip": false,
|
| 160 |
+
"normalized": false,
|
| 161 |
+
"rstrip": false,
|
| 162 |
+
"single_word": false,
|
| 163 |
+
"special": false
|
| 164 |
+
},
|
| 165 |
+
"20": {
|
| 166 |
+
"content": "<unused13>",
|
| 167 |
+
"lstrip": false,
|
| 168 |
+
"normalized": false,
|
| 169 |
+
"rstrip": false,
|
| 170 |
+
"single_word": false,
|
| 171 |
+
"special": false
|
| 172 |
+
},
|
| 173 |
+
"21": {
|
| 174 |
+
"content": "<unused14>",
|
| 175 |
+
"lstrip": false,
|
| 176 |
+
"normalized": false,
|
| 177 |
+
"rstrip": false,
|
| 178 |
+
"single_word": false,
|
| 179 |
+
"special": false
|
| 180 |
+
},
|
| 181 |
+
"22": {
|
| 182 |
+
"content": "<unused15>",
|
| 183 |
+
"lstrip": false,
|
| 184 |
+
"normalized": false,
|
| 185 |
+
"rstrip": false,
|
| 186 |
+
"single_word": false,
|
| 187 |
+
"special": false
|
| 188 |
+
},
|
| 189 |
+
"23": {
|
| 190 |
+
"content": "<unused16>",
|
| 191 |
+
"lstrip": false,
|
| 192 |
+
"normalized": false,
|
| 193 |
+
"rstrip": false,
|
| 194 |
+
"single_word": false,
|
| 195 |
+
"special": false
|
| 196 |
+
},
|
| 197 |
+
"24": {
|
| 198 |
+
"content": "<unused17>",
|
| 199 |
+
"lstrip": false,
|
| 200 |
+
"normalized": false,
|
| 201 |
+
"rstrip": false,
|
| 202 |
+
"single_word": false,
|
| 203 |
+
"special": false
|
| 204 |
+
},
|
| 205 |
+
"25": {
|
| 206 |
+
"content": "<unused18>",
|
| 207 |
+
"lstrip": false,
|
| 208 |
+
"normalized": false,
|
| 209 |
+
"rstrip": false,
|
| 210 |
+
"single_word": false,
|
| 211 |
+
"special": false
|
| 212 |
+
},
|
| 213 |
+
"26": {
|
| 214 |
+
"content": "<unused19>",
|
| 215 |
+
"lstrip": false,
|
| 216 |
+
"normalized": false,
|
| 217 |
+
"rstrip": false,
|
| 218 |
+
"single_word": false,
|
| 219 |
+
"special": false
|
| 220 |
+
},
|
| 221 |
+
"27": {
|
| 222 |
+
"content": "<unused20>",
|
| 223 |
+
"lstrip": false,
|
| 224 |
+
"normalized": false,
|
| 225 |
+
"rstrip": false,
|
| 226 |
+
"single_word": false,
|
| 227 |
+
"special": false
|
| 228 |
+
},
|
| 229 |
+
"28": {
|
| 230 |
+
"content": "<unused21>",
|
| 231 |
+
"lstrip": false,
|
| 232 |
+
"normalized": false,
|
| 233 |
+
"rstrip": false,
|
| 234 |
+
"single_word": false,
|
| 235 |
+
"special": false
|
| 236 |
+
},
|
| 237 |
+
"29": {
|
| 238 |
+
"content": "<unused22>",
|
| 239 |
+
"lstrip": false,
|
| 240 |
+
"normalized": false,
|
| 241 |
+
"rstrip": false,
|
| 242 |
+
"single_word": false,
|
| 243 |
+
"special": false
|
| 244 |
+
},
|
| 245 |
+
"30": {
|
| 246 |
+
"content": "<unused23>",
|
| 247 |
+
"lstrip": false,
|
| 248 |
+
"normalized": false,
|
| 249 |
+
"rstrip": false,
|
| 250 |
+
"single_word": false,
|
| 251 |
+
"special": false
|
| 252 |
+
},
|
| 253 |
+
"31": {
|
| 254 |
+
"content": "<unused24>",
|
| 255 |
+
"lstrip": false,
|
| 256 |
+
"normalized": false,
|
| 257 |
+
"rstrip": false,
|
| 258 |
+
"single_word": false,
|
| 259 |
+
"special": false
|
| 260 |
+
},
|
| 261 |
+
"32": {
|
| 262 |
+
"content": "<unused25>",
|
| 263 |
+
"lstrip": false,
|
| 264 |
+
"normalized": false,
|
| 265 |
+
"rstrip": false,
|
| 266 |
+
"single_word": false,
|
| 267 |
+
"special": false
|
| 268 |
+
},
|
| 269 |
+
"33": {
|
| 270 |
+
"content": "<unused26>",
|
| 271 |
+
"lstrip": false,
|
| 272 |
+
"normalized": false,
|
| 273 |
+
"rstrip": false,
|
| 274 |
+
"single_word": false,
|
| 275 |
+
"special": false
|
| 276 |
+
},
|
| 277 |
+
"34": {
|
| 278 |
+
"content": "<unused27>",
|
| 279 |
+
"lstrip": false,
|
| 280 |
+
"normalized": false,
|
| 281 |
+
"rstrip": false,
|
| 282 |
+
"single_word": false,
|
| 283 |
+
"special": false
|
| 284 |
+
},
|
| 285 |
+
"35": {
|
| 286 |
+
"content": "<unused28>",
|
| 287 |
+
"lstrip": false,
|
| 288 |
+
"normalized": false,
|
| 289 |
+
"rstrip": false,
|
| 290 |
+
"single_word": false,
|
| 291 |
+
"special": false
|
| 292 |
+
},
|
| 293 |
+
"36": {
|
| 294 |
+
"content": "<unused29>",
|
| 295 |
+
"lstrip": false,
|
| 296 |
+
"normalized": false,
|
| 297 |
+
"rstrip": false,
|
| 298 |
+
"single_word": false,
|
| 299 |
+
"special": false
|
| 300 |
+
},
|
| 301 |
+
"37": {
|
| 302 |
+
"content": "<unused30>",
|
| 303 |
+
"lstrip": false,
|
| 304 |
+
"normalized": false,
|
| 305 |
+
"rstrip": false,
|
| 306 |
+
"single_word": false,
|
| 307 |
+
"special": false
|
| 308 |
+
},
|
| 309 |
+
"38": {
|
| 310 |
+
"content": "<unused31>",
|
| 311 |
+
"lstrip": false,
|
| 312 |
+
"normalized": false,
|
| 313 |
+
"rstrip": false,
|
| 314 |
+
"single_word": false,
|
| 315 |
+
"special": false
|
| 316 |
+
},
|
| 317 |
+
"39": {
|
| 318 |
+
"content": "<unused32>",
|
| 319 |
+
"lstrip": false,
|
| 320 |
+
"normalized": false,
|
| 321 |
+
"rstrip": false,
|
| 322 |
+
"single_word": false,
|
| 323 |
+
"special": false
|
| 324 |
+
},
|
| 325 |
+
"40": {
|
| 326 |
+
"content": "<unused33>",
|
| 327 |
+
"lstrip": false,
|
| 328 |
+
"normalized": false,
|
| 329 |
+
"rstrip": false,
|
| 330 |
+
"single_word": false,
|
| 331 |
+
"special": false
|
| 332 |
+
},
|
| 333 |
+
"41": {
|
| 334 |
+
"content": "<unused34>",
|
| 335 |
+
"lstrip": false,
|
| 336 |
+
"normalized": false,
|
| 337 |
+
"rstrip": false,
|
| 338 |
+
"single_word": false,
|
| 339 |
+
"special": false
|
| 340 |
+
},
|
| 341 |
+
"42": {
|
| 342 |
+
"content": "<unused35>",
|
| 343 |
+
"lstrip": false,
|
| 344 |
+
"normalized": false,
|
| 345 |
+
"rstrip": false,
|
| 346 |
+
"single_word": false,
|
| 347 |
+
"special": false
|
| 348 |
+
},
|
| 349 |
+
"43": {
|
| 350 |
+
"content": "<unused36>",
|
| 351 |
+
"lstrip": false,
|
| 352 |
+
"normalized": false,
|
| 353 |
+
"rstrip": false,
|
| 354 |
+
"single_word": false,
|
| 355 |
+
"special": false
|
| 356 |
+
},
|
| 357 |
+
"44": {
|
| 358 |
+
"content": "<unused37>",
|
| 359 |
+
"lstrip": false,
|
| 360 |
+
"normalized": false,
|
| 361 |
+
"rstrip": false,
|
| 362 |
+
"single_word": false,
|
| 363 |
+
"special": false
|
| 364 |
+
},
|
| 365 |
+
"45": {
|
| 366 |
+
"content": "<unused38>",
|
| 367 |
+
"lstrip": false,
|
| 368 |
+
"normalized": false,
|
| 369 |
+
"rstrip": false,
|
| 370 |
+
"single_word": false,
|
| 371 |
+
"special": false
|
| 372 |
+
},
|
| 373 |
+
"46": {
|
| 374 |
+
"content": "<unused39>",
|
| 375 |
+
"lstrip": false,
|
| 376 |
+
"normalized": false,
|
| 377 |
+
"rstrip": false,
|
| 378 |
+
"single_word": false,
|
| 379 |
+
"special": false
|
| 380 |
+
},
|
| 381 |
+
"47": {
|
| 382 |
+
"content": "<unused40>",
|
| 383 |
+
"lstrip": false,
|
| 384 |
+
"normalized": false,
|
| 385 |
+
"rstrip": false,
|
| 386 |
+
"single_word": false,
|
| 387 |
+
"special": false
|
| 388 |
+
},
|
| 389 |
+
"48": {
|
| 390 |
+
"content": "<unused41>",
|
| 391 |
+
"lstrip": false,
|
| 392 |
+
"normalized": false,
|
| 393 |
+
"rstrip": false,
|
| 394 |
+
"single_word": false,
|
| 395 |
+
"special": false
|
| 396 |
+
},
|
| 397 |
+
"49": {
|
| 398 |
+
"content": "<unused42>",
|
| 399 |
+
"lstrip": false,
|
| 400 |
+
"normalized": false,
|
| 401 |
+
"rstrip": false,
|
| 402 |
+
"single_word": false,
|
| 403 |
+
"special": false
|
| 404 |
+
},
|
| 405 |
+
"50": {
|
| 406 |
+
"content": "<unused43>",
|
| 407 |
+
"lstrip": false,
|
| 408 |
+
"normalized": false,
|
| 409 |
+
"rstrip": false,
|
| 410 |
+
"single_word": false,
|
| 411 |
+
"special": false
|
| 412 |
+
},
|
| 413 |
+
"51": {
|
| 414 |
+
"content": "<unused44>",
|
| 415 |
+
"lstrip": false,
|
| 416 |
+
"normalized": false,
|
| 417 |
+
"rstrip": false,
|
| 418 |
+
"single_word": false,
|
| 419 |
+
"special": false
|
| 420 |
+
},
|
| 421 |
+
"52": {
|
| 422 |
+
"content": "<unused45>",
|
| 423 |
+
"lstrip": false,
|
| 424 |
+
"normalized": false,
|
| 425 |
+
"rstrip": false,
|
| 426 |
+
"single_word": false,
|
| 427 |
+
"special": false
|
| 428 |
+
},
|
| 429 |
+
"53": {
|
| 430 |
+
"content": "<unused46>",
|
| 431 |
+
"lstrip": false,
|
| 432 |
+
"normalized": false,
|
| 433 |
+
"rstrip": false,
|
| 434 |
+
"single_word": false,
|
| 435 |
+
"special": false
|
| 436 |
+
},
|
| 437 |
+
"54": {
|
| 438 |
+
"content": "<unused47>",
|
| 439 |
+
"lstrip": false,
|
| 440 |
+
"normalized": false,
|
| 441 |
+
"rstrip": false,
|
| 442 |
+
"single_word": false,
|
| 443 |
+
"special": false
|
| 444 |
+
},
|
| 445 |
+
"55": {
|
| 446 |
+
"content": "<unused48>",
|
| 447 |
+
"lstrip": false,
|
| 448 |
+
"normalized": false,
|
| 449 |
+
"rstrip": false,
|
| 450 |
+
"single_word": false,
|
| 451 |
+
"special": false
|
| 452 |
+
},
|
| 453 |
+
"56": {
|
| 454 |
+
"content": "<unused49>",
|
| 455 |
+
"lstrip": false,
|
| 456 |
+
"normalized": false,
|
| 457 |
+
"rstrip": false,
|
| 458 |
+
"single_word": false,
|
| 459 |
+
"special": false
|
| 460 |
+
},
|
| 461 |
+
"57": {
|
| 462 |
+
"content": "<unused50>",
|
| 463 |
+
"lstrip": false,
|
| 464 |
+
"normalized": false,
|
| 465 |
+
"rstrip": false,
|
| 466 |
+
"single_word": false,
|
| 467 |
+
"special": false
|
| 468 |
+
},
|
| 469 |
+
"58": {
|
| 470 |
+
"content": "<unused51>",
|
| 471 |
+
"lstrip": false,
|
| 472 |
+
"normalized": false,
|
| 473 |
+
"rstrip": false,
|
| 474 |
+
"single_word": false,
|
| 475 |
+
"special": false
|
| 476 |
+
},
|
| 477 |
+
"59": {
|
| 478 |
+
"content": "<unused52>",
|
| 479 |
+
"lstrip": false,
|
| 480 |
+
"normalized": false,
|
| 481 |
+
"rstrip": false,
|
| 482 |
+
"single_word": false,
|
| 483 |
+
"special": false
|
| 484 |
+
},
|
| 485 |
+
"60": {
|
| 486 |
+
"content": "<unused53>",
|
| 487 |
+
"lstrip": false,
|
| 488 |
+
"normalized": false,
|
| 489 |
+
"rstrip": false,
|
| 490 |
+
"single_word": false,
|
| 491 |
+
"special": false
|
| 492 |
+
},
|
| 493 |
+
"61": {
|
| 494 |
+
"content": "<unused54>",
|
| 495 |
+
"lstrip": false,
|
| 496 |
+
"normalized": false,
|
| 497 |
+
"rstrip": false,
|
| 498 |
+
"single_word": false,
|
| 499 |
+
"special": false
|
| 500 |
+
},
|
| 501 |
+
"62": {
|
| 502 |
+
"content": "<unused55>",
|
| 503 |
+
"lstrip": false,
|
| 504 |
+
"normalized": false,
|
| 505 |
+
"rstrip": false,
|
| 506 |
+
"single_word": false,
|
| 507 |
+
"special": false
|
| 508 |
+
},
|
| 509 |
+
"63": {
|
| 510 |
+
"content": "<unused56>",
|
| 511 |
+
"lstrip": false,
|
| 512 |
+
"normalized": false,
|
| 513 |
+
"rstrip": false,
|
| 514 |
+
"single_word": false,
|
| 515 |
+
"special": false
|
| 516 |
+
},
|
| 517 |
+
"64": {
|
| 518 |
+
"content": "<unused57>",
|
| 519 |
+
"lstrip": false,
|
| 520 |
+
"normalized": false,
|
| 521 |
+
"rstrip": false,
|
| 522 |
+
"single_word": false,
|
| 523 |
+
"special": false
|
| 524 |
+
},
|
| 525 |
+
"65": {
|
| 526 |
+
"content": "<unused58>",
|
| 527 |
+
"lstrip": false,
|
| 528 |
+
"normalized": false,
|
| 529 |
+
"rstrip": false,
|
| 530 |
+
"single_word": false,
|
| 531 |
+
"special": false
|
| 532 |
+
},
|
| 533 |
+
"66": {
|
| 534 |
+
"content": "<unused59>",
|
| 535 |
+
"lstrip": false,
|
| 536 |
+
"normalized": false,
|
| 537 |
+
"rstrip": false,
|
| 538 |
+
"single_word": false,
|
| 539 |
+
"special": false
|
| 540 |
+
},
|
| 541 |
+
"67": {
|
| 542 |
+
"content": "<unused60>",
|
| 543 |
+
"lstrip": false,
|
| 544 |
+
"normalized": false,
|
| 545 |
+
"rstrip": false,
|
| 546 |
+
"single_word": false,
|
| 547 |
+
"special": false
|
| 548 |
+
},
|
| 549 |
+
"68": {
|
| 550 |
+
"content": "<unused61>",
|
| 551 |
+
"lstrip": false,
|
| 552 |
+
"normalized": false,
|
| 553 |
+
"rstrip": false,
|
| 554 |
+
"single_word": false,
|
| 555 |
+
"special": false
|
| 556 |
+
},
|
| 557 |
+
"69": {
|
| 558 |
+
"content": "<unused62>",
|
| 559 |
+
"lstrip": false,
|
| 560 |
+
"normalized": false,
|
| 561 |
+
"rstrip": false,
|
| 562 |
+
"single_word": false,
|
| 563 |
+
"special": false
|
| 564 |
+
},
|
| 565 |
+
"70": {
|
| 566 |
+
"content": "<unused63>",
|
| 567 |
+
"lstrip": false,
|
| 568 |
+
"normalized": false,
|
| 569 |
+
"rstrip": false,
|
| 570 |
+
"single_word": false,
|
| 571 |
+
"special": false
|
| 572 |
+
},
|
| 573 |
+
"71": {
|
| 574 |
+
"content": "<unused64>",
|
| 575 |
+
"lstrip": false,
|
| 576 |
+
"normalized": false,
|
| 577 |
+
"rstrip": false,
|
| 578 |
+
"single_word": false,
|
| 579 |
+
"special": false
|
| 580 |
+
},
|
| 581 |
+
"72": {
|
| 582 |
+
"content": "<unused65>",
|
| 583 |
+
"lstrip": false,
|
| 584 |
+
"normalized": false,
|
| 585 |
+
"rstrip": false,
|
| 586 |
+
"single_word": false,
|
| 587 |
+
"special": false
|
| 588 |
+
},
|
| 589 |
+
"73": {
|
| 590 |
+
"content": "<unused66>",
|
| 591 |
+
"lstrip": false,
|
| 592 |
+
"normalized": false,
|
| 593 |
+
"rstrip": false,
|
| 594 |
+
"single_word": false,
|
| 595 |
+
"special": false
|
| 596 |
+
},
|
| 597 |
+
"74": {
|
| 598 |
+
"content": "<unused67>",
|
| 599 |
+
"lstrip": false,
|
| 600 |
+
"normalized": false,
|
| 601 |
+
"rstrip": false,
|
| 602 |
+
"single_word": false,
|
| 603 |
+
"special": false
|
| 604 |
+
},
|
| 605 |
+
"75": {
|
| 606 |
+
"content": "<unused68>",
|
| 607 |
+
"lstrip": false,
|
| 608 |
+
"normalized": false,
|
| 609 |
+
"rstrip": false,
|
| 610 |
+
"single_word": false,
|
| 611 |
+
"special": false
|
| 612 |
+
},
|
| 613 |
+
"76": {
|
| 614 |
+
"content": "<unused69>",
|
| 615 |
+
"lstrip": false,
|
| 616 |
+
"normalized": false,
|
| 617 |
+
"rstrip": false,
|
| 618 |
+
"single_word": false,
|
| 619 |
+
"special": false
|
| 620 |
+
},
|
| 621 |
+
"77": {
|
| 622 |
+
"content": "<unused70>",
|
| 623 |
+
"lstrip": false,
|
| 624 |
+
"normalized": false,
|
| 625 |
+
"rstrip": false,
|
| 626 |
+
"single_word": false,
|
| 627 |
+
"special": false
|
| 628 |
+
},
|
| 629 |
+
"78": {
|
| 630 |
+
"content": "<unused71>",
|
| 631 |
+
"lstrip": false,
|
| 632 |
+
"normalized": false,
|
| 633 |
+
"rstrip": false,
|
| 634 |
+
"single_word": false,
|
| 635 |
+
"special": false
|
| 636 |
+
},
|
| 637 |
+
"79": {
|
| 638 |
+
"content": "<unused72>",
|
| 639 |
+
"lstrip": false,
|
| 640 |
+
"normalized": false,
|
| 641 |
+
"rstrip": false,
|
| 642 |
+
"single_word": false,
|
| 643 |
+
"special": false
|
| 644 |
+
},
|
| 645 |
+
"80": {
|
| 646 |
+
"content": "<unused73>",
|
| 647 |
+
"lstrip": false,
|
| 648 |
+
"normalized": false,
|
| 649 |
+
"rstrip": false,
|
| 650 |
+
"single_word": false,
|
| 651 |
+
"special": false
|
| 652 |
+
},
|
| 653 |
+
"81": {
|
| 654 |
+
"content": "<unused74>",
|
| 655 |
+
"lstrip": false,
|
| 656 |
+
"normalized": false,
|
| 657 |
+
"rstrip": false,
|
| 658 |
+
"single_word": false,
|
| 659 |
+
"special": false
|
| 660 |
+
},
|
| 661 |
+
"82": {
|
| 662 |
+
"content": "<unused75>",
|
| 663 |
+
"lstrip": false,
|
| 664 |
+
"normalized": false,
|
| 665 |
+
"rstrip": false,
|
| 666 |
+
"single_word": false,
|
| 667 |
+
"special": false
|
| 668 |
+
},
|
| 669 |
+
"83": {
|
| 670 |
+
"content": "<unused76>",
|
| 671 |
+
"lstrip": false,
|
| 672 |
+
"normalized": false,
|
| 673 |
+
"rstrip": false,
|
| 674 |
+
"single_word": false,
|
| 675 |
+
"special": false
|
| 676 |
+
},
|
| 677 |
+
"84": {
|
| 678 |
+
"content": "<unused77>",
|
| 679 |
+
"lstrip": false,
|
| 680 |
+
"normalized": false,
|
| 681 |
+
"rstrip": false,
|
| 682 |
+
"single_word": false,
|
| 683 |
+
"special": false
|
| 684 |
+
},
|
| 685 |
+
"85": {
|
| 686 |
+
"content": "<unused78>",
|
| 687 |
+
"lstrip": false,
|
| 688 |
+
"normalized": false,
|
| 689 |
+
"rstrip": false,
|
| 690 |
+
"single_word": false,
|
| 691 |
+
"special": false
|
| 692 |
+
},
|
| 693 |
+
"86": {
|
| 694 |
+
"content": "<unused79>",
|
| 695 |
+
"lstrip": false,
|
| 696 |
+
"normalized": false,
|
| 697 |
+
"rstrip": false,
|
| 698 |
+
"single_word": false,
|
| 699 |
+
"special": false
|
| 700 |
+
},
|
| 701 |
+
"87": {
|
| 702 |
+
"content": "<unused80>",
|
| 703 |
+
"lstrip": false,
|
| 704 |
+
"normalized": false,
|
| 705 |
+
"rstrip": false,
|
| 706 |
+
"single_word": false,
|
| 707 |
+
"special": false
|
| 708 |
+
},
|
| 709 |
+
"88": {
|
| 710 |
+
"content": "<unused81>",
|
| 711 |
+
"lstrip": false,
|
| 712 |
+
"normalized": false,
|
| 713 |
+
"rstrip": false,
|
| 714 |
+
"single_word": false,
|
| 715 |
+
"special": false
|
| 716 |
+
},
|
| 717 |
+
"89": {
|
| 718 |
+
"content": "<unused82>",
|
| 719 |
+
"lstrip": false,
|
| 720 |
+
"normalized": false,
|
| 721 |
+
"rstrip": false,
|
| 722 |
+
"single_word": false,
|
| 723 |
+
"special": false
|
| 724 |
+
},
|
| 725 |
+
"90": {
|
| 726 |
+
"content": "<unused83>",
|
| 727 |
+
"lstrip": false,
|
| 728 |
+
"normalized": false,
|
| 729 |
+
"rstrip": false,
|
| 730 |
+
"single_word": false,
|
| 731 |
+
"special": false
|
| 732 |
+
},
|
| 733 |
+
"91": {
|
| 734 |
+
"content": "<unused84>",
|
| 735 |
+
"lstrip": false,
|
| 736 |
+
"normalized": false,
|
| 737 |
+
"rstrip": false,
|
| 738 |
+
"single_word": false,
|
| 739 |
+
"special": false
|
| 740 |
+
},
|
| 741 |
+
"92": {
|
| 742 |
+
"content": "<unused85>",
|
| 743 |
+
"lstrip": false,
|
| 744 |
+
"normalized": false,
|
| 745 |
+
"rstrip": false,
|
| 746 |
+
"single_word": false,
|
| 747 |
+
"special": false
|
| 748 |
+
},
|
| 749 |
+
"93": {
|
| 750 |
+
"content": "<unused86>",
|
| 751 |
+
"lstrip": false,
|
| 752 |
+
"normalized": false,
|
| 753 |
+
"rstrip": false,
|
| 754 |
+
"single_word": false,
|
| 755 |
+
"special": false
|
| 756 |
+
},
|
| 757 |
+
"94": {
|
| 758 |
+
"content": "<unused87>",
|
| 759 |
+
"lstrip": false,
|
| 760 |
+
"normalized": false,
|
| 761 |
+
"rstrip": false,
|
| 762 |
+
"single_word": false,
|
| 763 |
+
"special": false
|
| 764 |
+
},
|
| 765 |
+
"95": {
|
| 766 |
+
"content": "<unused88>",
|
| 767 |
+
"lstrip": false,
|
| 768 |
+
"normalized": false,
|
| 769 |
+
"rstrip": false,
|
| 770 |
+
"single_word": false,
|
| 771 |
+
"special": false
|
| 772 |
+
},
|
| 773 |
+
"96": {
|
| 774 |
+
"content": "<unused89>",
|
| 775 |
+
"lstrip": false,
|
| 776 |
+
"normalized": false,
|
| 777 |
+
"rstrip": false,
|
| 778 |
+
"single_word": false,
|
| 779 |
+
"special": false
|
| 780 |
+
},
|
| 781 |
+
"97": {
|
| 782 |
+
"content": "<unused90>",
|
| 783 |
+
"lstrip": false,
|
| 784 |
+
"normalized": false,
|
| 785 |
+
"rstrip": false,
|
| 786 |
+
"single_word": false,
|
| 787 |
+
"special": false
|
| 788 |
+
},
|
| 789 |
+
"98": {
|
| 790 |
+
"content": "<unused91>",
|
| 791 |
+
"lstrip": false,
|
| 792 |
+
"normalized": false,
|
| 793 |
+
"rstrip": false,
|
| 794 |
+
"single_word": false,
|
| 795 |
+
"special": false
|
| 796 |
+
},
|
| 797 |
+
"99": {
|
| 798 |
+
"content": "<unused92>",
|
| 799 |
+
"lstrip": false,
|
| 800 |
+
"normalized": false,
|
| 801 |
+
"rstrip": false,
|
| 802 |
+
"single_word": false,
|
| 803 |
+
"special": false
|
| 804 |
+
},
|
| 805 |
+
"100": {
|
| 806 |
+
"content": "<unused93>",
|
| 807 |
+
"lstrip": false,
|
| 808 |
+
"normalized": false,
|
| 809 |
+
"rstrip": false,
|
| 810 |
+
"single_word": false,
|
| 811 |
+
"special": false
|
| 812 |
+
},
|
| 813 |
+
"101": {
|
| 814 |
+
"content": "<unused94>",
|
| 815 |
+
"lstrip": false,
|
| 816 |
+
"normalized": false,
|
| 817 |
+
"rstrip": false,
|
| 818 |
+
"single_word": false,
|
| 819 |
+
"special": false
|
| 820 |
+
},
|
| 821 |
+
"102": {
|
| 822 |
+
"content": "<unused95>",
|
| 823 |
+
"lstrip": false,
|
| 824 |
+
"normalized": false,
|
| 825 |
+
"rstrip": false,
|
| 826 |
+
"single_word": false,
|
| 827 |
+
"special": false
|
| 828 |
+
},
|
| 829 |
+
"103": {
|
| 830 |
+
"content": "<unused96>",
|
| 831 |
+
"lstrip": false,
|
| 832 |
+
"normalized": false,
|
| 833 |
+
"rstrip": false,
|
| 834 |
+
"single_word": false,
|
| 835 |
+
"special": false
|
| 836 |
+
},
|
| 837 |
+
"104": {
|
| 838 |
+
"content": "<unused97>",
|
| 839 |
+
"lstrip": false,
|
| 840 |
+
"normalized": false,
|
| 841 |
+
"rstrip": false,
|
| 842 |
+
"single_word": false,
|
| 843 |
+
"special": false
|
| 844 |
+
},
|
| 845 |
+
"105": {
|
| 846 |
+
"content": "<unused98>",
|
| 847 |
+
"lstrip": false,
|
| 848 |
+
"normalized": false,
|
| 849 |
+
"rstrip": false,
|
| 850 |
+
"single_word": false,
|
| 851 |
+
"special": false
|
| 852 |
+
},
|
| 853 |
+
"106": {
|
| 854 |
+
"content": "<start_of_turn>",
|
| 855 |
+
"lstrip": false,
|
| 856 |
+
"normalized": false,
|
| 857 |
+
"rstrip": false,
|
| 858 |
+
"single_word": false,
|
| 859 |
+
"special": true
|
| 860 |
+
},
|
| 861 |
+
"107": {
|
| 862 |
+
"content": "<end_of_turn>",
|
| 863 |
+
"lstrip": false,
|
| 864 |
+
"normalized": false,
|
| 865 |
+
"rstrip": false,
|
| 866 |
+
"single_word": false,
|
| 867 |
+
"special": true
|
| 868 |
+
},
|
| 869 |
+
"108": {
|
| 870 |
+
"content": "\n",
|
| 871 |
+
"lstrip": false,
|
| 872 |
+
"normalized": false,
|
| 873 |
+
"rstrip": false,
|
| 874 |
+
"single_word": false,
|
| 875 |
+
"special": false
|
| 876 |
+
},
|
| 877 |
+
"109": {
|
| 878 |
+
"content": "\n\n",
|
| 879 |
+
"lstrip": false,
|
| 880 |
+
"normalized": false,
|
| 881 |
+
"rstrip": false,
|
| 882 |
+
"single_word": false,
|
| 883 |
+
"special": false
|
| 884 |
+
},
|
| 885 |
+
"110": {
|
| 886 |
+
"content": "\n\n\n",
|
| 887 |
+
"lstrip": false,
|
| 888 |
+
"normalized": false,
|
| 889 |
+
"rstrip": false,
|
| 890 |
+
"single_word": false,
|
| 891 |
+
"special": false
|
| 892 |
+
},
|
| 893 |
+
"111": {
|
| 894 |
+
"content": "\n\n\n\n",
|
| 895 |
+
"lstrip": false,
|
| 896 |
+
"normalized": false,
|
| 897 |
+
"rstrip": false,
|
| 898 |
+
"single_word": false,
|
| 899 |
+
"special": false
|
| 900 |
+
},
|
| 901 |
+
"112": {
|
| 902 |
+
"content": "\n\n\n\n\n",
|
| 903 |
+
"lstrip": false,
|
| 904 |
+
"normalized": false,
|
| 905 |
+
"rstrip": false,
|
| 906 |
+
"single_word": false,
|
| 907 |
+
"special": false
|
| 908 |
+
},
|
| 909 |
+
"113": {
|
| 910 |
+
"content": "\n\n\n\n\n\n",
|
| 911 |
+
"lstrip": false,
|
| 912 |
+
"normalized": false,
|
| 913 |
+
"rstrip": false,
|
| 914 |
+
"single_word": false,
|
| 915 |
+
"special": false
|
| 916 |
+
},
|
| 917 |
+
"114": {
|
| 918 |
+
"content": "\n\n\n\n\n\n\n",
|
| 919 |
+
"lstrip": false,
|
| 920 |
+
"normalized": false,
|
| 921 |
+
"rstrip": false,
|
| 922 |
+
"single_word": false,
|
| 923 |
+
"special": false
|
| 924 |
+
},
|
| 925 |
+
"115": {
|
| 926 |
+
"content": "\n\n\n\n\n\n\n\n",
|
| 927 |
+
"lstrip": false,
|
| 928 |
+
"normalized": false,
|
| 929 |
+
"rstrip": false,
|
| 930 |
+
"single_word": false,
|
| 931 |
+
"special": false
|
| 932 |
+
},
|
| 933 |
+
"116": {
|
| 934 |
+
"content": "\n\n\n\n\n\n\n\n\n",
|
| 935 |
+
"lstrip": false,
|
| 936 |
+
"normalized": false,
|
| 937 |
+
"rstrip": false,
|
| 938 |
+
"single_word": false,
|
| 939 |
+
"special": false
|
| 940 |
+
},
|
| 941 |
+
"117": {
|
| 942 |
+
"content": "\n\n\n\n\n\n\n\n\n\n",
|
| 943 |
+
"lstrip": false,
|
| 944 |
+
"normalized": false,
|
| 945 |
+
"rstrip": false,
|
| 946 |
+
"single_word": false,
|
| 947 |
+
"special": false
|
| 948 |
+
},
|
| 949 |
+
"118": {
|
| 950 |
+
"content": "\n\n\n\n\n\n\n\n\n\n\n",
|
| 951 |
+
"lstrip": false,
|
| 952 |
+
"normalized": false,
|
| 953 |
+
"rstrip": false,
|
| 954 |
+
"single_word": false,
|
| 955 |
+
"special": false
|
| 956 |
+
},
|
| 957 |
+
"119": {
|
| 958 |
+
"content": "\n\n\n\n\n\n\n\n\n\n\n\n",
|
| 959 |
+
"lstrip": false,
|
| 960 |
+
"normalized": false,
|
| 961 |
+
"rstrip": false,
|
| 962 |
+
"single_word": false,
|
| 963 |
+
"special": false
|
| 964 |
+
},
|
| 965 |
+
"120": {
|
| 966 |
+
"content": "\n\n\n\n\n\n\n\n\n\n\n\n\n",
|
| 967 |
+
"lstrip": false,
|
| 968 |
+
"normalized": false,
|
| 969 |
+
"rstrip": false,
|
| 970 |
+
"single_word": false,
|
| 971 |
+
"special": false
|
| 972 |
+
},
|
| 973 |
+
"121": {
|
| 974 |
+
"content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n",
|
| 975 |
+
"lstrip": false,
|
| 976 |
+
"normalized": false,
|
| 977 |
+
"rstrip": false,
|
| 978 |
+
"single_word": false,
|
| 979 |
+
"special": false
|
| 980 |
+
},
|
| 981 |
+
"122": {
|
| 982 |
+
"content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",
|
| 983 |
+
"lstrip": false,
|
| 984 |
+
"normalized": false,
|
| 985 |
+
"rstrip": false,
|
| 986 |
+
"single_word": false,
|
| 987 |
+
"special": false
|
| 988 |
+
},
|
| 989 |
+
"123": {
|
| 990 |
+
"content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",
|
| 991 |
+
"lstrip": false,
|
| 992 |
+
"normalized": false,
|
| 993 |
+
"rstrip": false,
|
| 994 |
+
"single_word": false,
|
| 995 |
+
"special": false
|
| 996 |
+
},
|
| 997 |
+
"124": {
|
| 998 |
+
"content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",
|
| 999 |
+
"lstrip": false,
|
| 1000 |
+
"normalized": false,
|
| 1001 |
+
"rstrip": false,
|
| 1002 |
+
"single_word": false,
|
| 1003 |
+
"special": false
|
| 1004 |
+
},
|
| 1005 |
+
"125": {
|
| 1006 |
+
"content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",
|
| 1007 |
+
"lstrip": false,
|
| 1008 |
+
"normalized": false,
|
| 1009 |
+
"rstrip": false,
|
| 1010 |
+
"single_word": false,
|
| 1011 |
+
"special": false
|
| 1012 |
+
},
|
| 1013 |
+
"126": {
|
| 1014 |
+
"content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",
|
| 1015 |
+
"lstrip": false,
|
| 1016 |
+
"normalized": false,
|
| 1017 |
+
"rstrip": false,
|
| 1018 |
+
"single_word": false,
|
| 1019 |
+
"special": false
|
| 1020 |
+
},
|
| 1021 |
+
"127": {
|
| 1022 |
+
"content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",
|
| 1023 |
+
"lstrip": false,
|
| 1024 |
+
"normalized": false,
|
| 1025 |
+
"rstrip": false,
|
| 1026 |
+
"single_word": false,
|
| 1027 |
+
"special": false
|
| 1028 |
+
},
|
| 1029 |
+
"128": {
|
| 1030 |
+
"content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",
|
| 1031 |
+
"lstrip": false,
|
| 1032 |
+
"normalized": false,
|
| 1033 |
+
"rstrip": false,
|
| 1034 |
+
"single_word": false,
|
| 1035 |
+
"special": false
|
| 1036 |
+
},
|
| 1037 |
+
"129": {
|
| 1038 |
+
"content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",
|
| 1039 |
+
"lstrip": false,
|
| 1040 |
+
"normalized": false,
|
| 1041 |
+
"rstrip": false,
|
| 1042 |
+
"single_word": false,
|
| 1043 |
+
"special": false
|
| 1044 |
+
},
|
| 1045 |
+
"130": {
|
| 1046 |
+
"content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",
|
| 1047 |
+
"lstrip": false,
|
| 1048 |
+
"normalized": false,
|
| 1049 |
+
"rstrip": false,
|
| 1050 |
+
"single_word": false,
|
| 1051 |
+
"special": false
|
| 1052 |
+
},
|
| 1053 |
+
"131": {
|
| 1054 |
+
"content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",
|
| 1055 |
+
"lstrip": false,
|
| 1056 |
+
"normalized": false,
|
| 1057 |
+
"rstrip": false,
|
| 1058 |
+
"single_word": false,
|
| 1059 |
+
"special": false
|
| 1060 |
+
},
|
| 1061 |
+
"132": {
|
| 1062 |
+
"content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",
|
| 1063 |
+
"lstrip": false,
|
| 1064 |
+
"normalized": false,
|
| 1065 |
+
"rstrip": false,
|
| 1066 |
+
"single_word": false,
|
| 1067 |
+
"special": false
|
| 1068 |
+
},
|
| 1069 |
+
"133": {
|
| 1070 |
+
"content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",
|
| 1071 |
+
"lstrip": false,
|
| 1072 |
+
"normalized": false,
|
| 1073 |
+
"rstrip": false,
|
| 1074 |
+
"single_word": false,
|
| 1075 |
+
"special": false
|
| 1076 |
+
},
|
| 1077 |
+
"134": {
|
| 1078 |
+
"content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",
|
| 1079 |
+
"lstrip": false,
|
| 1080 |
+
"normalized": false,
|
| 1081 |
+
"rstrip": false,
|
| 1082 |
+
"single_word": false,
|
| 1083 |
+
"special": false
|
| 1084 |
+
},
|
| 1085 |
+
"135": {
|
| 1086 |
+
"content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",
|
| 1087 |
+
"lstrip": false,
|
| 1088 |
+
"normalized": false,
|
| 1089 |
+
"rstrip": false,
|
| 1090 |
+
"single_word": false,
|
| 1091 |
+
"special": false
|
| 1092 |
+
},
|
| 1093 |
+
"136": {
|
| 1094 |
+
"content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",
|
| 1095 |
+
"lstrip": false,
|
| 1096 |
+
"normalized": false,
|
| 1097 |
+
"rstrip": false,
|
| 1098 |
+
"single_word": false,
|
| 1099 |
+
"special": false
|
| 1100 |
+
},
|
| 1101 |
+
"137": {
|
| 1102 |
+
"content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",
|
| 1103 |
+
"lstrip": false,
|
| 1104 |
+
"normalized": false,
|
| 1105 |
+
"rstrip": false,
|
| 1106 |
+
"single_word": false,
|
| 1107 |
+
"special": false
|
| 1108 |
+
},
|
| 1109 |
+
"138": {
|
| 1110 |
+
"content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",
|
| 1111 |
+
"lstrip": false,
|
| 1112 |
+
"normalized": false,
|
| 1113 |
+
"rstrip": false,
|
| 1114 |
+
"single_word": false,
|
| 1115 |
+
"special": false
|
| 1116 |
+
},
|
| 1117 |
+
"139": {
|
| 1118 |
+
"content": "▁▁",
|
| 1119 |
+
"lstrip": false,
|
| 1120 |
+
"normalized": false,
|
| 1121 |
+
"rstrip": false,
|
| 1122 |
+
"single_word": false,
|
| 1123 |
+
"special": false
|
| 1124 |
+
},
|
| 1125 |
+
"140": {
|
| 1126 |
+
"content": "▁▁▁",
|
| 1127 |
+
"lstrip": false,
|
| 1128 |
+
"normalized": false,
|
| 1129 |
+
"rstrip": false,
|
| 1130 |
+
"single_word": false,
|
| 1131 |
+
"special": false
|
| 1132 |
+
},
|
| 1133 |
+
"141": {
|
| 1134 |
+
"content": "▁▁▁▁",
|
| 1135 |
+
"lstrip": false,
|
| 1136 |
+
"normalized": false,
|
| 1137 |
+
"rstrip": false,
|
| 1138 |
+
"single_word": false,
|
| 1139 |
+
"special": false
|
| 1140 |
+
},
|
| 1141 |
+
"142": {
|
| 1142 |
+
"content": "▁▁▁▁▁",
|
| 1143 |
+
"lstrip": false,
|
| 1144 |
+
"normalized": false,
|
| 1145 |
+
"rstrip": false,
|
| 1146 |
+
"single_word": false,
|
| 1147 |
+
"special": false
|
| 1148 |
+
},
|
| 1149 |
+
"143": {
|
| 1150 |
+
"content": "▁▁▁▁▁▁",
|
| 1151 |
+
"lstrip": false,
|
| 1152 |
+
"normalized": false,
|
| 1153 |
+
"rstrip": false,
|
| 1154 |
+
"single_word": false,
|
| 1155 |
+
"special": false
|
| 1156 |
+
},
|
| 1157 |
+
"144": {
|
| 1158 |
+
"content": "▁▁▁▁▁▁▁",
|
| 1159 |
+
"lstrip": false,
|
| 1160 |
+
"normalized": false,
|
| 1161 |
+
"rstrip": false,
|
| 1162 |
+
"single_word": false,
|
| 1163 |
+
"special": false
|
| 1164 |
+
},
|
| 1165 |
+
"145": {
|
| 1166 |
+
"content": "▁▁▁▁▁▁▁▁",
|
| 1167 |
+
"lstrip": false,
|
| 1168 |
+
"normalized": false,
|
| 1169 |
+
"rstrip": false,
|
| 1170 |
+
"single_word": false,
|
| 1171 |
+
"special": false
|
| 1172 |
+
},
|
| 1173 |
+
"146": {
|
| 1174 |
+
"content": "▁▁▁▁▁▁▁▁▁",
|
| 1175 |
+
"lstrip": false,
|
| 1176 |
+
"normalized": false,
|
| 1177 |
+
"rstrip": false,
|
| 1178 |
+
"single_word": false,
|
| 1179 |
+
"special": false
|
| 1180 |
+
},
|
| 1181 |
+
"147": {
|
| 1182 |
+
"content": "▁▁▁▁▁▁▁▁▁▁",
|
| 1183 |
+
"lstrip": false,
|
| 1184 |
+
"normalized": false,
|
| 1185 |
+
"rstrip": false,
|
| 1186 |
+
"single_word": false,
|
| 1187 |
+
"special": false
|
| 1188 |
+
},
|
| 1189 |
+
"148": {
|
| 1190 |
+
"content": "▁▁▁▁▁▁▁▁▁▁▁",
|
| 1191 |
+
"lstrip": false,
|
| 1192 |
+
"normalized": false,
|
| 1193 |
+
"rstrip": false,
|
| 1194 |
+
"single_word": false,
|
| 1195 |
+
"special": false
|
| 1196 |
+
},
|
| 1197 |
+
"149": {
|
| 1198 |
+
"content": "▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 1199 |
+
"lstrip": false,
|
| 1200 |
+
"normalized": false,
|
| 1201 |
+
"rstrip": false,
|
| 1202 |
+
"single_word": false,
|
| 1203 |
+
"special": false
|
| 1204 |
+
},
|
| 1205 |
+
"150": {
|
| 1206 |
+
"content": "▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 1207 |
+
"lstrip": false,
|
| 1208 |
+
"normalized": false,
|
| 1209 |
+
"rstrip": false,
|
| 1210 |
+
"single_word": false,
|
| 1211 |
+
"special": false
|
| 1212 |
+
},
|
| 1213 |
+
"151": {
|
| 1214 |
+
"content": "▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 1215 |
+
"lstrip": false,
|
| 1216 |
+
"normalized": false,
|
| 1217 |
+
"rstrip": false,
|
| 1218 |
+
"single_word": false,
|
| 1219 |
+
"special": false
|
| 1220 |
+
},
|
| 1221 |
+
"152": {
|
| 1222 |
+
"content": "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 1223 |
+
"lstrip": false,
|
| 1224 |
+
"normalized": false,
|
| 1225 |
+
"rstrip": false,
|
| 1226 |
+
"single_word": false,
|
| 1227 |
+
"special": false
|
| 1228 |
+
},
|
| 1229 |
+
"153": {
|
| 1230 |
+
"content": "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 1231 |
+
"lstrip": false,
|
| 1232 |
+
"normalized": false,
|
| 1233 |
+
"rstrip": false,
|
| 1234 |
+
"single_word": false,
|
| 1235 |
+
"special": false
|
| 1236 |
+
},
|
| 1237 |
+
"154": {
|
| 1238 |
+
"content": "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 1239 |
+
"lstrip": false,
|
| 1240 |
+
"normalized": false,
|
| 1241 |
+
"rstrip": false,
|
| 1242 |
+
"single_word": false,
|
| 1243 |
+
"special": false
|
| 1244 |
+
},
|
| 1245 |
+
"155": {
|
| 1246 |
+
"content": "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 1247 |
+
"lstrip": false,
|
| 1248 |
+
"normalized": false,
|
| 1249 |
+
"rstrip": false,
|
| 1250 |
+
"single_word": false,
|
| 1251 |
+
"special": false
|
| 1252 |
+
},
|
| 1253 |
+
"156": {
|
| 1254 |
+
"content": "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 1255 |
+
"lstrip": false,
|
| 1256 |
+
"normalized": false,
|
| 1257 |
+
"rstrip": false,
|
| 1258 |
+
"single_word": false,
|
| 1259 |
+
"special": false
|
| 1260 |
+
},
|
| 1261 |
+
"157": {
|
| 1262 |
+
"content": "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 1263 |
+
"lstrip": false,
|
| 1264 |
+
"normalized": false,
|
| 1265 |
+
"rstrip": false,
|
| 1266 |
+
"single_word": false,
|
| 1267 |
+
"special": false
|
| 1268 |
+
},
|
| 1269 |
+
"158": {
|
| 1270 |
+
"content": "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 1271 |
+
"lstrip": false,
|
| 1272 |
+
"normalized": false,
|
| 1273 |
+
"rstrip": false,
|
| 1274 |
+
"single_word": false,
|
| 1275 |
+
"special": false
|
| 1276 |
+
},
|
| 1277 |
+
"159": {
|
| 1278 |
+
"content": "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 1279 |
+
"lstrip": false,
|
| 1280 |
+
"normalized": false,
|
| 1281 |
+
"rstrip": false,
|
| 1282 |
+
"single_word": false,
|
| 1283 |
+
"special": false
|
| 1284 |
+
},
|
| 1285 |
+
"160": {
|
| 1286 |
+
"content": "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 1287 |
+
"lstrip": false,
|
| 1288 |
+
"normalized": false,
|
| 1289 |
+
"rstrip": false,
|
| 1290 |
+
"single_word": false,
|
| 1291 |
+
"special": false
|
| 1292 |
+
},
|
| 1293 |
+
"161": {
|
| 1294 |
+
"content": "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 1295 |
+
"lstrip": false,
|
| 1296 |
+
"normalized": false,
|
| 1297 |
+
"rstrip": false,
|
| 1298 |
+
"single_word": false,
|
| 1299 |
+
"special": false
|
| 1300 |
+
},
|
| 1301 |
+
"162": {
|
| 1302 |
+
"content": "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 1303 |
+
"lstrip": false,
|
| 1304 |
+
"normalized": false,
|
| 1305 |
+
"rstrip": false,
|
| 1306 |
+
"single_word": false,
|
| 1307 |
+
"special": false
|
| 1308 |
+
},
|
| 1309 |
+
"163": {
|
| 1310 |
+
"content": "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 1311 |
+
"lstrip": false,
|
| 1312 |
+
"normalized": false,
|
| 1313 |
+
"rstrip": false,
|
| 1314 |
+
"single_word": false,
|
| 1315 |
+
"special": false
|
| 1316 |
+
},
|
| 1317 |
+
"164": {
|
| 1318 |
+
"content": "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 1319 |
+
"lstrip": false,
|
| 1320 |
+
"normalized": false,
|
| 1321 |
+
"rstrip": false,
|
| 1322 |
+
"single_word": false,
|
| 1323 |
+
"special": false
|
| 1324 |
+
},
|
| 1325 |
+
"165": {
|
| 1326 |
+
"content": "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 1327 |
+
"lstrip": false,
|
| 1328 |
+
"normalized": false,
|
| 1329 |
+
"rstrip": false,
|
| 1330 |
+
"single_word": false,
|
| 1331 |
+
"special": false
|
| 1332 |
+
},
|
| 1333 |
+
"166": {
|
| 1334 |
+
"content": "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 1335 |
+
"lstrip": false,
|
| 1336 |
+
"normalized": false,
|
| 1337 |
+
"rstrip": false,
|
| 1338 |
+
"single_word": false,
|
| 1339 |
+
"special": false
|
| 1340 |
+
},
|
| 1341 |
+
"167": {
|
| 1342 |
+
"content": "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 1343 |
+
"lstrip": false,
|
| 1344 |
+
"normalized": false,
|
| 1345 |
+
"rstrip": false,
|
| 1346 |
+
"single_word": false,
|
| 1347 |
+
"special": false
|
| 1348 |
+
},
|
| 1349 |
+
"168": {
|
| 1350 |
+
"content": "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 1351 |
+
"lstrip": false,
|
| 1352 |
+
"normalized": false,
|
| 1353 |
+
"rstrip": false,
|
| 1354 |
+
"single_word": false,
|
| 1355 |
+
"special": false
|
| 1356 |
+
},
|
| 1357 |
+
"169": {
|
| 1358 |
+
"content": "<table>",
|
| 1359 |
+
"lstrip": false,
|
| 1360 |
+
"normalized": false,
|
| 1361 |
+
"rstrip": false,
|
| 1362 |
+
"single_word": false,
|
| 1363 |
+
"special": false
|
| 1364 |
+
},
|
| 1365 |
+
"170": {
|
| 1366 |
+
"content": "<caption>",
|
| 1367 |
+
"lstrip": false,
|
| 1368 |
+
"normalized": false,
|
| 1369 |
+
"rstrip": false,
|
| 1370 |
+
"single_word": false,
|
| 1371 |
+
"special": false
|
| 1372 |
+
},
|
| 1373 |
+
"171": {
|
| 1374 |
+
"content": "<thead>",
|
| 1375 |
+
"lstrip": false,
|
| 1376 |
+
"normalized": false,
|
| 1377 |
+
"rstrip": false,
|
| 1378 |
+
"single_word": false,
|
| 1379 |
+
"special": false
|
| 1380 |
+
},
|
| 1381 |
+
"172": {
|
| 1382 |
+
"content": "<tbody>",
|
| 1383 |
+
"lstrip": false,
|
| 1384 |
+
"normalized": false,
|
| 1385 |
+
"rstrip": false,
|
| 1386 |
+
"single_word": false,
|
| 1387 |
+
"special": false
|
| 1388 |
+
},
|
| 1389 |
+
"173": {
|
| 1390 |
+
"content": "<tfoot>",
|
| 1391 |
+
"lstrip": false,
|
| 1392 |
+
"normalized": false,
|
| 1393 |
+
"rstrip": false,
|
| 1394 |
+
"single_word": false,
|
| 1395 |
+
"special": false
|
| 1396 |
+
},
|
| 1397 |
+
"174": {
|
| 1398 |
+
"content": "<tr>",
|
| 1399 |
+
"lstrip": false,
|
| 1400 |
+
"normalized": false,
|
| 1401 |
+
"rstrip": false,
|
| 1402 |
+
"single_word": false,
|
| 1403 |
+
"special": false
|
| 1404 |
+
},
|
| 1405 |
+
"175": {
|
| 1406 |
+
"content": "<th>",
|
| 1407 |
+
"lstrip": false,
|
| 1408 |
+
"normalized": false,
|
| 1409 |
+
"rstrip": false,
|
| 1410 |
+
"single_word": false,
|
| 1411 |
+
"special": false
|
| 1412 |
+
},
|
| 1413 |
+
"176": {
|
| 1414 |
+
"content": "<td>",
|
| 1415 |
+
"lstrip": false,
|
| 1416 |
+
"normalized": false,
|
| 1417 |
+
"rstrip": false,
|
| 1418 |
+
"single_word": false,
|
| 1419 |
+
"special": false
|
| 1420 |
+
},
|
| 1421 |
+
"177": {
|
| 1422 |
+
"content": "</table>",
|
| 1423 |
+
"lstrip": false,
|
| 1424 |
+
"normalized": false,
|
| 1425 |
+
"rstrip": false,
|
| 1426 |
+
"single_word": false,
|
| 1427 |
+
"special": false
|
| 1428 |
+
},
|
| 1429 |
+
"178": {
|
| 1430 |
+
"content": "</caption>",
|
| 1431 |
+
"lstrip": false,
|
| 1432 |
+
"normalized": false,
|
| 1433 |
+
"rstrip": false,
|
| 1434 |
+
"single_word": false,
|
| 1435 |
+
"special": false
|
| 1436 |
+
},
|
| 1437 |
+
"179": {
|
| 1438 |
+
"content": "</thead>",
|
| 1439 |
+
"lstrip": false,
|
| 1440 |
+
"normalized": false,
|
| 1441 |
+
"rstrip": false,
|
| 1442 |
+
"single_word": false,
|
| 1443 |
+
"special": false
|
| 1444 |
+
},
|
| 1445 |
+
"180": {
|
| 1446 |
+
"content": "</tbody>",
|
| 1447 |
+
"lstrip": false,
|
| 1448 |
+
"normalized": false,
|
| 1449 |
+
"rstrip": false,
|
| 1450 |
+
"single_word": false,
|
| 1451 |
+
"special": false
|
| 1452 |
+
},
|
| 1453 |
+
"181": {
|
| 1454 |
+
"content": "</tfoot>",
|
| 1455 |
+
"lstrip": false,
|
| 1456 |
+
"normalized": false,
|
| 1457 |
+
"rstrip": false,
|
| 1458 |
+
"single_word": false,
|
| 1459 |
+
"special": false
|
| 1460 |
+
},
|
| 1461 |
+
"182": {
|
| 1462 |
+
"content": "</tr>",
|
| 1463 |
+
"lstrip": false,
|
| 1464 |
+
"normalized": false,
|
| 1465 |
+
"rstrip": false,
|
| 1466 |
+
"single_word": false,
|
| 1467 |
+
"special": false
|
| 1468 |
+
},
|
| 1469 |
+
"183": {
|
| 1470 |
+
"content": "</th>",
|
| 1471 |
+
"lstrip": false,
|
| 1472 |
+
"normalized": false,
|
| 1473 |
+
"rstrip": false,
|
| 1474 |
+
"single_word": false,
|
| 1475 |
+
"special": false
|
| 1476 |
+
},
|
| 1477 |
+
"184": {
|
| 1478 |
+
"content": "</td>",
|
| 1479 |
+
"lstrip": false,
|
| 1480 |
+
"normalized": false,
|
| 1481 |
+
"rstrip": false,
|
| 1482 |
+
"single_word": false,
|
| 1483 |
+
"special": false
|
| 1484 |
+
},
|
| 1485 |
+
"185": {
|
| 1486 |
+
"content": "<h1>",
|
| 1487 |
+
"lstrip": false,
|
| 1488 |
+
"normalized": false,
|
| 1489 |
+
"rstrip": false,
|
| 1490 |
+
"single_word": false,
|
| 1491 |
+
"special": false
|
| 1492 |
+
},
|
| 1493 |
+
"186": {
|
| 1494 |
+
"content": "<h2>",
|
| 1495 |
+
"lstrip": false,
|
| 1496 |
+
"normalized": false,
|
| 1497 |
+
"rstrip": false,
|
| 1498 |
+
"single_word": false,
|
| 1499 |
+
"special": false
|
| 1500 |
+
},
|
| 1501 |
+
"187": {
|
| 1502 |
+
"content": "<h3>",
|
| 1503 |
+
"lstrip": false,
|
| 1504 |
+
"normalized": false,
|
| 1505 |
+
"rstrip": false,
|
| 1506 |
+
"single_word": false,
|
| 1507 |
+
"special": false
|
| 1508 |
+
},
|
| 1509 |
+
"188": {
|
| 1510 |
+
"content": "<h4>",
|
| 1511 |
+
"lstrip": false,
|
| 1512 |
+
"normalized": false,
|
| 1513 |
+
"rstrip": false,
|
| 1514 |
+
"single_word": false,
|
| 1515 |
+
"special": false
|
| 1516 |
+
},
|
| 1517 |
+
"189": {
|
| 1518 |
+
"content": "<h5>",
|
| 1519 |
+
"lstrip": false,
|
| 1520 |
+
"normalized": false,
|
| 1521 |
+
"rstrip": false,
|
| 1522 |
+
"single_word": false,
|
| 1523 |
+
"special": false
|
| 1524 |
+
},
|
| 1525 |
+
"190": {
|
| 1526 |
+
"content": "<h6>",
|
| 1527 |
+
"lstrip": false,
|
| 1528 |
+
"normalized": false,
|
| 1529 |
+
"rstrip": false,
|
| 1530 |
+
"single_word": false,
|
| 1531 |
+
"special": false
|
| 1532 |
+
},
|
| 1533 |
+
"191": {
|
| 1534 |
+
"content": "<blockquote>",
|
| 1535 |
+
"lstrip": false,
|
| 1536 |
+
"normalized": false,
|
| 1537 |
+
"rstrip": false,
|
| 1538 |
+
"single_word": false,
|
| 1539 |
+
"special": false
|
| 1540 |
+
},
|
| 1541 |
+
"192": {
|
| 1542 |
+
"content": "</h1>",
|
| 1543 |
+
"lstrip": false,
|
| 1544 |
+
"normalized": false,
|
| 1545 |
+
"rstrip": false,
|
| 1546 |
+
"single_word": false,
|
| 1547 |
+
"special": false
|
| 1548 |
+
},
|
| 1549 |
+
"193": {
|
| 1550 |
+
"content": "</h2>",
|
| 1551 |
+
"lstrip": false,
|
| 1552 |
+
"normalized": false,
|
| 1553 |
+
"rstrip": false,
|
| 1554 |
+
"single_word": false,
|
| 1555 |
+
"special": false
|
| 1556 |
+
},
|
| 1557 |
+
"194": {
|
| 1558 |
+
"content": "</h3>",
|
| 1559 |
+
"lstrip": false,
|
| 1560 |
+
"normalized": false,
|
| 1561 |
+
"rstrip": false,
|
| 1562 |
+
"single_word": false,
|
| 1563 |
+
"special": false
|
| 1564 |
+
},
|
| 1565 |
+
"195": {
|
| 1566 |
+
"content": "</h4>",
|
| 1567 |
+
"lstrip": false,
|
| 1568 |
+
"normalized": false,
|
| 1569 |
+
"rstrip": false,
|
| 1570 |
+
"single_word": false,
|
| 1571 |
+
"special": false
|
| 1572 |
+
},
|
| 1573 |
+
"196": {
|
| 1574 |
+
"content": "</h5>",
|
| 1575 |
+
"lstrip": false,
|
| 1576 |
+
"normalized": false,
|
| 1577 |
+
"rstrip": false,
|
| 1578 |
+
"single_word": false,
|
| 1579 |
+
"special": false
|
| 1580 |
+
},
|
| 1581 |
+
"197": {
|
| 1582 |
+
"content": "</h6>",
|
| 1583 |
+
"lstrip": false,
|
| 1584 |
+
"normalized": false,
|
| 1585 |
+
"rstrip": false,
|
| 1586 |
+
"single_word": false,
|
| 1587 |
+
"special": false
|
| 1588 |
+
},
|
| 1589 |
+
"198": {
|
| 1590 |
+
"content": "</blockquote>",
|
| 1591 |
+
"lstrip": false,
|
| 1592 |
+
"normalized": false,
|
| 1593 |
+
"rstrip": false,
|
| 1594 |
+
"single_word": false,
|
| 1595 |
+
"special": false
|
| 1596 |
+
},
|
| 1597 |
+
"199": {
|
| 1598 |
+
"content": "<strong>",
|
| 1599 |
+
"lstrip": false,
|
| 1600 |
+
"normalized": false,
|
| 1601 |
+
"rstrip": false,
|
| 1602 |
+
"single_word": false,
|
| 1603 |
+
"special": false
|
| 1604 |
+
},
|
| 1605 |
+
"200": {
|
| 1606 |
+
"content": "<em>",
|
| 1607 |
+
"lstrip": false,
|
| 1608 |
+
"normalized": false,
|
| 1609 |
+
"rstrip": false,
|
| 1610 |
+
"single_word": false,
|
| 1611 |
+
"special": false
|
| 1612 |
+
},
|
| 1613 |
+
"201": {
|
| 1614 |
+
"content": "<b>",
|
| 1615 |
+
"lstrip": false,
|
| 1616 |
+
"normalized": false,
|
| 1617 |
+
"rstrip": false,
|
| 1618 |
+
"single_word": false,
|
| 1619 |
+
"special": false
|
| 1620 |
+
},
|
| 1621 |
+
"202": {
|
| 1622 |
+
"content": "<i>",
|
| 1623 |
+
"lstrip": false,
|
| 1624 |
+
"normalized": false,
|
| 1625 |
+
"rstrip": false,
|
| 1626 |
+
"single_word": false,
|
| 1627 |
+
"special": false
|
| 1628 |
+
},
|
| 1629 |
+
"203": {
|
| 1630 |
+
"content": "<u>",
|
| 1631 |
+
"lstrip": false,
|
| 1632 |
+
"normalized": false,
|
| 1633 |
+
"rstrip": false,
|
| 1634 |
+
"single_word": false,
|
| 1635 |
+
"special": false
|
| 1636 |
+
},
|
| 1637 |
+
"204": {
|
| 1638 |
+
"content": "<s>",
|
| 1639 |
+
"lstrip": false,
|
| 1640 |
+
"normalized": false,
|
| 1641 |
+
"rstrip": false,
|
| 1642 |
+
"single_word": false,
|
| 1643 |
+
"special": false
|
| 1644 |
+
},
|
| 1645 |
+
"205": {
|
| 1646 |
+
"content": "<sub>",
|
| 1647 |
+
"lstrip": false,
|
| 1648 |
+
"normalized": false,
|
| 1649 |
+
"rstrip": false,
|
| 1650 |
+
"single_word": false,
|
| 1651 |
+
"special": false
|
| 1652 |
+
},
|
| 1653 |
+
"206": {
|
| 1654 |
+
"content": "<sup>",
|
| 1655 |
+
"lstrip": false,
|
| 1656 |
+
"normalized": false,
|
| 1657 |
+
"rstrip": false,
|
| 1658 |
+
"single_word": false,
|
| 1659 |
+
"special": false
|
| 1660 |
+
},
|
| 1661 |
+
"207": {
|
| 1662 |
+
"content": "<code>",
|
| 1663 |
+
"lstrip": false,
|
| 1664 |
+
"normalized": false,
|
| 1665 |
+
"rstrip": false,
|
| 1666 |
+
"single_word": false,
|
| 1667 |
+
"special": false
|
| 1668 |
+
},
|
| 1669 |
+
"208": {
|
| 1670 |
+
"content": "</strong>",
|
| 1671 |
+
"lstrip": false,
|
| 1672 |
+
"normalized": false,
|
| 1673 |
+
"rstrip": false,
|
| 1674 |
+
"single_word": false,
|
| 1675 |
+
"special": false
|
| 1676 |
+
},
|
| 1677 |
+
"209": {
|
| 1678 |
+
"content": "</em>",
|
| 1679 |
+
"lstrip": false,
|
| 1680 |
+
"normalized": false,
|
| 1681 |
+
"rstrip": false,
|
| 1682 |
+
"single_word": false,
|
| 1683 |
+
"special": false
|
| 1684 |
+
},
|
| 1685 |
+
"210": {
|
| 1686 |
+
"content": "</b>",
|
| 1687 |
+
"lstrip": false,
|
| 1688 |
+
"normalized": false,
|
| 1689 |
+
"rstrip": false,
|
| 1690 |
+
"single_word": false,
|
| 1691 |
+
"special": false
|
| 1692 |
+
},
|
| 1693 |
+
"211": {
|
| 1694 |
+
"content": "</i>",
|
| 1695 |
+
"lstrip": false,
|
| 1696 |
+
"normalized": false,
|
| 1697 |
+
"rstrip": false,
|
| 1698 |
+
"single_word": false,
|
| 1699 |
+
"special": false
|
| 1700 |
+
},
|
| 1701 |
+
"212": {
|
| 1702 |
+
"content": "</u>",
|
| 1703 |
+
"lstrip": false,
|
| 1704 |
+
"normalized": false,
|
| 1705 |
+
"rstrip": false,
|
| 1706 |
+
"single_word": false,
|
| 1707 |
+
"special": false
|
| 1708 |
+
},
|
| 1709 |
+
"213": {
|
| 1710 |
+
"content": "</s>",
|
| 1711 |
+
"lstrip": false,
|
| 1712 |
+
"normalized": false,
|
| 1713 |
+
"rstrip": false,
|
| 1714 |
+
"single_word": false,
|
| 1715 |
+
"special": false
|
| 1716 |
+
},
|
| 1717 |
+
"214": {
|
| 1718 |
+
"content": "</sub>",
|
| 1719 |
+
"lstrip": false,
|
| 1720 |
+
"normalized": false,
|
| 1721 |
+
"rstrip": false,
|
| 1722 |
+
"single_word": false,
|
| 1723 |
+
"special": false
|
| 1724 |
+
},
|
| 1725 |
+
"215": {
|
| 1726 |
+
"content": "</sup>",
|
| 1727 |
+
"lstrip": false,
|
| 1728 |
+
"normalized": false,
|
| 1729 |
+
"rstrip": false,
|
| 1730 |
+
"single_word": false,
|
| 1731 |
+
"special": false
|
| 1732 |
+
},
|
| 1733 |
+
"216": {
|
| 1734 |
+
"content": "</code>",
|
| 1735 |
+
"lstrip": false,
|
| 1736 |
+
"normalized": false,
|
| 1737 |
+
"rstrip": false,
|
| 1738 |
+
"single_word": false,
|
| 1739 |
+
"special": false
|
| 1740 |
+
}
|
| 1741 |
+
},
|
| 1742 |
+
"additional_special_tokens": [
|
| 1743 |
+
"<start_of_turn>",
|
| 1744 |
+
"<end_of_turn>"
|
| 1745 |
+
],
|
| 1746 |
+
"bos_token": "<bos>",
|
| 1747 |
+
"clean_up_tokenization_spaces": false,
|
| 1748 |
+
"do_lower_case": true,
|
| 1749 |
+
"eos_token": "<eos>",
|
| 1750 |
+
"extra_special_tokens": {},
|
| 1751 |
+
"model_input_names": [
|
| 1752 |
+
"input_ids"
|
| 1753 |
+
],
|
| 1754 |
+
"model_max_length": 1000000000000000019884624838656,
|
| 1755 |
+
"pad_token": "<pad>",
|
| 1756 |
+
"padding_side": "right",
|
| 1757 |
+
"processor_class": "Fgclip2Processor",
|
| 1758 |
+
"sp_model_kwargs": {},
|
| 1759 |
+
"spaces_between_special_tokens": false,
|
| 1760 |
+
"tokenizer_class": "GemmaTokenizer",
|
| 1761 |
+
"unk_token": "<unk>",
|
| 1762 |
+
"use_default_system_prompt": false
|
| 1763 |
+
}
|