Run this model with HF Jobs
Run ChuuniZ/models_collection on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/ChuuniZ/models_collection. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/ChuuniZ/models_collection on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use ChuuniZ/models_collection with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use ChuuniZ/models_collection with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("ChuuniZ/models_collection", dtype=torch.bfloat16, device_map="cuda") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
Files changed (50)
- BiRefNet/README.mdAdded+8
- Joy_caption/README.mdAdded+79
- Joy_caption/app.pyAdded+536
- Joy_caption/cgrkzexw-599808/text_model/adapter_config.jsonAdded+34
- Joy_caption/cgrkzexw-599808/text_model/special_tokens_map.jsonAdded+23
- Joy_caption/cgrkzexw-599808/text_model/tokenizer.jsonAdded
- Joy_caption/cgrkzexw-599808/text_model/tokenizer_config.jsonAdded+2064
- Joy_caption/joycaption_alpha_two_cli_mod.ipynbAdded+46
- Joy_caption/requirements.txtAdded+10
- LLM/Florence-2-base-PromptGen-v2.0/README.mdAdded+71
- LLM/Florence-2-base-PromptGen-v2.0/added_tokens.jsonAdded+1026
- LLM/Florence-2-base-PromptGen-v2.0/config.jsonAdded+137
- LLM/Florence-2-base-PromptGen-v2.0/generation_config.jsonAdded+13
- LLM/Florence-2-base-PromptGen-v2.0/preprocessor_config.jsonAdded+33
- LLM/Florence-2-base-PromptGen-v2.0/special_tokens_map.jsonAdded
- LLM/Florence-2-base-PromptGen-v2.0/tokenizer.jsonAdded
- LLM/Florence-2-base-PromptGen-v2.0/tokenizer_config.jsonAdded
- LLM/Florence-2-base-PromptGen-v2.0/vocab.jsonAdded
- LLM/Florence-2-large-PromptGen-v2.0/configuration_florence2.pyAdded+340
- LLM/Florence-2-large-PromptGen-v2.0/merges.txtAdded
- LLM/Florence-2-large-PromptGen-v2.0/processing_florence2.pyAdded+1088
- LLM/Florence-2-large-PromptGen-v2.0/vocab.jsonAdded
- checkpoints/put_checkpoints_hereAdded
- ckpts/wget-logAdded+11
- clip/put_clip_or_text_encoder_models_hereAdded
- clip/siglip-so400m-patch14-384/README.mdAdded+112
- clip/siglip-so400m-patch14-384/config.jsonAdded+25
- clip/siglip-so400m-patch14-384/preprocessor_config.jsonAdded+23
- clip/siglip-so400m-patch14-384/special_tokens_map.jsonAdded+23
- clip/siglip-so400m-patch14-384/tokenizer.jsonAdded
- clip/siglip-so400m-patch14-384/tokenizer_config.jsonAdded+33
- clip_vision/put_clip_vision_models_hereAdded
- configs/anything_v3.yamlAdded+73
- configs/v1-inference.yamlAdded+70
- configs/v1-inference_clip_skip_2.yamlAdded+73
- configs/v1-inference_clip_skip_2_fp16.yamlAdded+74
- configs/v1-inference_fp16.yamlAdded+71
- configs/v1-inpainting-inference.yamlAdded+71
- configs/v2-inference-v.yamlAdded+68
- configs/v2-inference-v_fp32.yamlAdded+68
- configs/v2-inference.yamlAdded+67
- configs/v2-inference_fp32.yamlAdded+67
- configs/v2-inpainting-inference.yamlAdded+158
- controlnet/put_controlnets_and_t2i_hereAdded
- controlnet/sd1.5/README.mdAdded+3
- controlnet/sd1.5/control_v11e_sd15_ip2p.yamlAdded+79
- controlnet/sd1.5/control_v11e_sd15_shuffle.yamlAdded+80
- controlnet/sd1.5/control_v11f1e_sd15_tile.yamlAdded+79
- controlnet/sd1.5/control_v11f1p_sd15_depth.yamlAdded+79
- controlnet/sd1.5/control_v11p_sd15_canny.yamlAdded+79
12345678
---license: mit---
This is used to store the checkpoints of BiRefNet, please refer the following repo link1. Official implement https://github.com/zhengpeng7/birefnet2. ComfyUI BiRefNet node https://github.com/viperyl/ComfyUI-BiRefNet12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879---license: mitlanguage:- en---# Image Captioning App
This is a mod of [Wi-zz/joy-caption-pre-alpha](https://huggingface.co/Wi-zz/joy-caption-pre-alpha) and [fancyfeast/joy-caption-alpha-two](https://huggingface.co/spaces/fancyfeast/joy-caption-alpha-two). Thanks to [dominic1021](https://huggingface.co/dominic1021), [IceHibiki](https://huggingface.co/IceHibiki), [BullseyeMxP](https://huggingface.co/BullseyeMxP), [Wakeme](https://huggingface.co/Wakeme).
# Notice: I will contribute to Wi-zz after shaping the code.
## Overview
This application generates descriptive captions for images using advanced ML models. It processes single images or entire directories, leveraging CLIP and LLM models for accurate and contextual captions. It has NSFW captioning support with natural language. This is just an extension of the original author's efforts to improve performance. Their repo is located here: https://huggingface.co/spaces/fancyfeast/joy-caption-alpha-two.
## Features
- Single image and batch processing- Multiple directory support- Custom output directory- Adjustable batch size- Progress tracking
## Usage
| Command | Description ||---------|-------------|| `python app.py image.jpg` | Process a single image || `python app.py /path/to/directory` | Process all images in a directory || `python app.py /path/to/dir1 /path/to/dir2` | Process multiple directories || `python app.py /path/to/dir --output /path/to/output` | Specify output directory || `python app.py /path/to/dir --bs 8` | Set batch size (default: 4) |
## Technical Details
- **Models**: CLIP (vision), LLM (language), custom ImageAdapter- **Optimization**: CUDA-enabled GPU support- **Error Handling**: Skips problematic images in batch processing
## Requirements
- Python 3.x- PyTorch- Transformers library- PEFT library- CUDA-capable GPU (recommended)
## Installation
Windows
```bashgit clone https://huggingface.co/John6666/joy-caption-alpha-two-cli-modcd joy-caption-alpha-two-cli-modpython -m venv venv.\venv\Scripts\activate# Change as per https://pytorch.org/get-started/locally/pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121pip install -r requirements.txt```
Linux
```bashgit clone https://huggingface.co/John6666/joy-caption-alpha-two-cli-modcd joy-caption-alpha-two-cli-modpython3 -m venv venvsource venv/bin/activatepip3 install torch torchvision torchaudiopip3 install -r requirements.txt```
## Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
## License
This project is licensed under the [MIT License](LICENSE).123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536import torch
import torch.amp.autocast_mode
import os
import sys
import logging
import warnings
import argparse
from PIL import Image
from pathlib import Path
from tqdm import tqdm
from torch import nn
from transformers import AutoModel, AutoProcessor, AutoTokenizer, PreTrainedTokenizer, PreTrainedTokenizerFast, AutoModelForCausalLM
from typing import List, Union
import torchvision.transforms.functional as TVF
from peft import PeftModel
import gc
import sys
IS_COLAB = 'google.colab' in sys.modules
# Constants
IMAGE_EXTENSIONS = ('.jpg', '.jpeg', '.png', '.bmp', '.webp')
HF_TOKEN = os.environ.get("HF_TOKEN", None)
BASE_DIR = Path(__file__).resolve().parent # Define the base directory
CHECKPOINT_PATH = BASE_DIR / Path("cgrkzexw-599808")
CLIP_PATH = "google/siglip-so400m-patch14-384"
DEFAULT_MODEL_PATH = "unsloth/Meta-Llama-3.1-8B-bnb-4bit"
#DEFAULT_MODEL_PATH = "unsloth/Meta-Llama-3.1-8B-Instruct-bnb-4bit" # Default in Alpha One Two.
#DEFAULT_MODEL_PATH = "Orenguteng/Llama-3.1-8B-Lexi-Uncensored-V2" # Works better but full weight.
LORA_PATH = CHECKPOINT_PATH / "text_model"
CAPTION_TYPE_MAP = {
"Descriptive": [
"Write a descriptive caption for this image in a formal tone.",
"Write a descriptive caption for this image in a formal tone within {word_count} words.",
"Write a {length} descriptive caption for this image in a formal tone.",
],
"Descriptive (Informal)": [
"Write a descriptive caption for this image in a casual tone.",
"Write a descriptive caption for this image in a casual tone within {word_count} words.",
"Write a {length} descriptive caption for this image in a casual tone.",
],
"Training Prompt": [
"Write a stable diffusion prompt for this image.",
"Write a stable diffusion prompt for this image within {word_count} words.",
"Write a {length} stable diffusion prompt for this image.",
],
"MidJourney": [
"Write a MidJourney prompt for this image.",
"Write a MidJourney prompt for this image within {word_count} words.",
"Write a {length} MidJourney prompt for this image.",
],
"Booru tag list": [
"Write a list of Booru tags for this image.",
"Write a list of Booru tags for this image within {word_count} words.",
"Write a {length} list of Booru tags for this image.",
],
"Booru-like tag list": [
"Write a list of Booru-like tags for this image.",
"Write a list of Booru-like tags for this image within {word_count} words.",
"Write a {length} list of Booru-like tags for this image.",
],
"Art Critic": [
"Analyze this image like an art critic would with information about its composition, style, symbolism, the use of color, light, any artistic movement it might belong to, etc.",
"Analyze this image like an art critic would with information about its composition, style, symbolism, the use of color, light, any artistic movement it might belong to, etc. Keep it within {word_count} words.",
"Analyze this image like an art critic would with information about its composition, style, symbolism, the use of color, light, any artistic movement it might belong to, etc. Keep it {length}.",
],
"Product Listing": [
"Write a caption for this image as though it were a product listing.",
"Write a caption for this image as though it were a product listing. Keep it under {word_count} words.",
"Write a {length} caption for this image as though it were a product listing.",
],
"Social Media Post": [
"Write a caption for this image as if it were being used for a social media post.",
"Write a caption for this image as if it were being used for a social media post. Limit the caption to {word_count} words.",
"Write a {length} caption for this image as if it were being used for a social media post.",
],
}
class ImageAdapter(nn.Module):
def __init__(self, input_features: int, output_features: int, ln1: bool, pos_emb: bool, num_image_tokens: int, deep_extract: bool):
super().__init__()
self.deep_extract = deep_extract
if self.deep_extract:
input_features = input_features * 5
self.linear1 = nn.Linear(input_features, output_features)
self.activation = nn.GELU()
self.linear2 = nn.Linear(output_features, output_features)
self.ln1 = nn.Identity() if not ln1 else nn.LayerNorm(input_features)
self.pos_emb = None if not pos_emb else nn.Parameter(torch.zeros(num_image_tokens, input_features))
# Other tokens (<|image_start|>, <|image_end|>, <|eot_id|>)
self.other_tokens = nn.Embedding(3, output_features)
self.other_tokens.weight.data.normal_(mean=0.0, std=0.02) # Matches HF's implementation of llama3
def forward(self, vision_outputs: torch.Tensor):
if self.deep_extract:
x = torch.concat((
vision_outputs[-2],
vision_outputs[3],
vision_outputs[7],
vision_outputs[13],
vision_outputs[20],
), dim=-1)
assert len(x.shape) == 3, f"Expected 3, got {len(x.shape)}" # batch, tokens, features
assert x.shape[-1] == vision_outputs[-2].shape[-1] * 5, f"Expected {vision_outputs[-2].shape[-1] * 5}, got {x.shape[-1]}"
else:
x = vision_outputs[-2]
x = self.ln1(x)
if self.pos_emb is not None:
assert x.shape[-2:] == self.pos_emb.shape, f"Expected {self.pos_emb.shape}, got {x.shape[-2:]}"
x = x + self.pos_emb
x = self.linear1(x)
x = self.activation(x)
x = self.linear2(x)
# <|image_start|>, IMAGE, <|image_end|>
other_tokens = self.other_tokens(torch.tensor([0, 1], device=self.other_tokens.weight.device).expand(x.shape[0], -1))
assert other_tokens.shape == (x.shape[0], 2, x.shape[2]), f"Expected {(x.shape[0], 2, x.shape[2])}, got {other_tokens.shape}"
x = torch.cat((other_tokens[:, 0:1], x, other_tokens[:, 1:2]), dim=1)
return x
def get_eot_embedding(self):
return self.other_tokens(torch.tensor([2], device=self.other_tokens.weight.device)).squeeze(0)
# Global Variables
IS_NF4 = True
IS_LORA = True
MODEL_PATH = DEFAULT_MODEL_PATH
device = "cuda" if torch.cuda.is_available() else "cpu"
print(f"Running on {device}")
warnings.filterwarnings("ignore", category=UserWarning)
logging.getLogger("transformers").setLevel(logging.ERROR)
class ImageAdapter(nn.Module):
def __init__(self, input_features: int, output_features: int, ln1: bool, pos_emb: bool, num_image_tokens: int, deep_extract: bool):
super().__init__()
self.deep_extract = deep_extract
if self.deep_extract:
input_features = input_features * 5
self.linear1 = nn.Linear(input_features, output_features)
self.activation = nn.GELU()
self.linear2 = nn.Linear(output_features, output_features)
self.ln1 = nn.Identity() if not ln1 else nn.LayerNorm(input_features)
self.pos_emb = None if not pos_emb else nn.Parameter(torch.zeros(num_image_tokens, input_features))
# Mode token
#self.mode_token = nn.Embedding(n_modes, output_features)
#self.mode_token.weight.data.normal_(mean=0.0, std=0.02) # Matches HF's implementation of llama3
# Other tokens (<|image_start|>, <|image_end|>, <|eot_id|>)
self.other_tokens = nn.Embedding(3, output_features)
self.other_tokens.weight.data.normal_(mean=0.0, std=0.02) # Matches HF's implementation of llama3
def forward(self, vision_outputs: torch.Tensor):
if self.deep_extract:
x = torch.concat((
vision_outputs[-2],
vision_outputs[3],
vision_outputs[7],
vision_outputs[13],
vision_outputs[20],
), dim=-1)
assert len(x.shape) == 3, f"Expected 3, got {len(x.shape)}" # batch, tokens, features
assert x.shape[-1] == vision_outputs[-2].shape[-1] * 5, f"Expected {vision_outputs[-2].shape[-1] * 5}, got {x.shape[-1]}"
else:
x = vision_outputs[-2]
x = self.ln1(x)
if self.pos_emb is not None:
assert x.shape[-2:] == self.pos_emb.shape, f"Expected {self.pos_emb.shape}, got {x.shape[-2:]}"
x = x + self.pos_emb
x = self.linear1(x)
x = self.activation(x)
x = self.linear2(x)
# Mode token
#mode_token = self.mode_token(mode)
#assert mode_token.shape == (x.shape[0], mode_token.shape[1], x.shape[2]), f"Expected {(x.shape[0], 1, x.shape[2])}, got {mode_token.shape}"
#x = torch.cat((x, mode_token), dim=1)
# <|image_start|>, IMAGE, <|image_end|>
other_tokens = self.other_tokens(torch.tensor([0, 1], device=self.other_tokens.weight.device).expand(x.shape[0], -1))
assert other_tokens.shape == (x.shape[0], 2, x.shape[2]), f"Expected {(x.shape[0], 2, x.shape[2])}, got {other_tokens.shape}"
x = torch.cat((other_tokens[:, 0:1], x, other_tokens[:, 1:2]), dim=1)
return x
def get_eot_embedding(self):
return self.other_tokens(torch.tensor([2], device=self.other_tokens.weight.device)).squeeze(0)
def load_models():
global MODEL_PATH, IS_NF4, IS_LORA
try:
if IS_NF4:
from transformers import BitsAndBytesConfig
nf4_config = BitsAndBytesConfig(load_in_4bit=True, bnb_4bit_quant_type="nf4",
bnb_4bit_use_double_quant=True, bnb_4bit_compute_dtype=torch.bfloat16)
print("Loading in NF4")
print("Loading CLIP 📎")
clip_processor = AutoProcessor.from_pretrained(CLIP_PATH)
clip_model = AutoModel.from_pretrained(CLIP_PATH).vision_model
assert (CHECKPOINT_PATH / "clip_model.pt").exists()
if (CHECKPOINT_PATH / "clip_model.pt").exists():
print("Loading VLM's custom vision model 📎")
checkpoint = torch.load(CHECKPOINT_PATH / "clip_model.pt", map_location='cpu', weights_only=False)
checkpoint = {k.replace("_orig_mod.module.", ""): v for k, v in checkpoint.items()}
clip_model.load_state_dict(checkpoint)
del checkpoint
clip_model.eval().requires_grad_(False).to(device)
print("Loading tokenizer 🪙")
tokenizer = AutoTokenizer.from_pretrained(CHECKPOINT_PATH / "text_model", use_fast=True)
assert isinstance(tokenizer, (PreTrainedTokenizer, PreTrainedTokenizerFast)), f"Tokenizer is of type {type(tokenizer)}"
print(f"Loading LLM: {MODEL_PATH} 🤖")
text_model = AutoModelForCausalLM.from_pretrained(MODEL_PATH, quantization_config=nf4_config).eval()
if False and IS_LORA and LORA_PATH.exists(): # omitted
print("Loading VLM's custom text model 🤖")
text_model = PeftModel.from_pretrained(model=text_model, model_id=LORA_PATH, quantization_config=nf4_config)
text_model = text_model.merge_and_unload(safe_merge=True) # to avoid PEFT bug https://github.com/huggingface/transformers/issues/28515
else: print("VLM's custom text model isn't loaded 🤖")
print("Loading image adapter 🖼️")
image_adapter = ImageAdapter(clip_model.config.hidden_size, text_model.config.hidden_size, False, False, 38, False).eval().to("cpu")
image_adapter.load_state_dict(torch.load(CHECKPOINT_PATH / "image_adapter.pt", map_location="cpu", weights_only=False))
image_adapter.eval().to(device)
else:
print("Loading in bfloat16")
print("Loading CLIP 📎")
clip_processor = AutoProcessor.from_pretrained(CLIP_PATH)
clip_model = AutoModel.from_pretrained(CLIP_PATH).vision_model
if (CHECKPOINT_PATH / "clip_model.pt").exists():
print("Loading VLM's custom vision model 📎")
checkpoint = torch.load(CHECKPOINT_PATH / "clip_model.pt", map_location='cpu', weights_only=False)
checkpoint = {k.replace("_orig_mod.module.", ""): v for k, v in checkpoint.items()}
clip_model.load_state_dict(checkpoint)
del checkpoint
clip_model.eval().requires_grad_(False).to(device)
print("Loading tokenizer 🪙")
tokenizer = AutoTokenizer.from_pretrained(CHECKPOINT_PATH / "text_model", use_fast=True)
assert isinstance(tokenizer, (PreTrainedTokenizer, PreTrainedTokenizerFast)), f"Tokenizer is of type {type(tokenizer)}"
print(f"Loading LLM: {MODEL_PATH} 🤖")
text_model = AutoModelForCausalLM.from_pretrained(MODEL_PATH, device_map="auto", torch_dtype=torch.bfloat16).eval() # device_map="auto" may cause LoRA issue
if IS_LORA and LORA_PATH.exists():
print("Loading VLM's custom text model 🤖")
text_model = PeftModel.from_pretrained(model=text_model, model_id=LORA_PATH, device_map=device)
text_model = text_model.merge_and_unload(safe_merge=True) # to avoid PEFT bug https://github.com/huggingface/transformers/issues/28515
else: print("VLM's custom text model isn't loaded 🤖")
print("Loading image adapter 🖼️")
image_adapter = ImageAdapter(clip_model.config.hidden_size, text_model.config.hidden_size, False, False, 38, False).eval().to("cpu")
image_adapter.load_state_dict(torch.load(CHECKPOINT_PATH / "image_adapter.pt", map_location="cpu", weights_only=False))
except Exception as e:
print(f"Error loading models: {e}")
sys.exit(1)
finally:
torch.cuda.empty_cache()
gc.collect()
return clip_processor, clip_model, tokenizer, text_model, image_adapter
@torch.inference_mode()
def stream_chat(input_images: List[Image.Image], caption_type: str, caption_length: Union[str, int], extra_options: list[str], name_input: str, custom_prompt: str,
max_new_tokens: int, top_p: float, temperature: float, batch_size: int, pbar: tqdm, models: tuple) -> List[str]:
global MODEL_PATH
clip_processor, clip_model, tokenizer, text_model, image_adapter = models
torch.cuda.empty_cache()
all_captions = []
# 'any' means no length specified
length = None if caption_length == "any" else caption_length
if isinstance(length, str):
try:
length = int(length)
except ValueError:
pass
# Build prompt
if length is None:
map_idx = 0
elif isinstance(length, int):
map_idx = 1
elif isinstance(length, str):
map_idx = 2
else:
raise ValueError(f"Invalid caption length: {length}")
prompt_str = CAPTION_TYPE_MAP[caption_type][map_idx]
# Add extra options
if len(extra_options) > 0:
prompt_str += " " + " ".join(extra_options)
# Add name, length, word_count
prompt_str = prompt_str.format(name=name_input, length=caption_length, word_count=caption_length)
if custom_prompt.strip() != "":
prompt_str = custom_prompt.strip()
# For debugging
print(f"Prompt: {prompt_str}")
for i in range(0, len(input_images), batch_size):
batch = input_images[i:i+batch_size]
for input_image in input_images:
try:
# Preprocess image
# NOTE: I found the default processor for so400M to have worse results than just using PIL directly
#image = clip_processor(images=input_image, return_tensors='pt').pixel_values
image = input_image.resize((384, 384), Image.LANCZOS)
pixel_values = TVF.pil_to_tensor(image).unsqueeze(0) / 255.0
pixel_values = TVF.normalize(pixel_values, [0.5], [0.5])
pixel_values = pixel_values.to(device)
except ValueError as e:
print(f"Error processing image: {e}")
print("Skipping this image and continuing...")
continue
# Embed image
# This results in Batch x Image Tokens x Features
with torch.amp.autocast_mode.autocast(device, enabled=True):
vision_outputs = clip_model(pixel_values=pixel_values, output_hidden_states=True)
image_features = vision_outputs.hidden_states
embedded_images = image_adapter(image_features).to(device)
# Build the conversation
convo = [
{
"role": "system",
"content": "You are a helpful image captioner.",
},
{
"role": "user",
"content": prompt_str,
},
]
# Format the conversation
convo_string = tokenizer.apply_chat_template(convo, tokenize = False, add_generation_prompt = True)
assert isinstance(convo_string, str)
# Tokenize the conversation
# prompt_str is tokenized separately so we can do the calculations below
convo_tokens = tokenizer.encode(convo_string, return_tensors="pt", add_special_tokens=False, truncation=False)
prompt_tokens = tokenizer.encode(prompt_str, return_tensors="pt", add_special_tokens=False, truncation=False)
assert isinstance(convo_tokens, torch.Tensor) and isinstance(prompt_tokens, torch.Tensor)
convo_tokens = convo_tokens.squeeze(0) # Squeeze just to make the following easier
prompt_tokens = prompt_tokens.squeeze(0)
# Calculate where to inject the image
eot_id_indices = (convo_tokens == tokenizer.convert_tokens_to_ids("<|eot_id|>")).nonzero(as_tuple=True)[0].tolist()
assert len(eot_id_indices) == 2, f"Expected 2 <|eot_id|> tokens, got {len(eot_id_indices)}"
preamble_len = eot_id_indices[1] - prompt_tokens.shape[0] # Number of tokens before the prompt
# Embed the tokens
convo_embeds = text_model.model.embed_tokens(convo_tokens.unsqueeze(0).to(device))
# Construct the input
input_embeds = torch.cat([
convo_embeds[:, :preamble_len], # Part before the prompt
embedded_images.to(dtype=convo_embeds.dtype), # Image
convo_embeds[:, preamble_len:], # The prompt and anything after it
], dim=1).to(device)
input_ids = torch.cat([
convo_tokens[:preamble_len].unsqueeze(0),
torch.zeros((1, embedded_images.shape[1]), dtype=torch.long), # Dummy tokens for the image (TODO: Should probably use a special token here so as not to confuse any generation algorithms that might be inspecting the input)
convo_tokens[preamble_len:].unsqueeze(0),
], dim=1).to(device)
attention_mask = torch.ones_like(input_ids)
# Debugging
#print(f"Input to model: {repr(tokenizer.decode(input_ids[0]))}")
generate_ids = text_model.generate(input_ids=input_ids, inputs_embeds=input_embeds, attention_mask=attention_mask, do_sample=True,
suppress_tokens=None, max_new_tokens=max_new_tokens, top_p=top_p, temperature=temperature)
# Trim off the prompt
generate_ids = generate_ids[:, input_ids.shape[1]:]
if generate_ids[0][-1] == tokenizer.eos_token_id or generate_ids[0][-1] == tokenizer.convert_tokens_to_ids("<|eot_id|>"):
generate_ids = generate_ids[:, :-1]
caption = tokenizer.batch_decode(generate_ids, skip_special_tokens=False, clean_up_tokenization_spaces=False)[0]
all_captions.append(caption.strip())
if pbar:
pbar.update(len(batch))
return all_captions
def process_directory(input_dir: Path, output_dir: Path, caption_type: str, caption_length: Union[str, int], extra_options: list[str], name_input: str, custom_prompt: str,
max_new_tokens: int, top_p: float, temperature: float, batch_size: int, models: tuple):
output_dir.mkdir(parents=True, exist_ok=True)
image_files = [f for f in input_dir.iterdir() if f.suffix.lower() in IMAGE_EXTENSIONS]
images_to_process = [f for f in image_files if not (output_dir / f"{f.stem}.txt").exists()]
if not images_to_process:
print("No new images to process.")
return
with tqdm(total=len(images_to_process), desc="Processing images", unit="image") as pbar:
for i in range(0, len(images_to_process), batch_size):
batch_files = images_to_process[i:i+batch_size]
batch_images = [Image.open(f).convert('RGB') for f in batch_files]
captions = stream_chat(batch_images, caption_type, caption_length, extra_options, name_input, custom_prompt,
max_new_tokens, top_p, temperature, batch_size, pbar, models)
for file, caption in zip(batch_files, captions):
with open(output_dir / f"{file.stem}.txt", 'w', encoding='utf-8') as f:
f.write(caption)
for img in batch_images:
img.close()
def parse_arguments():
parser = argparse.ArgumentParser(description="Process images and generate captions.")
parser.add_argument("input", nargs='+', help="Input image file or directory (or multiple directories)")
parser.add_argument("--output", help="Output directory (optional)")
parser.add_argument("--bs", type=int, default=4, help="Batch size (default: 4)")
parser.add_argument("--type", type=str, default="Descriptive",
choices=["Descriptive", "Descriptive (Informal)", "Training Prompt", "MidJourney", "Booru tag list", "Booru-like tag list", "Art Critic", "Product Listing", "Social Media Post"],
help='Caption Type (default: "Descriptive")')
parser.add_argument("--len", default="long",
choices=["any", "very short", "short", "medium-length", "long", "very long"] + [str(i) for i in range(20, 261, 10)],
help='Caption Length (default: "long")')
parser.add_argument("--extra", default=[], type=list[str], help='Extra Options',
choices=[
"If there is a person/character in the image you must refer to them as {name}.",
"Do NOT include information about people/characters that cannot be changed (like ethnicity, gender, etc), but do still include changeable attributes (like hair style).",
"Include information about lighting.",
"Include information about camera angle.",
"Include information about whether there is a watermark or not.",
"Include information about whether there are JPEG artifacts or not.",
"If it is a photo you MUST include information about what camera was likely used and details such as aperture, shutter speed, ISO, etc.",
"Do NOT include anything sexual; keep it PG.",
"Do NOT mention the image's resolution.",
"You MUST include information about the subjective aesthetic quality of the image from low to very high.",
"Include information on the image's composition style, such as leading lines, rule of thirds, or symmetry.",
"Do NOT mention any text that is in the image.",
"Specify the depth of field and whether the background is in focus or blurred.",
"If applicable, mention the likely use of artificial or natural lighting sources.",
"Do NOT use any ambiguous language.",
"Include whether the image is sfw, suggestive, or nsfw.",
"ONLY describe the most important elements of the image."
])
parser.add_argument("--name", type=str, default="", help='Person/Character Name (if applicable)')
parser.add_argument("--prompt", type=str, default="", help='Custom Prompt (optional, will override all other settings)')
parser.add_argument("--model", type=str, default=DEFAULT_MODEL_PATH,
help='Huggingface LLM repo (default: "unsloth/Meta-Llama-3.1-8B-bnb-4bit")')
parser.add_argument("--bf16", action="store_true", default=False, help="Use bfloat16 (default: NF4)")
parser.add_argument("--nolora", action="store_true", default=False, help="Disable VLM's custom text model (default: Enable)")
parser.add_argument("--tokens", type=int, default=300, help="Max tokens (default: 300)")
parser.add_argument("--topp", type=float, default=0.9, help="Top-P (default: 0.9)")
parser.add_argument("--temp", type=float, default=0.6, help="Temperature (default: 0.6)")
return parser.parse_args()
def is_valid_repo(repo_id):
from huggingface_hub import HfApi
import re
try:
if not re.fullmatch(r'^[^/,\s\"\']+/[^/,\s\"\']+$', repo_id): return False
api = HfApi()
if api.repo_exists(repo_id=repo_id): return True
else: return False
except Exception as e:
print(f"Failed to connect {repo_id}. {e}")
return False
def main():
global MODEL_PATH, IS_NF4, IS_LORA
args = parse_arguments()
input_paths = [Path(input_path) for input_path in args.input]
batch_size = args.bs
caption_type = args.type
caption_length = args.len
extra_options = args.extra
name_input = args.name
custom_prompt = args.prompt
max_new_tokens = args.tokens
top_p = args.topp
temperature = args.temp
IS_NF4 = False if args.bf16 else True
IS_LORA = False if args.nolora else True
if is_valid_repo(args.model): MODEL_PATH = args.model
else: sys.exit(1)
models = load_models()
for input_path in input_paths:
if input_path.is_file() and input_path.suffix.lower() in IMAGE_EXTENSIONS:
output_path = input_path.with_suffix('.txt')
print(f"Processing single image 🎞️: {input_path.name}")
with tqdm(total=1, desc="Processing image", unit="image") as pbar:
captions = stream_chat([Image.open(input_path).convert('RGB')], caption_type, caption_length, extra_options, name_input, custom_prompt,
max_new_tokens, top_p, temperature, 1, pbar, models)
with open(output_path, 'w', encoding='utf-8') as f:
f.write(captions[0])
print(f"Output saved to {output_path}")
elif input_path.is_dir():
output_path = Path(args.output) if args.output else input_path
print(f"Processing directory 📁: {input_path}")
print(f"Output directory 📦: {output_path}")
print(f"Batch size 🗄️: {batch_size}")
process_directory(input_path, output_path, caption_type, caption_length, extra_options, name_input, custom_prompt,
max_new_tokens, top_p, temperature, batch_size, models)
else:
print(f"Invalid input: {input_path}")
print("Skipping...")
if not input_paths:
print("Usage:")
print("For single image: python app.py [image_file] [--bs batch_size]")
print("For directory (same input/output): python app.py [directory] [--bs batch_size]")
print("For directory (separate input/output): python app.py [directory] --output [output_directory] [--bs batch_size]")
print("For multiple directories: python app.py [directory1] [directory2] ... [--output output_directory] [--bs batch_size]")
sys.exit(1)
if __name__ == "__main__":
main()12345678910111213141516171819202122232425262728293031323334{
"alpha_pattern": {},
"auto_mapping": null,
"base_model_name_or_path": "unsloth/Meta-Llama-3.1-8B-Instruct",
"bias": "none",
"fan_in_fan_out": false,
"inference_mode": true,
"init_lora_weights": true,
"layer_replication": null,
"layers_pattern": null,
"layers_to_transform": null,
"loftq_config": {},
"lora_alpha": 16,
"lora_dropout": 0,
"megatron_config": null,
"megatron_core": "megatron.core",
"modules_to_save": null,
"peft_type": "LORA",
"r": 64,
"rank_pattern": {},
"revision": null,
"target_modules": [
"q_proj",
"v_proj",
"gate_proj",
"down_proj",
"o_proj",
"k_proj",
"up_proj"
],
"task_type": "CAUSAL_LM",
"use_dora": false,
"use_rslora": false
}1234567891011121314151617181920212223{
"bos_token": {
"content": "<|begin_of_text|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false
},
"eos_token": {
"content": "<|eot_id|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false
},
"pad_token": {
"content": "<|finetune_right_pad_id|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false
}
}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064{
"added_tokens_decoder": {
"128000": {
"content": "<|begin_of_text|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128001": {
"content": "<|end_of_text|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128002": {
"content": "<|reserved_special_token_0|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128003": {
"content": "<|reserved_special_token_1|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128004": {
"content": "<|finetune_right_pad_id|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128005": {
"content": "<|reserved_special_token_2|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128006": {
"content": "<|start_header_id|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128007": {
"content": "<|end_header_id|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128008": {
"content": "<|eom_id|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128009": {
"content": "<|eot_id|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128010": {
"content": "<|python_tag|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128011": {
"content": "<|reserved_special_token_3|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128012": {
"content": "<|reserved_special_token_4|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128013": {
"content": "<|reserved_special_token_5|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128014": {
"content": "<|reserved_special_token_6|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128015": {
"content": "<|reserved_special_token_7|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128016": {
"content": "<|reserved_special_token_8|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128017": {
"content": "<|reserved_special_token_9|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128018": {
"content": "<|reserved_special_token_10|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128019": {
"content": "<|reserved_special_token_11|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128020": {
"content": "<|reserved_special_token_12|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128021": {
"content": "<|reserved_special_token_13|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128022": {
"content": "<|reserved_special_token_14|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128023": {
"content": "<|reserved_special_token_15|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128024": {
"content": "<|reserved_special_token_16|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128025": {
"content": "<|reserved_special_token_17|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128026": {
"content": "<|reserved_special_token_18|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128027": {
"content": "<|reserved_special_token_19|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128028": {
"content": "<|reserved_special_token_20|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128029": {
"content": "<|reserved_special_token_21|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128030": {
"content": "<|reserved_special_token_22|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128031": {
"content": "<|reserved_special_token_23|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128032": {
"content": "<|reserved_special_token_24|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128033": {
"content": "<|reserved_special_token_25|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128034": {
"content": "<|reserved_special_token_26|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128035": {
"content": "<|reserved_special_token_27|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128036": {
"content": "<|reserved_special_token_28|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128037": {
"content": "<|reserved_special_token_29|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128038": {
"content": "<|reserved_special_token_30|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128039": {
"content": "<|reserved_special_token_31|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128040": {
"content": "<|reserved_special_token_32|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128041": {
"content": "<|reserved_special_token_33|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128042": {
"content": "<|reserved_special_token_34|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128043": {
"content": "<|reserved_special_token_35|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128044": {
"content": "<|reserved_special_token_36|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128045": {
"content": "<|reserved_special_token_37|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128046": {
"content": "<|reserved_special_token_38|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128047": {
"content": "<|reserved_special_token_39|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128048": {
"content": "<|reserved_special_token_40|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128049": {
"content": "<|reserved_special_token_41|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128050": {
"content": "<|reserved_special_token_42|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128051": {
"content": "<|reserved_special_token_43|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128052": {
"content": "<|reserved_special_token_44|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128053": {
"content": "<|reserved_special_token_45|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128054": {
"content": "<|reserved_special_token_46|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128055": {
"content": "<|reserved_special_token_47|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128056": {
"content": "<|reserved_special_token_48|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128057": {
"content": "<|reserved_special_token_49|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128058": {
"content": "<|reserved_special_token_50|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128059": {
"content": "<|reserved_special_token_51|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128060": {
"content": "<|reserved_special_token_52|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128061": {
"content": "<|reserved_special_token_53|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128062": {
"content": "<|reserved_special_token_54|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128063": {
"content": "<|reserved_special_token_55|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128064": {
"content": "<|reserved_special_token_56|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128065": {
"content": "<|reserved_special_token_57|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128066": {
"content": "<|reserved_special_token_58|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128067": {
"content": "<|reserved_special_token_59|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128068": {
"content": "<|reserved_special_token_60|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128069": {
"content": "<|reserved_special_token_61|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128070": {
"content": "<|reserved_special_token_62|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128071": {
"content": "<|reserved_special_token_63|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128072": {
"content": "<|reserved_special_token_64|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128073": {
"content": "<|reserved_special_token_65|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128074": {
"content": "<|reserved_special_token_66|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128075": {
"content": "<|reserved_special_token_67|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128076": {
"content": "<|reserved_special_token_68|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128077": {
"content": "<|reserved_special_token_69|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128078": {
"content": "<|reserved_special_token_70|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128079": {
"content": "<|reserved_special_token_71|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128080": {
"content": "<|reserved_special_token_72|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128081": {
"content": "<|reserved_special_token_73|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128082": {
"content": "<|reserved_special_token_74|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128083": {
"content": "<|reserved_special_token_75|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128084": {
"content": "<|reserved_special_token_76|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128085": {
"content": "<|reserved_special_token_77|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128086": {
"content": "<|reserved_special_token_78|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128087": {
"content": "<|reserved_special_token_79|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128088": {
"content": "<|reserved_special_token_80|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128089": {
"content": "<|reserved_special_token_81|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128090": {
"content": "<|reserved_special_token_82|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128091": {
"content": "<|reserved_special_token_83|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128092": {
"content": "<|reserved_special_token_84|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128093": {
"content": "<|reserved_special_token_85|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128094": {
"content": "<|reserved_special_token_86|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128095": {
"content": "<|reserved_special_token_87|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128096": {
"content": "<|reserved_special_token_88|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128097": {
"content": "<|reserved_special_token_89|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128098": {
"content": "<|reserved_special_token_90|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128099": {
"content": "<|reserved_special_token_91|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128100": {
"content": "<|reserved_special_token_92|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128101": {
"content": "<|reserved_special_token_93|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128102": {
"content": "<|reserved_special_token_94|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128103": {
"content": "<|reserved_special_token_95|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128104": {
"content": "<|reserved_special_token_96|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128105": {
"content": "<|reserved_special_token_97|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128106": {
"content": "<|reserved_special_token_98|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128107": {
"content": "<|reserved_special_token_99|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128108": {
"content": "<|reserved_special_token_100|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128109": {
"content": "<|reserved_special_token_101|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128110": {
"content": "<|reserved_special_token_102|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128111": {
"content": "<|reserved_special_token_103|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128112": {
"content": "<|reserved_special_token_104|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128113": {
"content": "<|reserved_special_token_105|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128114": {
"content": "<|reserved_special_token_106|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128115": {
"content": "<|reserved_special_token_107|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128116": {
"content": "<|reserved_special_token_108|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128117": {
"content": "<|reserved_special_token_109|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128118": {
"content": "<|reserved_special_token_110|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128119": {
"content": "<|reserved_special_token_111|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128120": {
"content": "<|reserved_special_token_112|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128121": {
"content": "<|reserved_special_token_113|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128122": {
"content": "<|reserved_special_token_114|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128123": {
"content": "<|reserved_special_token_115|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128124": {
"content": "<|reserved_special_token_116|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128125": {
"content": "<|reserved_special_token_117|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128126": {
"content": "<|reserved_special_token_118|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128127": {
"content": "<|reserved_special_token_119|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128128": {
"content": "<|reserved_special_token_120|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128129": {
"content": "<|reserved_special_token_121|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128130": {
"content": "<|reserved_special_token_122|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128131": {
"content": "<|reserved_special_token_123|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128132": {
"content": "<|reserved_special_token_124|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128133": {
"content": "<|reserved_special_token_125|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128134": {
"content": "<|reserved_special_token_126|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128135": {
"content": "<|reserved_special_token_127|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128136": {
"content": "<|reserved_special_token_128|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128137": {
"content": "<|reserved_special_token_129|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128138": {
"content": "<|reserved_special_token_130|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128139": {
"content": "<|reserved_special_token_131|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128140": {
"content": "<|reserved_special_token_132|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128141": {
"content": "<|reserved_special_token_133|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128142": {
"content": "<|reserved_special_token_134|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128143": {
"content": "<|reserved_special_token_135|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128144": {
"content": "<|reserved_special_token_136|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128145": {
"content": "<|reserved_special_token_137|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128146": {
"content": "<|reserved_special_token_138|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128147": {
"content": "<|reserved_special_token_139|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128148": {
"content": "<|reserved_special_token_140|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128149": {
"content": "<|reserved_special_token_141|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128150": {
"content": "<|reserved_special_token_142|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128151": {
"content": "<|reserved_special_token_143|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128152": {
"content": "<|reserved_special_token_144|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128153": {
"content": "<|reserved_special_token_145|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128154": {
"content": "<|reserved_special_token_146|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128155": {
"content": "<|reserved_special_token_147|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128156": {
"content": "<|reserved_special_token_148|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128157": {
"content": "<|reserved_special_token_149|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128158": {
"content": "<|reserved_special_token_150|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128159": {
"content": "<|reserved_special_token_151|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128160": {
"content": "<|reserved_special_token_152|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128161": {
"content": "<|reserved_special_token_153|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128162": {
"content": "<|reserved_special_token_154|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128163": {
"content": "<|reserved_special_token_155|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128164": {
"content": "<|reserved_special_token_156|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128165": {
"content": "<|reserved_special_token_157|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128166": {
"content": "<|reserved_special_token_158|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128167": {
"content": "<|reserved_special_token_159|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128168": {
"content": "<|reserved_special_token_160|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128169": {
"content": "<|reserved_special_token_161|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128170": {
"content": "<|reserved_special_token_162|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128171": {
"content": "<|reserved_special_token_163|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128172": {
"content": "<|reserved_special_token_164|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128173": {
"content": "<|reserved_special_token_165|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128174": {
"content": "<|reserved_special_token_166|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128175": {
"content": "<|reserved_special_token_167|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128176": {
"content": "<|reserved_special_token_168|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128177": {
"content": "<|reserved_special_token_169|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128178": {
"content": "<|reserved_special_token_170|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128179": {
"content": "<|reserved_special_token_171|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128180": {
"content": "<|reserved_special_token_172|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128181": {
"content": "<|reserved_special_token_173|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128182": {
"content": "<|reserved_special_token_174|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128183": {
"content": "<|reserved_special_token_175|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128184": {
"content": "<|reserved_special_token_176|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128185": {
"content": "<|reserved_special_token_177|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128186": {
"content": "<|reserved_special_token_178|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128187": {
"content": "<|reserved_special_token_179|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128188": {
"content": "<|reserved_special_token_180|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128189": {
"content": "<|reserved_special_token_181|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128190": {
"content": "<|reserved_special_token_182|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128191": {
"content": "<|reserved_special_token_183|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128192": {
"content": "<|reserved_special_token_184|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128193": {
"content": "<|reserved_special_token_185|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128194": {
"content": "<|reserved_special_token_186|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128195": {
"content": "<|reserved_special_token_187|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128196": {
"content": "<|reserved_special_token_188|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128197": {
"content": "<|reserved_special_token_189|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128198": {
"content": "<|reserved_special_token_190|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128199": {
"content": "<|reserved_special_token_191|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128200": {
"content": "<|reserved_special_token_192|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128201": {
"content": "<|reserved_special_token_193|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128202": {
"content": "<|reserved_special_token_194|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128203": {
"content": "<|reserved_special_token_195|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128204": {
"content": "<|reserved_special_token_196|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128205": {
"content": "<|reserved_special_token_197|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128206": {
"content": "<|reserved_special_token_198|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128207": {
"content": "<|reserved_special_token_199|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128208": {
"content": "<|reserved_special_token_200|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128209": {
"content": "<|reserved_special_token_201|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128210": {
"content": "<|reserved_special_token_202|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128211": {
"content": "<|reserved_special_token_203|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128212": {
"content": "<|reserved_special_token_204|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128213": {
"content": "<|reserved_special_token_205|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128214": {
"content": "<|reserved_special_token_206|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128215": {
"content": "<|reserved_special_token_207|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128216": {
"content": "<|reserved_special_token_208|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128217": {
"content": "<|reserved_special_token_209|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128218": {
"content": "<|reserved_special_token_210|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128219": {
"content": "<|reserved_special_token_211|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128220": {
"content": "<|reserved_special_token_212|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128221": {
"content": "<|reserved_special_token_213|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128222": {
"content": "<|reserved_special_token_214|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128223": {
"content": "<|reserved_special_token_215|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128224": {
"content": "<|reserved_special_token_216|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128225": {
"content": "<|reserved_special_token_217|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128226": {
"content": "<|reserved_special_token_218|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128227": {
"content": "<|reserved_special_token_219|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128228": {
"content": "<|reserved_special_token_220|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128229": {
"content": "<|reserved_special_token_221|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128230": {
"content": "<|reserved_special_token_222|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128231": {
"content": "<|reserved_special_token_223|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128232": {
"content": "<|reserved_special_token_224|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128233": {
"content": "<|reserved_special_token_225|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128234": {
"content": "<|reserved_special_token_226|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128235": {
"content": "<|reserved_special_token_227|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128236": {
"content": "<|reserved_special_token_228|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128237": {
"content": "<|reserved_special_token_229|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128238": {
"content": "<|reserved_special_token_230|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128239": {
"content": "<|reserved_special_token_231|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128240": {
"content": "<|reserved_special_token_232|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128241": {
"content": "<|reserved_special_token_233|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128242": {
"content": "<|reserved_special_token_234|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128243": {
"content": "<|reserved_special_token_235|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128244": {
"content": "<|reserved_special_token_236|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128245": {
"content": "<|reserved_special_token_237|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128246": {
"content": "<|reserved_special_token_238|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128247": {
"content": "<|reserved_special_token_239|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128248": {
"content": "<|reserved_special_token_240|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128249": {
"content": "<|reserved_special_token_241|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128250": {
"content": "<|reserved_special_token_242|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128251": {
"content": "<|reserved_special_token_243|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128252": {
"content": "<|reserved_special_token_244|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128253": {
"content": "<|reserved_special_token_245|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128254": {
"content": "<|reserved_special_token_246|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128255": {
"content": "<|reserved_special_token_247|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
}
},
"bos_token": "<|begin_of_text|>",
"chat_template": "{{- bos_token }}\n{%- if custom_tools is defined %}\n {%- set tools = custom_tools %}\n{%- endif %}\n{%- if not tools_in_user_message is defined %}\n {%- set tools_in_user_message = true %}\n{%- endif %}\n{%- if not date_string is defined %}\n {%- set date_string = \"26 July 2024\" %}\n{%- endif %}\n{%- if not tools is defined %}\n {%- set tools = none %}\n{%- endif %}\n\n{#- This block extracts the system message, so we can slot it into the right place. #}\n{%- if messages[0]['role'] == 'system' %}\n {%- set system_message = messages[0]['content'] %}\n {%- set messages = messages[1:] %}\n{%- else %}\n {%- set system_message = \"\" %}\n{%- endif %}\n\n{#- System message + builtin tools #}\n{{- \"<|start_header_id|>system<|end_header_id|>\n\n\" }}\n{%- if builtin_tools is defined or tools is not none %}\n {{- \"Environment: ipython\n\" }}\n{%- endif %}\n{%- if builtin_tools is defined %}\n {{- \"Tools: \" + builtin_tools | reject('equalto', 'code_interpreter') | join(\", \") + \"\n\n\"}}\n{%- endif %}\n{{- \"Cutting Knowledge Date: December 2023\n\" }}\n{{- \"Today Date: \" + date_string + \"\n\n\" }}\n{%- if tools is not none and not tools_in_user_message %}\n {{- \"You have access to the following functions. To call a function, please respond with JSON for a function call.\" }}\n {{- 'Respond in the format {\"name\": function name, \"parameters\": dictionary of argument name and its value}.' }}\n {{- \"Do not use variables.\n\n\" }}\n {%- for t in tools %}\n {{- t | tojson(indent=4) }}\n {{- \"\n\n\" }}\n {%- endfor %}\n{%- endif %}\n{{- system_message }}\n{{- \"<|eot_id|>\" }}\n\n{#- Custom tools are passed in a user message with some extra guidance #}\n{%- if tools_in_user_message and not tools is none %}\n {#- Extract the first user message so we can plug it in here #}\n {%- if messages | length != 0 %}\n {%- set first_user_message = messages[0]['content'] %}\n {%- set messages = messages[1:] %}\n {%- else %}\n {{- raise_exception(\"Cannot put tools in the first user message when there's no first user message!\") }}\n{%- endif %}\n {{- '<|start_header_id|>user<|end_header_id|>\n\n' -}}\n {{- \"Given the following functions, please respond with a JSON for a function call \" }}\n {{- \"with its proper arguments that best answers the given prompt.\n\n\" }}\n {{- 'Respond in the format {\"name\": function name, \"parameters\": dictionary of argument name and its value}.' }}\n {{- \"Do not use variables.\n\n\" }}\n {%- for t in tools %}\n {{- t | tojson(indent=4) }}\n {{- \"\n\n\" }}\n {%- endfor %}\n {{- first_user_message + \"<|eot_id|>\"}}\n{%- endif %}\n\n{%- for message in messages %}\n {%- if not (message.role == 'ipython' or message.role == 'tool' or 'tool_calls' in message) %}\n {{- '<|start_header_id|>' + message['role'] + '<|end_header_id|>\n\n'+ message['content'] + '<|eot_id|>' }}\n {%- elif 'tool_calls' in message %}\n {%- if not message.tool_calls|length == 1 %}\n {{- raise_exception(\"This model only supports single tool-calls at once!\") }}\n {%- endif %}\n {%- set tool_call = message.tool_calls[0].function %}\n {%- if builtin_tools is defined and tool_call.name in builtin_tools %}\n {{- '<|start_header_id|>assistant<|end_header_id|>\n\n' -}}\n {{- \"<|python_tag|>\" + tool_call.name + \".call(\" }}\n {%- for arg_name, arg_val in tool_call.arguments | items %}\n {{- arg_name + '=\"' + arg_val + '\"' }}\n {%- if not loop.last %}\n {{- \", \" }}\n {%- endif %}\n {%- endfor %}\n {{- \")\" }}\n {%- else %}\n {{- '<|start_header_id|>assistant<|end_header_id|>\n\n' -}}\n {{- '{\"name\": \"' + tool_call.name + '\", ' }}\n {{- '\"parameters\": ' }}\n {{- tool_call.arguments | tojson }}\n {{- \"}\" }}\n {%- endif %}\n {%- if builtin_tools is defined %}\n {#- This means we're in ipython mode #}\n {{- \"<|eom_id|>\" }}\n {%- else %}\n {{- \"<|eot_id|>\" }}\n {%- endif %}\n {%- elif message.role == \"tool\" or message.role == \"ipython\" %}\n {{- \"<|start_header_id|>ipython<|end_header_id|>\n\n\" }}\n {%- if message.content is mapping or message.content is iterable %}\n {{- message.content | tojson }}\n {%- else %}\n {{- message.content }}\n {%- endif %}\n {{- \"<|eot_id|>\" }}\n {%- endif %}\n{%- endfor %}\n{%- if add_generation_prompt %}\n {{- '<|start_header_id|>assistant<|end_header_id|>\n\n' }}\n{%- endif %}\n",
"clean_up_tokenization_spaces": true,
"eos_token": "<|eot_id|>",
"model_input_names": [
"input_ids",
"attention_mask"
],
"model_max_length": 131072,
"pad_token": "<|finetune_right_pad_id|>",
"padding_side": "right",
"tokenizer_class": "PreTrainedTokenizerFast"
}12345678910111213141516171819202122232425262728293031323334353637383940414243444546{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "id": "ZgkQ4kDil23W" }, "outputs": [], "source": [ "!git clone https://huggingface.co/John6666/joy-caption-alpha-two-cli-mod/\n", "!pip install -r /content/joy-caption-alpha-two-cli-mod/requirements.txt\n", "!pip install bitsandbytes triton\n", "!pip install accelerate==0.30.1\n", "!python /content/joy-caption-alpha-two-cli-mod/app.py" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "gPwD8BVsnU7p" }, "outputs": [], "source": [ "!python /content/joy-caption-alpha-two-cli-mod/app.py" ] } ], "metadata": { "accelerator": "GPU", "colab": { "gpuType": "T4", "provenance": [] }, "kernelspec": { "display_name": "Python 3", "name": "python3" }, "language_info": { "name": "python" } }, "nbformat": 4, "nbformat_minor": 0}12345678910huggingface_hub>=0.23.4
accelerate
torch
transformers==4.44.0
sentencepiece
bitsandbytes
Pillow
protobuf
peft==0.12.0
torchvision1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071---license: mit---# Florence-2-base-PromptGen v2.0This upgrade is based on PromptGen 1.5 with some new features to the model:
## Features:* Improved caption quality for \<GENERATE_TAGS\>, \<DETAILED_CAPTION\> and \<MORE_DETAILED_CAPTION\>. <img style="width:100%; hight:100%" src="https://msdn.miaoshouai.com/miaoshou/bo/2024-11-05_03-15-15.png" /> <img style="width:100%; hight:100%" src="https://msdn.miaoshouai.com/miaoshou/bo/2024-11-05_03-40-29.png" />* A new \<ANALYZE\> instruction, which helps the model to better understands the image composition of the input image. <img style="width:100%; hight:100%" src="https://msdn.miaoshouai.com/miaoshou/bo/2024-11-05_03-42-58.png" /> <img style="width:100%; hight:100%" src="https://msdn.miaoshouai.com/miaoshou/bo/2024-11-05_07-42-36.png" />* Memory efficient compare to other models! This is a really light weight caption model that allows you to use a little more than 1G of VRAM and produce lightening fast and high quality image captions. <img style="width:100%; hight:100%" src="https://msdn.miaoshouai.com/miaoshou/bo/2024-09-05_12-56-39.png" />* Designed to handle image captions for Flux model for both T5XXL CLIP and CLIP_L, the Miaoshou Tagger new node called "Flux CLIP Text Encode" which eliminates the need to run two separate tagger tools for caption creation. You can easily populate both CLIPs in a single generation, significantly boosting speed when working with Flux models. <img style="width:100%; hight:100%" src="https://msdn.miaoshouai.com/miaoshou/bo/2024-09-05_14-11-02.png" /> ## Instruction prompt:\<GENERATE_TAGS\> generate prompt as danbooru style tags<br>\<CAPTION\> a one line caption for the image<br>\<DETAILED_CAPTION\> a structured caption format which detects the position of the subjects in the image<br>\<MORE_DETAILED_CAPTION\> a very detailed description for the image<br>\<ANALYZE\> image composition analysis mode<br>\<MIXED_CAPTION\> a mixed caption style of more detailed caption and tags, this is extremely useful for FLUX model when using T5XXL and CLIP_L together. A new node in MiaoshouTagger ComfyUI is added to support this instruction.<br>\<MIXED_CAPTION_PLUS\> Combine the power of mixed caption with analyze.<br>
## Version History:For version 2.0, you will notice the following1. \<ANALYZE\> along with a beta node in ComfyUI for partial image analysis2. A new instruction for \<MIXED_CAPTION_PLUS\>3. A much improve accuracy for \<GENERATE_TAGS\>, \<DETAILED_CAPTION\> and \<MORE_DETAILED_CAPTION\>
## How to use:
To use this model, you can load it directly from the Hugging Face Model Hub:
```python
model = AutoModelForCausalLM.from_pretrained("MiaoshouAI/Florence-2-base-PromptGen-v2.0", trust_remote_code=True)processor = AutoProcessor.from_pretrained("MiaoshouAI/Florence-2-base-PromptGen-v2.0", trust_remote_code=True)
prompt = "<MORE_DETAILED_CAPTION>"
url = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/car.jpg?download=true"image = Image.open(requests.get(url, stream=True).raw)
inputs = processor(text=prompt, images=image, return_tensors="pt").to(device)
generated_ids = model.generate( input_ids=inputs["input_ids"], pixel_values=inputs["pixel_values"], max_new_tokens=1024, do_sample=False, num_beams=3)generated_text = processor.batch_decode(generated_ids, skip_special_tokens=False)[0]
parsed_answer = processor.post_process_generation(generated_text, task=prompt, image_size=(image.width, image.height))
print(parsed_answer)```
## Use under MiaoshouAI Tagger ComfyUIIf you just want to use this model, you can use it under ComfyUI-Miaoshouai-Tagger
https://github.com/miaoshouai/ComfyUI-Miaoshouai-Tagger
A detailed use and install instruction is already there.(If you have already installed MiaoshouAI Tagger, you need to update the node in ComfyUI Manager first or use git pull to get the latest update.)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026{ "</cap>": 51270, "</dcap>": 51274, "</grounding>": 51276, "</ncap>": 51272, "</ocr>": 50268, "</od>": 50266, "</poly>": 51287, "</proposal>": 51285, "</region_cap>": 51281, "</region_to_desciption>": 51283, "</seg>": 51278, "<and>": 51288, "<cap>": 51269, "<dcap>": 51273, "<grounding>": 51275, "<loc_0>": 50269, "<loc_100>": 50369, "<loc_101>": 50370, "<loc_102>": 50371, "<loc_103>": 50372, "<loc_104>": 50373, "<loc_105>": 50374, "<loc_106>": 50375, "<loc_107>": 50376, "<loc_108>": 50377, "<loc_109>": 50378, "<loc_10>": 50279, "<loc_110>": 50379, "<loc_111>": 50380, "<loc_112>": 50381, "<loc_113>": 50382, "<loc_114>": 50383, "<loc_115>": 50384, "<loc_116>": 50385, "<loc_117>": 50386, "<loc_118>": 50387, "<loc_119>": 50388, "<loc_11>": 50280, "<loc_120>": 50389, "<loc_121>": 50390, "<loc_122>": 50391, "<loc_123>": 50392, "<loc_124>": 50393, "<loc_125>": 50394, "<loc_126>": 50395, "<loc_127>": 50396, "<loc_128>": 50397, "<loc_129>": 50398, "<loc_12>": 50281, "<loc_130>": 50399, "<loc_131>": 50400, "<loc_132>": 50401, "<loc_133>": 50402, "<loc_134>": 50403, "<loc_135>": 50404, "<loc_136>": 50405, "<loc_137>": 50406, "<loc_138>": 50407, "<loc_139>": 50408, "<loc_13>": 50282, "<loc_140>": 50409, "<loc_141>": 50410, "<loc_142>": 50411, "<loc_143>": 50412, "<loc_144>": 50413, "<loc_145>": 50414, "<loc_146>": 50415, "<loc_147>": 50416, "<loc_148>": 50417, "<loc_149>": 50418, "<loc_14>": 50283, "<loc_150>": 50419, "<loc_151>": 50420, "<loc_152>": 50421, "<loc_153>": 50422, "<loc_154>": 50423, "<loc_155>": 50424, "<loc_156>": 50425, "<loc_157>": 50426, "<loc_158>": 50427, "<loc_159>": 50428, "<loc_15>": 50284, "<loc_160>": 50429, "<loc_161>": 50430, "<loc_162>": 50431, "<loc_163>": 50432, "<loc_164>": 50433, "<loc_165>": 50434, "<loc_166>": 50435, "<loc_167>": 50436, "<loc_168>": 50437, "<loc_169>": 50438, "<loc_16>": 50285, "<loc_170>": 50439, "<loc_171>": 50440, "<loc_172>": 50441, "<loc_173>": 50442, "<loc_174>": 50443, "<loc_175>": 50444, "<loc_176>": 50445, "<loc_177>": 50446, "<loc_178>": 50447, "<loc_179>": 50448, "<loc_17>": 50286, "<loc_180>": 50449, "<loc_181>": 50450, "<loc_182>": 50451, "<loc_183>": 50452, "<loc_184>": 50453, "<loc_185>": 50454, "<loc_186>": 50455, "<loc_187>": 50456, "<loc_188>": 50457, "<loc_189>": 50458, "<loc_18>": 50287, "<loc_190>": 50459, "<loc_191>": 50460, "<loc_192>": 50461, "<loc_193>": 50462, "<loc_194>": 50463, "<loc_195>": 50464, "<loc_196>": 50465, "<loc_197>": 50466, "<loc_198>": 50467, "<loc_199>": 50468, "<loc_19>": 50288, "<loc_1>": 50270, "<loc_200>": 50469, "<loc_201>": 50470, "<loc_202>": 50471, "<loc_203>": 50472, "<loc_204>": 50473, "<loc_205>": 50474, "<loc_206>": 50475, "<loc_207>": 50476, "<loc_208>": 50477, "<loc_209>": 50478, "<loc_20>": 50289, "<loc_210>": 50479, "<loc_211>": 50480, "<loc_212>": 50481, "<loc_213>": 50482, "<loc_214>": 50483, "<loc_215>": 50484, "<loc_216>": 50485, "<loc_217>": 50486, "<loc_218>": 50487, "<loc_219>": 50488, "<loc_21>": 50290, "<loc_220>": 50489, "<loc_221>": 50490, "<loc_222>": 50491, "<loc_223>": 50492, "<loc_224>": 50493, "<loc_225>": 50494, "<loc_226>": 50495, "<loc_227>": 50496, "<loc_228>": 50497, "<loc_229>": 50498, "<loc_22>": 50291, "<loc_230>": 50499, "<loc_231>": 50500, "<loc_232>": 50501, "<loc_233>": 50502, "<loc_234>": 50503, "<loc_235>": 50504, "<loc_236>": 50505, "<loc_237>": 50506, "<loc_238>": 50507, "<loc_239>": 50508, "<loc_23>": 50292, "<loc_240>": 50509, "<loc_241>": 50510, "<loc_242>": 50511, "<loc_243>": 50512, "<loc_244>": 50513, "<loc_245>": 50514, "<loc_246>": 50515, "<loc_247>": 50516, "<loc_248>": 50517, "<loc_249>": 50518, "<loc_24>": 50293, "<loc_250>": 50519, "<loc_251>": 50520, "<loc_252>": 50521, "<loc_253>": 50522, "<loc_254>": 50523, "<loc_255>": 50524, "<loc_256>": 50525, "<loc_257>": 50526, "<loc_258>": 50527, "<loc_259>": 50528, "<loc_25>": 50294, "<loc_260>": 50529, "<loc_261>": 50530, "<loc_262>": 50531, "<loc_263>": 50532, "<loc_264>": 50533, "<loc_265>": 50534, "<loc_266>": 50535, "<loc_267>": 50536, "<loc_268>": 50537, "<loc_269>": 50538, "<loc_26>": 50295, "<loc_270>": 50539, "<loc_271>": 50540, "<loc_272>": 50541, "<loc_273>": 50542, "<loc_274>": 50543, "<loc_275>": 50544, "<loc_276>": 50545, "<loc_277>": 50546, "<loc_278>": 50547, "<loc_279>": 50548, "<loc_27>": 50296, "<loc_280>": 50549, "<loc_281>": 50550, "<loc_282>": 50551, "<loc_283>": 50552, "<loc_284>": 50553, "<loc_285>": 50554, "<loc_286>": 50555, "<loc_287>": 50556, "<loc_288>": 50557, "<loc_289>": 50558, "<loc_28>": 50297, "<loc_290>": 50559, "<loc_291>": 50560, "<loc_292>": 50561, "<loc_293>": 50562, "<loc_294>": 50563, "<loc_295>": 50564, "<loc_296>": 50565, "<loc_297>": 50566, "<loc_298>": 50567, "<loc_299>": 50568, "<loc_29>": 50298, "<loc_2>": 50271, "<loc_300>": 50569, "<loc_301>": 50570, "<loc_302>": 50571, "<loc_303>": 50572, "<loc_304>": 50573, "<loc_305>": 50574, "<loc_306>": 50575, "<loc_307>": 50576, "<loc_308>": 50577, "<loc_309>": 50578, "<loc_30>": 50299, "<loc_310>": 50579, "<loc_311>": 50580, "<loc_312>": 50581, "<loc_313>": 50582, "<loc_314>": 50583, "<loc_315>": 50584, "<loc_316>": 50585, "<loc_317>": 50586, "<loc_318>": 50587, "<loc_319>": 50588, "<loc_31>": 50300, "<loc_320>": 50589, "<loc_321>": 50590, "<loc_322>": 50591, "<loc_323>": 50592, "<loc_324>": 50593, "<loc_325>": 50594, "<loc_326>": 50595, "<loc_327>": 50596, "<loc_328>": 50597, "<loc_329>": 50598, "<loc_32>": 50301, "<loc_330>": 50599, "<loc_331>": 50600, "<loc_332>": 50601, "<loc_333>": 50602, "<loc_334>": 50603, "<loc_335>": 50604, "<loc_336>": 50605, "<loc_337>": 50606, "<loc_338>": 50607, "<loc_339>": 50608, "<loc_33>": 50302, "<loc_340>": 50609, "<loc_341>": 50610, "<loc_342>": 50611, "<loc_343>": 50612, "<loc_344>": 50613, "<loc_345>": 50614, "<loc_346>": 50615, "<loc_347>": 50616, "<loc_348>": 50617, "<loc_349>": 50618, "<loc_34>": 50303, "<loc_350>": 50619, "<loc_351>": 50620, "<loc_352>": 50621, "<loc_353>": 50622, "<loc_354>": 50623, "<loc_355>": 50624, "<loc_356>": 50625, "<loc_357>": 50626, "<loc_358>": 50627, "<loc_359>": 50628, "<loc_35>": 50304, "<loc_360>": 50629, "<loc_361>": 50630, "<loc_362>": 50631, "<loc_363>": 50632, "<loc_364>": 50633, "<loc_365>": 50634, "<loc_366>": 50635, "<loc_367>": 50636, "<loc_368>": 50637, "<loc_369>": 50638, "<loc_36>": 50305, "<loc_370>": 50639, "<loc_371>": 50640, "<loc_372>": 50641, "<loc_373>": 50642, "<loc_374>": 50643, "<loc_375>": 50644, "<loc_376>": 50645, "<loc_377>": 50646, "<loc_378>": 50647, "<loc_379>": 50648, "<loc_37>": 50306, "<loc_380>": 50649, "<loc_381>": 50650, "<loc_382>": 50651, "<loc_383>": 50652, "<loc_384>": 50653, "<loc_385>": 50654, "<loc_386>": 50655, "<loc_387>": 50656, "<loc_388>": 50657, "<loc_389>": 50658, "<loc_38>": 50307, "<loc_390>": 50659, "<loc_391>": 50660, "<loc_392>": 50661, "<loc_393>": 50662, "<loc_394>": 50663, "<loc_395>": 50664, "<loc_396>": 50665, "<loc_397>": 50666, "<loc_398>": 50667, "<loc_399>": 50668, "<loc_39>": 50308, "<loc_3>": 50272, "<loc_400>": 50669, "<loc_401>": 50670, "<loc_402>": 50671, "<loc_403>": 50672, "<loc_404>": 50673, "<loc_405>": 50674, "<loc_406>": 50675, "<loc_407>": 50676, "<loc_408>": 50677, "<loc_409>": 50678, "<loc_40>": 50309, "<loc_410>": 50679, "<loc_411>": 50680, "<loc_412>": 50681, "<loc_413>": 50682, "<loc_414>": 50683, "<loc_415>": 50684, "<loc_416>": 50685, "<loc_417>": 50686, "<loc_418>": 50687, "<loc_419>": 50688, "<loc_41>": 50310, "<loc_420>": 50689, "<loc_421>": 50690, "<loc_422>": 50691, "<loc_423>": 50692, "<loc_424>": 50693, "<loc_425>": 50694, "<loc_426>": 50695, "<loc_427>": 50696, "<loc_428>": 50697, "<loc_429>": 50698, "<loc_42>": 50311, "<loc_430>": 50699, "<loc_431>": 50700, "<loc_432>": 50701, "<loc_433>": 50702, "<loc_434>": 50703, "<loc_435>": 50704, "<loc_436>": 50705, "<loc_437>": 50706, "<loc_438>": 50707, "<loc_439>": 50708, "<loc_43>": 50312, "<loc_440>": 50709, "<loc_441>": 50710, "<loc_442>": 50711, "<loc_443>": 50712, "<loc_444>": 50713, "<loc_445>": 50714, "<loc_446>": 50715, "<loc_447>": 50716, "<loc_448>": 50717, "<loc_449>": 50718, "<loc_44>": 50313, "<loc_450>": 50719, "<loc_451>": 50720, "<loc_452>": 50721, "<loc_453>": 50722, "<loc_454>": 50723, "<loc_455>": 50724, "<loc_456>": 50725, "<loc_457>": 50726, "<loc_458>": 50727, "<loc_459>": 50728, "<loc_45>": 50314, "<loc_460>": 50729, "<loc_461>": 50730, "<loc_462>": 50731, "<loc_463>": 50732, "<loc_464>": 50733, "<loc_465>": 50734, "<loc_466>": 50735, "<loc_467>": 50736, "<loc_468>": 50737, "<loc_469>": 50738, "<loc_46>": 50315, "<loc_470>": 50739, "<loc_471>": 50740, "<loc_472>": 50741, "<loc_473>": 50742, "<loc_474>": 50743, "<loc_475>": 50744, "<loc_476>": 50745, "<loc_477>": 50746, "<loc_478>": 50747, "<loc_479>": 50748, "<loc_47>": 50316, "<loc_480>": 50749, "<loc_481>": 50750, "<loc_482>": 50751, "<loc_483>": 50752, "<loc_484>": 50753, "<loc_485>": 50754, "<loc_486>": 50755, "<loc_487>": 50756, "<loc_488>": 50757, "<loc_489>": 50758, "<loc_48>": 50317, "<loc_490>": 50759, "<loc_491>": 50760, "<loc_492>": 50761, "<loc_493>": 50762, "<loc_494>": 50763, "<loc_495>": 50764, "<loc_496>": 50765, "<loc_497>": 50766, "<loc_498>": 50767, "<loc_499>": 50768, "<loc_49>": 50318, "<loc_4>": 50273, "<loc_500>": 50769, "<loc_501>": 50770, "<loc_502>": 50771, "<loc_503>": 50772, "<loc_504>": 50773, "<loc_505>": 50774, "<loc_506>": 50775, "<loc_507>": 50776, "<loc_508>": 50777, "<loc_509>": 50778, "<loc_50>": 50319, "<loc_510>": 50779, "<loc_511>": 50780, "<loc_512>": 50781, "<loc_513>": 50782, "<loc_514>": 50783, "<loc_515>": 50784, "<loc_516>": 50785, "<loc_517>": 50786, "<loc_518>": 50787, "<loc_519>": 50788, "<loc_51>": 50320, "<loc_520>": 50789, "<loc_521>": 50790, "<loc_522>": 50791, "<loc_523>": 50792, "<loc_524>": 50793, "<loc_525>": 50794, "<loc_526>": 50795, "<loc_527>": 50796, "<loc_528>": 50797, "<loc_529>": 50798, "<loc_52>": 50321, "<loc_530>": 50799, "<loc_531>": 50800, "<loc_532>": 50801, "<loc_533>": 50802, "<loc_534>": 50803, "<loc_535>": 50804, "<loc_536>": 50805, "<loc_537>": 50806, "<loc_538>": 50807, "<loc_539>": 50808, "<loc_53>": 50322, "<loc_540>": 50809, "<loc_541>": 50810, "<loc_542>": 50811, "<loc_543>": 50812, "<loc_544>": 50813, "<loc_545>": 50814, "<loc_546>": 50815, "<loc_547>": 50816, "<loc_548>": 50817, "<loc_549>": 50818, "<loc_54>": 50323, "<loc_550>": 50819, "<loc_551>": 50820, "<loc_552>": 50821, "<loc_553>": 50822, "<loc_554>": 50823, "<loc_555>": 50824, "<loc_556>": 50825, "<loc_557>": 50826, "<loc_558>": 50827, "<loc_559>": 50828, "<loc_55>": 50324, "<loc_560>": 50829, "<loc_561>": 50830, "<loc_562>": 50831, "<loc_563>": 50832, "<loc_564>": 50833, "<loc_565>": 50834, "<loc_566>": 50835, "<loc_567>": 50836, "<loc_568>": 50837, "<loc_569>": 50838, "<loc_56>": 50325, "<loc_570>": 50839, "<loc_571>": 50840, "<loc_572>": 50841, "<loc_573>": 50842, "<loc_574>": 50843, "<loc_575>": 50844, "<loc_576>": 50845, "<loc_577>": 50846, "<loc_578>": 50847, "<loc_579>": 50848, "<loc_57>": 50326, "<loc_580>": 50849, "<loc_581>": 50850, "<loc_582>": 50851, "<loc_583>": 50852, "<loc_584>": 50853, "<loc_585>": 50854, "<loc_586>": 50855, "<loc_587>": 50856, "<loc_588>": 50857, "<loc_589>": 50858, "<loc_58>": 50327, "<loc_590>": 50859, "<loc_591>": 50860, "<loc_592>": 50861, "<loc_593>": 50862, "<loc_594>": 50863, "<loc_595>": 50864, "<loc_596>": 50865, "<loc_597>": 50866, "<loc_598>": 50867, "<loc_599>": 50868, "<loc_59>": 50328, "<loc_5>": 50274, "<loc_600>": 50869, "<loc_601>": 50870, "<loc_602>": 50871, "<loc_603>": 50872, "<loc_604>": 50873, "<loc_605>": 50874, "<loc_606>": 50875, "<loc_607>": 50876, "<loc_608>": 50877, "<loc_609>": 50878, "<loc_60>": 50329, "<loc_610>": 50879, "<loc_611>": 50880, "<loc_612>": 50881, "<loc_613>": 50882, "<loc_614>": 50883, "<loc_615>": 50884, "<loc_616>": 50885, "<loc_617>": 50886, "<loc_618>": 50887, "<loc_619>": 50888, "<loc_61>": 50330, "<loc_620>": 50889, "<loc_621>": 50890, "<loc_622>": 50891, "<loc_623>": 50892, "<loc_624>": 50893, "<loc_625>": 50894, "<loc_626>": 50895, "<loc_627>": 50896, "<loc_628>": 50897, "<loc_629>": 50898, "<loc_62>": 50331, "<loc_630>": 50899, "<loc_631>": 50900, "<loc_632>": 50901, "<loc_633>": 50902, "<loc_634>": 50903, "<loc_635>": 50904, "<loc_636>": 50905, "<loc_637>": 50906, "<loc_638>": 50907, "<loc_639>": 50908, "<loc_63>": 50332, "<loc_640>": 50909, "<loc_641>": 50910, "<loc_642>": 50911, "<loc_643>": 50912, "<loc_644>": 50913, "<loc_645>": 50914, "<loc_646>": 50915, "<loc_647>": 50916, "<loc_648>": 50917, "<loc_649>": 50918, "<loc_64>": 50333, "<loc_650>": 50919, "<loc_651>": 50920, "<loc_652>": 50921, "<loc_653>": 50922, "<loc_654>": 50923, "<loc_655>": 50924, "<loc_656>": 50925, "<loc_657>": 50926, "<loc_658>": 50927, "<loc_659>": 50928, "<loc_65>": 50334, "<loc_660>": 50929, "<loc_661>": 50930, "<loc_662>": 50931, "<loc_663>": 50932, "<loc_664>": 50933, "<loc_665>": 50934, "<loc_666>": 50935, "<loc_667>": 50936, "<loc_668>": 50937, "<loc_669>": 50938, "<loc_66>": 50335, "<loc_670>": 50939, "<loc_671>": 50940, "<loc_672>": 50941, "<loc_673>": 50942, "<loc_674>": 50943, "<loc_675>": 50944, "<loc_676>": 50945, "<loc_677>": 50946, "<loc_678>": 50947, "<loc_679>": 50948, "<loc_67>": 50336, "<loc_680>": 50949, "<loc_681>": 50950, "<loc_682>": 50951, "<loc_683>": 50952, "<loc_684>": 50953, "<loc_685>": 50954, "<loc_686>": 50955, "<loc_687>": 50956, "<loc_688>": 50957, "<loc_689>": 50958, "<loc_68>": 50337, "<loc_690>": 50959, "<loc_691>": 50960, "<loc_692>": 50961, "<loc_693>": 50962, "<loc_694>": 50963, "<loc_695>": 50964, "<loc_696>": 50965, "<loc_697>": 50966, "<loc_698>": 50967, "<loc_699>": 50968, "<loc_69>": 50338, "<loc_6>": 50275, "<loc_700>": 50969, "<loc_701>": 50970, "<loc_702>": 50971, "<loc_703>": 50972, "<loc_704>": 50973, "<loc_705>": 50974, "<loc_706>": 50975, "<loc_707>": 50976, "<loc_708>": 50977, "<loc_709>": 50978, "<loc_70>": 50339, "<loc_710>": 50979, "<loc_711>": 50980, "<loc_712>": 50981, "<loc_713>": 50982, "<loc_714>": 50983, "<loc_715>": 50984, "<loc_716>": 50985, "<loc_717>": 50986, "<loc_718>": 50987, "<loc_719>": 50988, "<loc_71>": 50340, "<loc_720>": 50989, "<loc_721>": 50990, "<loc_722>": 50991, "<loc_723>": 50992, "<loc_724>": 50993, "<loc_725>": 50994, "<loc_726>": 50995, "<loc_727>": 50996, "<loc_728>": 50997, "<loc_729>": 50998, "<loc_72>": 50341, "<loc_730>": 50999, "<loc_731>": 51000, "<loc_732>": 51001, "<loc_733>": 51002, "<loc_734>": 51003, "<loc_735>": 51004, "<loc_736>": 51005, "<loc_737>": 51006, "<loc_738>": 51007, "<loc_739>": 51008, "<loc_73>": 50342, "<loc_740>": 51009, "<loc_741>": 51010, "<loc_742>": 51011, "<loc_743>": 51012, "<loc_744>": 51013, "<loc_745>": 51014, "<loc_746>": 51015, "<loc_747>": 51016, "<loc_748>": 51017, "<loc_749>": 51018, "<loc_74>": 50343, "<loc_750>": 51019, "<loc_751>": 51020, "<loc_752>": 51021, "<loc_753>": 51022, "<loc_754>": 51023, "<loc_755>": 51024, "<loc_756>": 51025, "<loc_757>": 51026, "<loc_758>": 51027, "<loc_759>": 51028, "<loc_75>": 50344, "<loc_760>": 51029, "<loc_761>": 51030, "<loc_762>": 51031, "<loc_763>": 51032, "<loc_764>": 51033, "<loc_765>": 51034, "<loc_766>": 51035, "<loc_767>": 51036, "<loc_768>": 51037, "<loc_769>": 51038, "<loc_76>": 50345, "<loc_770>": 51039, "<loc_771>": 51040, "<loc_772>": 51041, "<loc_773>": 51042, "<loc_774>": 51043, "<loc_775>": 51044, "<loc_776>": 51045, "<loc_777>": 51046, "<loc_778>": 51047, "<loc_779>": 51048, "<loc_77>": 50346, "<loc_780>": 51049, "<loc_781>": 51050, "<loc_782>": 51051, "<loc_783>": 51052, "<loc_784>": 51053, "<loc_785>": 51054, "<loc_786>": 51055, "<loc_787>": 51056, "<loc_788>": 51057, "<loc_789>": 51058, "<loc_78>": 50347, "<loc_790>": 51059, "<loc_791>": 51060, "<loc_792>": 51061, "<loc_793>": 51062, "<loc_794>": 51063, "<loc_795>": 51064, "<loc_796>": 51065, "<loc_797>": 51066, "<loc_798>": 51067, "<loc_799>": 51068, "<loc_79>": 50348, "<loc_7>": 50276, "<loc_800>": 51069, "<loc_801>": 51070, "<loc_802>": 51071, "<loc_803>": 51072, "<loc_804>": 51073, "<loc_805>": 51074, "<loc_806>": 51075, "<loc_807>": 51076, "<loc_808>": 51077, "<loc_809>": 51078, "<loc_80>": 50349, "<loc_810>": 51079, "<loc_811>": 51080, "<loc_812>": 51081, "<loc_813>": 51082, "<loc_814>": 51083, "<loc_815>": 51084, "<loc_816>": 51085, "<loc_817>": 51086, "<loc_818>": 51087, "<loc_819>": 51088, "<loc_81>": 50350, "<loc_820>": 51089, "<loc_821>": 51090, "<loc_822>": 51091, "<loc_823>": 51092, "<loc_824>": 51093, "<loc_825>": 51094, "<loc_826>": 51095, "<loc_827>": 51096, "<loc_828>": 51097, "<loc_829>": 51098, "<loc_82>": 50351, "<loc_830>": 51099, "<loc_831>": 51100, "<loc_832>": 51101, "<loc_833>": 51102, "<loc_834>": 51103, "<loc_835>": 51104, "<loc_836>": 51105, "<loc_837>": 51106, "<loc_838>": 51107, "<loc_839>": 51108, "<loc_83>": 50352, "<loc_840>": 51109, "<loc_841>": 51110, "<loc_842>": 51111, "<loc_843>": 51112, "<loc_844>": 51113, "<loc_845>": 51114, "<loc_846>": 51115, "<loc_847>": 51116, "<loc_848>": 51117, "<loc_849>": 51118, "<loc_84>": 50353, "<loc_850>": 51119, "<loc_851>": 51120, "<loc_852>": 51121, "<loc_853>": 51122, "<loc_854>": 51123, "<loc_855>": 51124, "<loc_856>": 51125, "<loc_857>": 51126, "<loc_858>": 51127, "<loc_859>": 51128, "<loc_85>": 50354, "<loc_860>": 51129, "<loc_861>": 51130, "<loc_862>": 51131, "<loc_863>": 51132, "<loc_864>": 51133, "<loc_865>": 51134, "<loc_866>": 51135, "<loc_867>": 51136, "<loc_868>": 51137, "<loc_869>": 51138, "<loc_86>": 50355, "<loc_870>": 51139, "<loc_871>": 51140, "<loc_872>": 51141, "<loc_873>": 51142, "<loc_874>": 51143, "<loc_875>": 51144, "<loc_876>": 51145, "<loc_877>": 51146, "<loc_878>": 51147, "<loc_879>": 51148, "<loc_87>": 50356, "<loc_880>": 51149, "<loc_881>": 51150, "<loc_882>": 51151, "<loc_883>": 51152, "<loc_884>": 51153, "<loc_885>": 51154, "<loc_886>": 51155, "<loc_887>": 51156, "<loc_888>": 51157, "<loc_889>": 51158, "<loc_88>": 50357, "<loc_890>": 51159, "<loc_891>": 51160, "<loc_892>": 51161, "<loc_893>": 51162, "<loc_894>": 51163, "<loc_895>": 51164, "<loc_896>": 51165, "<loc_897>": 51166, "<loc_898>": 51167, "<loc_899>": 51168, "<loc_89>": 50358, "<loc_8>": 50277, "<loc_900>": 51169, "<loc_901>": 51170, "<loc_902>": 51171, "<loc_903>": 51172, "<loc_904>": 51173, "<loc_905>": 51174, "<loc_906>": 51175, "<loc_907>": 51176, "<loc_908>": 51177, "<loc_909>": 51178, "<loc_90>": 50359, "<loc_910>": 51179, "<loc_911>": 51180, "<loc_912>": 51181, "<loc_913>": 51182, "<loc_914>": 51183, "<loc_915>": 51184, "<loc_916>": 51185, "<loc_917>": 51186, "<loc_918>": 51187, "<loc_919>": 51188, "<loc_91>": 50360, "<loc_920>": 51189, "<loc_921>": 51190, "<loc_922>": 51191, "<loc_923>": 51192, "<loc_924>": 51193, "<loc_925>": 51194, "<loc_926>": 51195, "<loc_927>": 51196, "<loc_928>": 51197, "<loc_929>": 51198, "<loc_92>": 50361, "<loc_930>": 51199, "<loc_931>": 51200, "<loc_932>": 51201, "<loc_933>": 51202, "<loc_934>": 51203, "<loc_935>": 51204, "<loc_936>": 51205, "<loc_937>": 51206, "<loc_938>": 51207, "<loc_939>": 51208, "<loc_93>": 50362, "<loc_940>": 51209, "<loc_941>": 51210, "<loc_942>": 51211, "<loc_943>": 51212, "<loc_944>": 51213, "<loc_945>": 51214, "<loc_946>": 51215, "<loc_947>": 51216, "<loc_948>": 51217, "<loc_949>": 51218, "<loc_94>": 50363, "<loc_950>": 51219, "<loc_951>": 51220, "<loc_952>": 51221, "<loc_953>": 51222, "<loc_954>": 51223, "<loc_955>": 51224, "<loc_956>": 51225, "<loc_957>": 51226, "<loc_958>": 51227, "<loc_959>": 51228, "<loc_95>": 50364, "<loc_960>": 51229, "<loc_961>": 51230, "<loc_962>": 51231, "<loc_963>": 51232, "<loc_964>": 51233, "<loc_965>": 51234, "<loc_966>": 51235, "<loc_967>": 51236, "<loc_968>": 51237, "<loc_969>": 51238, "<loc_96>": 50365, "<loc_970>": 51239, "<loc_971>": 51240, "<loc_972>": 51241, "<loc_973>": 51242, "<loc_974>": 51243, "<loc_975>": 51244, "<loc_976>": 51245, "<loc_977>": 51246, "<loc_978>": 51247, "<loc_979>": 51248, "<loc_97>": 50366, "<loc_980>": 51249, "<loc_981>": 51250, "<loc_982>": 51251, "<loc_983>": 51252, "<loc_984>": 51253, "<loc_985>": 51254, "<loc_986>": 51255, "<loc_987>": 51256, "<loc_988>": 51257, "<loc_989>": 51258, "<loc_98>": 50367, "<loc_990>": 51259, "<loc_991>": 51260, "<loc_992>": 51261, "<loc_993>": 51262, "<loc_994>": 51263, "<loc_995>": 51264, "<loc_996>": 51265, "<loc_997>": 51266, "<loc_998>": 51267, "<loc_999>": 51268, "<loc_99>": 50368, "<loc_9>": 50278, "<ncap>": 51271, "<ocr>": 50267, "<od>": 50265, "<poly>": 51286, "<proposal>": 51284, "<region_cap>": 51280, "<region_to_desciption>": 51282, "<seg>": 51277, "<sep>": 51279}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137{ "_name_or_path": "microsoft/Florence-2-base", "architectures": [ "Florence2ForConditionalGeneration" ], "auto_map": { "AutoConfig": "configuration_florence2.Florence2Config", "AutoModelForCausalLM": "modeling_florence2.Florence2ForConditionalGeneration" }, "bos_token_id": 0, "eos_token_id": 2, "ignore_index": -100, "is_encoder_decoder": true, "model_type": "florence2", "pad_token_id": 1, "projection_dim": 768, "text_config": { "_name_or_path": "", "activation_dropout": 0.1, "activation_function": "gelu", "add_bias_logits": false, "add_cross_attention": false, "add_final_layer_norm": false, "architectures": null, "attention_dropout": 0.1, "bad_words_ids": null, "begin_suppress_tokens": null, "bos_token_id": 0, "chunk_size_feed_forward": 0, "classif_dropout": 0.1, "classifier_dropout": 0.0, "cross_attention_hidden_size": null, "d_model": 768, "decoder_attention_heads": 12, "decoder_ffn_dim": 3072, "decoder_layerdrop": 0.0, "decoder_layers": 6, "decoder_start_token_id": 2, "diversity_penalty": 0.0, "do_sample": false, "dropout": 0.1, "early_stopping": true, "encoder_attention_heads": 12, "encoder_ffn_dim": 3072, "encoder_layerdrop": 0.0, "encoder_layers": 6, "encoder_no_repeat_ngram_size": 0, "eos_token_id": 2, "exponential_decay_length_penalty": null, "finetuning_task": null, "forced_bos_token_id": 0, "forced_eos_token_id": 2, "gradient_checkpointing": false, "id2label": { "0": "LABEL_0", "1": "LABEL_1", "2": "LABEL_2" }, "init_std": 0.02, "is_decoder": false, "is_encoder_decoder": true, "label2id": { "LABEL_0": 0, "LABEL_1": 1, "LABEL_2": 2 }, "length_penalty": 1.0, "max_length": 20, "max_position_embeddings": 1024, "min_length": 0, "model_type": "florence2_language", "no_repeat_ngram_size": 3, "normalize_before": false, "num_beam_groups": 1, "num_beams": 3, "num_hidden_layers": 6, "num_return_sequences": 1, "output_attentions": false, "output_hidden_states": false, "output_scores": false, "pad_token_id": 1, "prefix": null, "problem_type": null, "pruned_heads": {}, "remove_invalid_values": false, "repetition_penalty": 1.0, "return_dict": true, "return_dict_in_generate": false, "scale_embedding": false, "sep_token_id": null, "suppress_tokens": null, "task_specific_params": null, "temperature": 1.0, "tf_legacy_loss": false, "tie_encoder_decoder": false, "tie_word_embeddings": true, "tokenizer_class": null, "top_k": 50, "top_p": 1.0, "torch_dtype": null, "torchscript": false, "typical_p": 1.0, "use_bfloat16": false, "use_cache": true, "vocab_size": 51289 }, "torch_dtype": "float32", "transformers_version": "4.44.2", "vision_config": { "model_type": "davit", "drop_path_rate": 0.1, "patch_size": [7, 3, 3, 3], "patch_stride": [4, 2, 2, 2], "patch_padding": [3, 1, 1, 1], "patch_prenorm": [false, true, true, true], "enable_checkpoint": false, "dim_embed": [128, 256, 512, 1024], "num_heads": [4, 8, 16, 32], "num_groups": [4, 8, 16, 32], "depths": [1, 1, 9, 1], "window_size": 12, "projection_dim": 768, "visual_temporal_embedding": { "type": "COSINE", "max_temporal_embeddings": 100 }, "image_pos_embed": { "type": "learned_abs_2d", "max_pos_embeddings": 50 }, "image_feature_source": ["spatial_avg_pool", "temporal_avg_pool"] }, "vocab_size": 51289, "torch_dtype": "float16", "transformers_version": "4.41.0.dev0", "is_encoder_decoder": true}12345678910111213{ "_from_model_config": true, "bos_token_id": 0, "decoder_start_token_id": 2, "early_stopping": true, "eos_token_id": 2, "forced_bos_token_id": 0, "forced_eos_token_id": 2, "no_repeat_ngram_size": 3, "num_beams": 3, "pad_token_id": 1, "transformers_version": "4.44.2"}123456789101112131415161718192021222324252627282930313233{ "auto_map": { "AutoProcessor": "processing_florence2.Florence2Processor" }, "crop_size": { "height": 768, "width": 768 }, "do_center_crop": false, "do_convert_rgb": null, "do_normalize": true, "do_rescale": true, "do_resize": true, "image_mean": [ 0.485, 0.456, 0.406 ], "image_processor_type": "CLIPImageProcessor", "image_seq_length": 577, "image_std": [ 0.229, 0.224, 0.225 ], "processor_class": "Florence2Processor", "resample": 3, "rescale_factor": 0.00392156862745098, "size": { "height": 768, "width": 768 }}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340# coding=utf-8# Copyright 2024 Microsoft and the HuggingFace Inc. team. All rights reserved.# Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# You may obtain a copy of the License at## http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.import warnings""" Florence-2 configuration"""
from typing import Optional
from transformers import AutoConfigfrom transformers.configuration_utils import PretrainedConfigfrom transformers.utils import logging
logger = logging.get_logger(__name__)
class Florence2VisionConfig(PretrainedConfig): r""" This is the configuration class to store the configuration of a [`Florence2VisionModel`]. It is used to instantiate a Florence2VisionModel according to the specified arguments, defining the model architecture. Instantiating a configuration with the defaults will yield a similar configuration to that of the Florence2VisionModel architecture.
Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the documentation from [`PretrainedConfig`] for more information.
Args: drop_path_rate (`float`, *optional*, defaults to 0.1): The dropout rate of the drop path layer. patch_size (`List[int]`, *optional*, defaults to [7, 3, 3, 3]): The patch size of the image. patch_stride (`List[int]`, *optional*, defaults to [4, 2, 2, 2]): The patch stride of the image. patch_padding (`List[int]`, *optional*, defaults to [3, 1, 1, 1]): The patch padding of the image. patch_prenorm (`List[bool]`, *optional*, defaults to [false, true, true, true]): Whether to apply layer normalization before the patch embedding layer. enable_checkpoint (`bool`, *optional*, defaults to False): Whether to enable checkpointing. dim_embed (`List[int]`, *optional*, defaults to [256, 512, 1024, 2048]): The dimension of the embedding layer. num_heads (`List[int]`, *optional*, defaults to [8, 16, 32, 64]): The number of attention heads. num_groups (`List[int]`, *optional*, defaults to [8, 16, 32, 64]): The number of groups. depths (`List[int]`, *optional*, defaults to [1, 1, 9, 1]): The depth of the model. window_size (`int`, *optional*, defaults to 12): The window size of the model. projection_dim (`int`, *optional*, defaults to 1024): The dimension of the projection layer. visual_temporal_embedding (`dict`, *optional*): The configuration of the visual temporal embedding. image_pos_embed (`dict`, *optional*): The configuration of the image position embedding. image_feature_source (`List[str]`, *optional*, defaults to ["spatial_avg_pool", "temporal_avg_pool"]): The source of the image feature. Example:
```python >>> from transformers import Florence2VisionConfig, Florence2VisionModel
>>> # Initializing a Florence2 Vision style configuration >>> configuration = Florence2VisionConfig()
>>> # Initializing a model (with random weights) >>> model = Florence2VisionModel(configuration)
>>> # Accessing the model configuration >>> configuration = model.config ```"""
model_type = "florence2_vision" keys_to_ignore_at_inference = ["past_key_values"]
def __init__( self, drop_path_rate=0.1, patch_size=[7, 3, 3, 3], patch_stride=[4, 2, 2, 2], patch_padding=[3, 1, 1, 1], patch_prenorm=[False, True, True, True], enable_checkpoint=False, dim_embed=[256, 512, 1024, 2048], num_heads=[8, 16, 32, 64], num_groups=[8, 16, 32, 64], depths=[1, 1, 9, 1], window_size=12, projection_dim=1024, visual_temporal_embedding=None, image_pos_embed=None, image_feature_source=["spatial_avg_pool", "temporal_avg_pool"], **kwargs, ): self.drop_path_rate = drop_path_rate self.patch_size = patch_size self.patch_stride = patch_stride self.patch_padding = patch_padding self.patch_prenorm = patch_prenorm self.enable_checkpoint = enable_checkpoint self.dim_embed = dim_embed self.num_heads = num_heads self.num_groups = num_groups self.depths = depths self.window_size = window_size self.projection_dim = projection_dim self.visual_temporal_embedding = visual_temporal_embedding self.image_pos_embed = image_pos_embed self.image_feature_source = image_feature_source
super().__init__(**kwargs)
class Florence2LanguageConfig(PretrainedConfig): r""" This is the configuration class to store the configuration of a [`Florence2LanguagePreTrainedModel`]. It is used to instantiate a BART model according to the specified arguments, defining the model architecture. Instantiating a configuration with the defaults will yield a similar configuration to that of the BART [facebook/bart-large](https://huggingface.co/facebook/bart-large) architecture.
Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the documentation from [`PretrainedConfig`] for more information.
Args: vocab_size (`int`, *optional*, defaults to 51289): Vocabulary size of the Florence2Language model. Defines the number of different tokens that can be represented by the `inputs_ids` passed when calling [`Florence2LanguageModel`]. d_model (`int`, *optional*, defaults to 1024): Dimensionality of the layers and the pooler layer. encoder_layers (`int`, *optional*, defaults to 12): Number of encoder layers. decoder_layers (`int`, *optional*, defaults to 12): Number of decoder layers. encoder_attention_heads (`int`, *optional*, defaults to 16): Number of attention heads for each attention layer in the Transformer encoder. decoder_attention_heads (`int`, *optional*, defaults to 16): Number of attention heads for each attention layer in the Transformer decoder. decoder_ffn_dim (`int`, *optional*, defaults to 4096): Dimensionality of the "intermediate" (often named feed-forward) layer in decoder. encoder_ffn_dim (`int`, *optional*, defaults to 4096): Dimensionality of the "intermediate" (often named feed-forward) layer in decoder. activation_function (`str` or `function`, *optional*, defaults to `"gelu"`): The non-linear activation function (function or string) in the encoder and pooler. If string, `"gelu"`, `"relu"`, `"silu"` and `"gelu_new"` are supported. dropout (`float`, *optional*, defaults to 0.1): The dropout probability for all fully connected layers in the embeddings, encoder, and pooler. attention_dropout (`float`, *optional*, defaults to 0.0): The dropout ratio for the attention probabilities. activation_dropout (`float`, *optional*, defaults to 0.0): The dropout ratio for activations inside the fully connected layer. classifier_dropout (`float`, *optional*, defaults to 0.0): The dropout ratio for classifier. max_position_embeddings (`int`, *optional*, defaults to 1024): The maximum sequence length that this model might ever be used with. Typically set this to something large just in case (e.g., 512 or 1024 or 2048). init_std (`float`, *optional*, defaults to 0.02): The standard deviation of the truncated_normal_initializer for initializing all weight matrices. encoder_layerdrop (`float`, *optional*, defaults to 0.0): The LayerDrop probability for the encoder. See the [LayerDrop paper](see https://arxiv.org/abs/1909.11556) for more details. decoder_layerdrop (`float`, *optional*, defaults to 0.0): The LayerDrop probability for the decoder. See the [LayerDrop paper](see https://arxiv.org/abs/1909.11556) for more details. scale_embedding (`bool`, *optional*, defaults to `False`): Scale embeddings by diving by sqrt(d_model). use_cache (`bool`, *optional*, defaults to `True`): Whether or not the model should return the last key/values attentions (not used by all models). num_labels (`int`, *optional*, defaults to 3): The number of labels to use in [`Florence2LanguageForSequenceClassification`]. forced_eos_token_id (`int`, *optional*, defaults to 2): The id of the token to force as the last generated token when `max_length` is reached. Usually set to `eos_token_id`.
Example:
```python >>> from transformers import Florence2LanguageConfig, Florence2LanguageModel
>>> # Initializing a Florence2 Language style configuration >>> configuration = Florence2LanguageConfig()
>>> # Initializing a model (with random weights) >>> model = Florence2LangaugeModel(configuration)
>>> # Accessing the model configuration >>> configuration = model.config ```"""
model_type = "florence2_language" keys_to_ignore_at_inference = ["past_key_values"] attribute_map = {"num_attention_heads": "encoder_attention_heads", "hidden_size": "d_model"}
def __init__( self, vocab_size=51289, max_position_embeddings=1024, encoder_layers=12, encoder_ffn_dim=4096, encoder_attention_heads=16, decoder_layers=12, decoder_ffn_dim=4096, decoder_attention_heads=16, encoder_layerdrop=0.0, decoder_layerdrop=0.0, activation_function="gelu", d_model=1024, dropout=0.1, attention_dropout=0.0, activation_dropout=0.0, init_std=0.02, classifier_dropout=0.0, scale_embedding=False, use_cache=True, num_labels=3, pad_token_id=1, bos_token_id=0, eos_token_id=2, is_encoder_decoder=True, decoder_start_token_id=2, forced_eos_token_id=2, **kwargs, ): self.vocab_size = vocab_size self.max_position_embeddings = max_position_embeddings self.d_model = d_model self.encoder_ffn_dim = encoder_ffn_dim self.encoder_layers = encoder_layers self.encoder_attention_heads = encoder_attention_heads self.decoder_ffn_dim = decoder_ffn_dim self.decoder_layers = decoder_layers self.decoder_attention_heads = decoder_attention_heads self.dropout = dropout self.attention_dropout = attention_dropout self.activation_dropout = activation_dropout self.activation_function = activation_function self.init_std = init_std self.encoder_layerdrop = encoder_layerdrop self.decoder_layerdrop = decoder_layerdrop self.classifier_dropout = classifier_dropout self.use_cache = use_cache self.num_hidden_layers = encoder_layers self.scale_embedding = scale_embedding # scale factor will be sqrt(d_model) if True
super().__init__( num_labels=num_labels, pad_token_id=pad_token_id, bos_token_id=bos_token_id, eos_token_id=eos_token_id, is_encoder_decoder=is_encoder_decoder, decoder_start_token_id=decoder_start_token_id, forced_eos_token_id=forced_eos_token_id, **kwargs, )
# ensure backward compatibility for BART CNN models if self.forced_bos_token_id is None and kwargs.get("force_bos_token_to_be_generated", False): self.forced_bos_token_id = self.bos_token_id warnings.warn( f"Please make sure the config includes `forced_bos_token_id={self.bos_token_id}` in future versions. " "The config can simply be saved and uploaded again to be fixed." )
class Florence2Config(PretrainedConfig): r""" This is the configuration class to store the configuration of a [`Florence2ForConditionalGeneration`]. It is used to instantiate an Florence-2 model according to the specified arguments, defining the model architecture.
Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the documentation from [`PretrainedConfig`] for more information.
Args: vision_config (`Florence2VisionConfig`, *optional*): Custom vision config or dict text_config (`Union[AutoConfig, dict]`, *optional*): The config object of the text backbone. ignore_index (`int`, *optional*, defaults to -100): The ignore index for the loss function. vocab_size (`int`, *optional*, defaults to 51289): Vocabulary size of the Florence2model. Defines the number of different tokens that can be represented by the `inputs_ids` passed when calling [`~Florence2ForConditionalGeneration`] projection_dim (`int`, *optional*, defaults to 1024): Dimension of the multimodal projection space.
Example:
```python >>> from transformers import Florence2ForConditionalGeneration, Florence2Config, CLIPVisionConfig, BartConfig
>>> # Initializing a clip-like vision config >>> vision_config = CLIPVisionConfig()
>>> # Initializing a Bart config >>> text_config = BartConfig()
>>> # Initializing a Florence-2 configuration >>> configuration = Florence2Config(vision_config, text_config)
>>> # Initializing a model from the florence-2 configuration >>> model = Florence2ForConditionalGeneration(configuration)
>>> # Accessing the model configuration >>> configuration = model.config ```"""
model_type = "florence2" is_composition = False
def __init__( self, vision_config=None, text_config=None, ignore_index=-100, vocab_size=51289, projection_dim=1024, **kwargs, ): self.ignore_index = ignore_index self.vocab_size = vocab_size self.projection_dim = projection_dim if vision_config is not None: vision_config = PretrainedConfig(**vision_config) self.vision_config = vision_config self.vocab_size = self.vocab_size
self.text_config = text_config if text_config is not None: self.text_config = Florence2LanguageConfig(**text_config)
super().__init__(**kwargs)
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088# coding=utf-8# Copyright 2024 Microsoft and The HuggingFace Inc. team.## Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# You may obtain a copy of the License at## http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License."""Processor class for Florence-2."""
import reimport loggingfrom typing import List, Optional, Unionimport numpy as np
import torch
from transformers.feature_extraction_utils import BatchFeaturefrom transformers.image_utils import ImageInput, is_valid_imagefrom transformers.processing_utils import ProcessorMixinfrom transformers.tokenization_utils_base import ( PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy,)from transformers.utils import TensorType
logger = logging.getLogger(__name__)
# Copied from transformers.models.idefics2.processing_idefics2.is_urldef is_url(val) -> bool: return isinstance(val, str) and val.startswith("http")
# Copied from transformers.models.idefics2.processing_idefics2.is_image_or_image_urldef is_image_or_image_url(elem): return is_url(elem) or is_valid_image(elem)
def _is_str_or_image(elem): return isinstance(elem, (str)) or is_image_or_image_url(elem)
class Florence2Processor(ProcessorMixin): r""" Constructs a Florence2 processor which wraps a Florence2 image processor and a Florence2 tokenizer into a single processor.
[`Florence2Processor`] offers all the functionalities of [`CLIPImageProcessor`] and [`BartTokenizerFast`]. See the [`~Florence2Processor.__call__`] and [`~Florence2Processor.decode`] for more information.
Args: image_processor ([`CLIPImageProcessor`], *optional*): The image processor is a required input. tokenizer ([`BartTokenizerFast`], *optional*): The tokenizer is a required input. """
attributes = ["image_processor", "tokenizer"] image_processor_class = "CLIPImageProcessor" tokenizer_class = ("BartTokenizer", "BartTokenizerFast")
def __init__( self, image_processor=None, tokenizer=None, ): if image_processor is None: raise ValueError("You need to specify an `image_processor`.") if tokenizer is None: raise ValueError("You need to specify a `tokenizer`.") if not hasattr(image_processor, "image_seq_length"): raise ValueError("Image processor is missing an `image_seq_length` attribute.")
self.image_seq_length = image_processor.image_seq_length
tokens_to_add = { 'additional_special_tokens': \ tokenizer.additional_special_tokens + \ ['<od>', '</od>', '<ocr>', '</ocr>'] + \ [f'<loc_{x}>' for x in range(1000)] + \ ['<cap>', '</cap>', '<ncap>', '</ncap>','<dcap>', '</dcap>', '<grounding>', '</grounding>', '<seg>', '</seg>', '<sep>', '<region_cap>', '</region_cap>', '<region_to_desciption>', '</region_to_desciption>', '<proposal>', '</proposal>', '<poly>', '</poly>', '<and>'] } tokenizer.add_special_tokens(tokens_to_add)
self.tasks_answer_post_processing_type = { '<OCR>': 'pure_text', '<OCR_WITH_REGION>': 'ocr', '<CAPTION>': 'pure_text', '<DETAILED_CAPTION>': 'pure_text', '<MORE_DETAILED_CAPTION>': 'pure_text', '<OD>': 'description_with_bboxes', '<DENSE_REGION_CAPTION>': 'description_with_bboxes', '<CAPTION_TO_PHRASE_GROUNDING>': "phrase_grounding", '<REFERRING_EXPRESSION_SEGMENTATION>': 'polygons', '<REGION_TO_SEGMENTATION>': 'polygons', '<OPEN_VOCABULARY_DETECTION>': 'description_with_bboxes_or_polygons', '<REGION_TO_CATEGORY>': 'pure_text', '<REGION_TO_DESCRIPTION>': 'pure_text', '<REGION_TO_OCR>': 'pure_text', '<REGION_PROPOSAL>': 'bboxes' }
self.task_prompts_without_inputs = { '<OCR>': 'What is the text in the image?', '<OCR_WITH_REGION>': 'What is the text in the image, with regions?', '<CAPTION>': 'What does the image describe?', '<DETAILED_CAPTION>': 'Describe in detail what is shown in the image.', '<MORE_DETAILED_CAPTION>': 'Describe with a paragraph what is shown in the image.', '<OD>': 'Locate the objects with category name in the image.', '<DENSE_REGION_CAPTION>': 'Locate the objects in the image, with their descriptions.', '<REGION_PROPOSAL>': 'Locate the region proposals in the image.' }
self.task_prompts_with_input = { '<CAPTION_TO_PHRASE_GROUNDING>': "Locate the phrases in the caption: {input}", '<REFERRING_EXPRESSION_SEGMENTATION>': 'Locate {input} in the image with mask', '<REGION_TO_SEGMENTATION>': 'What is the polygon mask of region {input}', '<OPEN_VOCABULARY_DETECTION>': 'Locate {input} in the image.', '<REGION_TO_CATEGORY>': 'What is the region {input}?', '<REGION_TO_DESCRIPTION>': 'What does the region {input} describe?', '<REGION_TO_OCR>': 'What text is in the region {input}?', }
self.post_processor = Florence2PostProcesser(tokenizer=tokenizer)
super().__init__(image_processor, tokenizer) def _construct_prompts(self, text): # replace the task tokens with the task prompts if task token is in the text prompts = [] for _text in text: # 1. fixed task prompts without additional inputs for task_token, task_prompt in self.task_prompts_without_inputs.items(): if task_token in _text: assert _text == task_token, f"Task token {task_token} should be the only token in the text." _text = task_prompt break # 2. task prompts with additional inputs for task_token, task_prompt in self.task_prompts_with_input.items(): if task_token in _text: _text = task_prompt.format(input=_text.replace(task_token, '')) break prompts.append(_text) return prompts
def __call__( self, text: Union[TextInput, PreTokenizedInput, List[TextInput], List[PreTokenizedInput]] = None, images: ImageInput = None, tokenize_newline_separately: bool = True, padding: Union[bool, str, PaddingStrategy] = False, truncation: Union[bool, str, TruncationStrategy] = None, max_length=None, return_tensors: Optional[Union[str, TensorType]] = TensorType.PYTORCH, do_resize: bool = None, do_normalize: bool = None, image_mean: Optional[Union[float, List[float]]] = None, image_std: Optional[Union[float, List[float]]] = None, data_format: Optional["ChannelDimension"] = "channels_first", # noqa: F821 input_data_format: Optional[ Union[str, "ChannelDimension"] # noqa: F821 ] = None, resample: "PILImageResampling" = None, # noqa: F821 do_convert_rgb: bool = None, do_thumbnail: bool = None, do_align_long_axis: bool = None, do_rescale: bool = None, ) -> BatchFeature: """ Main method to prepare for the model one or several sequences(s) and image(s). This method forwards the `text` and `kwargs` arguments to BartTokenizerFast's [`~BartTokenizerFast.__call__`] if `text` is not `None` to encode the text. To prepare the image(s), this method forwards the `images` and `kwrags` arguments to CLIPImageProcessor's [`~CLIPImageProcessor.__call__`] if `images` is not `None`. Please refer to the doctsring of the above two methods for more information.
Args: text (`str`, `List[str]`, `List[List[str]]`): The sequence or batch of sequences to be encoded. Each sequence can be a string or a list of strings (pretokenized string). If the sequences are provided as list of strings (pretokenized), you must set `is_split_into_words=True` (to lift the ambiguity with a batch of sequences). images (`PIL.Image.Image`, `np.ndarray`, `torch.Tensor`, `List[PIL.Image.Image]`, `List[np.ndarray]`, `List[torch.Tensor]`): The image or batch of images to be prepared. Each image can be a PIL image, NumPy array or PyTorch tensor. In case of a NumPy array/PyTorch tensor, each image should be of shape (C, H, W), where C is a number of channels, H and W are image height and width. tokenize_newline_separately (`bool`, defaults to `True`): Adds a separately tokenized '\n' at the end of the prompt. padding (`bool`, `str` or [`~utils.PaddingStrategy`], *optional*, defaults to `False`): Select a strategy to pad the returned sequences (according to the model's padding side and padding index) among: - `True` or `'longest'`: Pad to the longest sequence in the batch (or no padding if only a single sequence if provided). - `'max_length'`: Pad to a maximum length specified with the argument `max_length` or to the maximum acceptable input length for the model if that argument is not provided. - `False` or `'do_not_pad'` (default): No padding (i.e., can output a batch with sequences of different lengths). max_length (`int`, *optional*): Maximum length of the returned list and optionally padding length (see above). truncation (`bool`, *optional*): Activates truncation to cut input sequences longer than `max_length` to `max_length`. return_tensors (`str` or [`~utils.TensorType`], *optional*): If set, will return tensors of a particular framework. Acceptable values are:
- `'tf'`: Return TensorFlow `tf.constant` objects. - `'pt'`: Return PyTorch `torch.Tensor` objects. - `'np'`: Return NumPy `np.ndarray` objects. - `'jax'`: Return JAX `jnp.ndarray` objects.
Returns: [`BatchFeature`]: A [`BatchFeature`] with the following fields:
- **input_ids** -- List of token ids to be fed to a model. Returned when `text` is not `None`. If `suffix` is provided, the `input_ids` will also contain the suffix input ids. - **attention_mask** -- List of indices specifying which tokens should be attended to by the model (when `return_attention_mask=True` or if *"attention_mask"* is in `self.model_input_names` and if `text` is not `None`). - **pixel_values** -- Pixel values to be fed to a model. Returned when `images` is not `None`. - **labels** -- Labels compatible with training if `suffix` is not None """
return_token_type_ids = False
if images is None: raise ValueError("`images` are expected as arguments to a `Florence2Processor` instance.") if text is None: logger.warning_once( "You are using Florence-2 without a text prompt." ) text = ""
if isinstance(text, List) and isinstance(images, List): if len(images) < len(text): raise ValueError( f"Received {len(images)} images for {len(text)} prompts. Each prompt should be associated with an image." ) if _is_str_or_image(text): text = [text] elif isinstance(text, list) and _is_str_or_image(text[0]): pass
pixel_values = self.image_processor( images, do_resize=do_resize, do_normalize=do_normalize, return_tensors=return_tensors, image_mean=image_mean, image_std=image_std, input_data_format=input_data_format, data_format=data_format, resample=resample, do_convert_rgb=do_convert_rgb, )["pixel_values"]
if max_length is not None: max_length -= self.image_seq_length # max_length has to account for the image tokens
text = self._construct_prompts(text)
inputs = self.tokenizer( text, return_tensors=return_tensors, padding=padding, max_length=max_length, truncation=truncation, return_token_type_ids=return_token_type_ids, )
return_data = {**inputs, "pixel_values": pixel_values}
if return_token_type_ids: labels = inputs["input_ids"].masked_fill(inputs["token_type_ids"] == 0, -100) return_data.update({"labels": labels}) return BatchFeature(data=return_data)
# Copied from transformers.models.clip.processing_clip.CLIPProcessor.batch_decode with CLIP->Florence2 def batch_decode(self, *args, **kwargs): """ This method forwards all its arguments to BartTokenizerFast's [`~PreTrainedTokenizer.batch_decode`]. Please refer to the docstring of this method for more information. """ return self.tokenizer.batch_decode(*args, **kwargs)
# Copied from transformers.models.clip.processing_clip.CLIPProcessor.decode with CLIP->Florence2 def decode(self, *args, **kwargs): """ This method forwards all its arguments to BartTokenizerFast's [`~PreTrainedTokenizer.decode`]. Please refer to the docstring of this method for more information. """ return self.tokenizer.decode(*args, **kwargs)
@property # Copied from transformers.models.clip.processing_clip.CLIPProcessor.model_input_names with CLIP->Florence2 def model_input_names(self): tokenizer_input_names = self.tokenizer.model_input_names image_processor_input_names = self.image_processor.model_input_names return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names))
def post_process_generation(self, text, task, image_size): """ Post-process the output of the model to each of the task outputs.
Args: text (`str`): The text to post-process. task (`str`): The task to post-process the text for. image_size (`Tuple[int, int]`): The size of the image. height x width. """
task_answer_post_processing_type = self.tasks_answer_post_processing_type.get(task, 'pure_text') task_answer = self.post_processor( text=text, image_size=image_size, parse_tasks=task_answer_post_processing_type, )[task_answer_post_processing_type]
if task_answer_post_processing_type == 'pure_text': final_answer = task_answer # remove the special tokens final_answer = final_answer.replace('<s>', '').replace('</s>', '') elif task_answer_post_processing_type in ['od', 'description_with_bboxes', 'bboxes']: od_instances = task_answer bboxes_od = [_od_instance['bbox'] for _od_instance in od_instances] labels_od = [str(_od_instance['cat_name']) for _od_instance in od_instances] final_answer = {'bboxes': bboxes_od, 'labels': labels_od} elif task_answer_post_processing_type in ['ocr']: bboxes = [_od_instance['quad_box'] for _od_instance in task_answer] labels = [str(_od_instance['text']) for _od_instance in task_answer] final_answer = {'quad_boxes': bboxes, 'labels': labels} elif task_answer_post_processing_type in ['phrase_grounding']: bboxes = [] labels = [] for _grounded_phrase in task_answer: for _bbox in _grounded_phrase['bbox']: bboxes.append(_bbox) labels.append(_grounded_phrase['cat_name']) final_answer = {'bboxes': bboxes, 'labels': labels} elif task_answer_post_processing_type in ['description_with_polygons', 'polygons']: labels = [] polygons = [] for result in task_answer: label = result['cat_name'] _polygons = result['polygons'] labels.append(label) polygons.append(_polygons) final_answer = {'polygons': polygons, 'labels': labels} elif task_answer_post_processing_type in ['description_with_bboxes_or_polygons']: bboxes = [] bboxes_labels = [] polygons = [] polygons_labels = [] for result in task_answer: label = result['cat_name'] if 'polygons' in result: _polygons = result['polygons'] polygons.append(_polygons) polygons_labels.append(label) else: _bbox = result['bbox'] bboxes.append(_bbox) bboxes_labels.append(label) final_answer = {'bboxes': bboxes, 'bboxes_labels': bboxes_labels, 'polygons': polygons, 'polygons_labels': polygons_labels} else: raise ValueError('Unknown task answer post processing type: {}'.format(task_answer_post_processing_type))
final_answer = { task: final_answer} return final_answer
class BoxQuantizer(object): def __init__(self, mode, bins): self.mode = mode self.bins = bins
def quantize(self, boxes: torch.Tensor, size): bins_w, bins_h = self.bins # Quantization bins. size_w, size_h = size # Original image size. size_per_bin_w = size_w / bins_w size_per_bin_h = size_h / bins_h xmin, ymin, xmax, ymax = boxes.split(1, dim=-1) # Shape: 4 * [N, 1].
if self.mode == 'floor': quantized_xmin = ( xmin / size_per_bin_w).floor().clamp(0, bins_w - 1) quantized_ymin = ( ymin / size_per_bin_h).floor().clamp(0, bins_h - 1) quantized_xmax = ( xmax / size_per_bin_w).floor().clamp(0, bins_w - 1) quantized_ymax = ( ymax / size_per_bin_h).floor().clamp(0, bins_h - 1)
elif self.mode == 'round': raise NotImplementedError()
else: raise ValueError('Incorrect quantization type.')
quantized_boxes = torch.cat( (quantized_xmin, quantized_ymin, quantized_xmax, quantized_ymax), dim=-1 ).int()
return quantized_boxes
def dequantize(self, boxes: torch.Tensor, size): bins_w, bins_h = self.bins # Quantization bins. size_w, size_h = size # Original image size. size_per_bin_w = size_w / bins_w size_per_bin_h = size_h / bins_h xmin, ymin, xmax, ymax = boxes.split(1, dim=-1) # Shape: 4 * [N, 1].
if self.mode == 'floor': # Add 0.5 to use the center position of the bin as the coordinate. dequantized_xmin = (xmin + 0.5) * size_per_bin_w dequantized_ymin = (ymin + 0.5) * size_per_bin_h dequantized_xmax = (xmax + 0.5) * size_per_bin_w dequantized_ymax = (ymax + 0.5) * size_per_bin_h
elif self.mode == 'round': raise NotImplementedError()
else: raise ValueError('Incorrect quantization type.')
dequantized_boxes = torch.cat( (dequantized_xmin, dequantized_ymin, dequantized_xmax, dequantized_ymax), dim=-1 )
return dequantized_boxes
class CoordinatesQuantizer(object): """ Quantize coornidates (Nx2) """
def __init__(self, mode, bins): self.mode = mode self.bins = bins
def quantize(self, coordinates: torch.Tensor, size): bins_w, bins_h = self.bins # Quantization bins. size_w, size_h = size # Original image size. size_per_bin_w = size_w / bins_w size_per_bin_h = size_h / bins_h assert coordinates.shape[-1] == 2, 'coordinates should be shape (N, 2)' x, y = coordinates.split(1, dim=-1) # Shape: 4 * [N, 1].
if self.mode == 'floor': quantized_x = (x / size_per_bin_w).floor().clamp(0, bins_w - 1) quantized_y = (y / size_per_bin_h).floor().clamp(0, bins_h - 1)
elif self.mode == 'round': raise NotImplementedError()
else: raise ValueError('Incorrect quantization type.')
quantized_coordinates = torch.cat( (quantized_x, quantized_y), dim=-1 ).int()
return quantized_coordinates
def dequantize(self, coordinates: torch.Tensor, size): bins_w, bins_h = self.bins # Quantization bins. size_w, size_h = size # Original image size. size_per_bin_w = size_w / bins_w size_per_bin_h = size_h / bins_h assert coordinates.shape[-1] == 2, 'coordinates should be shape (N, 2)' x, y = coordinates.split(1, dim=-1) # Shape: 4 * [N, 1].
if self.mode == 'floor': # Add 0.5 to use the center position of the bin as the coordinate. dequantized_x = (x + 0.5) * size_per_bin_w dequantized_y = (y + 0.5) * size_per_bin_h
elif self.mode == 'round': raise NotImplementedError()
else: raise ValueError('Incorrect quantization type.')
dequantized_coordinates = torch.cat( (dequantized_x, dequantized_y), dim=-1 )
return dequantized_coordinates
class Florence2PostProcesser(object): r""" Florence-2 post process for converting text prediction to various tasks results.
Args: config: A dict of configs. tokenizer: A tokenizer for decoding text to spans. sample config: UNIFIED_POST_PROCESS: # commom configs NUM_BBOX_HEIGHT_BINS: 1000 NUM_BBOX_WIDTH_BINS: 1000 COORDINATES_HEIGHT_BINS: 1000 COORDINATES_WIDTH_BINS: 1000 # task specific configs, override the common configs PRASE_TASKS: - TASK_NAME: 'video_dense_caption' PATTERN: 'r<time_(\d+)><time_(\d+)>([a-zA-Z0-9 ]+)' SCORE_MODE: 'avg_cat_name_scores' NUM_BINS: 100 - TASK_NAME: 'od' PATTERN: 'r<loc_(\d+)><loc_(\d+)><loc_(\d+)><loc_(\d+)>([a-zA-Z0-9 ]+)' SCORE_MODE: 'avg_cat_name_scores'
Returns: parsed_dict (dict): A dict of parsed results. """ def __init__( self, tokenizer=None ): parse_tasks = [] parse_task_configs = {} config = self._create_default_config() for task in config['PARSE_TASKS']: parse_tasks.append(task['TASK_NAME']) parse_task_configs[task['TASK_NAME']] = task
self.config = config self.parse_tasks = parse_tasks self.parse_tasks_configs = parse_task_configs
self.tokenizer = tokenizer if self.tokenizer is not None: self.all_special_tokens = set(self.tokenizer.all_special_tokens)
self.init_quantizers() self.black_list_of_phrase_grounding = self._create_black_list_of_phrase_grounding()
def _create_black_list_of_phrase_grounding(self): black_list = {}
if 'phrase_grounding' in self.parse_tasks and self.parse_tasks_configs['phrase_grounding']['FILTER_BY_BLACK_LIST']: black_list = set( ['it', 'I', 'me', 'mine', 'you', 'your', 'yours', 'he', 'him', 'his', 'she', 'her', 'hers', 'they', 'them', 'their', 'theirs', 'one', 'oneself', 'we', 'us', 'our', 'ours', 'you', 'your', 'yours', 'they', 'them', 'their', 'theirs', 'mine', 'yours', 'his', 'hers', 'its', 'ours', 'yours', 'theirs', 'myself', 'yourself', 'himself', 'herself', 'itself', 'ourselves', 'yourselves', 'themselves', 'this', 'that', 'these', 'those', 'who', 'whom', 'whose', 'which', 'what', 'who', 'whom', 'whose', 'which', 'that', 'all', 'another', 'any', 'anybody', 'anyone', 'anything', 'each', 'everybody', 'everyone', 'everything', 'few', 'many', 'nobody', 'none', 'one', 'several', 'some', 'somebody', 'someone', 'something', 'each other', 'one another', 'myself', 'yourself', 'himself', 'herself', 'itself', 'ourselves', 'yourselves', 'themselves', 'the image', 'image', 'images', 'the', 'a', 'an', 'a group', 'other objects', 'lots', 'a set', ] )
return black_list def _create_default_config(self): config = { 'NUM_BBOX_HEIGHT_BINS': 1000, 'NUM_BBOX_WIDTH_BINS': 1000, 'BOX_QUANTIZATION_MODE': 'floor', 'COORDINATES_HEIGHT_BINS': 1000, 'COORDINATES_WIDTH_BINS': 1000, 'COORDINATES_QUANTIZATION_MODE': 'floor', 'PARSE_TASKS': [ { 'TASK_NAME': 'od', 'PATTERN': r'([a-zA-Z0-9 ]+)<loc_(\\d+)><loc_(\\d+)><loc_(\\d+)><loc_(\\d+)>' }, { 'TASK_NAME': 'ocr', 'PATTERN': r'(.+?)<loc_(\d+)><loc_(\d+)><loc_(\d+)><loc_(\d+)><loc_(\d+)><loc_(\d+)><loc_(\d+)><loc_(\d+)>', 'AREA_THRESHOLD': 0.00 }, { 'TASK_NAME': 'phrase_grounding', 'FILTER_BY_BLACK_LIST': True }, { 'TASK_NAME': 'pure_text', }, { 'TASK_NAME': 'description_with_bboxes', }, { 'TASK_NAME': 'description_with_polygons', }, { 'TASK_NAME': 'polygons', }, { 'TASK_NAME': 'bboxes', }, { 'TASK_NAME': 'description_with_bboxes_or_polygons', } ] }
return config
def init_quantizers(self): # we have box_quantizer (od, grounding) and coordinates_quantizer (ocr, referring_segmentation) num_bbox_height_bins = self.config.get('NUM_BBOX_HEIGHT_BINS', 1000) num_bbox_width_bins = self.config.get('NUM_BBOX_WIDTH_BINS', 1000) box_quantization_mode = self.config.get('BOX_QUANTIZATION_MODE', 'floor') self.box_quantizer = BoxQuantizer( box_quantization_mode, (num_bbox_width_bins, num_bbox_height_bins), ) num_bbox_height_bins = self.config['COORDINATES_HEIGHT_BINS'] if 'COORDINATES_HEIGHT_BINS' in self.config else self.config.get('NUM_BBOX_HEIGHT_BINS', 1000) num_bbox_width_bins = self.config['COORDINATES_WIDTH_BINS'] if 'COORDINATES_WIDTH_BINS' in self.config else self.config.get('NUM_BBOX_WIDTH_BINS', 1000) box_quantization_mode = self.config.get('COORDINATES_QUANTIZATION_MODE') if 'COORDINATES_QUANTIZATION_MODE' in self.config else self.config.get('BOX_QUANTIZATION_MODE', 'floor') self.coordinates_quantizer = CoordinatesQuantizer( box_quantization_mode, (num_bbox_width_bins, num_bbox_height_bins), )
def decode_with_spans(self, tokenizer, token_ids): filtered_tokens = tokenizer.convert_ids_to_tokens( token_ids, skip_special_tokens=False) assert len(filtered_tokens) == len(token_ids)
# To avoid mixing byte-level and unicode for byte-level BPT # we need to build string separately for added tokens and byte-level tokens # cf. https://github.com/huggingface/transformers/issues/1133 sub_texts = [] for token in filtered_tokens: if token in self.all_special_tokens: sub_texts.append(token) else: if isinstance(tokenizer, (BartTokenizer, BartTokenizerFast)): sub_text = tokenizer.convert_tokens_to_string([token]) elif isinstance(tokenizer, (T5Tokenizer, T5TokenizerFast)): # Ref: https://github.com/google/sentencepiece#whitespace-is-treated-as-a-basic-symbol # Note: Do not strip sub_text as it may have functional whitespace sub_text = token.replace('▁', ' ') else: raise ValueError(f'type {type(tokenizer)} not supported') sub_texts.append(sub_text)
text = '' spans = [] for sub_text in sub_texts: span = (len(text), len(text) + len(sub_text)) # [start index, end index). text += sub_text spans.append(span)
# Text format: # 1. T5Tokenizer/T5TokenizerFast: # "<loc_1><loc_2><loc_3><loc_4> transplanting dog<loc_1><loc_2><loc_3><loc_4> cat</s>" # Equivalent to t5_tokenizer.decode(input_ids, skip_special_tokens=False, clean_up_tokenization_spaces=False, spaces_between_special_tokens=False) # 2. BartTokenizer (need to double check): # "<s><loc_1><loc_2><loc_3><loc_4>transplanting dog<loc_1><loc_2><loc_3><loc_4>cat</s>" # Equivalent to bart_tokenizer.decode(input_ids, skip_special_tokens=False, clean_up_tokenization_spaces=False, spaces_between_special_tokens=False) return text, spans
def parse_od_from_text_and_spans( self, text, pattern, image_size, phrase_centric=False ): parsed = list(re.finditer(pattern, text))
instances = [] for i in range(len(parsed)): # Prepare instance. instance = {}
if phrase_centric: bbox_bins = [int(parsed[i].group(j)) for j in range(2, 6)] else: bbox_bins = [int(parsed[i].group(j)) for j in range(1, 5)] instance['bbox'] = self.box_quantizer.dequantize( boxes=torch.tensor(bbox_bins), size=image_size ).tolist()
if phrase_centric: instance['cat_name'] = parsed[i].group(1).lower().strip() else: instance['cat_name'] = parsed[i].group(5).lower().strip() instances.append(instance)
return instances
def parse_ocr_from_text_and_spans(self, text, pattern, image_size, area_threshold=-1.0, ): bboxes = [] labels = [] text = text.replace('<s>', '') # ocr with regions parsed = re.findall(pattern, text) instances = [] image_width, image_height = image_size
for ocr_line in parsed: ocr_content = ocr_line[0] quad_box = ocr_line[1:] quad_box = [int(i) for i in quad_box] quad_box = self.coordinates_quantizer.dequantize( torch.tensor(np.array(quad_box).reshape(-1, 2)), size=image_size ).reshape(-1).tolist()
if area_threshold > 0: x_coords = [i for i in quad_box[0::2]] y_coords = [i for i in quad_box[1::2]]
# apply the Shoelace formula area = 0.5 * abs(sum(x_coords[i] * y_coords[i + 1] - x_coords[i + 1] * y_coords[i] for i in range(4 - 1)))
if area < (image_width * image_height) * area_threshold: continue
bboxes.append(quad_box) labels.append(ocr_content) instances.append({ 'quad_box': quad_box, 'text': ocr_content, }) return instances
def parse_phrase_grounding_from_text_and_spans(self, text, pattern, image_size): # ignore <s> </s> and <pad> cur_span = 0 if text.startswith('<s>'): cur_span += 3
text = text.replace('<s>', '') text = text.replace('</s>', '') text = text.replace('<pad>', '')
pattern = r"([^<]+(?:<loc_\d+>){4,})" phrases = re.findall(pattern, text) # pattern should be text pattern and od pattern pattern = r'^\s*(.*?)(?=<od>|</od>|<box>|</box>|<bbox>|</bbox>|<loc_)' box_pattern = r'<loc_(\d+)><loc_(\d+)><loc_(\d+)><loc_(\d+)>'
instances = [] for pharse_text in phrases: phrase_text_strip = pharse_text.replace('<ground>', '', 1) phrase_text_strip = pharse_text.replace('<obj>', '', 1)
if phrase_text_strip == '': cur_span += len(pharse_text) continue
# Prepare instance. instance = {}
# parse phrase, get string phrase = re.search(pattern, phrase_text_strip) if phrase is None: cur_span += len(pharse_text) continue
# parse bboxes by box_pattern bboxes_parsed = list(re.finditer(box_pattern, pharse_text)) if len(bboxes_parsed) == 0: cur_span += len(pharse_text) continue
phrase = phrase.group() # remove leading and trailing spaces phrase = phrase.strip()
if phrase in self.black_list_of_phrase_grounding: cur_span += len(pharse_text) continue
# a list of list bbox_bins = [[int(_bboxes_parsed.group(j)) for j in range(1, 5)] for _bboxes_parsed in bboxes_parsed] instance['bbox'] = self.box_quantizer.dequantize( boxes=torch.tensor(bbox_bins), size=image_size ).tolist()
# exclude non-ascii characters phrase = phrase.encode('ascii',errors='ignore').decode('ascii') instance['cat_name'] = phrase
instances.append(instance)
return instances
def parse_description_with_bboxes_from_text_and_spans(self, text, pattern, image_size, allow_empty_phrase=False): # temporary parse solution, split by '.' # ignore <s> </s> and <pad>
text = text.replace('<s>', '') text = text.replace('</s>', '') text = text.replace('<pad>', '')
if allow_empty_phrase: pattern = rf"(?:(?:<loc_\d+>){{4,}})" else: pattern = r"([^<]+(?:<loc_\d+>){4,})" phrases = re.findall(pattern, text) # pattern should be text pattern and od pattern pattern = r'^\s*(.*?)(?=<od>|</od>|<box>|</box>|<bbox>|</bbox>|<loc_)' box_pattern = r'<loc_(\d+)><loc_(\d+)><loc_(\d+)><loc_(\d+)>'
instances = [] for pharse_text in phrases: phrase_text_strip = pharse_text.replace('<ground>', '', 1) phrase_text_strip = pharse_text.replace('<obj>', '', 1)
if phrase_text_strip == '' and not allow_empty_phrase: continue
# parse phrase, get string phrase = re.search(pattern, phrase_text_strip) if phrase is None: continue
phrase = phrase.group() # remove leading and trailing spaces phrase = phrase.strip()
# parse bboxes by box_pattern bboxes_parsed = list(re.finditer(box_pattern, pharse_text)) if len(bboxes_parsed) == 0: continue
# a list of list bbox_bins = [[int(_bboxes_parsed.group(j)) for j in range(1, 5)] for _bboxes_parsed in bboxes_parsed]
bboxes = self.box_quantizer.dequantize( boxes=torch.tensor(bbox_bins), size=image_size ).tolist()
phrase = phrase.encode('ascii',errors='ignore').decode('ascii') for _bboxes in bboxes: # Prepare instance. instance = {} instance['bbox'] = _bboxes # exclude non-ascii characters instance['cat_name'] = phrase instances.append(instance)
return instances
def parse_description_with_polygons_from_text_and_spans(self, text, pattern, image_size, allow_empty_phrase=False, polygon_sep_token='<sep>', polygon_start_token='<poly>', polygon_end_token='</poly>', with_box_at_start=False, ): # ref_seg format: '<expression><x1><y1><x2><y2><><><sep><><><><>' # ignore <s> </s> and <pad>
text = text.replace('<s>', '') text = text.replace('</s>', '') text = text.replace('<pad>', '')
if allow_empty_phrase: pattern = rf"(?:(?:<loc_\d+>|{re.escape(polygon_sep_token)}|{re.escape(polygon_start_token)}|{re.escape(polygon_end_token)}){{4,}})" else: # [^<]+: This part matches one or more characters that are not the < symbol. # The ^ inside the square brackets [] is a negation, meaning it matches anything except <. # pattern = rf"([^<]+(?:<loc_\d+>|{re.escape(polygon_sep_token)}|{re.escape(polygon_start_token)}|{re.escape(polygon_end_token)}){{4,}})" phrases = re.findall(pattern, text)
phrase_string_pattern = r'^\s*(.*?)(?=<od>|</od>|<box>|</box>|<bbox>|</bbox>|<loc_|<poly>)' box_pattern = rf'((?:<loc_\d+>)+)(?:{re.escape(polygon_sep_token)}|$)'
# one polygons instance is separated by polygon_start_token and polygon_end_token polygons_instance_pattern = rf'{re.escape(polygon_start_token)}(.*?){re.escape(polygon_end_token)}' instances = [] for phrase_text in phrases:
# exclude loc_\d+> # need to get span if want to include category score phrase_text_strip = re.sub(r'^loc_\d+>', '', phrase_text, count=1)
# phrase = phrase.replace('<poly>', '') # phrase = phrase.replace('poly>', '')
if phrase_text_strip == '' and not allow_empty_phrase: continue
# parse phrase, get string phrase = re.search(phrase_string_pattern, phrase_text_strip) if phrase is None: continue phrase = phrase.group() # remove leading and trailing spaces phrase = phrase.strip()
# parse bboxes by box_pattern
# split by polygon_start_token and polygon_end_token first using polygons_instance_pattern if polygon_start_token in phrase_text and polygon_end_token in phrase_text: polygons_instances_parsed = list(re.finditer(polygons_instance_pattern, phrase_text)) else: polygons_instances_parsed = [phrase_text]
for _polygons_instances_parsed in polygons_instances_parsed: # Prepare instance. instance = {}
# polygons_parsed= list(re.finditer(box_pattern, phrase_text)) if isinstance(_polygons_instances_parsed, str): polygons_parsed= list(re.finditer(box_pattern, _polygons_instances_parsed)) else: polygons_parsed= list(re.finditer(box_pattern, _polygons_instances_parsed.group(1))) if len(polygons_parsed) == 0: continue
# a list of list (polygon) bbox = [] polygons = [] for _polygon_parsed in polygons_parsed: # group 1: whole <loc_\d+>...</loc_\d+> _polygon = _polygon_parsed.group(1) # parse into list of int _polygon = [int(_loc_parsed.group(1)) for _loc_parsed in re.finditer(r'<loc_(\d+)>', _polygon)] if with_box_at_start and len(bbox) == 0: if len(_polygon) > 4: # no valid bbox prediction bbox = _polygon[:4] _polygon = _polygon[4:] else: bbox = [0, 0, 0, 0] # abandon last element if is not paired if len(_polygon) % 2 == 1: _polygon = _polygon[:-1] # reshape into (n, 2) _polygon = self.coordinates_quantizer.dequantize( torch.tensor(np.array(_polygon).reshape(-1, 2)), size=image_size ).reshape(-1).tolist() # reshape back polygons.append(_polygon)
instance['cat_name'] = phrase instance['polygons'] = polygons if len(bbox) != 0: instance['bbox'] = self.box_quantizer.dequantize( boxes=torch.tensor([bbox]), size=image_size ).tolist()[0]
instances.append(instance)
return instances
def __call__( self, text=None, image_size=None, parse_tasks=None, ): """ Args: text: model outputs image_size: (width, height) parse_tasks: a list of tasks to parse, if None, parse all tasks.
""" if parse_tasks is not None: if isinstance(parse_tasks, str): parse_tasks = [parse_tasks] for _parse_task in parse_tasks: assert _parse_task in self.parse_tasks, f'parse task {_parse_task} not supported' # sequence or text should be provided assert text is not None, 'text should be provided'
parsed_dict = { 'text': text }
for task in self.parse_tasks: if parse_tasks is not None and task not in parse_tasks: continue
pattern = self.parse_tasks_configs[task].get('PATTERN', None)
if task == 'ocr': instances = self.parse_ocr_from_text_and_spans( text, pattern=pattern, image_size=image_size, area_threshold=self.parse_tasks_configs[task].get('AREA_THRESHOLD', 0.0), ) parsed_dict['ocr'] = instances elif task == 'phrase_grounding': instances = self.parse_phrase_grounding_from_text_and_spans( text, pattern=pattern, image_size=image_size, ) parsed_dict['phrase_grounding'] = instances elif task == 'pure_text': parsed_dict['pure_text'] = text elif task == 'description_with_bboxes': instances = self.parse_description_with_bboxes_from_text_and_spans( text, pattern=pattern, image_size=image_size, ) parsed_dict['description_with_bboxes'] = instances elif task == 'description_with_polygons': instances = self.parse_description_with_polygons_from_text_and_spans( text, pattern=pattern, image_size=image_size, ) parsed_dict['description_with_polygons'] = instances elif task == 'polygons': instances = self.parse_description_with_polygons_from_text_and_spans( text, pattern=pattern, image_size=image_size, allow_empty_phrase=True, ) parsed_dict['polygons'] = instances elif task == 'bboxes': instances = self.parse_description_with_bboxes_from_text_and_spans( text, pattern=pattern, image_size=image_size, allow_empty_phrase=True, ) parsed_dict['bboxes'] = instances elif task == 'description_with_bboxes_or_polygons': if '<poly>' in text: # only support either polygons or bboxes, not both at the same time instances = self.parse_description_with_polygons_from_text_and_spans( text, pattern=pattern, image_size=image_size, ) else: instances = self.parse_description_with_bboxes_from_text_and_spans( text, pattern=pattern, image_size=image_size, ) parsed_dict['description_with_bboxes_or_polygons'] = instances else: raise ValueError("task {} is not supported".format(task))
return parsed_dict1234567891011--2024-11-26 12:45:57-- https://www.liblib.art/modelinfo/f8b990b20cb943e3aa0e96f34099d794?from=feedResolving www.liblib.art (www.liblib.art)... 47.93.126.33Connecting to www.liblib.art (www.liblib.art)|47.93.126.33|:443... connected.HTTP request sent, awaiting response... 200 OKLength: 48128 (47K) [text/html]Saving to: ‘f8b990b20cb943e3aa0e96f34099d794?from=feed’
f8b990b 0%[ ] 0 --.-KB/s
f8b990b20cb943e 100%[====>] 47.00K 310KB/s in 0.2s
2024-11-26 12:45:59 (310 KB/s) - ‘f8b990b20cb943e3aa0e96f34099d794?from=feed’ saved [48128/48128]
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112---license: apache-2.0tags:- visionwidget:- src: https://huggingface.co/datasets/mishig/sample_images/resolve/main/cat-dog-music.png candidate_labels: playing music, playing sports example_title: Cat & Dog---
# SigLIP (shape-optimized model)
SigLIP model pre-trained on WebLi at resolution 384x384. It was introduced in the paper [Sigmoid Loss for Language Image Pre-Training](https://arxiv.org/abs/2303.15343) by Zhai et al. and first released in [this repository](https://github.com/google-research/big_vision).
This model has the SoViT-400m architecture, which is the shape-optimized version as presented in [Getting ViT in Shape: Scaling Laws for Compute-Optimal Model Design](https://arxiv.org/abs/2305.13035) by Alabdulmohsin et al.
Disclaimer: The team releasing SigLIP did not write a model card for this model so this model card has been written by the Hugging Face team.
## Model description
SigLIP is [CLIP](https://huggingface.co/docs/transformers/model_doc/clip), a multimodal model, with a better loss function. The sigmoid loss operates solely on image-text pairs and does not require a global view of the pairwise similarities for normalization. This allows further scaling up the batch size, while also performing better at smaller batch sizes.
A TLDR of SigLIP by one of the authors can be found [here](https://twitter.com/giffmana/status/1692641733459267713).
## Intended uses & limitations
You can use the raw model for tasks like zero-shot image classification and image-text retrieval. See the [model hub](https://huggingface.co/models?search=google/siglip) to look forother versions on a task that interests you.
### How to use
Here is how to use this model to perform zero-shot image classification:
```pythonfrom PIL import Imageimport requestsfrom transformers import AutoProcessor, AutoModelimport torch
model = AutoModel.from_pretrained("google/siglip-so400m-patch14-384")processor = AutoProcessor.from_pretrained("google/siglip-so400m-patch14-384")
url = "http://images.cocodataset.org/val2017/000000039769.jpg"image = Image.open(requests.get(url, stream=True).raw)
texts = ["a photo of 2 cats", "a photo of 2 dogs"]inputs = processor(text=texts, images=image, padding="max_length", return_tensors="pt")
with torch.no_grad(): outputs = model(**inputs)
logits_per_image = outputs.logits_per_imageprobs = torch.sigmoid(logits_per_image) # these are the probabilitiesprint(f"{probs[0][0]:.1%} that image 0 is '{texts[0]}'")```
Alternatively, one can leverage the pipeline API which abstracts away the complexity for the user:
```pythonfrom transformers import pipelinefrom PIL import Imageimport requests
# load pipeimage_classifier = pipeline(task="zero-shot-image-classification", model="google/siglip-so400m-patch14-384")
# load imageurl = 'http://images.cocodataset.org/val2017/000000039769.jpg'image = Image.open(requests.get(url, stream=True).raw)
# inferenceoutputs = image_classifier(image, candidate_labels=["2 cats", "a plane", "a remote"])outputs = [{"score": round(output["score"], 4), "label": output["label"] } for output in outputs]print(outputs)```For more code examples, we refer to the [documentation](https://huggingface.co/transformers/main/model_doc/siglip.html#).
## Training procedure
### Training data
SigLIP is pre-trained on the WebLI dataset [(Chen et al., 2023)](https://arxiv.org/abs/2209.06794).
### Preprocessing
Images are resized/rescaled to the same resolution (384x384) and normalized across the RGB channels with mean (0.5, 0.5, 0.5) and standard deviation (0.5, 0.5, 0.5).
Texts are tokenized and padded to the same length (64 tokens).
### Compute
The model was trained on 16 TPU-v4 chips for three days.
## Evaluation results
Evaluation of SigLIP compared to CLIP is shown below (taken from the paper).
<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/model_doc/siglip_table.jpeg"alt="drawing" width="600"/>
### BibTeX entry and citation info
```bibtex@misc{zhai2023sigmoid, title={Sigmoid Loss for Language Image Pre-Training}, author={Xiaohua Zhai and Basil Mustafa and Alexander Kolesnikov and Lucas Beyer}, year={2023}, eprint={2303.15343}, archivePrefix={arXiv}, primaryClass={cs.CV}}```12345678910111213141516171819202122232425{ "architectures": [ "SiglipModel" ], "initializer_factor": 1.0, "model_type": "siglip", "text_config": { "hidden_size": 1152, "intermediate_size": 4304, "model_type": "siglip_text_model", "num_attention_heads": 16, "num_hidden_layers": 27 }, "torch_dtype": "float32", "transformers_version": "4.37.0.dev0", "vision_config": { "hidden_size": 1152, "image_size": 384, "intermediate_size": 4304, "model_type": "siglip_vision_model", "num_attention_heads": 16, "num_hidden_layers": 27, "patch_size": 14 }}1234567891011121314151617181920212223{ "do_normalize": true, "do_rescale": true, "do_resize": true, "image_mean": [ 0.5, 0.5, 0.5 ], "image_processor_type": "SiglipImageProcessor", "image_std": [ 0.5, 0.5, 0.5 ], "processor_class": "SiglipProcessor", "resample": 3, "rescale_factor": 0.00392156862745098, "size": { "height": 384, "width": 384 }}1234567891011121314151617181920212223{ "eos_token": { "content": "</s>", "lstrip": true, "normalized": false, "rstrip": true, "single_word": false }, "pad_token": { "content": "</s>", "lstrip": true, "normalized": false, "rstrip": true, "single_word": false }, "unk_token": { "content": "<unk>", "lstrip": true, "normalized": false, "rstrip": true, "single_word": false }}123456789101112131415161718192021222324252627282930313233{ "added_tokens_decoder": { "1": { "content": "</s>", "lstrip": true, "normalized": false, "rstrip": true, "single_word": false, "special": true }, "2": { "content": "<unk>", "lstrip": true, "normalized": false, "rstrip": true, "single_word": false, "special": true } }, "additional_special_tokens": [], "clean_up_tokenization_spaces": true, "do_lower_case": true, "eos_token": "</s>", "model_input_names": [ "input_ids" ], "model_max_length": 64, "pad_token": "</s>", "processor_class": "SiglipProcessor", "sp_model_kwargs": {}, "tokenizer_class": "SiglipTokenizer", "unk_token": "<unk>"}12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273model: base_learning_rate: 1.0e-04 target: ldm.models.diffusion.ddpm.LatentDiffusion params: linear_start: 0.00085 linear_end: 0.0120 num_timesteps_cond: 1 log_every_t: 200 timesteps: 1000 first_stage_key: "jpg" cond_stage_key: "txt" image_size: 64 channels: 4 cond_stage_trainable: false # Note: different from the one we trained before conditioning_key: crossattn monitor: val/loss_simple_ema scale_factor: 0.18215 use_ema: False
scheduler_config: # 10000 warmup steps target: ldm.lr_scheduler.LambdaLinearScheduler params: warm_up_steps: [ 10000 ] cycle_lengths: [ 10000000000000 ] # incredibly large number to prevent corner cases f_start: [ 1.e-6 ] f_max: [ 1. ] f_min: [ 1. ]
unet_config: target: ldm.modules.diffusionmodules.openaimodel.UNetModel params: image_size: 32 # unused in_channels: 4 out_channels: 4 model_channels: 320 attention_resolutions: [ 4, 2, 1 ] num_res_blocks: 2 channel_mult: [ 1, 2, 4, 4 ] num_heads: 8 use_spatial_transformer: True transformer_depth: 1 context_dim: 768 use_checkpoint: True legacy: False
first_stage_config: target: ldm.models.autoencoder.AutoencoderKL params: embed_dim: 4 monitor: val/rec_loss ddconfig: double_z: true z_channels: 4 resolution: 256 in_channels: 3 out_ch: 3 ch: 128 ch_mult: - 1 - 2 - 4 - 4 num_res_blocks: 2 attn_resolutions: [] dropout: 0.0 lossconfig: target: torch.nn.Identity
cond_stage_config: target: ldm.modules.encoders.modules.FrozenCLIPEmbedder params: layer: "hidden" layer_idx: -212345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970model: base_learning_rate: 1.0e-04 target: ldm.models.diffusion.ddpm.LatentDiffusion params: linear_start: 0.00085 linear_end: 0.0120 num_timesteps_cond: 1 log_every_t: 200 timesteps: 1000 first_stage_key: "jpg" cond_stage_key: "txt" image_size: 64 channels: 4 cond_stage_trainable: false # Note: different from the one we trained before conditioning_key: crossattn monitor: val/loss_simple_ema scale_factor: 0.18215 use_ema: False
scheduler_config: # 10000 warmup steps target: ldm.lr_scheduler.LambdaLinearScheduler params: warm_up_steps: [ 10000 ] cycle_lengths: [ 10000000000000 ] # incredibly large number to prevent corner cases f_start: [ 1.e-6 ] f_max: [ 1. ] f_min: [ 1. ]
unet_config: target: ldm.modules.diffusionmodules.openaimodel.UNetModel params: image_size: 32 # unused in_channels: 4 out_channels: 4 model_channels: 320 attention_resolutions: [ 4, 2, 1 ] num_res_blocks: 2 channel_mult: [ 1, 2, 4, 4 ] num_heads: 8 use_spatial_transformer: True transformer_depth: 1 context_dim: 768 use_checkpoint: True legacy: False
first_stage_config: target: ldm.models.autoencoder.AutoencoderKL params: embed_dim: 4 monitor: val/rec_loss ddconfig: double_z: true z_channels: 4 resolution: 256 in_channels: 3 out_ch: 3 ch: 128 ch_mult: - 1 - 2 - 4 - 4 num_res_blocks: 2 attn_resolutions: [] dropout: 0.0 lossconfig: target: torch.nn.Identity
cond_stage_config: target: ldm.modules.encoders.modules.FrozenCLIPEmbedder12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273model: base_learning_rate: 1.0e-04 target: ldm.models.diffusion.ddpm.LatentDiffusion params: linear_start: 0.00085 linear_end: 0.0120 num_timesteps_cond: 1 log_every_t: 200 timesteps: 1000 first_stage_key: "jpg" cond_stage_key: "txt" image_size: 64 channels: 4 cond_stage_trainable: false # Note: different from the one we trained before conditioning_key: crossattn monitor: val/loss_simple_ema scale_factor: 0.18215 use_ema: False
scheduler_config: # 10000 warmup steps target: ldm.lr_scheduler.LambdaLinearScheduler params: warm_up_steps: [ 10000 ] cycle_lengths: [ 10000000000000 ] # incredibly large number to prevent corner cases f_start: [ 1.e-6 ] f_max: [ 1. ] f_min: [ 1. ]
unet_config: target: ldm.modules.diffusionmodules.openaimodel.UNetModel params: image_size: 32 # unused in_channels: 4 out_channels: 4 model_channels: 320 attention_resolutions: [ 4, 2, 1 ] num_res_blocks: 2 channel_mult: [ 1, 2, 4, 4 ] num_heads: 8 use_spatial_transformer: True transformer_depth: 1 context_dim: 768 use_checkpoint: True legacy: False
first_stage_config: target: ldm.models.autoencoder.AutoencoderKL params: embed_dim: 4 monitor: val/rec_loss ddconfig: double_z: true z_channels: 4 resolution: 256 in_channels: 3 out_ch: 3 ch: 128 ch_mult: - 1 - 2 - 4 - 4 num_res_blocks: 2 attn_resolutions: [] dropout: 0.0 lossconfig: target: torch.nn.Identity
cond_stage_config: target: ldm.modules.encoders.modules.FrozenCLIPEmbedder params: layer: "hidden" layer_idx: -21234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374model: base_learning_rate: 1.0e-04 target: ldm.models.diffusion.ddpm.LatentDiffusion params: linear_start: 0.00085 linear_end: 0.0120 num_timesteps_cond: 1 log_every_t: 200 timesteps: 1000 first_stage_key: "jpg" cond_stage_key: "txt" image_size: 64 channels: 4 cond_stage_trainable: false # Note: different from the one we trained before conditioning_key: crossattn monitor: val/loss_simple_ema scale_factor: 0.18215 use_ema: False
scheduler_config: # 10000 warmup steps target: ldm.lr_scheduler.LambdaLinearScheduler params: warm_up_steps: [ 10000 ] cycle_lengths: [ 10000000000000 ] # incredibly large number to prevent corner cases f_start: [ 1.e-6 ] f_max: [ 1. ] f_min: [ 1. ]
unet_config: target: ldm.modules.diffusionmodules.openaimodel.UNetModel params: use_fp16: True image_size: 32 # unused in_channels: 4 out_channels: 4 model_channels: 320 attention_resolutions: [ 4, 2, 1 ] num_res_blocks: 2 channel_mult: [ 1, 2, 4, 4 ] num_heads: 8 use_spatial_transformer: True transformer_depth: 1 context_dim: 768 use_checkpoint: True legacy: False
first_stage_config: target: ldm.models.autoencoder.AutoencoderKL params: embed_dim: 4 monitor: val/rec_loss ddconfig: double_z: true z_channels: 4 resolution: 256 in_channels: 3 out_ch: 3 ch: 128 ch_mult: - 1 - 2 - 4 - 4 num_res_blocks: 2 attn_resolutions: [] dropout: 0.0 lossconfig: target: torch.nn.Identity
cond_stage_config: target: ldm.modules.encoders.modules.FrozenCLIPEmbedder params: layer: "hidden" layer_idx: -21234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071model: base_learning_rate: 1.0e-04 target: ldm.models.diffusion.ddpm.LatentDiffusion params: linear_start: 0.00085 linear_end: 0.0120 num_timesteps_cond: 1 log_every_t: 200 timesteps: 1000 first_stage_key: "jpg" cond_stage_key: "txt" image_size: 64 channels: 4 cond_stage_trainable: false # Note: different from the one we trained before conditioning_key: crossattn monitor: val/loss_simple_ema scale_factor: 0.18215 use_ema: False
scheduler_config: # 10000 warmup steps target: ldm.lr_scheduler.LambdaLinearScheduler params: warm_up_steps: [ 10000 ] cycle_lengths: [ 10000000000000 ] # incredibly large number to prevent corner cases f_start: [ 1.e-6 ] f_max: [ 1. ] f_min: [ 1. ]
unet_config: target: ldm.modules.diffusionmodules.openaimodel.UNetModel params: use_fp16: True image_size: 32 # unused in_channels: 4 out_channels: 4 model_channels: 320 attention_resolutions: [ 4, 2, 1 ] num_res_blocks: 2 channel_mult: [ 1, 2, 4, 4 ] num_heads: 8 use_spatial_transformer: True transformer_depth: 1 context_dim: 768 use_checkpoint: True legacy: False
first_stage_config: target: ldm.models.autoencoder.AutoencoderKL params: embed_dim: 4 monitor: val/rec_loss ddconfig: double_z: true z_channels: 4 resolution: 256 in_channels: 3 out_ch: 3 ch: 128 ch_mult: - 1 - 2 - 4 - 4 num_res_blocks: 2 attn_resolutions: [] dropout: 0.0 lossconfig: target: torch.nn.Identity
cond_stage_config: target: ldm.modules.encoders.modules.FrozenCLIPEmbedder1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071model: base_learning_rate: 7.5e-05 target: ldm.models.diffusion.ddpm.LatentInpaintDiffusion params: linear_start: 0.00085 linear_end: 0.0120 num_timesteps_cond: 1 log_every_t: 200 timesteps: 1000 first_stage_key: "jpg" cond_stage_key: "txt" image_size: 64 channels: 4 cond_stage_trainable: false # Note: different from the one we trained before conditioning_key: hybrid # important monitor: val/loss_simple_ema scale_factor: 0.18215 finetune_keys: null
scheduler_config: # 10000 warmup steps target: ldm.lr_scheduler.LambdaLinearScheduler params: warm_up_steps: [ 2500 ] # NOTE for resuming. use 10000 if starting from scratch cycle_lengths: [ 10000000000000 ] # incredibly large number to prevent corner cases f_start: [ 1.e-6 ] f_max: [ 1. ] f_min: [ 1. ]
unet_config: target: ldm.modules.diffusionmodules.openaimodel.UNetModel params: image_size: 32 # unused in_channels: 9 # 4 data + 4 downscaled image + 1 mask out_channels: 4 model_channels: 320 attention_resolutions: [ 4, 2, 1 ] num_res_blocks: 2 channel_mult: [ 1, 2, 4, 4 ] num_heads: 8 use_spatial_transformer: True transformer_depth: 1 context_dim: 768 use_checkpoint: True legacy: False
first_stage_config: target: ldm.models.autoencoder.AutoencoderKL params: embed_dim: 4 monitor: val/rec_loss ddconfig: double_z: true z_channels: 4 resolution: 256 in_channels: 3 out_ch: 3 ch: 128 ch_mult: - 1 - 2 - 4 - 4 num_res_blocks: 2 attn_resolutions: [] dropout: 0.0 lossconfig: target: torch.nn.Identity
cond_stage_config: target: ldm.modules.encoders.modules.FrozenCLIPEmbedder
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768model: base_learning_rate: 1.0e-4 target: ldm.models.diffusion.ddpm.LatentDiffusion params: parameterization: "v" linear_start: 0.00085 linear_end: 0.0120 num_timesteps_cond: 1 log_every_t: 200 timesteps: 1000 first_stage_key: "jpg" cond_stage_key: "txt" image_size: 64 channels: 4 cond_stage_trainable: false conditioning_key: crossattn monitor: val/loss_simple_ema scale_factor: 0.18215 use_ema: False # we set this to false because this is an inference only config
unet_config: target: ldm.modules.diffusionmodules.openaimodel.UNetModel params: use_checkpoint: True use_fp16: True image_size: 32 # unused in_channels: 4 out_channels: 4 model_channels: 320 attention_resolutions: [ 4, 2, 1 ] num_res_blocks: 2 channel_mult: [ 1, 2, 4, 4 ] num_head_channels: 64 # need to fix for flash-attn use_spatial_transformer: True use_linear_in_transformer: True transformer_depth: 1 context_dim: 1024 legacy: False
first_stage_config: target: ldm.models.autoencoder.AutoencoderKL params: embed_dim: 4 monitor: val/rec_loss ddconfig: #attn_type: "vanilla-xformers" double_z: true z_channels: 4 resolution: 256 in_channels: 3 out_ch: 3 ch: 128 ch_mult: - 1 - 2 - 4 - 4 num_res_blocks: 2 attn_resolutions: [] dropout: 0.0 lossconfig: target: torch.nn.Identity
cond_stage_config: target: ldm.modules.encoders.modules.FrozenOpenCLIPEmbedder params: freeze: True layer: "penultimate"1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768model: base_learning_rate: 1.0e-4 target: ldm.models.diffusion.ddpm.LatentDiffusion params: parameterization: "v" linear_start: 0.00085 linear_end: 0.0120 num_timesteps_cond: 1 log_every_t: 200 timesteps: 1000 first_stage_key: "jpg" cond_stage_key: "txt" image_size: 64 channels: 4 cond_stage_trainable: false conditioning_key: crossattn monitor: val/loss_simple_ema scale_factor: 0.18215 use_ema: False # we set this to false because this is an inference only config
unet_config: target: ldm.modules.diffusionmodules.openaimodel.UNetModel params: use_checkpoint: True use_fp16: False image_size: 32 # unused in_channels: 4 out_channels: 4 model_channels: 320 attention_resolutions: [ 4, 2, 1 ] num_res_blocks: 2 channel_mult: [ 1, 2, 4, 4 ] num_head_channels: 64 # need to fix for flash-attn use_spatial_transformer: True use_linear_in_transformer: True transformer_depth: 1 context_dim: 1024 legacy: False
first_stage_config: target: ldm.models.autoencoder.AutoencoderKL params: embed_dim: 4 monitor: val/rec_loss ddconfig: #attn_type: "vanilla-xformers" double_z: true z_channels: 4 resolution: 256 in_channels: 3 out_ch: 3 ch: 128 ch_mult: - 1 - 2 - 4 - 4 num_res_blocks: 2 attn_resolutions: [] dropout: 0.0 lossconfig: target: torch.nn.Identity
cond_stage_config: target: ldm.modules.encoders.modules.FrozenOpenCLIPEmbedder params: freeze: True layer: "penultimate"12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667model: base_learning_rate: 1.0e-4 target: ldm.models.diffusion.ddpm.LatentDiffusion params: linear_start: 0.00085 linear_end: 0.0120 num_timesteps_cond: 1 log_every_t: 200 timesteps: 1000 first_stage_key: "jpg" cond_stage_key: "txt" image_size: 64 channels: 4 cond_stage_trainable: false conditioning_key: crossattn monitor: val/loss_simple_ema scale_factor: 0.18215 use_ema: False # we set this to false because this is an inference only config
unet_config: target: ldm.modules.diffusionmodules.openaimodel.UNetModel params: use_checkpoint: True use_fp16: True image_size: 32 # unused in_channels: 4 out_channels: 4 model_channels: 320 attention_resolutions: [ 4, 2, 1 ] num_res_blocks: 2 channel_mult: [ 1, 2, 4, 4 ] num_head_channels: 64 # need to fix for flash-attn use_spatial_transformer: True use_linear_in_transformer: True transformer_depth: 1 context_dim: 1024 legacy: False
first_stage_config: target: ldm.models.autoencoder.AutoencoderKL params: embed_dim: 4 monitor: val/rec_loss ddconfig: #attn_type: "vanilla-xformers" double_z: true z_channels: 4 resolution: 256 in_channels: 3 out_ch: 3 ch: 128 ch_mult: - 1 - 2 - 4 - 4 num_res_blocks: 2 attn_resolutions: [] dropout: 0.0 lossconfig: target: torch.nn.Identity
cond_stage_config: target: ldm.modules.encoders.modules.FrozenOpenCLIPEmbedder params: freeze: True layer: "penultimate"12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667model: base_learning_rate: 1.0e-4 target: ldm.models.diffusion.ddpm.LatentDiffusion params: linear_start: 0.00085 linear_end: 0.0120 num_timesteps_cond: 1 log_every_t: 200 timesteps: 1000 first_stage_key: "jpg" cond_stage_key: "txt" image_size: 64 channels: 4 cond_stage_trainable: false conditioning_key: crossattn monitor: val/loss_simple_ema scale_factor: 0.18215 use_ema: False # we set this to false because this is an inference only config
unet_config: target: ldm.modules.diffusionmodules.openaimodel.UNetModel params: use_checkpoint: True use_fp16: False image_size: 32 # unused in_channels: 4 out_channels: 4 model_channels: 320 attention_resolutions: [ 4, 2, 1 ] num_res_blocks: 2 channel_mult: [ 1, 2, 4, 4 ] num_head_channels: 64 # need to fix for flash-attn use_spatial_transformer: True use_linear_in_transformer: True transformer_depth: 1 context_dim: 1024 legacy: False
first_stage_config: target: ldm.models.autoencoder.AutoencoderKL params: embed_dim: 4 monitor: val/rec_loss ddconfig: #attn_type: "vanilla-xformers" double_z: true z_channels: 4 resolution: 256 in_channels: 3 out_ch: 3 ch: 128 ch_mult: - 1 - 2 - 4 - 4 num_res_blocks: 2 attn_resolutions: [] dropout: 0.0 lossconfig: target: torch.nn.Identity
cond_stage_config: target: ldm.modules.encoders.modules.FrozenOpenCLIPEmbedder params: freeze: True layer: "penultimate"123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158model: base_learning_rate: 5.0e-05 target: ldm.models.diffusion.ddpm.LatentInpaintDiffusion params: linear_start: 0.00085 linear_end: 0.0120 num_timesteps_cond: 1 log_every_t: 200 timesteps: 1000 first_stage_key: "jpg" cond_stage_key: "txt" image_size: 64 channels: 4 cond_stage_trainable: false conditioning_key: hybrid scale_factor: 0.18215 monitor: val/loss_simple_ema finetune_keys: null use_ema: False
unet_config: target: ldm.modules.diffusionmodules.openaimodel.UNetModel params: use_checkpoint: True image_size: 32 # unused in_channels: 9 out_channels: 4 model_channels: 320 attention_resolutions: [ 4, 2, 1 ] num_res_blocks: 2 channel_mult: [ 1, 2, 4, 4 ] num_head_channels: 64 # need to fix for flash-attn use_spatial_transformer: True use_linear_in_transformer: True transformer_depth: 1 context_dim: 1024 legacy: False
first_stage_config: target: ldm.models.autoencoder.AutoencoderKL params: embed_dim: 4 monitor: val/rec_loss ddconfig: #attn_type: "vanilla-xformers" double_z: true z_channels: 4 resolution: 256 in_channels: 3 out_ch: 3 ch: 128 ch_mult: - 1 - 2 - 4 - 4 num_res_blocks: 2 attn_resolutions: [ ] dropout: 0.0 lossconfig: target: torch.nn.Identity
cond_stage_config: target: ldm.modules.encoders.modules.FrozenOpenCLIPEmbedder params: freeze: True layer: "penultimate"
data: target: ldm.data.laion.WebDataModuleFromConfig params: tar_base: null # for concat as in LAION-A p_unsafe_threshold: 0.1 filter_word_list: "data/filters.yaml" max_pwatermark: 0.45 batch_size: 8 num_workers: 6 multinode: True min_size: 512 train: shards: - "pipe:aws s3 cp s3://stability-aws/laion-a-native/part-0/{00000..18699}.tar -" - "pipe:aws s3 cp s3://stability-aws/laion-a-native/part-1/{00000..18699}.tar -" - "pipe:aws s3 cp s3://stability-aws/laion-a-native/part-2/{00000..18699}.tar -" - "pipe:aws s3 cp s3://stability-aws/laion-a-native/part-3/{00000..18699}.tar -" - "pipe:aws s3 cp s3://stability-aws/laion-a-native/part-4/{00000..18699}.tar -" #{00000-94333}.tar" shuffle: 10000 image_key: jpg image_transforms: - target: torchvision.transforms.Resize params: size: 512 interpolation: 3 - target: torchvision.transforms.RandomCrop params: size: 512 postprocess: target: ldm.data.laion.AddMask params: mode: "512train-large" p_drop: 0.25 # NOTE use enough shards to avoid empty validation loops in workers validation: shards: - "pipe:aws s3 cp s3://deep-floyd-s3/datasets/laion_cleaned-part5/{93001..94333}.tar - " shuffle: 0 image_key: jpg image_transforms: - target: torchvision.transforms.Resize params: size: 512 interpolation: 3 - target: torchvision.transforms.CenterCrop params: size: 512 postprocess: target: ldm.data.laion.AddMask params: mode: "512train-large" p_drop: 0.25
lightning: find_unused_parameters: True modelcheckpoint: params: every_n_train_steps: 5000
callbacks: metrics_over_trainsteps_checkpoint: params: every_n_train_steps: 10000
image_logger: target: main.ImageLogger params: enable_autocast: False disabled: False batch_frequency: 1000 max_images: 4 increase_log_steps: False log_first_step: False log_images_kwargs: use_ema_scope: False inpaint: False plot_progressive_rows: False plot_diffusion_rows: False N: 4 unconditional_guidance_scale: 5.0 unconditional_guidance_label: [""] ddim_steps: 50 # todo check these out for depth2img, ddim_eta: 0.0 # todo check these out for depth2img,
trainer: benchmark: True val_check_interval: 5000000 num_sanity_val_steps: 0 accumulate_grad_batches: 1123Safetensors/FP16 versions of the new [ControlNet-v1-1](https://huggingface.co/lllyasviel/ControlNet-v1-1) checkpoints.
Best used with [ComfyUI](https://github.com/comfyanonymous/ComfyUI) but should work fine with all other UIs that support controlnets.12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879model: target: cldm.cldm.ControlLDM params: linear_start: 0.00085 linear_end: 0.0120 num_timesteps_cond: 1 log_every_t: 200 timesteps: 1000 first_stage_key: "jpg" cond_stage_key: "txt" control_key: "hint" image_size: 64 channels: 4 cond_stage_trainable: false conditioning_key: crossattn monitor: val/loss_simple_ema scale_factor: 0.18215 use_ema: False only_mid_control: False
control_stage_config: target: cldm.cldm.ControlNet params: image_size: 32 # unused in_channels: 4 hint_channels: 3 model_channels: 320 attention_resolutions: [ 4, 2, 1 ] num_res_blocks: 2 channel_mult: [ 1, 2, 4, 4 ] num_heads: 8 use_spatial_transformer: True transformer_depth: 1 context_dim: 768 use_checkpoint: True legacy: False
unet_config: target: cldm.cldm.ControlledUnetModel params: image_size: 32 # unused in_channels: 4 out_channels: 4 model_channels: 320 attention_resolutions: [ 4, 2, 1 ] num_res_blocks: 2 channel_mult: [ 1, 2, 4, 4 ] num_heads: 8 use_spatial_transformer: True transformer_depth: 1 context_dim: 768 use_checkpoint: True legacy: False
first_stage_config: target: ldm.models.autoencoder.AutoencoderKL params: embed_dim: 4 monitor: val/rec_loss ddconfig: double_z: true z_channels: 4 resolution: 256 in_channels: 3 out_ch: 3 ch: 128 ch_mult: - 1 - 2 - 4 - 4 num_res_blocks: 2 attn_resolutions: [] dropout: 0.0 lossconfig: target: torch.nn.Identity
cond_stage_config: target: ldm.modules.encoders.modules.FrozenCLIPEmbedder1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980model: target: cldm.cldm.ControlLDM params: linear_start: 0.00085 linear_end: 0.0120 num_timesteps_cond: 1 log_every_t: 200 timesteps: 1000 first_stage_key: "jpg" cond_stage_key: "txt" control_key: "hint" image_size: 64 channels: 4 cond_stage_trainable: false conditioning_key: crossattn monitor: val/loss_simple_ema scale_factor: 0.18215 use_ema: False only_mid_control: False global_average_pooling: True
control_stage_config: target: cldm.cldm.ControlNet params: image_size: 32 # unused in_channels: 4 hint_channels: 3 model_channels: 320 attention_resolutions: [ 4, 2, 1 ] num_res_blocks: 2 channel_mult: [ 1, 2, 4, 4 ] num_heads: 8 use_spatial_transformer: True transformer_depth: 1 context_dim: 768 use_checkpoint: True legacy: False
unet_config: target: cldm.cldm.ControlledUnetModel params: image_size: 32 # unused in_channels: 4 out_channels: 4 model_channels: 320 attention_resolutions: [ 4, 2, 1 ] num_res_blocks: 2 channel_mult: [ 1, 2, 4, 4 ] num_heads: 8 use_spatial_transformer: True transformer_depth: 1 context_dim: 768 use_checkpoint: True legacy: False
first_stage_config: target: ldm.models.autoencoder.AutoencoderKL params: embed_dim: 4 monitor: val/rec_loss ddconfig: double_z: true z_channels: 4 resolution: 256 in_channels: 3 out_ch: 3 ch: 128 ch_mult: - 1 - 2 - 4 - 4 num_res_blocks: 2 attn_resolutions: [] dropout: 0.0 lossconfig: target: torch.nn.Identity
cond_stage_config: target: ldm.modules.encoders.modules.FrozenCLIPEmbedder12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879model: target: cldm.cldm.ControlLDM params: linear_start: 0.00085 linear_end: 0.0120 num_timesteps_cond: 1 log_every_t: 200 timesteps: 1000 first_stage_key: "jpg" cond_stage_key: "txt" control_key: "hint" image_size: 64 channels: 4 cond_stage_trainable: false conditioning_key: crossattn monitor: val/loss_simple_ema scale_factor: 0.18215 use_ema: False only_mid_control: False
control_stage_config: target: cldm.cldm.ControlNet params: image_size: 32 # unused in_channels: 4 hint_channels: 3 model_channels: 320 attention_resolutions: [ 4, 2, 1 ] num_res_blocks: 2 channel_mult: [ 1, 2, 4, 4 ] num_heads: 8 use_spatial_transformer: True transformer_depth: 1 context_dim: 768 use_checkpoint: True legacy: False
unet_config: target: cldm.cldm.ControlledUnetModel params: image_size: 32 # unused in_channels: 4 out_channels: 4 model_channels: 320 attention_resolutions: [ 4, 2, 1 ] num_res_blocks: 2 channel_mult: [ 1, 2, 4, 4 ] num_heads: 8 use_spatial_transformer: True transformer_depth: 1 context_dim: 768 use_checkpoint: True legacy: False
first_stage_config: target: ldm.models.autoencoder.AutoencoderKL params: embed_dim: 4 monitor: val/rec_loss ddconfig: double_z: true z_channels: 4 resolution: 256 in_channels: 3 out_ch: 3 ch: 128 ch_mult: - 1 - 2 - 4 - 4 num_res_blocks: 2 attn_resolutions: [] dropout: 0.0 lossconfig: target: torch.nn.Identity
cond_stage_config: target: ldm.modules.encoders.modules.FrozenCLIPEmbedder12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879model: target: cldm.cldm.ControlLDM params: linear_start: 0.00085 linear_end: 0.0120 num_timesteps_cond: 1 log_every_t: 200 timesteps: 1000 first_stage_key: "jpg" cond_stage_key: "txt" control_key: "hint" image_size: 64 channels: 4 cond_stage_trainable: false conditioning_key: crossattn monitor: val/loss_simple_ema scale_factor: 0.18215 use_ema: False only_mid_control: False
control_stage_config: target: cldm.cldm.ControlNet params: image_size: 32 # unused in_channels: 4 hint_channels: 3 model_channels: 320 attention_resolutions: [ 4, 2, 1 ] num_res_blocks: 2 channel_mult: [ 1, 2, 4, 4 ] num_heads: 8 use_spatial_transformer: True transformer_depth: 1 context_dim: 768 use_checkpoint: True legacy: False
unet_config: target: cldm.cldm.ControlledUnetModel params: image_size: 32 # unused in_channels: 4 out_channels: 4 model_channels: 320 attention_resolutions: [ 4, 2, 1 ] num_res_blocks: 2 channel_mult: [ 1, 2, 4, 4 ] num_heads: 8 use_spatial_transformer: True transformer_depth: 1 context_dim: 768 use_checkpoint: True legacy: False
first_stage_config: target: ldm.models.autoencoder.AutoencoderKL params: embed_dim: 4 monitor: val/rec_loss ddconfig: double_z: true z_channels: 4 resolution: 256 in_channels: 3 out_ch: 3 ch: 128 ch_mult: - 1 - 2 - 4 - 4 num_res_blocks: 2 attn_resolutions: [] dropout: 0.0 lossconfig: target: torch.nn.Identity
cond_stage_config: target: ldm.modules.encoders.modules.FrozenCLIPEmbedder12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879model: target: cldm.cldm.ControlLDM params: linear_start: 0.00085 linear_end: 0.0120 num_timesteps_cond: 1 log_every_t: 200 timesteps: 1000 first_stage_key: "jpg" cond_stage_key: "txt" control_key: "hint" image_size: 64 channels: 4 cond_stage_trainable: false conditioning_key: crossattn monitor: val/loss_simple_ema scale_factor: 0.18215 use_ema: False only_mid_control: False
control_stage_config: target: cldm.cldm.ControlNet params: image_size: 32 # unused in_channels: 4 hint_channels: 3 model_channels: 320 attention_resolutions: [ 4, 2, 1 ] num_res_blocks: 2 channel_mult: [ 1, 2, 4, 4 ] num_heads: 8 use_spatial_transformer: True transformer_depth: 1 context_dim: 768 use_checkpoint: True legacy: False
unet_config: target: cldm.cldm.ControlledUnetModel params: image_size: 32 # unused in_channels: 4 out_channels: 4 model_channels: 320 attention_resolutions: [ 4, 2, 1 ] num_res_blocks: 2 channel_mult: [ 1, 2, 4, 4 ] num_heads: 8 use_spatial_transformer: True transformer_depth: 1 context_dim: 768 use_checkpoint: True legacy: False
first_stage_config: target: ldm.models.autoencoder.AutoencoderKL params: embed_dim: 4 monitor: val/rec_loss ddconfig: double_z: true z_channels: 4 resolution: 256 in_channels: 3 out_ch: 3 ch: 128 ch_mult: - 1 - 2 - 4 - 4 num_res_blocks: 2 attn_resolutions: [] dropout: 0.0 lossconfig: target: torch.nn.Identity
cond_stage_config: target: ldm.modules.encoders.modules.FrozenCLIPEmbedderBiRefNet/README.mdAdded+8
Joy_caption/README.mdAdded+79
Joy_caption/app.pyAdded+536
Joy_caption/cgrkzexw-599808/text_model/adapter_config.jsonAdded+34
Joy_caption/cgrkzexw-599808/text_model/special_tokens_map.jsonAdded+23
Joy_caption/cgrkzexw-599808/text_model/tokenizer.jsonAdded
Joy_caption/cgrkzexw-599808/text_model/tokenizer_config.jsonAdded+2064
Joy_caption/joycaption_alpha_two_cli_mod.ipynbAdded+46
Joy_caption/requirements.txtAdded+10
LLM/Florence-2-base-PromptGen-v2.0/README.mdAdded+71
LLM/Florence-2-base-PromptGen-v2.0/added_tokens.jsonAdded+1026
LLM/Florence-2-base-PromptGen-v2.0/config.jsonAdded+137
LLM/Florence-2-base-PromptGen-v2.0/generation_config.jsonAdded+13
LLM/Florence-2-base-PromptGen-v2.0/preprocessor_config.jsonAdded+33
LLM/Florence-2-base-PromptGen-v2.0/special_tokens_map.jsonAdded
LLM/Florence-2-base-PromptGen-v2.0/tokenizer.jsonAdded
LLM/Florence-2-base-PromptGen-v2.0/tokenizer_config.jsonAdded
LLM/Florence-2-base-PromptGen-v2.0/vocab.jsonAdded
LLM/Florence-2-large-PromptGen-v2.0/configuration_florence2.pyAdded+340
LLM/Florence-2-large-PromptGen-v2.0/merges.txtAdded
LLM/Florence-2-large-PromptGen-v2.0/processing_florence2.pyAdded+1088
LLM/Florence-2-large-PromptGen-v2.0/vocab.jsonAdded
checkpoints/put_checkpoints_hereAdded
ckpts/wget-logAdded+11
clip/put_clip_or_text_encoder_models_hereAdded
clip/siglip-so400m-patch14-384/README.mdAdded+112
clip/siglip-so400m-patch14-384/config.jsonAdded+25
clip/siglip-so400m-patch14-384/preprocessor_config.jsonAdded+23
clip/siglip-so400m-patch14-384/special_tokens_map.jsonAdded+23
clip/siglip-so400m-patch14-384/tokenizer.jsonAdded
clip/siglip-so400m-patch14-384/tokenizer_config.jsonAdded+33
clip_vision/put_clip_vision_models_hereAdded
configs/anything_v3.yamlAdded+73
configs/v1-inference.yamlAdded+70
configs/v1-inference_clip_skip_2.yamlAdded+73
configs/v1-inference_clip_skip_2_fp16.yamlAdded+74
configs/v1-inference_fp16.yamlAdded+71
configs/v1-inpainting-inference.yamlAdded+71
configs/v2-inference-v.yamlAdded+68
configs/v2-inference-v_fp32.yamlAdded+68
configs/v2-inference.yamlAdded+67
configs/v2-inference_fp32.yamlAdded+67
configs/v2-inpainting-inference.yamlAdded+158
controlnet/put_controlnets_and_t2i_hereAdded
controlnet/sd1.5/README.mdAdded+3
controlnet/sd1.5/control_v11e_sd15_ip2p.yamlAdded+79
controlnet/sd1.5/control_v11e_sd15_shuffle.yamlAdded+80
controlnet/sd1.5/control_v11f1e_sd15_tile.yamlAdded+79
controlnet/sd1.5/control_v11f1p_sd15_depth.yamlAdded+79
controlnet/sd1.5/control_v11p_sd15_canny.yamlAdded+79