Showing preview only (795K chars total). Download the full file or copy to clipboard to get everything.
Repository: ZYM-PKU/UDiffText
Branch: main
Commit: 9c9d0ab5b468
Files: 142
Total size: 749.6 KB
Directory structure:
gitextract_cem8xir5/
├── .gitignore
├── LICENSE
├── README.md
├── configs/
│ ├── dataset/
│ │ ├── icd13.yaml
│ │ ├── locr.yaml
│ │ ├── st.yaml
│ │ └── tsg.yaml
│ ├── demo.yaml
│ ├── pretrain.yaml
│ ├── test/
│ │ └── textdesign_sd_2.yaml
│ ├── test.yaml
│ ├── train/
│ │ └── textdesign_sd_2.yaml
│ └── train.yaml
├── dataset/
│ ├── __init__.py
│ ├── dataloader.py
│ └── utils/
│ └── words.txt
├── demo.py
├── metrics.py
├── pretrain.py
├── requirements.txt
├── scripts/
│ └── preprocess/
│ └── laion_ocr_pre.ipynb
├── sgm/
│ ├── __init__.py
│ ├── lr_scheduler.py
│ ├── models/
│ │ ├── __init__.py
│ │ ├── autoencoder.py
│ │ └── diffusion.py
│ ├── modules/
│ │ ├── __init__.py
│ │ ├── attention.py
│ │ ├── autoencoding/
│ │ │ ├── __init__.py
│ │ │ ├── losses/
│ │ │ │ └── __init__.py
│ │ │ └── regularizers/
│ │ │ └── __init__.py
│ │ ├── diffusionmodules/
│ │ │ ├── __init__.py
│ │ │ ├── denoiser.py
│ │ │ ├── denoiser_scaling.py
│ │ │ ├── denoiser_weighting.py
│ │ │ ├── discretizer.py
│ │ │ ├── guiders.py
│ │ │ ├── loss.py
│ │ │ ├── model.py
│ │ │ ├── openaimodel.py
│ │ │ ├── sampling.py
│ │ │ ├── sampling_utils.py
│ │ │ ├── sigma_sampling.py
│ │ │ ├── util.py
│ │ │ └── wrappers.py
│ │ ├── distributions/
│ │ │ ├── __init__.py
│ │ │ └── distributions.py
│ │ ├── ema.py
│ │ ├── encoders/
│ │ │ ├── __init__.py
│ │ │ └── modules.py
│ │ └── predictors/
│ │ └── model.py
│ └── util.py
├── src/
│ └── parseq/
│ ├── .gitignore
│ ├── Datasets.md
│ ├── LICENSE
│ ├── NOTICE
│ ├── README.md
│ ├── bench.py
│ ├── configs/
│ │ ├── bench.yaml
│ │ ├── charset/
│ │ │ ├── 36_lowercase.yaml
│ │ │ ├── 62_mixed-case.yaml
│ │ │ └── 94_full.yaml
│ │ ├── dataset/
│ │ │ ├── real.yaml
│ │ │ └── synth.yaml
│ │ ├── experiment/
│ │ │ ├── abinet-sv.yaml
│ │ │ ├── abinet.yaml
│ │ │ ├── crnn.yaml
│ │ │ ├── parseq-patch16-224.yaml
│ │ │ ├── parseq-tiny.yaml
│ │ │ ├── parseq.yaml
│ │ │ ├── trba.yaml
│ │ │ ├── trbc.yaml
│ │ │ ├── tune_abinet-lm.yaml
│ │ │ └── vitstr.yaml
│ │ ├── main.yaml
│ │ ├── model/
│ │ │ ├── abinet.yaml
│ │ │ ├── crnn.yaml
│ │ │ ├── parseq.yaml
│ │ │ ├── trba.yaml
│ │ │ └── vitstr.yaml
│ │ └── tune.yaml
│ ├── hubconf.py
│ ├── read.py
│ ├── requirements.txt
│ ├── setup.cfg
│ ├── setup.py
│ ├── strhub/
│ │ ├── __init__.py
│ │ ├── data/
│ │ │ ├── __init__.py
│ │ │ ├── aa_overrides.py
│ │ │ ├── augment.py
│ │ │ ├── dataset.py
│ │ │ ├── module.py
│ │ │ └── utils.py
│ │ └── models/
│ │ ├── __init__.py
│ │ ├── abinet/
│ │ │ ├── LICENSE
│ │ │ ├── __init__.py
│ │ │ ├── attention.py
│ │ │ ├── backbone.py
│ │ │ ├── model.py
│ │ │ ├── model_abinet_iter.py
│ │ │ ├── model_alignment.py
│ │ │ ├── model_language.py
│ │ │ ├── model_vision.py
│ │ │ ├── resnet.py
│ │ │ ├── system.py
│ │ │ └── transformer.py
│ │ ├── base.py
│ │ ├── crnn/
│ │ │ ├── LICENSE
│ │ │ ├── __init__.py
│ │ │ ├── model.py
│ │ │ └── system.py
│ │ ├── modules.py
│ │ ├── parseq/
│ │ │ ├── __init__.py
│ │ │ ├── modules.py
│ │ │ └── system.py
│ │ ├── trba/
│ │ │ ├── __init__.py
│ │ │ ├── feature_extraction.py
│ │ │ ├── model.py
│ │ │ ├── prediction.py
│ │ │ ├── system.py
│ │ │ └── transformation.py
│ │ ├── utils.py
│ │ └── vitstr/
│ │ ├── __init__.py
│ │ ├── model.py
│ │ └── system.py
│ ├── test.py
│ ├── tools/
│ │ ├── art_converter.py
│ │ ├── case_sensitive_str_datasets_converter.py
│ │ ├── coco_2_converter.py
│ │ ├── coco_text_converter.py
│ │ ├── create_lmdb_dataset.py
│ │ ├── filter_lmdb.py
│ │ ├── lsvt_converter.py
│ │ ├── mlt19_converter.py
│ │ ├── openvino_converter.py
│ │ ├── test_abinet_lm_acc.py
│ │ └── textocr_converter.py
│ ├── train.py
│ └── tune.py
├── test.py
├── train.py
└── util.py
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
**/__pycache__
.vscode
checkpoints
logs
outputs
temp
================================================
FILE: LICENSE
================================================
MIT License
Copyright (c) 2024 Yiming Zhao
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: README.md
================================================
## UDiffText: A Unified Framework for High-quality Text Synthesis in Arbitrary Images via Character-aware Diffusion Models
<a href='https://arxiv.org/abs/2312.04884'><img src='https://img.shields.io/badge/Arxiv-2312.04884-DF826C'></a>
<a href='https://udifftext.github.io/'><img src='https://img.shields.io/badge/Project-UDiffText-D0F288'></a>
<a href='https://huggingface.co/spaces/ZYMPKU/UDiffText'><img src='https://img.shields.io/badge/%F0%9F%A4%97%20Demo-UDiffText-8ADAB2'></a>
#### Our proposed UDiffText is capable of synthesizing accurate and harmonious text in either synthetic or real-word images, thus can be applied to tasks like scene text editing (a), arbitrary text generation (b) and accurate T2I generation (c)

### 📬 News
- **2023.7.16** Our paper is accepted by ECCV2024!🥳
- **2023.12.11** Version 2.0 update (getting rid of trash codes🚮)
- **2023.12.3** Build Hugging Face demo
- **2023.12.1** Build Github project page
- **2023.11.30** Version 1.0 upload
### 🔨 Installation
1. Clone this repo:
```
git clone https://github.com/ZYM-PKU/UDiffText.git
cd UDiffText
```
2. Install required Python packages
```
conda create -n udiff python=3.11
conda activate udiff
pip install torch==2.1.1 torchvision==0.16.1 --index-url https://download.pytorch.org/whl/cu121
pip install -r requirements.txt
```
3. Make the checkpoint directory and build the tree structure
```
mkdir ./checkpoints
checkpoints
├── AEs // AutoEncoder
├── encoders
├── LabelEncoder // Character-level encoder
└── ViTSTR // STR encoder
├── predictors // STR model
├── pretrained // Pretrained SD
└── ***.ckpt // UDiffText checkpoint
```
### 💻 Training
1. Prepare your data
#### LAION-OCR
- Create a data directory **{your data root}/LAION-OCR** in your disk and put your data in it. Then set the **data_root** field in **./configs/dataset/locr.yaml**.
- For the downloading and preprocessing of Laion-OCR dataset, please refer to [TextDiffuser](https://github.com/microsoft/unilm/tree/master/textdiffuser) and our **./scripts/preprocess/laion_ocr_pre.ipynb**.
#### ICDAR13
- Create a data directory **{your data root}/ICDAR13** in your disk and put your data in it. Then set the **data_root** field in **./configs/dataset/icd13.yaml**.
- Build the tree structure as below:
```
ICDAR13
├── train // training set
├── annos // annotations
├── gt_x.txt
├── ...
└── images // images
├── img_x.jpg
├── ...
└── val // validation set
├── annos // annotations
├── gt_img_x.txt
├── ...
└── images // images
├── img_x.jpg
├── ...
```
#### TextSeg
- Create a data directory **{your data root}/TextSeg** in your disk and put your data in it. Then set the **data_root** field in **./configs/dataset/tsg.yaml**.
- Build the tree structure as below:
```
TextSeg
├── train // training set
├── annotation // annotations
├── x_anno.json // annotation json file
├── x_mask.png // character-level mask
├── ...
└── image // images
├── x.jpg.jpg
├── ...
└── val // validation set
├── annotation // annotations
├── x_anno.json // annotation json file
├── x_mask.png // character-level mask
├── ...
└── image // images
├── x.jpg
├── ...
```
#### SynthText
- Create a data directory **{your data root}/SynthText** in your disk and put your data in it. Then set the **data_root** field in **./configs/dataset/st.yaml**.
- Build the tree structure as below:
```
SynthText
├── 1 // part 1
├── ant+hill_1_0.jpg // image
├── ant+hill_1_1.jpg
├── ...
├── 2 // part 2
├── ...
└── gt.mat // annotation file
```
2. Train the character-level encoder
Set the parameters in **./configs/pretrain.yaml** and run:
```
python pretrain.py
```
3. Train the UDiffText model
Download the [pretrained model](https://huggingface.co/stabilityai/stable-diffusion-2-inpainting/blob/main/512-inpainting-ema.ckpt) and put it in **./checkpoints/pretrained/**. You can ignore the "Missing Key" or "Unexcepted Key" warning when loading the checkpoint.
Set the parameters in **./configs/train.yaml**, especially the paths:
```
load_ckpt_path: ./checkpoints/pretrained/512-inpainting-ema.ckpt // Checkpoint of the pretrained SD
model_cfg_path: ./configs/train/textdesign_sd_2.yaml // UDiffText model config
dataset_cfg_path: ./configs/dataset/locr.yaml // Use the Laion-OCR dataset
```
and run:
```
python train.py
```
### 📏 Evaluation
1. Download our available [checkpoints](https://drive.google.com/drive/folders/1s8IWqqydaJBjukxViGKFj2N33lfoVkGf?usp=sharing) and put them in the corresponding directories in **./checkpoints**.
2. Set the parameters in **./configs/test.yaml**, especially the paths:
```
load_ckpt_path: "./checkpoints/***.ckpt" // UDiffText checkpoint
model_cfg_path: "./configs/test/textdesign_sd_2.yaml" // UDiffText model config
dataset_cfg_path: "./configs/dataset/locr.yaml" // LAION-OCR dataset config
```
and run:
```
python test.py
```
### 🖼️ Demo
In order to run an interactive demo on your own machine, execute the code:
```
python demo.py
```
or try our online demo at [hugging face](https://huggingface.co/spaces/ZYMPKU/UDiffText):

### 🎉 Acknowledgement
- **Dataset**: We sincerely thank the open-source large image-text dataset LAION-OCR with character-level segmentations provided by [TextDiffuser](https://github.com/microsoft/unilm/tree/master/textdiffuser).
- **Code & Model**: We build our project based on the code repo of [Stable Diffusion XL](https://github.com/Stability-AI/generative-models) and leverage the pretrained checkpoint of [Stable Diffusion 2.0](https://github.com/Stability-AI/stablediffusion).
### 🪬 Citation
```
@misc{zhao2023udifftext,
title={UDiffText: A Unified Framework for High-quality Text Synthesis in Arbitrary Images via Character-aware Diffusion Models},
author={Yiming Zhao and Zhouhui Lian},
year={2023},
eprint={2312.04884},
archivePrefix={arXiv},
primaryClass={cs.CV}
}
```
================================================
FILE: configs/dataset/icd13.yaml
================================================
target: ICDAR13Dataset
params:
data_root: '{your data root}'
H: 512
W: 512
word_len: [1, 8]
seq_len: 12
mask_min_ratio: 0.01
aug_text_enabled: True
aug_text_ratio: 1.0
================================================
FILE: configs/dataset/locr.yaml
================================================
target: LAIONOCRDataset
params:
data_root: '{your data root}'
H: 512
W: 512
word_len: [1, 12]
seq_len: 12
mask_min_ratio: 0.01
seg_min_ratio: 0.001
aug_text_enabled: True
aug_text_ratio: 1.0
use_cached: False
length: 100000
================================================
FILE: configs/dataset/st.yaml
================================================
target: SynthTextDataset
params:
data_root: '{your data root}'
H: 512
W: 512
word_len: [1, 12]
mask_min_ratio: 0.01
seg_min_ratio: 0.001
length: 100000
use_cached: False
================================================
FILE: configs/dataset/tsg.yaml
================================================
target: TextSegDataset
params:
data_root: '{your data root}'
H: 512
W: 512
word_len: [1, 12]
seq_len: 12
mask_min_ratio: 0.01
seg_min_ratio: 0.005
aug_text_enabled: True
aug_text_ratio: 1.0
================================================
FILE: configs/demo.yaml
================================================
type: "demo"
# path
load_ckpt_path: "./checkpoints/{your checkpoint path}.ckpt"
model_cfg_path: "./configs/test/textdesign_sd_2.yaml"
# param
H: 512
W: 512
seq_len: 12
batch_size: 1
channel: 4 # AE latent channel
factor: 8 # AE downsample factor
scale: [4.0, 0.0] # cfg scale, None
noise_iters: 10
force_uc_zero_embeddings: ["ref", "label"]
aae_enabled: False
detailed: False
# runtime
steps: 50
init_step: 0
num_workers: 0
gpu: 0
================================================
FILE: configs/pretrain.yaml
================================================
# path
ckpt_dir: './checkpoints/encoders/LabelEncoder'
dataset:
target: dataset.dataloader.LabelDataset
params:
size: 224
length: 100000
font_path: './dataset/utils/arial.ttf'
min_len: 1
max_len: 12
model:
target: sgm.modules.encoders.modules.LabelEncoder
params:
trainable: True
max_len: 12
emb_dim: 2048
n_heads: 8
n_trans_layers: 12
lr: 1e-5
lambda_cls: 0.1
lambda_pos: 0.1
visual_config:
target: sgm.modules.encoders.modules.ViTSTREncoder
params:
freeze: True
ckpt_path: "./checkpoints/encoders/ViTSTR/vitstr_base_patch16_224.pth"
size: 224
patch_size: 16
embed_dim: 768
depth: 12
num_heads: 12
mlp_ratio: 4
qkv_bias: True
in_chans: 1
num_workers: 0
batch_size: 256
check_freq: 5
lightning:
max_epochs: 1000
accelerator: "cuda"
devices:
- 0
default_root_dir: "./logs/pre_logs"
================================================
FILE: configs/test/textdesign_sd_2.yaml
================================================
model:
target: sgm.models.diffusion.DiffusionEngine
params:
opt_keys:
- t_attn
input_key: image
scale_factor: 0.18215
disable_first_stage_autocast: True
denoiser_config:
target: sgm.modules.diffusionmodules.denoiser.DiscreteDenoiser
params:
num_idx: 1000
weighting_config:
target: sgm.modules.diffusionmodules.denoiser_weighting.EpsWeighting
scaling_config:
target: sgm.modules.diffusionmodules.denoiser_scaling.EpsScaling
discretization_config:
target: sgm.modules.diffusionmodules.discretizer.LegacyDDPMDiscretization
network_config:
target: sgm.modules.diffusionmodules.openaimodel.UnifiedUNetModel
params:
in_channels: 9
out_channels: 4
ctrl_channels: 0
model_channels: 320
attention_resolutions: [4, 2, 1]
save_attn_type: [t_attn]
save_attn_layers: [output_blocks.6.1]
num_res_blocks: 2
channel_mult: [1, 2, 4, 4]
num_head_channels: 64
use_linear_in_transformer: True
transformer_depth: 1
t_context_dim: 2048
conditioner_config:
target: sgm.modules.GeneralConditioner
params:
emb_models:
# textual crossattn cond
- is_trainable: False
emb_key: t_crossattn
ucg_rate: 0.1
input_key: label
target: sgm.modules.encoders.modules.LabelEncoder
params:
max_len: 12
emb_dim: 2048
n_heads: 8
n_trans_layers: 12
ckpt_path: ./checkpoints/encoders/LabelEncoder/epoch=19-step=7820.ckpt
# concat cond
- is_trainable: False
input_key: mask
target: sgm.modules.encoders.modules.SpatialRescaler
params:
in_channels: 1
multiplier: 0.125
- is_trainable: False
input_key: masked
target: sgm.modules.encoders.modules.LatentEncoder
params:
scale_factor: 0.18215
config:
target: sgm.models.autoencoder.AutoencoderKLInferenceWrapper
params:
ckpt_path: ./checkpoints/AEs/AE_inpainting_2.safetensors
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
first_stage_config:
target: sgm.models.autoencoder.AutoencoderKLInferenceWrapper
params:
ckpt_path: ./checkpoints/AEs/AE_inpainting_2.safetensors
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
loss_fn_config:
target: sgm.modules.diffusionmodules.loss.FullLoss # StandardDiffusionLoss
params:
seq_len: 12
kernel_size: 3
gaussian_sigma: 1.0
min_attn_size: 16
lambda_local_loss: 0.01
lambda_ocr_loss: 0.001
ocr_enabled: False
predictor_config:
target: sgm.modules.predictors.model.ParseqPredictor
params:
ckpt_path: "./checkpoints/predictors/parseq-bb5792a6.pt"
sigma_sampler_config:
target: sgm.modules.diffusionmodules.sigma_sampling.DiscreteSampling
params:
num_idx: 1000
discretization_config:
target: sgm.modules.diffusionmodules.discretizer.LegacyDDPMDiscretization
================================================
FILE: configs/test.yaml
================================================
type: "test"
# path
load_ckpt_path: "./checkpoints/{your checkpoint path}.ckpt"
model_cfg_path: "./configs/test/textdesign_sd_2.yaml"
dataset_cfg_path: "./configs/dataset/icd13.yaml"
output_dir: "./outputs"
temp_dir: "./temp"
# param
channel: 4 # AE latent channel
factor: 8 # AE downsample factor
scale: [5.0, 0.0] # cfg scale, None
noise_iters: 10 # iterations for initial noise searching
force_uc_zero_embeddings: ["label"] # condition label
aae_enabled: False # attend and excite
detailed: False # save visualization results
# runtime
steps: 50 # sampling steps
init_step: 0
batch_size: 1
num_workers: 0
gpu: 0 # index of your gpu device
max_iter: 100
shuffle: True
quan_test: False # quantitative test
# ocr
ocr_enabled: True
predictor_config:
target: sgm.modules.predictors.model.ParseqPredictor
params:
ckpt_path: "./checkpoints/predictors/parseq-bb5792a6.pt"
================================================
FILE: configs/train/textdesign_sd_2.yaml
================================================
model:
target: sgm.models.diffusion.DiffusionEngine
params:
opt_keys:
- t_attn
- t_norm
input_key: image
scale_factor: 0.18215
disable_first_stage_autocast: True
denoiser_config:
target: sgm.modules.diffusionmodules.denoiser.DiscreteDenoiser
params:
num_idx: 1000
weighting_config:
target: sgm.modules.diffusionmodules.denoiser_weighting.EpsWeighting
scaling_config:
target: sgm.modules.diffusionmodules.denoiser_scaling.EpsScaling
discretization_config:
target: sgm.modules.diffusionmodules.discretizer.LegacyDDPMDiscretization
network_config:
target: sgm.modules.diffusionmodules.openaimodel.UnifiedUNetModel
params:
in_channels: 9
out_channels: 4
ctrl_channels: 0
model_channels: 320
attention_resolutions: [4, 2, 1]
save_attn_type: [t_attn]
save_attn_layers: [output_blocks.6.1]
num_res_blocks: 2
channel_mult: [1, 2, 4, 4]
num_head_channels: 64
use_linear_in_transformer: True
transformer_depth: 1
t_context_dim: 2048
conditioner_config:
target: sgm.modules.GeneralConditioner
params:
emb_models:
# textual crossattn cond
- is_trainable: False
emb_key: t_crossattn
ucg_rate: 0.1
input_key: label
target: sgm.modules.encoders.modules.LabelEncoder
params:
max_len: 12
emb_dim: 2048
n_heads: 8
n_trans_layers: 12
ckpt_path: ./checkpoints/encoders/LabelEncoder/epoch=19-step=7820.ckpt
# concat cond
- is_trainable: False
input_key: mask
target: sgm.modules.encoders.modules.SpatialRescaler
params:
in_channels: 1
multiplier: 0.125
- is_trainable: False
input_key: masked
target: sgm.modules.encoders.modules.LatentEncoder
params:
scale_factor: 0.18215
config:
target: sgm.models.autoencoder.AutoencoderKLInferenceWrapper
params:
ckpt_path: ./checkpoints/AEs/AE_inpainting_2.safetensors
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
first_stage_config:
target: sgm.models.autoencoder.AutoencoderKLInferenceWrapper
params:
ckpt_path: ./checkpoints/AEs/AE_inpainting_2.safetensors
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
loss_fn_config:
target: sgm.modules.diffusionmodules.loss.FullLoss # StandardDiffusionLoss
params:
seq_len: 12
kernel_size: 3
gaussian_sigma: 1.0
min_attn_size: 16
lambda_local_loss: 0.01
lambda_ocr_loss: 0.001
ocr_enabled: False
predictor_config:
target: sgm.modules.predictors.model.ParseqPredictor
params:
ckpt_path: "./checkpoints/predictors/parseq-bb5792a6.pt"
sigma_sampler_config:
target: sgm.modules.diffusionmodules.sigma_sampling.DiscreteSampling
params:
num_idx: 1000
discretization_config:
target: sgm.modules.diffusionmodules.discretizer.LegacyDDPMDiscretization
sampler_config:
target: sgm.modules.diffusionmodules.sampling.EulerEDMSampler
params:
num_steps: 50
discretization_config:
target: sgm.modules.diffusionmodules.discretizer.LegacyDDPMDiscretization
guider_config:
target: sgm.modules.diffusionmodules.guiders.VanillaCFG
params:
scale: 5.0
================================================
FILE: configs/train.yaml
================================================
type: "train"
# path
save_ckpt_dir: ./checkpoints
load_ckpt_path: ./checkpoints/pretrained/512-inpainting-ema.ckpt
model_cfg_path: ./configs/train/textdesign_sd_2.yaml
dataset_cfg_path: ./configs/dataset/locr.yaml
# param
save_ckpt_freq: 1
num_workers: 0
batch_size: 16
base_learning_rate: 5.0e-5
shuffle: False
# runtime
lightning:
max_epochs: 100
accelerator: gpu
strategy: ddp_find_unused_parameters_true
accumulate_grad_batches: 4
devices: [1,2,3,4,5,6,7,8]
default_root_dir: ./logs/base_logs
profiler: simple
================================================
FILE: dataset/__init__.py
================================================
================================================
FILE: dataset/dataloader.py
================================================
import os,glob
import torch
import cv2
import scipy
import string
import json
import torchvision.transforms as transforms
import torch.nn.functional as F
import torch.utils.data as data
import numpy as np
from tqdm import tqdm
from omegaconf import OmegaConf
from PIL import Image, ImageDraw, ImageFont
from os.path import join as ospj
from torchvision.utils import save_image
from random import choice, randint, sample, uniform, shuffle
from util import *
def region_draw_text(H, W, r_bbox, text, font_path = "./dataset/utils/arial.ttf"):
m_top, m_bottom, m_left, m_right = r_bbox
m_h, m_w = m_bottom-m_top, m_right-m_left
font = ImageFont.truetype(font_path, 128)
std_l, std_t, std_r, std_b = font.getbbox(text)
std_h, std_w = std_b - std_t, std_r - std_l
image = Image.new('RGB', (std_w, std_h), color = (255, 255, 255))
draw = ImageDraw.Draw(image)
draw.text((0, 0), text, fill = (0, 0, 0), font=font, anchor="lt")
transform = transforms.Compose([
transforms.Resize((m_h, m_w), transforms.InterpolationMode.BICUBIC, antialias=True),
transforms.ToTensor()
])
image = transform(image)
result = torch.ones((3, H, W))
result[:, m_top:m_bottom, m_left:m_right] = image
return result
def initialize_word_dict():
with open('./dataset/utils/words.txt', 'r') as f:
word_list = f.readlines()
words = []
for word_line in word_list:
words += word_line[:-1].split(" ")
words.sort(key = lambda w: len(w))
word_dict = {l:[] for l in range(len(words[0]), len(words[-1])+1)}
for word in words:
word_dict[len(word)].append(word)
return word_dict
class LabelDataset(data.Dataset):
def __init__(self, size, length, font_path, min_len, max_len) -> None:
super().__init__()
# constraint
self.length = length
self.size = size
# path
self.font_path = font_path
# word dict
self.character = string.printable[:-6]
self.min_len = min_len
self.max_len = max_len
self.grayscale = transforms.Grayscale()
self.resize = transforms.Resize((self.size, self.size), transforms.InterpolationMode.BICUBIC, antialias=True)
def __len__(self):
return self.length
def __getitem__(self, index):
while True:
text_len = randint(self.min_len, self.max_len)
text = "".join([choice(self.character) for i in range(text_len)])
font_path = self.font_path
try:
font = ImageFont.truetype(font_path, 128)
std_l, std_t, std_r, std_b = font.getbbox(text)
std_h, std_w = std_b - std_t, std_r - std_l
if std_h == 0 or std_w == 0:
continue
except:
continue
try:
image = Image.new('RGB', (std_w, std_h), color = (0,0,0))
draw = ImageDraw.Draw(image)
draw.text((0, 0), text, fill = (255,255,255), font=font, anchor="lt")
except:
continue
image = transforms.ToTensor()(image)
image = self.grayscale(image)
image = self.resize(image)
batch = {
"image": image,
"text": text
}
return batch
class ICDAR13Dataset(data.Dataset):
def __init__(self, cfgs, datype) -> None:
super().__init__()
# basic
self.type = datype
self.character = string.printable[:-6]
# path
self.data_root = ospj(cfgs.data_root, "ICDAR13", self.type)
self.image_root = ospj(self.data_root, "images")
self.anno_root = ospj(self.data_root, "annos")
self.anno_paths = sorted(glob.glob(ospj(self.anno_root, "*.txt")))
# constraint
self.H = cfgs.H
self.W = cfgs.W
self.word_len = cfgs.word_len
self.seq_len = cfgs.seq_len
self.mask_min_ratio = cfgs.mask_min_ratio
self.aug_text_enabled = cfgs.aug_text_enabled
self.aug_text_ratio = cfgs.aug_text_ratio
self.items = []
total_count = 0
for anno_path in self.anno_paths:
name = anno_path.split(os.sep)[-1].split(".")[0].replace("gt_", "")
with open(anno_path, "r") as fp:
annos = fp.readlines()
for anno in annos:
total_count += 1
text = anno.split("\"")[1]
left, top, right, bottom = [int(s) for s in anno.split(", ")[:4]]
area = (bottom-top) * (right-left)
bbox = np.array((top, bottom, left, right))
if len(text) < self.word_len[0] or len(text) > self.word_len[1]: continue
if not all([c in self.character for c in text]): continue
if area / (self.H * self.W) < self.mask_min_ratio: continue
self.items.append({
"image_path": ospj(self.image_root, f"{name}.jpg"),
"text": text,
"bbox": bbox
})
self.length = len(self.items)
print(f"Total: {total_count}, filtered: {self.length}")
self.count = -1
self.word_dict = initialize_word_dict()
def __len__(self):
return self.length
def augment(self, image, bbox):
h, w, _ = image.shape
m_top, m_bottom, m_left, m_right = bbox
mask = np.ones((h, w), dtype=np.uint8)
mask[m_top:m_bottom, m_left:m_right] = 0
if h >= w:
delta = (h-w)//2
m_left += delta; m_right += delta
image = cv2.copyMakeBorder(image, 0,0,delta,delta, cv2.BORDER_REPLICATE)
mask = cv2.copyMakeBorder(mask, 0,0,delta,delta, cv2.BORDER_CONSTANT, value = (1,1,1))
else:
delta = (w-h)//2
m_top += delta; m_bottom += delta
image = cv2.copyMakeBorder(image, delta,delta,0,0, cv2.BORDER_REPLICATE)
mask = cv2.copyMakeBorder(mask, delta,delta,0,0, cv2.BORDER_CONSTANT, value = (1,1,1))
m_h, m_w = int(m_bottom-m_top), int(m_right-m_left)
c_h, c_w = m_top + m_h//2, m_left + m_w//2
h, w, _ = image.shape
area = (m_bottom-m_top) * (m_right-m_left)
aug_min_ratio = self.mask_min_ratio * 4
if area/(h*w) < aug_min_ratio:
d = int((area/aug_min_ratio)**0.5)
d = max(d, max(m_h, m_w))
if c_h <= h - c_h:
delta_top = min(c_h, d//2)
delta_bottom = d - delta_top
else:
delta_bottom = min(h - c_h, d//2)
delta_top = d - delta_bottom
if c_w <= w - c_w:
delta_left = min(c_w, d//2)
delta_right = d - delta_left
else:
delta_right = min(w - c_w, d//2)
delta_left = d - delta_right
n_top, n_bottom = c_h - delta_top, c_h + delta_bottom
n_left, n_right = c_w - delta_left, c_w + delta_right
image = image[n_top:n_bottom, n_left:n_right, :]
mask = mask[n_top:n_bottom, n_left:n_right]
m_top -= n_top; m_bottom -= n_top
m_left -= n_left; m_right -= n_left
h, w, _ = image.shape
m_top, m_bottom = int(m_top * (self.H/h)), int(m_bottom * (self.H/h))
m_left, m_right = int(m_left * (self.W/w)), int(m_right * (self.W/w))
image = cv2.resize(image, (self.W, self.H))
mask = cv2.resize(mask, (self.W, self.H))
r_bbox = torch.tensor((m_top, m_bottom, m_left, m_right))
return image, mask, r_bbox
def __getitem__(self, index):
self.count += 1
item = self.items[index]
image_path = item["image_path"]
text = item["text"]
bbox = item["bbox"]
aug_text = choice(self.word_dict[len(text)]) if uniform(0, 1) <= self.aug_text_ratio else text
image = Image.open(image_path).convert("RGB")
w, h = image.size
image = np.asarray(image)
image, mask, r_bbox = self.augment(image, bbox)
image = torch.from_numpy(image.transpose(2,0,1)).to(dtype=torch.float32) / 127.5 - 1.0
mask = torch.from_numpy(mask[None]).to(dtype=torch.float32)
masked = image * mask
mask = 1 - mask
seg_mask = torch.cat((torch.ones(len(text)), torch.zeros(self.seq_len-len(text))))
rendered = region_draw_text(self.H, self.W, r_bbox, aug_text if self.aug_text_enabled else text)
# additional cond
txt = f"\"{aug_text if self.aug_text_enabled else text}\""
original_size_as_tuple = torch.tensor((h, w))
crop_coords_top_left = torch.tensor((0, 0))
target_size_as_tuple = torch.tensor((self.H, self.W))
batch = {
"image": image,
"mask": mask,
"masked": masked,
"seg_mask": seg_mask,
"r_bbox": r_bbox,
"rendered": rendered,
"label": aug_text if self.aug_text_enabled else text,
"txt": txt,
"original_size_as_tuple": original_size_as_tuple,
"crop_coords_top_left": crop_coords_top_left,
"target_size_as_tuple": target_size_as_tuple,
"name": str(self.count)
}
return batch
class TextSegDataset(data.Dataset):
def __init__(self, cfgs, datype) -> None:
super().__init__()
# basic
self.type = datype
self.character = string.printable[:-6]
# path
self.data_root = ospj(cfgs.data_root, "TextSeg", self.type)
self.image_root = ospj(self.data_root, "image")
self.anno_root = ospj(self.data_root, "annotation")
# constraint
self.H = cfgs.H
self.W = cfgs.W
self.word_len = cfgs.word_len
self.seq_len = cfgs.seq_len
self.mask_min_ratio = cfgs.mask_min_ratio
self.seg_min_ratio = cfgs.seg_min_ratio
self.aug_text_enabled = cfgs.aug_text_enabled
self.aug_text_ratio = cfgs.aug_text_ratio
image_paths = sorted(glob.glob(ospj(self.image_root, "*.jpg")))
anno_paths = sorted(glob.glob(ospj(self.anno_root, "*.json")))
seg_paths = sorted([p for p in glob.glob(ospj(self.anno_root, "*.png")) if "eff" not in p])
self.items = []
total_count = 0
for image_path, anno_path, seg_path in zip(image_paths, anno_paths, seg_paths):
with open(anno_path, "rb") as fp:
annos = json.load(fp)
for anno in annos.values():
total_count += 1
text = anno["text"]
chars = [anno["char"][key]["text"] for key in anno["char"]]
bbox = np.array(anno["bbox"]).reshape((4,2))
seg_values = [c["mask_value"] for c in anno["char"].values()]
area = cv2.contourArea(bbox)
if "".join(chars) != text: continue
if "#" in text: continue
if len(text) < self.word_len[0] or len(text) > self.word_len[1]: continue
if not all([c in self.character for c in text]): continue
if area / (self.H * self.W) < self.mask_min_ratio: continue
self.items.append({
"image_path": image_path,
"seg_path": seg_path,
"text": text,
"bbox": bbox,
"seg_values": seg_values
})
self.length = len(self.items)
print(f"Total: {total_count}, filtered: {self.length}")
self.count = -1
self.word_dict = initialize_word_dict()
def __len__(self):
return self.length
def augment(self, image, seg, text, bbox, seg_values):
h, w, _ = image.shape
m_top, m_bottom = int(np.min(bbox[:,1])), int(np.max(bbox[:,1]))
m_left, m_right = int(np.min(bbox[:,0])), int(np.max(bbox[:,0]))
mask = np.ones((h, w), dtype=np.uint8)
mask = cv2.fillConvexPoly(mask, bbox, 0)
if h >= w:
delta = (h-w)//2
m_left += delta; m_right += delta
image = cv2.copyMakeBorder(image, 0,0,delta,delta, cv2.BORDER_REPLICATE)
mask = cv2.copyMakeBorder(mask, 0,0,delta,delta, cv2.BORDER_CONSTANT, value = (1,1,1))
seg = cv2.copyMakeBorder(seg, 0,0,delta,delta, cv2.BORDER_CONSTANT, value = (0,0,0))
else:
delta = (w-h)//2
m_top += delta; m_bottom += delta
image = cv2.copyMakeBorder(image, delta,delta,0,0, cv2.BORDER_REPLICATE)
mask = cv2.copyMakeBorder(mask, delta,delta,0,0, cv2.BORDER_CONSTANT, value = (1,1,1))
seg = cv2.copyMakeBorder(seg, delta,delta,0,0, cv2.BORDER_CONSTANT, value = (0,0,0))
m_h, m_w = int(m_bottom-m_top), int(m_right-m_left)
c_h, c_w = m_top + m_h//2, m_left + m_w//2
h, w, _ = image.shape
area = cv2.contourArea(bbox)
aug_min_ratio = self.mask_min_ratio * 4
if area/(h*w) < aug_min_ratio:
d = int((area/aug_min_ratio)**0.5)
d = max(d, max(m_h, m_w))
if c_h <= h - c_h:
delta_top = min(c_h, d//2)
delta_bottom = d - delta_top
else:
delta_bottom = min(h - c_h, d//2)
delta_top = d - delta_bottom
if c_w <= w - c_w:
delta_left = min(c_w, d//2)
delta_right = d - delta_left
else:
delta_right = min(w - c_w, d//2)
delta_left = d - delta_right
n_top, n_bottom = c_h - delta_top, c_h + delta_bottom
n_left, n_right = c_w - delta_left, c_w + delta_right
image = image[n_top:n_bottom, n_left:n_right, :]
mask = mask[n_top:n_bottom, n_left:n_right]
seg = seg[n_top:n_bottom, n_left:n_right, :]
m_top -= n_top; m_bottom -= n_top
m_left -= n_left; m_right -= n_left
segs = []
text_indices = [[i for i, c in enumerate(text) if c == ch] for ch in text]
for i in range(len(text)):
indices = text_indices[i]
seg_i = np.sum([(seg == seg_values[ind]).astype(np.uint8).mean(axis=-1) for ind in indices], axis=0) # position un-aware
seg_i = np.clip(seg_i, 0, 1)
seg_i = cv2.morphologyEx(seg_i, cv2.MORPH_OPEN, np.ones((1,2),np.int8), iterations=2) # denoise
seg_i = cv2.morphologyEx(seg_i, cv2.MORPH_OPEN, np.ones((2,1),np.int8), iterations=2) # denoise
seg_i = cv2.morphologyEx(seg_i, cv2.MORPH_DILATE, np.ones((3,3),np.int8), iterations=7) # dilate
segs.append(seg_i[None])
segs = segs + [np.zeros_like(segs[0]) for i in range(self.seq_len-len(segs))]
seg = np.concatenate(segs, axis=0)
h, w, _ = image.shape
m_top, m_bottom = int(m_top * (self.H/h)), int(m_bottom * (self.H/h))
m_left, m_right = int(m_left * (self.W/w)), int(m_right * (self.W/w))
image = cv2.resize(image, (self.W, self.H))
seg = cv2.resize(seg.transpose((1,2,0)), (self.W, self.H)).transpose((2,0,1))
mask = cv2.resize(mask, (self.W, self.H))
r_bbox = torch.tensor((m_top, m_bottom, m_left, m_right))
return image, seg, mask, r_bbox
def __getitem__(self, index):
self.count += 1
while True:
item = self.items[index]
image_path = item["image_path"]
seg_path = item["seg_path"]
text = item["text"]
bbox = item["bbox"]
seg_values = item["seg_values"]
aug_text = choice(self.word_dict[len(text)]) if uniform(0, 1) <= self.aug_text_ratio else text
image = Image.open(image_path).convert("RGB")
seg = Image.open(seg_path).convert("RGB")
w, h = image.size
image = np.asarray(image)
seg = np.asarray(seg)
image, seg, mask, r_bbox = self.augment(image, seg, text, bbox, seg_values)
image = torch.from_numpy(image.transpose(2,0,1)).to(dtype=torch.float32) / 127.5 - 1.0
mask = torch.from_numpy(mask[None]).to(dtype=torch.float32)
masked = image * mask
mask = 1 - mask
seg = torch.from_numpy(seg)
seg_mask = torch.cat((torch.ones(len(text)), torch.zeros(self.seq_len-len(text))))
rendered = region_draw_text(self.H, self.W, r_bbox, aug_text if self.aug_text_enabled else text)
# additional cond
txt = f"\"{aug_text if self.aug_text_enabled else text}\""
original_size_as_tuple = torch.tensor((h, w))
crop_coords_top_left = torch.tensor((0, 0))
target_size_as_tuple = torch.tensor((self.H, self.W))
batch = {
"image": image,
"seg": seg,
"seg_mask": seg_mask,
"mask": mask,
"masked": masked,
"r_bbox": r_bbox,
"rendered": rendered,
"label": aug_text if self.aug_text_enabled else text,
"txt": txt,
"original_size_as_tuple": original_size_as_tuple,
"crop_coords_top_left": crop_coords_top_left,
"target_size_as_tuple": target_size_as_tuple,
"name": str(self.count)
}
return batch
class SynthTextDataset(data.Dataset):
def __init__(self, cfgs, datype) -> None:
super().__init__()
# basic
self.type = datype
self.length = cfgs.length
self.character = string.printable[:-6]
# path
self.data_root = ospj(cfgs.data_root, "SynthText")
self.anno_path = ospj(self.data_root, "gt.mat")
# constraint
self.H = cfgs.H
self.W = cfgs.W
self.word_len = cfgs.word_len
self.mask_min_ratio = cfgs.mask_min_ratio
self.seg_min_ratio = cfgs.seg_min_ratio
anno = scipy.io.loadmat(self.anno_path)
image_names = anno["imnames"][0]
word_bboxes = anno["wordBB"][0]
char_bboxes = anno["charBB"][0]
txts = anno["txt"][0]
if cfgs.use_cached:
with open(ospj(self.data_root, "items.json"), "r") as fp:
self.items = json.load(fp)
else:
self.items = []
for image_name, word_bbox, char_bbox, txt in zip(image_names, word_bboxes, char_bboxes, txts):
image_name = image_name[0]
image_path = ospj(self.data_root, image_name)
txt_list = []
for frag in txt:
frag = frag.replace("\n", " ")
frags = [s for s in frag.split(" ") if s != ""]
txt_list += frags
if word_bbox.ndim < 3: word_bbox = word_bbox[...,None]
word_bbox = word_bbox.transpose((2,1,0)).astype(np.int32)
char_bbox = char_bbox.transpose((2,1,0)).astype(np.int32)
pointer = 0
for bbox, text in zip(word_bbox, txt_list):
seg_bboxs = char_bbox[pointer: pointer+len(text)]
pointer += len(text)
area = cv2.contourArea(bbox)
if len(text) < self.word_len[0] or len(text) > self.word_len[1]: continue
if area / (self.H * self.W) < self.mask_min_ratio: continue
self.items.append({
"image_path": image_path,
"text": text,
"bbox": bbox.tolist(),
"seg_bboxs" : seg_bboxs.tolist()
})
with open(ospj(self.data_root, "items.json"), "w") as fp:
json.dump(self.items, fp)
self.count = -1
def __len__(self):
return self.length
def augment(self, image, bbox, seg_bboxs):
h, w, _ = image.shape
m_top, m_bottom = max(0, int(np.min(bbox[:,1]))), min(h, int(np.max(bbox[:,1])))
m_left, m_right = max(0, int(np.min(bbox[:,0]))), min(w, int(np.max(bbox[:,0])))
mask = np.ones((h, w), dtype=np.uint8)
mask = cv2.fillConvexPoly(mask, bbox, 0)
segs = []
seg_sum = 0
for seg_bbox in seg_bboxs:
seg_i = np.zeros_like(mask)
seg_i = cv2.fillConvexPoly(seg_i, seg_bbox, 1)
segs.append(seg_i[None])
seg_sum += seg_i.sum()
seg_ratio = float(seg_sum / len(segs)) / (h*w)
segs = segs + [np.zeros_like(segs[0]) for i in range(self.word_len[1]-len(segs))]
seg = np.concatenate(segs, axis=0)
if h >= w:
delta = (h-w)//2
m_left += delta; m_right += delta
image = cv2.copyMakeBorder(image, 0,0,delta,delta, cv2.BORDER_REPLICATE)
mask = cv2.copyMakeBorder(mask, 0,0,delta,delta, cv2.BORDER_CONSTANT, value = (1,1,1))
seg = cv2.copyMakeBorder(seg.transpose((1,2,0)), 0,0,delta,delta, cv2.BORDER_CONSTANT, value = (0,0,0)).transpose((2,0,1))
else:
delta = (w-h)//2
m_top += delta; m_bottom += delta
image = cv2.copyMakeBorder(image, delta,delta,0,0, cv2.BORDER_REPLICATE)
mask = cv2.copyMakeBorder(mask, delta,delta,0,0, cv2.BORDER_CONSTANT, value = (1,1,1))
seg = cv2.copyMakeBorder(seg.transpose((1,2,0)), delta,delta,0,0, cv2.BORDER_CONSTANT, value = (0,0,0)).transpose((2,0,1))
m_h, m_w = int(m_bottom-m_top), int(m_right-m_left)
c_h, c_w = m_top + m_h//2, m_left + m_w//2
h, w, _ = image.shape
area = cv2.contourArea(bbox)
aug_min_ratio = self.mask_min_ratio * 4
if area/(h*w) < aug_min_ratio:
d = int((area/aug_min_ratio)**0.5)
d = max(d, max(m_h, m_w))
if c_h <= h - c_h:
delta_top = min(c_h, d//2)
delta_bottom = d - delta_top
else:
delta_bottom = min(h - c_h, d//2)
delta_top = d - delta_bottom
if c_w <= w - c_w:
delta_left = min(c_w, d//2)
delta_right = d - delta_left
else:
delta_right = min(w - c_w, d//2)
delta_left = d - delta_right
n_top, n_bottom = c_h - delta_top, c_h + delta_bottom
n_left, n_right = c_w - delta_left, c_w + delta_right
image = image[n_top:n_bottom, n_left:n_right, :]
mask = mask[n_top:n_bottom, n_left:n_right]
seg = seg[:, n_top:n_bottom, n_left:n_right]
m_top -= n_top; m_bottom -= n_top
m_left -= n_left; m_right -= n_left
h, w, _ = image.shape
m_top, m_bottom = int(m_top * (self.H/h)), int(m_bottom * (self.H/h))
m_left, m_right = int(m_left * (self.W/w)), int(m_right * (self.W/w))
image = cv2.resize(image, (self.W, self.H))
seg = cv2.resize(seg.transpose((1,2,0)), (self.W, self.H)).transpose((2,0,1))
mask = cv2.resize(mask, (self.W, self.H))
r_bbox = torch.tensor((m_top, m_bottom, m_left, m_right))
return image, seg, mask, seg_ratio, r_bbox
def __getitem__(self, index):
self.count += 1
while True:
item = choice(self.items)
image_path = item["image_path"]
text = item["text"]
bbox = np.array(item["bbox"])
seg_bboxs = np.array(item["seg_bboxs"])
image = Image.open(image_path).convert("RGB")
w, h = image.size
image = np.asarray(image)
image, seg, mask, seg_ratio, r_bbox = self.augment(image, bbox, seg_bboxs)
if seg_ratio < self.seg_min_ratio: continue
image = torch.from_numpy(image.transpose(2,0,1)).to(dtype=torch.float32) / 127.5 - 1.0
mask = torch.from_numpy(mask[None]).to(dtype=torch.float32)
masked = image * mask
mask = 1 - mask
seg = torch.from_numpy(seg).to(dtype=torch.float32)
seg_mask = torch.cat((torch.ones(len(text)), torch.zeros(self.word_len[1]-len(text))))
# additional cond
txt = f"\"{text}\""
original_size_as_tuple = torch.tensor((h, w))
crop_coords_top_left = torch.tensor((0, 0))
target_size_as_tuple = torch.tensor((self.H, self.W))
batch = {
"image": image,
"seg": seg,
"seg_mask": seg_mask,
"mask": mask,
"masked": masked,
"r_bbox": r_bbox,
"label": text,
"txt": txt,
"original_size_as_tuple": original_size_as_tuple,
"crop_coords_top_left": crop_coords_top_left,
"target_size_as_tuple": target_size_as_tuple,
"name": str(self.count)
}
return batch
class LAIONOCRDataset(data.Dataset):
def __init__(self, cfgs, datype) -> None:
super().__init__()
# basic
self.type = datype
self.character = string.printable[:-6]
# path
self.data_root = ospj(cfgs.data_root, "LAION-OCR", self.type)
# constraint
self.H = cfgs.H
self.W = cfgs.W
self.W_std = 512
self.H_std = 512
self.word_len = cfgs.word_len
self.seq_len = cfgs.seq_len
self.mask_min_ratio = cfgs.mask_min_ratio
self.seg_min_ratio = cfgs.seg_min_ratio
self.aug_text_enabled = cfgs.aug_text_enabled if self.type != "train" else False
self.aug_text_ratio = cfgs.aug_text_ratio
if cfgs.use_cached:
with open(ospj(cfgs.data_root, "LAION-OCR", f"{self.type}_items.json"), "r") as fp:
self.items = json.load(fp)
else:
self.items = []
data_dirs = sorted(glob.glob(ospj(self.data_root, "*")))
len_count = area_count = text_count = 0
for data_dir in data_dirs:
image_path = ospj(data_dir, "image.jpg")
ocr_path = ospj(data_dir, "ocr.txt")
seg_path = ospj(data_dir, "charseg.npy")
with open(ocr_path, "r") as fp:
ocrs = fp.readlines()
for ocr in ocrs:
text, bbox_str, _ = ocr.strip("\n").split(" ")
bbox = np.array([int(v) for v in bbox_str.split(",")]).reshape((4,2))
area = cv2.contourArea(bbox)
if len(text) < self.word_len[0] or len(text) > self.word_len[1]:
len_count += 1
continue
if not all([c in self.character for c in text]):
text_count += 1
continue
if area / (self.W_std*self.H_std) < self.mask_min_ratio:
area_count += 1
continue
self.items.append({
"image_path": image_path,
"seg_path": seg_path,
"text": text,
"bbox_str": bbox_str,
})
with open(ospj(cfgs.data_root, "LAION-OCR", f"{self.type}_items.json"), "w") as fp:
json.dump(self.items, fp)
print(f"Total length: {len(self.items)} filtered out {len_count} len_ill, {area_count} area_ill, {text_count} text_ill")
self.length = cfgs.length
self.count = -1
self.word_dict = initialize_word_dict()
def __len__(self):
return self.length
def augment(self, image, seg, text, bbox):
image = cv2.resize(image, (self.W_std, self.H_std))
seg = cv2.resize(seg.astype(np.uint8), (self.W_std, self.H_std))
mask = np.ones((self.H_std, self.W_std), dtype=np.uint8)
mask = cv2.fillConvexPoly(mask, bbox, 0)
h, w, _ = image.shape
m_top, m_bottom = max(0, int(np.min(bbox[:,1]))), min(self.H_std, int(np.max(bbox[:,1])))
m_left, m_right = max(0, int(np.min(bbox[:,0]))), min(self.W_std, int(np.max(bbox[:,0])))
m_h, m_w = int(m_bottom-m_top), int(m_right-m_left)
c_h, c_w = m_top + m_h//2, m_left + m_w//2
area = cv2.contourArea(bbox)
aug_min_ratio = self.mask_min_ratio * 4
if area/(h*w) < aug_min_ratio:
d = int((area/aug_min_ratio)**0.5)
d = max(d, max(m_h, m_w))
if c_h <= h - c_h:
delta_top = min(c_h, d//2)
delta_bottom = d - delta_top
else:
delta_bottom = min(h - c_h, d//2)
delta_top = d - delta_bottom
if c_w <= w - c_w:
delta_left = min(c_w, d//2)
delta_right = d - delta_left
else:
delta_right = min(w - c_w, d//2)
delta_left = d - delta_right
n_top, n_bottom = c_h - delta_top, c_h + delta_bottom
n_left, n_right = c_w - delta_left, c_w + delta_right
image = image[n_top:n_bottom, n_left:n_right, :]
mask = mask[n_top:n_bottom, n_left:n_right]
seg = seg[n_top:n_bottom, n_left:n_right]
m_top -= n_top; m_bottom -= n_top
m_left -= n_left; m_right -= n_left
seg = seg * (1 - mask)
segs = [None for i in range(len(text))]
ch_dict = {}
for i in range(len(text)):
if text[i] in ch_dict: ch_dict[text[i]].append(i)
else: ch_dict[text[i]] = [i]
for ch in ch_dict:
ind = self.character.find(ch) + 1
ind_l = self.character.find(ch.lower()) + 1
seg_i = ((seg == ind).astype(np.uint8) + (seg == ind_l).astype(np.uint8))
seg_i = cv2.morphologyEx(seg_i, cv2.MORPH_OPEN, np.ones((1,2),np.int8), iterations=1) # denoise
seg_i = cv2.morphologyEx(seg_i, cv2.MORPH_OPEN, np.ones((2,1),np.int8), iterations=1) # denoise
seg_i = cv2.morphologyEx(seg_i, cv2.MORPH_DILATE, np.ones((3,3),np.int8), iterations=5) # dilate
retval, labels, stats, centroids = cv2.connectedComponentsWithStats(seg_i, connectivity=4)
if retval < len(ch_dict[ch]) + 1:
return None, None, None, None
stats = stats[1:].tolist()
if retval > len(ch_dict[ch]) + 1:
stats.sort(key = lambda st: st[-1])
stats.reverse()
stats = stats[:len(ch_dict[ch])]
stats.sort(key = lambda st: st[0])
for idx, stat in enumerate(stats):
x, y, w, h, s = stat
s_mask = np.zeros_like(seg_i)
s_mask[y:y+h, x:x+w] = 1
seg_i_mask = seg_i * s_mask
segs[ch_dict[ch][idx]] = seg_i_mask[None]
segs = segs + [np.zeros_like(segs[0]) for i in range(self.seq_len-len(segs))]
seg = np.concatenate(segs, axis=0)
h, w, _ = image.shape
m_top, m_bottom = int(m_top * (self.H/h)), int(m_bottom * (self.H/h))
m_left, m_right = int(m_left * (self.W/w)), int(m_right * (self.W/w))
image = cv2.resize(image, (self.W, self.H))
seg = cv2.resize(seg.transpose((1,2,0)), (self.W, self.H)).transpose((2,0,1))
mask = cv2.resize(mask, (self.W, self.H))
r_bbox = torch.tensor((m_top, m_bottom, m_left, m_right))
return image, seg, mask, r_bbox
def __getitem__(self, index):
self.count += 1
while True:
item = choice(self.items)
image_path = item["image_path"]
seg_path = item["seg_path"]
text = item["text"]
bbox_str = item["bbox_str"]
bbox = np.array([int(v) for v in bbox_str.split(",")]).reshape((4,2))
aug_text = choice(self.word_dict[len(text)]) if uniform(0, 1) <= self.aug_text_ratio else text
image = Image.open(image_path).convert("RGB")
seg = np.load(seg_path)
w, h = image.size
image = np.asarray(image)
image, seg, mask, r_bbox = self.augment(image, seg, text, bbox)
if image is None: continue
image = torch.from_numpy(image.transpose(2,0,1)).to(dtype=torch.float32) / 127.5 - 1.0
mask = torch.from_numpy(mask[None]).to(dtype=torch.float32)
masked = image * mask
mask = 1 - mask
seg = torch.from_numpy(seg).to(dtype=torch.float32)
seg_mask = torch.cat((torch.ones(len(text)), torch.zeros(self.seq_len-len(text))))
m_top, m_bottom, m_left, m_right = r_bbox
ref = image[:, m_top:m_bottom, m_left:m_right]
ref = F.interpolate(ref[None], (128, 128))[0]
# rendered = region_draw_text(self.H, self.W, r_bbox, aug_text if self.aug_text_enabled else text)
# additional cond
txt = f"\"{aug_text if self.aug_text_enabled else text}\""
original_size_as_tuple = torch.tensor((h, w))
crop_coords_top_left = torch.tensor((0, 0))
target_size_as_tuple = torch.tensor((self.H, self.W))
batch = {
"image": image,
"seg": seg,
"seg_mask": seg_mask,
"mask": mask,
"masked": masked,
"r_bbox": r_bbox,
"ref": ref,
# "rendered": rendered,
"label": aug_text if self.aug_text_enabled else text,
"txt": txt,
"original_size_as_tuple": original_size_as_tuple,
"crop_coords_top_left": crop_coords_top_left,
"target_size_as_tuple": target_size_as_tuple,
"name": str(self.count)
}
return batch
def get_dataloader(cfgs, datype="train"):
dataset_cfgs = OmegaConf.load(cfgs.dataset_cfg_path)
print(f"Extracting data from {dataset_cfgs.target}")
Dataset = eval(dataset_cfgs.target)
dataset = Dataset(dataset_cfgs.params, datype = datype)
return data.DataLoader(dataset=dataset, batch_size=cfgs.batch_size, shuffle=cfgs.shuffle, num_workers=cfgs.num_workers, drop_last=True)
================================================
FILE: dataset/utils/words.txt
================================================
the of and to in a is was that for as with by on are from be or his were it an at not which have he had this has also their but one can its on the other been more they used first all two citation than into would only time who most may such some many when after between over these her about there use no them new him will out during made both then often so any being such as where number could main p. through system people known each while if called convert same later three because well work before the same under part very different became year did large example several city early until much government found own since she even form power do those around state including set high life against second century within world still end using small name what now usually American without however began like as well area make common the most water United States another way due must long less four death said film order due to back public does left based few become known as s given country major British place group considered among game point used to period support war music down million important systems control should took day family language last original result political line members case as well as see single just process along similar take following we although countries right either times areas published the other local include population never data home every various the time modern further development per how led possible military popular term though history generally you off rather men law developed German held human production body general the world light sometimes states late field based on having came above available book others York next created U.S. show himself out of wrote days died word play again great service age seen children level released works continued pp. the two five higher species energy required change means team January information theory New York produced making built design role addition included almost side position groups able de land total range July national space written social version Europe season force air allowed largest good type itself received women low throughout taken standard little least that is free cases size thus school especially old upon particular terms effect provide lower certain together present always short parts words third April described too up to established might played forces natural June once months rate European numbers six man rather than hand typically value England London October could be final the country September average France instead current December international program character increased a few surface across thought company followed best provided economic games significant named function building went return uses fact study below full source lost America person a number changes longer research individual languages strong structure party larger run open cause aircraft away far region need food forms increase outside started material cannot November half head market near record traditional special style all the sent story February player designed top at least themselves model returned band because of help types come points added events network limited services nature army former father close view allow won specific elements practice lines gave pressure introduced produce moved whether religious put official movement my Germany students trade method attack in order problems art eventually evidence referred results caused remained influence success meaning brought believed enough features give young white culture problem characters lead action according referred to conditions performance according to effects amount black business working better difficult temperature education real money smaller create located directly sound leading ground therefore get private formed particularly Chinese television subject south cities album class industry computer beginning community already complete go players associated related physical our town move complex interest rule speed commonly in order to rights living for example greater writing find growth killed court levels house against the office done shows Spanish needed saw central entire fire son books mostly access soon today earlier variety additional percent foreign ever recorded future widely title all of shown successful radio project construction changed king remains mass personal policy code includes involved Africa idea names separate base length rules key units likely makes release cost church films majority primary performed methods stated appear whole so that member allows decided Japanese reported sold capital science society rest stage event whose recent color legal highly career song frequently placed simple defined me mother appeared India schools turn simply relationship multiple nearly sense past relatively forced software attempt north William quickly companies programs products direct site sources previous technology battle front provides necessary served originally along with approach image seven experience Greek parts of text towards completed memory ability commercial UK health replaced worked yet start economy highest property behind knowledge test response largely sea reached president wide night operations supported act training reason Britain list issues occur loss the government reduced active functions remain lack to do clear gas island cells taking contains takes approximately exist basis distance independent intended elected product adopted actually wife ended born Christian keep potential course matter love issue objects things heavy oil center regular George the following divided eight date James summer direction laws numerous account income individuals concept plan announced Russian failed applied values northern proposed ships resulting estimated appears continue Canada red married object studies media engine passed Henry Australia machine quality founded hold say parties letter Japan expected treatment normal signal blood financial status video older carried compared know wanted accepted via read each other types of animals turned unit feature southern increasing met prevent songs applications require opened marriage contain equipment playing section remaining properties asked the case ten Charles activity whom ways buildings basic probably running materials stories edition location noted cell analysis Russia Rome removed becomes paper activities billion fall child cut operating degree ship occurs less than novel completely except inside Robert troops Jewish report call flow metal appointed offered told frequency initial campaign discovered definition historical models allowing operation police poor weight not have ancient here primarily agreed hit west heat security David claimed positive easily environment scientific going regions ISBN ball tradition reach requires St. extended charge female face serve equal Italy letters refused immediately believe supply effective internal versions cultural leave th mainly negative soldiers question spread suggested Paul
difference unique fully musical relations civil cover something board becoming famous hard plants situation workers Indian shot medical instead of risk device decision techniques weeks previously western phase responsible purpose race article gives reference giving authority critical sets Italian in the world ideas California growing element instance kept moving rock share nuclear causes reduce vote efforts table output car determined win era notes finally ordered application develop distribution represented leaving quite the population woman devices contrast offer tried presence the top mean scale us river collection content attempt to says powerful comes the best humans travel resulted proved African combined road felt page receive tax address teams connected pay annual despite disease birth closed kind agreement actual price claim goal management flight rise fuel brother maximum month presented write east male gold reaction powers resources latter plant middle motion observed rates your currently station appearance volume avoid consists deal families argued room scene user depending advantage weapons target prior records temperatures speech spent focus mission dead constant existence lived daughter signed relative blue occurred helped damage meant actions professional friends contact places solution Asia beyond meeting structures standards care exchange peace sequence carry county nor organization chemical showed factors federal transport capacity Washington e in that meet be used to claims upper pass perform attacks extremely effort the public opening tend initially literature alone attention paid sides useful centuries fixed follow winter Thomas crew origin serious alternative differences featured responsible for centre pieces strength measure examples track plans officers shape star Richard joined refer command existing cards leaders figure plays Louis piece houses classes conflict fields stars th century composed positions vary round gain tend to seeAlso impact slightly behavior depending on look as to nothing raised hands compared to reasons toward choice heart identified creating maintain refers condition constructed overall reading marked fourth division failure saying tour recently formal unable have to needs mind stations digital religion Spain think grew represent typical parents display competition acid and so fell week determine protection wave users build processes projects return to technique to keep fish cast drive starting unable to expanded affected entirely combination forward resistance entered factor equivalent attempts episode attempted away from providing sector external increases university ice ones achieved decades expressed Americans double demand regarded refer to architecture audience issued fight citizens match in all aid limit sexual goods seems costs distinct granted perhaps improved green file need to on to importance electric significantly DNA cycle normally components describes creation TV layer tree bring fighting stop and also core format increasingly thousands animal leader understanding break unknown classical extensive sign Israel the people host causing destroyed protect describe Peter arrived square voice industrial purposes magnetic containing finished follows nation rare cars continues that time planned radiation recording advanced engines principle student islands philosophy sought officials rapidly recognized secondary particles pattern staff covered runs traffic awarded lives deep the whole United Kingdom expansion identity context controlled images organizations derived Ireland administration bodies opposed friend chosen greatly and not designs nations surrounding urban zero otherwise error native setting gained why territory acts artists communication launched J. regional card freedom coast visible begin contract arms showing the past message generation involved in Mary nine leaves stone ran global popularity broadcast minor sites instruments improve wall contemporary soil Edward carbon conducted symbol as one at the end operate somewhat be seen close to news communities developing influenced domestic port machines figures views got declared note search contained employed input step lead to bridge respect worldwide caused by the idea captured want maintained route achieve publication consider magazine orders winning formation Australian ring reports onto subsequent details safety storage plane climate World War II accept connection the field dark managed practical shared be found measures visit capable movie spring calls independence obtained aspects dance learning opposition begins towns split brain interest in Jews at all technical directed introduction belief border owned prior to Chicago doing involves suffered transfer offers enemy correct possibly oxygen greatest exists measured closely policies dedicated press producing scholars steel heard accounts usage computers daily walls Canadian fiction rejected stable score engineering ensure indicate mentioned eastern forms of path skin proper trial oldest statement mixed most important officially portion reality the book dry heavily height authors fast hundred specifically author kind of block channel string Mexico Jesus institutions instrument residents combat selected vehicles coming manner rarely Irish goes hot pair royal neither organized effectively expensive really suggests processing opposite severe operated depends characteristics regarding yards enter interests glass college a high practices testing bands the story trees ends facilities place in faith grow slow armed churches mode background job writers defeated cable leadership transmission patterns thing Dutch density attached big bottom atmosphere networks degrees dropped electronic i might be strongly items roles translation pages apply assigned signals extent viewed Michael debate minimum periods programming visited ultimately frame hardware prices whereas as a result establish permanent holds strategy escape authorities acting join listed sex edge screen decade critics cold continuous generated solid violence liquid iron investment likely to sufficient composition broke experienced et exactly map ratio documents anything questions twice North America converted elections slaves threat time in studio contributed household wind train truth changing for each rural capable of sales secret bus football movements theories labor modified Christ cross expression stock atoms chain earth leads understand box impossible principles requirements weather considerable director earliest vehicle added to moral Johnson district literary respectively am set up prepared subsequently preferred trying sports mechanism concerned courts leading to task treated voltage translated hydrogen inspired victory advance appropriate faster nearby theme to go drawn standing arts parallel adding component relationships waves focused kill locations notable printed separated resolution tools officer subject to the amount essential medium opportunity solar etc. teaching argument don't Columbia GDP cultures painting tests bit amounts molecules roads launch crime fleet holding learned stay stored pure balance and all successfully picture politics circuit request Joseph environmental distributed produces affect prime revealed eye universe fans patients wood governments Berlin occasionally selection taught acquired fundamental linear Alexander choose episodes n floor angle incorporated try benefit description die studied Poland dates list of artist flat protein concluded hundreds speak extra subjects approved electrons chance easy implemented husband ideal planning concepts grown understood extreme intelligence quantum receiving Scotland online knew unless Jones out to rapid shall Texas academic reputation the future experiments explained park eyes sections audio in fact persons store budget corresponding sister charged broken capture script rich work on
moves opera Williams progress logic massive root assumed writer post be able domain foot link bank library document someone criticism everything huge linked performances represents seats thousand obtain bad mechanical Martin come to crisis and others clearly colors sample instructions the air circumstances electrical inner made of scenes copies e.g funds prominent straight personnel rank adult stand losses speaking ago m exact support for category fit housing necessarily attended limits mark couple roughly seasons widespread remove a certain street opinion review concern entry wear decisions exception identify categories compounds council efficient algorithm markets performing suitable the majority electron in turn males reaching serving slowly possibility stages horse skills concerns collected mental moment younger let manufacturing suggest recognition variable village add substantial styles detailed visual learn Angeles tells weak guitar defeat delivered ending feel in particular passing abandoned discovery poetry lowest mathematical apparent designated gun varies seem the church ethnic gradually newly p plot supporting and/or reducing Los Angeles confirmed hair supplies zone W. looking drug involving pain sell brief constitution benefits declined efficiency spiritual titles channels explain fear merely representation filled instruction perfect orbit replace guns tracks goals University Press articles lands matters conventional apart encouraged newspaper probability settlement silver succeeded symptoms a man in general in two joint populations transition vast legislation theorem votes immediate mountains adapted fifth fine genetic signs assistance consumption existed indicated symbols traditions settled prison spaces bass formula scientists the front transferred shift chose entitled kingdom save shortly candidates mountain one's desire mobile send lot sugar taxes trading interpretation else proof reform serves charges bits committed BBC secure steps the line the point Arab fewer infrastructure seek outer relation sort absolute drop files interface net implementation returning New York City bound decline morning variations vector absence attributed cancer membership responsibility spirit chief classified discussed Zealand discussion landing principal historians camera opposed to branch need for ordinary regularly e.g. survive agents proteins seconds universal interview accompanied arrested distinction reign specified repeated New Zealand accurate agricultural jobs unusual carrying mounted Oxford executed vessels work in yellow easier evolved peak permitted promote seat suit arranged tube unlike evolution reduction union writings dangerous wild dependent diameter pilot survived usual define equation noise particle rail together with circle installed interior none sounds streets variation wealth consistent finding in use novels passes weapon executive experiment exposure forest hunting integrated vertical hour protected restricted Egypt exposed partly boat fashion situations Virginia conference draw planet links strike tell outside of printing sentence depth Jackson at that criminal identical other than returns roots telephone agent argues Dr. communications engaged females convention frequent print i.e. uniform be an texts velocity transportation years old Hitler falls seemed Elizabeth administrative closer anyone debt references representing agriculture laid interested duties Wilson bear broad didn't physics finite server throne attached to award copy in addition meat fluid invasion affairs experiences median ceremony paintings vision IBM credit disk in front killing km losing demonstrated faced apparently composed of measurement regard wine writes stopped the present Sunday quarter tanks spoken Asian bar finds funding given to incident routes comparison procedure begun large number museum Hollywood birds experimental mathematics raise ruled biological consisting solutions theatre twelve drawing employees reference to spectrum banks damaged reactions stands blocks characteristic firm homes or not visitors clock agree favor ready safe prove Francisco accused flying an average desired painted varying the law Christians answer consisted evil traditionally brown interaction notably appeal extension recommended stability be in illegal bill forming industries it's lasted trained assembly candidate herself option association beliefs committee essentially percentage sons sum happened hope indicates minister von Germans layers Soviet Union purchased gender perceived promoted the season actors aspect deaths driven effect of stores Super Bowl clubs concentration worth arrangement as a result of keeping approaches surrounded Sweden chapter mouth plate revenue league phrase classic mixture researchers tool years ago calling errors lay reflect so-called statements hospital operational passage concrete plus thin arrival concert conduct heads offices conversion drugs for which messages treaty brothers deal with featuring the military attacked difficulty jazz strings try to la in front of pitch rotation elsewhere medicine miles comic fishing receiver column covers duty demands earned axis sleep want to web hence purchase Davis turns as of bought criticized generate Christmas hypothesis the data fired lose turning divisions in place at the same time businesses emphasis farmers label living in themes offering caught poem switch alcohol murder reflected youth senior boundaries handle historic indeed lists scheme superior arm connections dominated sun the greatest campus soul detail continuing master selling infantry missions the individual I'm random rose slave wrong destruction distinguished piano proposal sport partially producer rising suffering waters foundation artillery doctrine magnitude atomic boundary speakers accuracy department nd consisting of inhabitants meetings platform railway struggle thinking camp dominant getting in addition to ranges supports varied calendar educational papers enjoyed isolated to come boats sale door passengers tape Mr. diplomatic employment optical branches controls formerly milk x argue colour downtown influential solo Christianity editor empty owners rivers South Africa credited challenge classification controversy count worn characterized phenomenon responded retired fresh horses notion organic musicians snow involve vacuum attracted narrow technologies Philip boy interpreted invited made up depicted occupied surviving website destroy hearing organisms Muslim labour missile targets cited empire execution tail grounds lies index more than one marks partner restrictions creates controversial manager stress pairs remote restored festival carrier albums load specialized diverse kinds operator soft invented simultaneously configuration temporary differ focus on precise reforms bringing in part customers genre airport aware decrease denied live in the great codes complexity electricity exports stood frequencies purpose of quantity dating folk participate territories virtually buried peoples satellite equal to trip express properly quantities speeds perspective societies voted annually extend governor magic USA hole lifetime regime requiring wing Boston Netherlands account of equipped evening honor session steam surfaces DVD Lincoln admitted maintenance naturally make it separation thereby variables Lewis adults poverty retained armies wire ed. exclusively headquarters movies warfare roll United Nations aim explanation legs starts thermal Islam curve enemies lake objective volumes opponents rear civilian the market approval contribution fruit ownership prisoners gone ocean protocol regardless row tons facility reverse threatened wooden artistic fellow medieval meters stream Norway receives structural victims Mars Microsoft clothing emerged falling participants supposed attributed to fair fairly for two measurements tribes chamber consequence inflation operates owner stronger theoretical equally therapy Korea emperor offensive valid voting celebrated investigation origins spot supporters twenty Swedish recognize shorter tasks the ship tissue wearing revolution slavery San Francisco binary distinguish fought gods eggs injury a lot centers procedures
realized exercise hired buy disc long-term observation estate recovery Jerusalem mechanisms province Austria brand fly manufacturers trend bonds concerning dated functional observations substance independently logo replacement partial struck driving journey justice except for expand i.e intense one another publicly scheduled seeking warm aimed editions factory Vietnam difficulties plastic Arthur ranging Egyptian defend processor radar tank the East Frederick binding crystal motor rain spacecraft thick arguments attend hosted judge of age advice naval regardless of with this Indians everyone operators decay dimensions on which ties expedition racing sees formally sequences strict villages bomb contributions license underlying varieties Portuguese bacteria emergency gene spending breaking draft entering equations rely patent stayed colonies occasions tested tower covering divine reviews districts looked producers convinced infinite intellectual advertising maintaining maps teacher edited estimate indigenous races ranked coverage displayed dramatic explains cash concentrated courses guide referring samples sizes Brazil dog possession consist dispute distances improvements driver gravity hosts ions mining relevant winner Harry Stephen beam distinctive for instance passenger proportion regulations survey commission compound universities finish patient philosophical shooting strategic drum interactions radical relief ahead biggest contribute graphics logical scored poems this way consequences salt considerably bond complicated recordings definitions go to crowd explicitly wounded at which comedy delivery equilibrium alive applies competitive feed ill marry publishing actor agencies artificial compete Pennsylvania involvement manufactured metals neck NFL algorithms array keys readers requirement underground copper tourism conclusion consumer vice waste burned drew feeling insurance missing serve as tied as if by one eat jurisdiction nominated occasion retain talk voters addressed beautiful behaviour leg personality completion defensive gets violent supplied this point disorder intention rise to take place virtual wider capabilities custom describing diseases girls neutral illness imperial phone prey prayer provinces Israeli delay accident circular Philadelphia automatically negotiations reliable abroad adjacent calculated cavalry displays genes lyrics window database flag helps reduces register sharp stones dynamic farm missiles Pakistan attempting client influences referring to demanded entertainment flights hall potentially amongst opponent trains check facing familiar followers judges once again pointed rice chart cooperation ask newspapers obvious transmitted Greece alongside beings tends the throne women's st allies high school matrix sensitive stating beat casualties childhood composer much as terminal marketing coastal commissioned dollars entrance establishment penalty prevented shell compression faces Ohio quoted releases seeing Adams directions retirement a little kinds of Scott capita enabled spoke that one vowel mechanics molecular permission removal the common coalition conservative counties devoted titled wish baseball mainstream node registered engage notation singing atom funeral integral marine programme psychological rooms strip transformation shaped significance skill tournament Simon colonial constitutional detect engineers girl horizontal millions decreased hoped loop participation raw ruling god modes set in sky valuable coach columns drives fusion suicide remainder representative worship Francis compatible historian laser CPU c compact destination generations kings mail parliament recovered imposed in time minimal mix occurring ranks wings alliance coins consist of danger invention ongoing shares sphere acceptance assault believes environments relative to at that time handling liberal sure Apollo Cambridge collections in the past opportunities crimes deck deemed implies termed traveled Roosevelt bishops developments fitted minority altitude b corner decide exhibit foods keyboard momentum on one renamed collapse tall Kennedy bases depend divorce promised rocket wealthy Clark abstract corporate drink filter holes implement injured per capita walk rd Judaism excess hidden mention representatives spend synthesis Victoria abilities connect originated preserved rings confusion magnetic field resigned strictly unemployment Robinson orientation plasma portrayed similarly Islamic aged boys bright options partners planets Carolina Taylor addresses alleged bed institution rainfall well-known molecule pushed wars assist at one bears locally maintains winds export forth injuries vessel Florida historically awards bulk currency fallen laboratory manuscript capability colony interference minute physically Romans nucleus repeatedly vocal architectural eliminated initiated preserve trials all over certainly favour hear requested with it estimates wins alternate dependent on distant preparation sending the Union trust Albert ages banned creative psychology assigned to castle establishing firing heating by two drinking Vienna called for in response membrane no more parks singles drama extensively for it ministers next to retreat sixth to explain Kong conflicts phenomena powered sort of act as as it is Caribbean circuits headed identification longest permit punishment statistics variants as long as crucial dialogue saved scores teeth arrest commander fill improvement science fiction belt cutting des crown sole be called claiming immigrants literally restaurants restore taste accomplished participate in to sell Nazi agency bone campaigns chemistry happen personally pilots presidential recalled respond criteria enormous lie matches rescue variant wore corruption defines facts flowers gathered parameters quick solve tension audiences sight anniversary carries documentary encourage narrative reason for reportedly reserves teachers vital wheel arrive behalf diet seriously the road vowels yield infection perception poorly respective solely treat Saturday considering informed insisted interval teach van whatever Norwegian assets duration enable grant metric ports shock Jefferson Mexican assume attitude computing giant give the jury parent truly accessible burning crops gap profit shapes statistical consecutive determining drivers rational the distance adaptation briefly coal defence diagram doubt sfn acted appearances at home cooking dogs landscape prepare residence with respect to acids cabinet limitations oral sand come from consent counter discipline emotional encountered manage pictures severely suspended aware of smooth spin cargo correspondence pope publications valley warning bars entities altered challenges confidence eating jet lasting raising signature the many cattle deeply imported integration settings submitted tendency tubes deployed guilty nitrogen advantages intermediate open to framework only a few pop succession happens interesting predicted pursue detected in favor so much worst Illinois as such at the time of commercially disaster rely on survival Michigan dealing dimension filmed fled jump paint placing thereafter to death Catherine Howard manufacture temple Jim Napoleon as a whole cooling fan instances seed BCE Switzerland absorbed cool exclusive precipitation prize rival shifted watch willing Danish competing poet scope Hong asks departure depression dress presents reaches tries Olympic beer dust expanding firms guest lift regulation surgery wedding at first constantly legally reception walking analog confused discuss edges indicating muscle outcome schedule sessions settlers successor Bruce Roger exceptions hits masses meets delayed electromagnetic excellent geometry traveling Korean Muslims attacking libraries migration select tribute ultimate children's consciousness humanity priority feelings ignored intensity availability bones breaks carriers crop democracy fighters push apartment finance intervention make up shipping construct franchise looks situated Samuel catch craft dialects dramatically dual neighborhood opposing plates camps guard precisely verse North American borders dioxide gift nomination reserve reserved windows communicate consumed correctly engineer no one wet comprehensive unsuccessful verb Indiana adds diversity grand moderate prohibited v. Cuba appearing fail segment the City touch Moscow in the middle tables findings mutual nouns removing
tended travels Gregory Scottish dynasty hotel specification unlikely Nobel democratic flows protest sufficiently bishop dishes escaped founding judicial packet scales arbitrary possess appointment ceased dismissed in favor of settlements theater Broadway contents cotton holiday several times account for as much as atmospheric crossing detection introduce orbital organs purely revised actively afterwards aired c. embedded happy waiting angles bread concerts for that grave praised precision pump visiting acceptable at night charts condita connecting coup deliver layout readily rebels suddenly intervals manual pronounced proven transported acknowledged beauty bet cult demand for economics legislature priests resource surprise urbe Ab urbe condita compromise crash elite expense forcing prefer automatic clergy plain replacing tropical vulnerable approached cloud commitment everyday frames integer putting rounds substances unclear Sydney documented farming mine mirror moon of interest politicians repair spelling strategies bombing harm tip wavelength Afghanistan lighter victim Joe exile linked to measuring updated Jupiter carefully coffee fraction freely provisions replied stem agreements asking der doors enforcement forests panel religions reveals roof sentences worse Allen Hebrew cm continuously cuts garden lacked studying the club IP doesn't exhibition muscles utility MHz al. conservation departments item only if overcome racial tactics the community Lawrence clinical corresponds customs employ graduate instrumental phases sword the Indian transform adoption canal demonstrate dense educated fighter graph priest rocks stops Margaret bow collect electoral enjoy made up of overseas participated profile secured transformed Persian affects ban clay fragments joining lens processors ritual City of fiber pool proportional reveal sacred Andrew Marshall avoided combine focuses inspiration on top qualities sit Colorado arose chip disappeared experts nodes pg. publish recover separately the few theology Welsh arise collective contest gases heritage inherited navigation payment residential weekly Douglas bridges concentrations consideration diagnosis latest navy organ Hamilton Jane amateur civilians closing consistently friendly grade helping sophisticated withdrew landed legacy resolved romantic rubber shut clean coin critic developers grain grammar internet radius Alfred anywhere attributes depend on directors disputes entity knows sharing shots Finland Kansas funded nobility orange thrown travelled Denmark circles expressions fee friendship governed Missouri bid in large internationally legend mild Iraq Muhammad Turkish Walter assumption eaten storm surrender telling the stage dying filed heated noun sitting smoke subset Otto bird breeding examination fate follow the jurisdictions occupation beach formats ion sciences the earth Massachusetts Steve commands fires reader Berkeley belong contracts deals debut elaborate mature on the other hand portions relatives revolt temporarily the truth trouble evolutionary partnership presentation sectors shells shoot shops this day three times unity Georgia authorized consumers newer substantially Daniel Hughes chips households journal magazines occasional pollution scoring so as suffer working on assistant daughters ink not known proposals sail the dead ammunition cameras so far attract large-scale loved profits railroad swimming thrust uncertain wages year in World War I disorders glucose mines pulled terrain tourist wants Jordan advances battles blade charter console dream exposed to fat feedback adopt autumn explosion lighting attractive chains cognitive package renewed touchdown fictional primitive revolutionary singer topic Gilbert Wright antenna contrary improving myth reflects shore Harvard buses essay fantasy gay in the field mainland opinions powder drawings eliminate most likely numbered pick recognised suitable for Tony calculations comparable portrait simpler steady tunnel captain clients clothes customer descent disputed flood heavier minerals scattered the normal topics absorption algebra birthday f imports teachings at this time default mere rough segments silent the true Hong Kong decreases grid in public most often observe seeds smallest striking the same way desert feared legitimate paths picked stack Anderson crystals flexible fund inserted slower statue the poor Austrian circulation extending facilitate genus hospitals lesser settle threats zones Caesar compensation found on in practice politically siege commentary consensus contacts dies doctor hostile monitor parliamentary suggesting sustained the usual affair aggressive conventions correspond cycles guidance handled licensed promotion rebellion sea level whilst Norman awareness citizenship condemned dancing differs encoding exist in feeding lakes palace professor seventh submarine talks the information visits Donald balls defining ease faculty preceding Mississippi Swiss accommodate comments festivals servers tea width absent accordance civilization commented compositions emissions golden relating restoration totally uniforms Russell abuse arithmetic bandwidth eleven in love planes pleasure prototype sheet skilled squares targeted wait collaboration continent differently doctors emission imprisoned inches organisation permanently serial static Taiwan enhanced enters equality filming habitat y Great Britain championship flew lunar mentions merchants nose productions promise symbolic to date virus Star Trek USS clouds enables neighboring secular Houston South America al apply to contribute to exploration hull implementations indirect nervous ruler speaker aimed at applying gains lights privately sweet technological translations blow cancelled cuisine determines loyal photographs suspected accurately aims dissolved rhythm traits Jr. boards brings hierarchy sacrifice stadium too much Carl arrangements chemicals combinations currents dealt doubled orchestra NASA d elevation encounter healthy resolve thoughts See also advised banking cinema cylinder derivative effectiveness on the right radioactive satellites set to switching withdrawal Arizona Moore cluster Morris colleges descendants isotopes rotating verbs Finnish Franklin dubbed essence gaining impressed manuscripts pole posts queen wasn't Athens Friday bronze expelled informal legislative loyalty regions of remarkable switched the letter Cooper Warner continental discussions memorial promoting ride systematic the soil throw uncommon Alan citizen discover divide observer pressures render risks Kelly can't controlling conversation founder immigration interviews merged names of Harold In July baby evaluation schemes Portugal RAF adequate considers descriptions reflection reversed slight syndrome talent the record tie treatments In April Juan beneath burn compared with favored in common monthly preventing reconstruction thirty competitions composers conjunction passive seal search for suited virtue Disney blind enhance immune impression leather linguistic mammals mineral pp prompted tobacco witness Kent Shakespeare acquire bearing celebration counted on the ground polar ready to realm wishes Brian after which do with evident gauge intelligent interpretations nerve out with philosophers progressive pull the lead Cleveland assassination excessive human rights ingredients monks nobles point of view sculpture spite Buddhist Karl challenged coordinate extends fails favorite tales Iran Puerto amino assembled battery closest erected explicit gravitational odd payments platforms provision reactor requests the planet Catholic Church Europeans Middle East Thompson en intent it may be alphabet delegates discrete farms judgment rendered shoulder sin successive wished Czech Dallas allow for associations gate harsh investors naming peaceful reasoning European Union Indonesia RNA acoustic coordinates full of graduated hill yields Orleans Sullivan assessment belong to dozen drag governing incorporate revived self sudden the press trace Ruth arc civil war combining practiced rulers Anthony Sierra blues coat colours deliberately discrimination reasonable unstable administered colored digits in length pregnancy qualified retail theatrical egg knowing meal meanings processed protests soldier vegetation withdraw biography engage in engagement loaded martial regulated strikes stroke tourists great deal noble paying propaganda raids resumed trends uranium Julian casting demonstration
expect fifty hero registers remember transit unified Ottoman insufficient isolation municipal refugees sentenced timing welfare st century autonomy boom decorated del fame on behalf of routine synthetic the border topology Christopher Second World Stalin accounting bombs hills spite of streams the help tongue toxic tribe united Benjamin Minnesota RFC all but ancestors combustion deposits electronics exceed explosive gathering illustrated in charge notice shop slot solved succeed tiny Carter Diego New England biology conceived if not neutron perfectly preparing relied valve vectors The American architect collapsed full-time mortality odds accounted harmonic reads sing cables constitute dollar handed loans moments pursued territorial to the right Greeks artifacts assisted barrier ceremonies coined deficit finger grows guests in exchange manufacturer of course phrases revenues Melbourne Syria bias credits emphasized fifteen kills symmetry Intel colleagues drove forbidden monetary strips unions corporations gross mayor questioned volunteers Alice aboard fees friction interact labeled lifestyle no other resist servants shallow work for Gordon and so on bytes loose populated touring FBI Palestinian Stanley consonant container emerging expert march on top of pregnant provincial tale Second World War armed forces di entries lengths openly threw wheels with that Louisiana differing ethical fabric independent of responses steadily viewing Marx New Jersey ahead of arrives closely related extinction hands of merchant modifications nevertheless prime minister productive rifle set out versus a great deal animation choosing defended explore hopes integers loan melting meter offspring outcomes reproduction rigid sisters switches Nicholas The National choices confined du genome persuaded possessed pounds seasonal sodium ticket Aristotle Murray New Orleans aside compiled footage honour observers papal spirits vs. acceleration apart from centres chest convert to publisher shopping borrowed breed careful dances murdered nights plague preference revival wound animated creatures crossed flavor flower harder innovation introducing investigate operas specify vegetables Belgium Parsons arriving attendance contributing elevated enzymes insulin peasants protocols angular athletes convicted eligible mixing monopoly pressed sends to the point wireless Anglo-Saxon Harris amendment at times constraints dish failing objectives organism rating secretary Hungary Reagan broadcasting cap celebrate designer drums exit factories harmony inherent present-day remembered so as to submarines technically the open Mr Oregon calculation carbon dioxide chapters completing deeper done in elementary neutrons prevents pulse shoes Pierre counting fed optimal projected rolling seized terminology wavelengths Campbell Constantine Manchester depicting geometric justified scholar wage Hall of Fame NBC afternoon cellular derive ear examined gates lacking small number voyage whenever Wilhelm broader desirable differential organised printer resignation revision Middle Ages controller excluded in the future initiative kingdoms most recent slide so many turbine uncertainty assumptions at about autobiography balanced belonging focusing inheritance pace presidency relating to relies reporting sovereignty throwing empirical give a photo soils timber Harrison airports armour at the top conducting devoted to editing functionality guaranteed in accordance oxidation oxide performers predict similarities transactions wheat wish to Marcus Ontario archaeological as is clusters councils emitted erosion holy occupy proceeded riding shipped span tours triangle vapor blacks emotions favorable hip identified as looking for nuclei offset periodic plural proceed sheets Turner advocated believing coupled genuine go on hybrid limiting long time not allowed outbreak protective spatial Batman Moses designers foreign policy fossil hop seeks singular tensions undergraduate work as Manhattan Thailand The New York Times consequently domains heir more or less optional organize passages printers professionals punk ranking reliability Churchill advent cloth correspond to decreasing exhibits gear in relation to lessons margin modules monitoring orbits stick Constantinople addressing boiling cheaper commanded compiler convenient copyright factions federal government generating modest necessity not used on board permits rays reject two weeks asserted flexibility furniture highway installation nickname of the best reinforced talking Darwin Nintendo allied basketball carry out destroying dose horror import liver nm skull Leo Victorian Wisconsin anxiety broadcasts consonants contexts earn grants labels missed monarch physician travelling up for Collins Nixon calcium continuity enterprise fingers onwards outstanding relates simplified summit syntax assuming blocked collecting debated implications lectures liked mid mood pipe pride resident responsibilities rod terrestrial the worst Amsterdam Latin America Prussia descended enacted freed in accordance with insects junior motivated overhead rituals twentieth valued Maryland Morocco achievement alter backed da decides draws fiscal livestock modification on the left patrol reflecting rows scholarship southeast survivors theological tissues towers Argentina abolished attitudes determination discharge explored referendum Atari Clinton D.C. I've Miami back of comment dreams dried northwest one or two proximity routing attending calculate cultivation exhaust ministry multiplication signing standardized strain University of California Zhou at once begin to brass communist emerge geographical hide hunt k oath philosopher satisfy Florence Milan Vietnamese chair curves emergence floating foundations inputs organisations touchdowns viewers Alaska Baltimore Roman Catholic Russians bell chess countryside declaration fatal filters grass keeps machinery outdoor panels predators traced trapped vocabulary wires Mrs. Parker arguing barrel competitors conquest hotels not use noticed restaurant sake southwest spots trigger undertaken CIA Eric Northern Ireland altogether ancestry conception derives dialect essays generic gifts myself omitted pay for salary syllable acquisition cooked costly decimal dominance donated identifying museums run by tactical the elements worlds Sri amplitude boost cheap enabling fever flesh graphic implied infant intact integrity nationwide photography prisoner protecting quarters seemingly suggestion tomb two-thirds vitamin Wagner bitter gardens innovative module praise prefix privileges sailing tonnes transmit Eisenhower Wallace chronic definite dominate drops extensions horn managing recreational saving scientist scripts shield the vote to this day valves Monday carved divorced execute fruits genres ratings representations respected undergo Luke Zeus choose to commanders declare gray in the middle of infrared literacy realistic safely thanks wisdom Alexandria afford editors inferior neighbouring participating pen pointing proceedings proceeds strange the gods the screen uncle voices Mitchell heaven horizon matching natural gas polarization practitioners tight Bernard Catholics Germanic armor axioms burial guarantee men's one day posted specimens stolen strongest treaties tuning achieving guards inhabited inverse neighborhoods profound projection urged withdrawn Antonio Stewart Torah allegedly badly conquered cream gather half-life imply more and more polynomial profession pursuit speeches trick victories Hungarian Mao brick by means of consistent with extraordinary kg lawyer managers militia not considered not exist prevalent providers quiet subtle testimony trail I will approximation conductor extract flash infected mistake moisture purple raid renowned stamp supposedly unconscious Ali Toronto adventure astronomical battlefield bore cat derivatives flux geographic intake invaded lifted minimize numerical opens oriented releasing simplest stamps subjected tenure venues abandon ballot champion compressed cultivated forty incorrect leaf offense sailed stressed toll Nazis Tennessee acute attraction case the defendant demanding diamond helicopter in charge of investigated memories monarchy nominal not know reluctant silicon Buddhism bay charity induced modify one time pass through peaks privacy stance tolerance venture adjusted backing be added belonged decisive dressed expectations harmful lateral mystery performs rivalry sunlight Baltic abundant freight inclusion look at owing predominantly premiere repeat struggled swing texture video game worker Anna Lloyd analogous barely collision compare conscious entropy eventual expenses finishing fission guided housed imprisonment prince
sensors traded tribal whereby whites counterparts deceased develops dinner exhibited lying many times planted programmes revenge sick sung surrendered that's wives Abraham any time bills closure enterprises fibers flowing illustration playoffs suburbs tens the necessary torture viable walked commerce frozen guidelines in love with irregular metropolitan poles puts respond to rifles rises the works upgrade utilized Morgan associate centered coil corps economic growth exceeded inland investigations morality photograph preservation prone pronunciation similarity thesis truck adaptations byte faithful functioning kinetic marketed possibilities resemble with the exception of Isaac Thai algebraic as for attribute bombers burden companion counts couples defending discoveries elderly ensuing flour incomplete presumably refined reward sensitivity shifts threshold weakened Fred Oklahoma Sony a million affecting answers belongs cannon comics et al identifies musician nutrients on the surface publicity put on surplus torpedo transparent Eugene Prussian albeit allocated averages behaviors concludes damages emphasize ethics fun g kick locked paradox portable reply spreading starred telecommunications witnessed Hudson Saudi cement curriculum grammatical namely not take regulatory shadow socialist structured Malaysia absorb accessed answered boxes coding criticised devised encouraging failures fault grandfather imaging investments marking modulation mythology regulate scholarly studios the specific transaction voluntary warned Byzantine Ukraine Venice aerial disks efficiently fortune ideals incidents made for masters packets rendering speculation tiles tones up on youngest abundance arises certified clause conclusions lecture negotiate occurrence productivity react rebuilt remarked sharply underwent Holland Jonathan achievements ally as far as assumes cartridge copied cut off everywhere explaining farther fastest inability liberty obsolete point to prayers resistant weaker Hawaii arrows beta dam eternal fertility filling hardly helium indirectly receivers registration sealed sheep soundtrack staged sustain the crowd triple Einstein Linux Lucas Peru Pius actress chairman citing continually crowned enforce feels freezing globe journalist obligations overlap trademark venue warriors Afghan Native Americans Rhine Vatican barriers clocks cup exercises free of mouse out for preceded rated rejection spectral videos watching widow Boeing Columbus Denver Dick Matthew Saturn deployment designation earning elder email explanations loading lock marriages mile painter syllables Jan apparatus arrow aviation bullet contracted elect imagination in case kernel lengthy negotiated put in put into sat Bulgaria Pittsburgh about to accepting appear to be artwork breakdown buying considerations crews dropping flooding incoming interpret mate specifications stationary thickness topological unrelated Montgomery Native American Venus absolutely aesthetic as soon bigger burst conspiracy discontinued firearms in conjunction interfaces patents specially substitute Nigeria Warsaw aggression approaching astronomy avoiding enzyme fraud functions of invested log marched ordering predecessor relate salvation stems suppressed the latest versa Bulgarian South Carolina baptism beaches cache enforced hitting lamps people's propulsion prose secretly shaft sponsored stretch tune veterans Abu Hispanic Iowa batteries colonists correction couldn't customary debts formations formulas grades likewise profitable refusal rhetoric shut down supreme vice versa IEEE Nelson Romania Talmud Watson adapted to compensate consume cruise curved economies eighth grey handful high-speed highways pack rope time was universally urine Armstrong accidentally amplifier appealed arch convince declining in conjunction with individually naked problematic ratios twin Jacob adverse aided alike as soon as depiction ears indication kept in loses metallic scenario upgraded Austin Chris Hindu Lois Philippines bonus complained cousin damaging extant illustrations lacks predictions slope taxation ers Patrick admission ambiguous be at cleared composite deny desktop firmly governmental mothers packages resign sequel thumb adventures approximate at sea capitalism cave cricket crude encoded forever generates hub insight loads missionaries norm owing to payload poll seldom senses spread out whales Anglican Arabia Herbert advocate autonomous bin encounters exceptional family size gallery gradual hoping humidity kilometers mobility neurons northeast passion realize regards sailors subjective to the left Claudius accidents cavity championships commodity connection with contested in return peers picked up prints publishers r refuse rivals servant short-lived Roman Empire bankruptcy bottle cathode combines entitled to extinct helicopters honey republic validity winners witnesses Albania Kentucky Methodist Ross alien aligned analyzed ancestor announcement busy cartridges delays disciplines ecological ensuring envelope facto galaxy gaming grains innovations limbs magical merger norms relativity temples tense trips vendors Singapore activated after the war applicable biographer calculus climb cubic displaced economically famine in question interfere journals jumping ratified storms successes till vulnerable to Turing ambitious anger coming from computation computational contained in disabled employs grouped impose in power man's not possible paved refuses relay shortened simplicity sketch tuned underwater Americas Atlanta Cuban Detroit Friedrich Marie San Diego a bit cathedral diesel dynamics eldest happiness lawyers leagues licensing pension ray resonance satisfied sovereign thoroughly tidal watched Hz confirm conflict with denote diminished expertise extracted humor infections knights lung other side receptors Munich Plato alpha be determined challenging conclude cosmic dancers discs enrolled fears hiding journalists judged myths observing parade photons pink refuge retaining tenth the arts the string weekend Yale alternating angry breast by far compatibility displacement harvest impressive mandatory neighbors parameter statute terminals trucks verses Curtis Protestants Stuart USSR agrees births blamed denominations drought early years estates expressing justification microwave prominence stomach strengthened suspect the ring tournaments transitions weights beneficial blades committees comparing costume diving heroes in this way inexpensive invisible number one prescribed receptor simulation surprised violin wake Euclidean Nancy activists automated axiom bound to box office button canon compulsory crushed dice distributions drainage flame fur impacts in the air nationalist per cent summary transcription AFL Evans Venezuela all that appeal to climbing congregation connects dependence documentation employee examine homosexual inadequate listening lit lungs no. realism sampling signaling socially stake suits transmitter Liverpool North Africa electric field faction healing instability lamp lowered obtaining peaked prone to recommendations rockets rounded spinning the score unnecessary wartime Richmond Seattle assignment consistency in effect monastery onset robust scandal sensor triggered Edwards Panama Tokyo coefficient collectively de facto diagnosed exterior formulation grace he's inch interests of loops lost to municipalities practically sufficient to suspension warming weakness Barry Dave Rogers basically dealer debris generals ideology monument parking perpendicular rectangular the negative to retain violation Tim asserts buffer chord commit cure debates dozens earthquake exhausted fourteen in prison nervous system of language petroleum proclaimed readings rebel searching strengthen African-American Augustine built-in cheese elimination exported goddess governance internally liberation loud medal motivation placement recruited resort riders sauce sensory silence specialist traces tracking bonding bounded dissolution dividing exploit genera inscription likelihood obliged phones promising rotor sulfur Voyager accent bomber breathing complement frontier imagery meaningful not allow obligation persecution probe quantum mechanics solving the Academy theaters Giovanni Socrates USB aging auxiliary bind corporation decorative exercised mapping playoff railroads relocated rider seals specimen the eye the other side toured Dominican Serbia XML adjust call for chicken comfortable comprises flee hemisphere isotope pm postal preliminary protagonist somewhere suppress the religious treating Gary Syrian backwards bilateral but for coefficients convenience if and only if nuclear weapons princes progressed prosperity recall restriction slowed spare warrant Utah celebrations chaos critically diffusion drinks excluding
fulfill galaxies in place of lawsuit mount sorts terrorist transfers verbal winters Alabama Joan at most bag brilliant converts creature decree deities depicts distortion ensemble feathers finest hockey induction latitude like to mutations peripheral plains pushing reactors thread volcanic wolf wool Hugh armoured digit honored jumps makers melody nationalism obscure predecessors programmers propagation provided for quarterback replication selective supernatural telescope traders tragedy Catholicism Colombia Indies Quebec admit celestial come in congregations correlation deposited desires doses favourite financing ft identities impulse injection instant knife not so numbering pocket resisted simultaneous spontaneous submit the Americas the particular triumph unrest unusually valleys Clement Julius Lebanon Sanskrit accelerated compilation defenders detector distance between enclosed extraction jail lasts loosely manipulation prosecution robot sexuality sixteen speaks stationed statues stopping subordinate superiority the numbers wounds Dewey Fourier HTML IMF Jerry Oakland Princeton Tracy accompanying basin downward generator guilt hanging incorporates linking matched photos physicians possessions pot prestige pumps tickets uprising upset voiced Edgar Larry Ltd. Nevada Roy UV Vikings appoint assert comprising executives exotic flown give up heading interactive parish pin reviewed short-term sympathetic tunnels Charlotte Palestine Rio chambers chapel comparatively contemporaries generators governors in full irrigation lattice lenses marching nephew plots presenting prolonged reprinted ski soap supplement surname yearly Belgian Calvin Celtic Gandhi Rico a thousand advancing biblical broadly concentrate dome formulated in support of inscriptions intentions monasteries poetic proportions rally resembles variance barrels brands careers chromosomes conferences creator designing destinations evenly instructed lanes nonetheless poets proprietary starring thirteen zinc Ferdinand Google New Testament Red Army Stanford Yugoslavia collaborated converting defects diabetes exchanged fort intersection key to manually natives one-third ought persistent potassium preparations quotes reconnaissance router salts smoking socialism sporting stretched two or three upward vol. volunteer way in welcomed with the help of Baptist Freud Ralph adapt agenda any one attorney battalions contributes cooler custody definitive locate migrated nationally premium pupils reproduce shelter the picture update upright wholly Adelaide Edmund Hopkins Romanian Salvador afraid be allowed beaten bets competed complexes marble minds resulting from sketches the administration Benedict Brooklyn Reynolds affiliated authentic browser certificate chances chocolate controllers coordination degradation dictionary gamma guitars higher education implementing in high justify marginal mutually mysterious posed protons quote surveillance temporal unchanged I/O Jedi Lithuania Luftwaffe Oliver Raymond Sox Stockholm architects automobile backward branches of collectors convey delivering diary ensured grip isn't lover maritime mutation persuade petition pose pronouns realised regain singers the good Holmes Iranian Motorola blocking buried in commenced disadvantage excited favoured hereditary oppose outward planetary proposition restrict rushing short story suffrage symmetric tennis to the end vocals Bryan Lanka Leone acclaim anticipated cartoon circa delegation demonstrations dive drafted energies geography intentionally juice ninth ozone plantations promises thanks to to let unaware Canterbury Charlie Dublin Geneva Portland aluminium cabin constitutes foreigners mountainous packed partition pixel probable rods rolled tricks very much wildlife Jimmy Malcolm Naples Roberts Ronald a base allegations allocation blend canceled constituted deciding ecclesiastical emotion lovers mask noting pulling purchasing shortage tallest Academy Award Africans alternatives at any time at the bottom bacterial ceremonial defenses directing discussing engaging expeditions force in genius imaginary interrupt introduces lab luxury photon portraits prestigious prevailing punished purity qualify repertoire retains shifting short of specifies stocks susceptible unexpected warmer wrapped South Korea aftermath bowl chooses cleaning discovers dispersed encryption header ineffective manages mankind medals once more pipeline retreated run in sensation tremendous whale Baldwin Beijing Cameron Columbia University Graham Norse Slavic accordingly ambassador as seen exploitation fossils interrupted keen noticeable poison risen souls tin ultraviolet unprecedented Barbara Final Fantasy Ian Jesus Christ North Carolina Southeast Asia a vast acclaimed constructing disbanded do it employers invitation nineteenth substitution accusations calm cord daytime deer feasible fix general public govern halls in a way integrate masculine orchestral right hand the wild three-dimensional tide Royal Navy Yankees accepts clan common law corners demolished dot immense instituted learns not enough penalties positively semiconductor struggles suite surgical swept take up the complete tram Wayne accession advocates arguably axes believe in canonical cease containers costumes darkness departed emperors financially golf habits locals massacre of service pathway possesses reactive respects scarce scattering tariff terrible threatening Croatia House of Representatives Ryan Vancouver adjectives amplifiers bicycle brightness contrary to corn declaring down on fertile forgotten hash holidays in line in. incidence kinetic energy obviously ordained peninsula remarks rigorous semantics sins sleeping spiral steep stripped the article trilogy Wikipedia World Bank X-Men capturing configurations dams floors horns ideological indoor innings maturity midnight pipes screening severity substrate trails walks USAF Vincent Wednesday abbreviated accidental ambiguity breach civic discarded ensures fierce hollow in advance in contact inevitable meditation mistakes provider sensitive to solids stays take on the dark underneath websites Bennett Jamaica Steelers accompany agree to airborne allegiance ammonia aristocracy comprised continents convergence crust diamonds licenses listen literal precedent proton raises take over tightly und unpopular wax Ann Burton a hard admired arena beef benefit from complaints concessions constellation depended devastating discusses enthusiasm gasoline harbour in the way intensive lost in overwhelming pound premiered proving reproductive routinely smell soup spherical staple tough vice president Prague Security Council South Wales Taliban Western Europe civil rights corrected crashed criterion disagreement dye inquiry keyboards patron reunited revealing telegraph the strong unification uniquely wines ASCII Conrad Eastern Europe Sami almost entirely asset caves continue to be distribute employer employing five-year for certain mandate paradigm positioned post-war regiment rent slopes speculated supervision tract Arabs Brazilian Game Boy Sri Lanka Susan airline anchor appeals burnt destroyers differed dwarf enlarged inequality licence of choice penetration propellant regiments small amount stuck take advantage of the opposition warships Blake Hoover Johnny additions altar cartoons checked complications courage depths discourse folded fragment hat infinity joke large amount octave ore resting retire run on savings summoned taking place the possible trap weighed Helen Macedonia Madrid Personal life Puerto Rico Redskins Sicily Thursday a couple of averaging behavioral censorship doubles eliminating feminist flags gambling halt helmet humanitarian in a series magnet not change pagan prevention repairs reporter sexually silk unhappy welcome I'll Iraqi Johann Republic of China Vegas activation amended assess be heard be known as beams beds can do coastline constituent epic for long fuels geological heights liability pottery suffix Amiga Carlos Kansas City Nile attain best-known brake bubble deity differ from exploring ferry free will honorary hypotheses innocent leap legendary nearest networking objected originating patch progression surveys terrorism undertook Costa ambient aperture beside darker drain earnings evaluate expresses famously generalized humorous impedance importantly in spite intrinsic kitchen manga obstacles peasant prohibition put it refusing seated short time sperm tactic theatres think of toxicity transformations waiting for Solomon abortion calculating captivity corrupt editorial equals every day happening limestone marker mid-s notions posthumously prediction pulses reconstructed sang set by warrior Bismarck Edinburgh Nero Sherman South African Unix altitudes analyze associates astronomers boot cats climates consoles dawn dietary divides embarked fatty fights gaps ghost hammer
hurt in spite of infants inference instantly lifelong lightning mating neural performer physiological premises recurring rolls ruins runway rushed successors treason Athenian Isabella MTV North Korea assured blast butter ceiling come into comparative conflicting depict devil diagnostic differentiate disciples inherently mercury merge modeled oceans organizing outlined solvent suburban sums swim the special unofficial vertically viruses Chiang Ethiopia Gibson Luther Sudan Tamil USD at the start ballet conviction criminals destructive disappear experiencing for a time hate help to joints kidney military service motions quit real-time recipient referenced robots rotated senators submerged the details the general public trusted vibration violations wolves young man th-century Hepburn I'd aggregate alloys aluminum attracting blank contamination databases evolve hunters inform local government outlets owns periodically precious programmer seek to so long steal stepped strains summers t Gibraltar Latino Sarah backup be true benefited characterised colonization computed coupled with disliked feminine fortified fuselage hunted illusion illustrate mathematicians nest penetrate saints storyline survives transistors utilize well in yeast Bavaria Tucker accumulation after that anonymous beating by law conceptual denoted deposition exchanges folklore glands glory habit holder in the face of in the presence of indicator launching lineage pale programming language put to real estate recognizes sculptures separating trade with yard Buddha Kim Mann Theodore accumulated analogy anime annexation auction chromosome complementary coronation day in demonstrates drift familiar with floppy in service initiatives it will be lifting maternal metabolic numerals organizational presumed revelation spectacular suspicion Bros. José Qing Ted Terry Tolkien anatomy at the expense of circulated commodities counterpart crosses deaf distinguish between embraced explosives interim knight listing mud municipality polymer preferences screens touched vertices young people English language Las Vegas Sega athletic behave commentators disability download evaluated floods gradient hung infinitely junction palm presidents private sector semantic spectators subsidies susceptible to sustainable Carnegie Helena Kosovo Montreal Norfolk after this amounted be difficult bull by hand certification chloride chorus cocaine confrontation criticisms crowds defeating deviation energetic first place fitness guerrilla home run homosexuality in search of incompatible jointly miners opium passing through pathways phosphate platinum proofs railways rape the present day trait wanting Esperanto Irving Libya airlines amino acids be regarded compliance continuation dissolve exploited graphical inconsistent knot mirrors mistaken negatively oscillator pirates pretty treatise withstand Amazon Lutheran Manuel Old English Westminster attachment be on bison blame carriage contradiction cruisers dairy distinguishing drunk economists enlisted feast granting house in interfere with interpreter jerseys locks loves mice of use pixels quest reasonably reinforcements rejects seas slang the moon threads trunk unlimited wise Aaron Albany Milton Vladimir be expected be possible besides bold comprise depressed dining exiled ignore informally meals nicknamed panic ranged recession saint snake terror torque undergoing Arnold Caroline Connecticut Jacques Saxon Thomson battalion boarding brought about continuum distinctions drummer exceeding exhibitions halted humour le manned memoirs progressively rainy rescued styles of submission the limit Antony Hugo Jon NBA PRC Scots accounting for communal cylinders deliberate earthquakes feudal head of state histories leisure look for null popularized portrayal prepared for propose referee retrieve satire siblings staying strained surprising the crown updates wells workforce Chaplin Gaza House of Commons Wittgenstein acquiring afterward assassinated averaged canals capitalist civilizations compensate for consolidated dots embassy exceeds graduates hazardous helpful initiate lots motors offshore on land procession shoots specialty teaches the executive thinks tired Bengal Cromwell Emma Geoffrey Kevin New South Toledo Welles acres ancestral assessed cardinals cockpit comfort ever since habitats horizontally iconic inclined jewelry know the legends liquids methodology missionary outline pursuing repeating sanctions suppression tariffs theorists transistor treasure triangular vague vote for wherein Argentine Franz Leonard Macedonian Malta and the rest anyway bent communicate with cooperative coordinated deputy disposal endorsed in between markings mounting obliged to offence overview perceive pleased pressing proposes rotate run for screenplay shuttle spanning upwards usable veto Achilles Saudi Arabia Ukrainian all the way balloon coating compete with confronted deposit domination done with doubts fake for the purpose of hell heroic incorporating jaw limitation nominations painters paired precursor quantitative reconciliation removes resemblance revisions satisfaction squadrons step in supporter unwilling KMT Kant Kenya Normandy Powell beans captive except that gameplay healthcare homage knocked migrants millennium minorities ought to patronage pins prototypes proud randomly reservoir reside shortages tag tapes the living thicker torn transmitting yes alert cardinal carry the checks convex cooled deeds denounced endemic endings facilitated finale financed focal for life freshwater invade knee look like lord patented prizes respiratory result from shoulders throughout the world translate trio unreliable visibility Carthage Cicero MGM Odysseus Steven approve arrays ballistic be present be understood boss cone critique deficiency devastated gang highlighted in combat intervene metaphor needle not occur p.m. piston propositions rats riots second edition sediment soluble springs straightforward vicinity violated work at Godzilla Harvey Hausdorff LP Nicaragua Star Wars The First Titus Truman accommodation adjustment attained cancel eighteen equator exponential function as hierarchical in print induce manipulate neglected outright parity principally recreation securities verified Central Asia Jew Neil airplane cassette centralized charging coasts coral distress etymology evacuated exclusion from the first glasses hostility hydraulic hypothetical in color institutional issuing oak oneself originate pants plaque psychologists set theory spheres suggestions underway vote in Chen Democratic Party Egyptians Gabriel Kabul Mormon Routledge Thames bloody catalogue collector compose displaying fall into fermentation holdings icon in parallel in writing kit pad patches phonetic rites salmon sits splitting substituted surpassed tears terminated the interests wherever Almost all Congo Galileo Lockheed abbreviation aerodynamic attacker certainty chords colleague conform convincing denotes derivation desperate eager exclude field goal four-year generous globally have done immunity in contact with in detail injected invest joy malaria murders nationality occupies owed relying resurrection shed sink solitary sorted sparked stresses the courts trade in turbines useless working class Alex Hinduism IQ Turks a poor acknowledge all-time archaic bare batch bricks but then comply contraction diffraction ed emphasizes endangered escapes expectancy galleries improves joins lady laying migrate modeling monk moons nerves objections overthrow perform a pigment pioneer pitcher residual sunk synthesized trajectory trivial wouldn't Birmingham Craig Falun Fraser Monroe New Mexico New South Wales Petersburg aquatic arising boiled bottles breeds conditional constructions diagrams equivalence expenditure flies fluids going on guitarist hire hosting indefinitely miniature other's outputs pitched pray prophet ready for restoring rush scan selecting smart spy stripes subsidiary superseded tails the summit Babylonian Dakota Kenneth Ron affinity be regarded as beats clearing decoration demographic depleted drying enthusiastic experimentation finals heart attack hunger inception incorrectly inscribed interacting left hand lions mercy merit morale offerings olive painful psychiatric snakes sometime spell spotted viewpoint virtues Hume Milwaukee Whigs all in assertion asteroid blockade casino chiefly chiefs commissions debuted ecosystem fireworks fundamentally gentle immigrant in operation in the absence of limb oils physicists plantation republics routers shortest streak subspecies sympathy throat woods A major Ethernet Macintosh Maine Mickey Sacramento a deal apple ash assign cane coconut coupling elastic embryo escort facial for sale hatred honors inversion its way make use of on earth passed by programmed prolific rebuilding resolutions sentiment settling sinking specialists suppose synonymous talents worried Barnes Delhi First World Grammy
Herodotus Ludwig Shaw accumulate alignment anthropology attested backbone classify coherent collisions composing compute demonstrating devotion fall in fragile fulfilled graduation guides inefficient influx live on luck more than half not believe official language onward persisted predominant prominently recommendation sails shocked skeleton slots stellar surroundings the duration tips v vertex African American Barcelona Tibetan Tuesday Viking adjective alliances armored at one time attracted to attractions be changed besieged campuses cancellation coloured companions compelled cow deteriorated directory disastrous ejected evaporation favourable finances float gel handles in society in the event of jokes lap like that no matter nobody pigments practicing scanning stimulus subject matter the authorities trillion voltages Gaulle Grand Prix Julia Oxford University Press Vermont alcoholic authenticity ceramic inaugurated inducted insertion institute matrices natural resources prevalence signatures torpedoes undergone Carson Jason NCAA antiquity arcade become one coming to comparisons conductors contingent depictions dispatched downstream enduring go into granite intercepted jersey legitimacy lesbian mill monuments occupying parallels pointer recursive the contrary weigh yielded ATP Boris Greenland Hitchcock Latin American Phillips Rachel Shanghai attended by cites conservatives contrasts corpse decomposition fluctuations fog forum imagine listeners modernization obey optimization pigs popularly relaxed repaired resembling scenarios tile topped troubled tunes unwanted Bosnia Burke DJ Hawaiian Mongolia RCA Sierra Leone States, the Tacitus all over the world antennas apartments breakthrough deadly dignity donations dragon ecology embrace ethanol executing expired follow-up glaciers gospel grams income tax larvae maximize metabolism preaching prefixes premier promptly propeller rails reporters reunion ridges squad sticks subdivided supplier suspicious talked to some extent upcoming volatile workshop AFC Algeria Babylon Beatles Cohen Gerald Hubbard Santiago The President VHS acidic comic book conscience cylindrical disagreed establishments fungi impractical inspection lasers microscopic mold monastic monitors ourselves potato potatoes recorder resume schools of seize telephones theorems welding Buffy Cornwall HD Hampshire Kirk Norton Pluto The International Vulcan and blue archives baptized burns cf fairy farmer figure in in production of old planting poured protects provoked rim ruined securing somehow spells sued targeting tertiary with regard to you're Allan Andy Dover Ernst Franco Gaelic Israelis Obama TARDIS West Indies Zimbabwe advertisements amendments bullets causal communion crystalline demise disasters encompasses fold for free garrison heirs hormone in reference to intellectuals intimate invalid jets linguistics morphology nutrient orthodox pioneered promotional radically relate to simulate tangent there's verify viewer Castro Eusebius abolition antibiotics breath brigades buttons checking commonly known constrained deprived duo enslaved epidemic eruption ethnicity expenditures expulsion homeland in reality installations lever lucrative pick up pledged pork prospect racism reinforce remnants slogan snowfall spaced stretching very well visitor washed won't BIOS Dennis Dorothy English-speaking HIV Hamburg Ltd O. Wilde anode aristocratic chase confirmation confusing cooperate defect diplomacy disappointed discretion drastically electrically entirety experimented explorers fathers fins flank frustrated humid in case of lined mathematician microprocessor misleading motive plagued prefer to presided radio station rap recognizable republican systematically take part in truce Bermuda Breton Clarke Indonesian Plutarch Taft answer to authoritative casual coincide commonplace delta descriptive dug emigrated fearing holders in excess it must be localized parachute pedal pit preserving privilege quartz radios realizes rid stimulated subscription transforms ACLU Albanian Brunswick Delaware Franks Haiti John Paul Taiwanese additive administrator adopting ambitions arrange cake coils congestion constituents contrasted daylight efficacy emit expectation first round font fortifications good and h in the background incomes inventory linguists lion mills narrator non observable packaging pendulum poisoning queue rebuild rotary see that skating stretches the Commonwealth theoretically therapeutic throughput transferring voter weighing without being First World War Leopold Mason Nasser UC West Africa abstraction academy accomplish alarm at this point celebrity configured conquer consulting contaminated cortex day-to-day disguise donation fence fleeing hearts highest point honest hook imminent in the hands of insect inventor lease mathematically melt not work oversee photographic politician polls portray rewarded routines sacked setup shade skiing spelled sponsor sworn under construction unfinished unsuccessfully veteran Adolf Athena Broncos Erie Estonia Gustav Horace Nietzsche PCI Paige Syracuse abnormal bark bodily commanding decks endurance escaping exceptionally fibre flooded grounded implying in private in the process of labelled landowners middle class monster multiplied nowadays overnight professors ratification theft triangles Alfonso PlayStation Quran Yemen alloy atop be due beads binds canvas catalyst cipher counsel declares fauna flavors fused hazard implicit infancy interviewed medications obstacle open the participant political party proponents recruit sacrifices subscribers sweep textiles visually void Basel Ernest Falun Gong Keith Mbit/s Mozart Palestinians Persia The King Tibet admits affection amino acid ancient times blessing derive from diagonal discouraged enrollment faded fried highlight install locomotives lowering memorable minus monarchs monitored nickel notorious papacy pleasant polymers promotes rabbis recovering reed romance safer sank so it is spacing spans thorough touching travelers uniformly Athenians Chapman Diana Ecuador Hanover Heracles Indianapolis Morse Scotia Wall Street adhere adherents aforementioned analyses angel antibodies archive bags bat classroom commemorate contacted contempt cook corrosion doubling elevations foul graphite greenhouse inventions kids landscapes modern-day overlapping pollen postponed puzzle responds rhythmic ridge shoe spinal stimulate strands struggling swords tags unto variously Assyrian Bobby Davies Hannibal Joel Khrushchev accelerate believers brakes bugs categorized come up constants convoy definitely differentiation disadvantages duel evolving grandmother harbor hostilities incapable journalism lexical lips live with metaphysical mystical negligible not found on the part of paragraph passed on password protested pseudonym qualification recognise recognizing rooted seating seem to be sexes taxi the Father transitional twins vegetable verdict z Cincinnati Hamas Hancock Luis Savoy Whig Xavier Yankee biased bleeding bride concealed cope cycling discovering elders exaggerated for a long time genetically in principle motives noon not included pads parody patrons plug prevailed radial reproduced rocky southeastern strengthening stuff textbook the weather unavailable utilizing veins voluntarily worthy years. Berber Bohemia British Army Great Lakes Gregorian Humphrey People's Republic The Roman administrators angels appreciation athlete backgrounds be thought of belts can not characterization choir conjecture deposed distinguishes first edition fitting fortress guy in with investigating lethal lightweight nomenclature of the dead personalities rented rumors strand sunshine the campus the unique tragic upstream very good Ambrose CPUs Copenhagen adulthood advancement affiliation algae anarchist appointments ashes back and forth boots care for celebrities confident confiscated connector dB denomination donor enthusiasts equity establishes first person harvested human being inside of liturgical mediation monsoon plea probabilities pulp recruits reel reformed replica rotational supervised supplemented textbooks trauma tumor turning point undertake upgrades Clara Heinrich House of Lords Huxley Indo-European Jerome Keynes Lenin Macmillan Omaha Somerset Versailles Weber a.m. air force angular momentum augmented be so bypass calibration discharged electrode fight against from the beginning get to grief heterosexual imagined impurities lifespan martial arts miss negotiation nurse provisional public domain quietly quotation secrets segregation to be seen truths two-year unpublished vastly velocities Cambodia Latvia Saxony Stevenson The European Whitney adaptive analytical anthem coated compass convened cows cyclic dedication delicate dictatorship dipole disturbed drop in encourages founders free from hybrids incentive infectious knots latitudes lineup methane mg narrower originates pearls populace postwar proverbs public opinion realization recipes reflective slip tender Bristol Church of England Goldman Hercules
================================================
FILE: demo.py
================================================
import cv2
import torch
import os, glob
import numpy as np
import gradio as gr
from PIL import Image
from omegaconf import OmegaConf
from contextlib import nullcontext
from pytorch_lightning import seed_everything
from os.path import join as ospj
from util import *
def predict(cfgs, model, sampler, batch):
context = nullcontext if cfgs.aae_enabled else torch.no_grad
with context():
batch, batch_uc_1 = prepare_batch(cfgs, batch)
c, uc_1 = model.conditioner.get_unconditional_conditioning(
batch,
batch_uc=batch_uc_1,
force_uc_zero_embeddings=cfgs.force_uc_zero_embeddings,
)
x = sampler.get_init_noise(cfgs, model, cond=c, batch=batch, uc=uc_1)
samples_z = sampler(model, x, cond=c, batch=batch, uc=uc_1, init_step=0,
aae_enabled = cfgs.aae_enabled, detailed = cfgs.detailed)
samples_x = model.decode_first_stage(samples_z)
samples = torch.clamp((samples_x + 1.0) / 2.0, min=0.0, max=1.0)
return samples, samples_z
def demo_predict(input_blk, text, num_samples, steps, scale, seed, show_detail):
global cfgs, global_index
global_index += 1
if num_samples > 1: cfgs.noise_iters = 0
cfgs.batch_size = num_samples
cfgs.steps = steps
cfgs.scale[0] = scale
cfgs.detailed = show_detail
seed_everything(seed)
sampler = init_sampling(cfgs)
image = input_blk["image"]
mask = input_blk["mask"]
image = cv2.resize(image, (cfgs.W, cfgs.H))
mask = cv2.resize(mask, (cfgs.W, cfgs.H))
mask = (mask == 0).astype(np.int32)
image = torch.from_numpy(image.transpose(2,0,1)).to(dtype=torch.float32) / 127.5 - 1.0
mask = torch.from_numpy(mask.transpose(2,0,1)).to(dtype=torch.float32).mean(dim=0, keepdim=True)
masked = image * mask
mask = 1 - mask
seg_mask = torch.cat((torch.ones(len(text)), torch.zeros(cfgs.seq_len-len(text))))
# additional cond
txt = f"\"{text}\""
original_size_as_tuple = torch.tensor((cfgs.H, cfgs.W))
crop_coords_top_left = torch.tensor((0, 0))
target_size_as_tuple = torch.tensor((cfgs.H, cfgs.W))
image = torch.tile(image[None], (num_samples, 1, 1, 1))
mask = torch.tile(mask[None], (num_samples, 1, 1, 1))
masked = torch.tile(masked[None], (num_samples, 1, 1, 1))
seg_mask = torch.tile(seg_mask[None], (num_samples, 1))
original_size_as_tuple = torch.tile(original_size_as_tuple[None], (num_samples, 1))
crop_coords_top_left = torch.tile(crop_coords_top_left[None], (num_samples, 1))
target_size_as_tuple = torch.tile(target_size_as_tuple[None], (num_samples, 1))
text = [text for i in range(num_samples)]
txt = [txt for i in range(num_samples)]
name = [str(global_index) for i in range(num_samples)]
batch = {
"image": image,
"mask": mask,
"masked": masked,
"seg_mask": seg_mask,
"label": text,
"txt": txt,
"original_size_as_tuple": original_size_as_tuple,
"crop_coords_top_left": crop_coords_top_left,
"target_size_as_tuple": target_size_as_tuple,
"name": name
}
samples, samples_z = predict(cfgs, model, sampler, batch)
samples = samples.cpu().numpy().transpose(0, 2, 3, 1) * 255
results = [Image.fromarray(sample.astype(np.uint8)) for sample in samples]
if cfgs.detailed:
sections = []
attn_map = Image.open(f"./temp/attn_map/attn_map_{global_index}.png")
seg_maps = np.load(f"./temp/seg_map/seg_{global_index}.npy")
for i, seg_map in enumerate(seg_maps):
seg_map = cv2.resize(seg_map, (cfgs.W, cfgs.H))
sections.append((seg_map, text[0][i]))
seg = (results[0], sections)
else:
attn_map = None
seg = None
return results, attn_map, seg
if __name__ == "__main__":
os.makedirs("./temp", exist_ok=True)
os.makedirs("./temp/attn_map", exist_ok=True)
os.makedirs("./temp/seg_map", exist_ok=True)
cfgs = OmegaConf.load("./configs/demo.yaml")
model = init_model(cfgs)
global_index = 0
block = gr.Blocks().queue()
with block:
with gr.Row():
gr.HTML(
"""
<div style="text-align: center; max-width: 1200px; margin: 20px auto;">
<h1 style="font-weight: 600; font-size: 2rem; margin: 0.5rem;">
UDiffText: A Unified Framework for High-quality Text Synthesis in Arbitrary Images via Character-aware Diffusion Models
</h1>
<ul style="text-align: center; margin: 0.5rem;">
<li style="display: inline-block; margin:auto;"><a href='https://arxiv.org/abs/2312.04884'><img src='https://img.shields.io/badge/Arxiv-2312.04884-DF826C'></a></li>
<li style="display: inline-block; margin:auto;"><a href='https://github.com/ZYM-PKU/UDiffText'><img src='https://img.shields.io/badge/Code-UDiffText-D0F288'></a></li>
<li style="display: inline-block; margin:auto;"><a href='https://udifftext.github.io'><img src='https://img.shields.io/badge/Project-UDiffText-8ADAB2'></a></li>
</ul>
<h2 style="text-align: left; font-weight: 450; font-size: 1rem; margin: 0.5rem;">
Our proposed UDiffText is capable of synthesizing accurate and harmonious text in either synthetic or real-word images, thus can be applied to tasks like scene text editing (a), arbitrary text generation (b) and accurate T2I generation (c)
</h2>
<div align=center><img src="file/demo/teaser.png" alt="UDiffText" width="80%"></div>
</div>
"""
)
with gr.Row():
with gr.Column():
input_blk = gr.Image(source='upload', tool='sketch', type="numpy", label="Input", height=512)
text = gr.Textbox(label="Text to render:", info="the text you want to render at the masked region")
run_button = gr.Button(variant="primary")
with gr.Accordion("Advanced options", open=False):
num_samples = gr.Slider(label="Images", info="number of generated images, locked as 1", minimum=1, maximum=1, value=1, step=1)
steps = gr.Slider(label="Steps", info ="denoising sampling steps", minimum=1, maximum=200, value=50, step=1)
scale = gr.Slider(label="Guidance Scale", info="the scale of classifier-free guidance (CFG)", minimum=0.0, maximum=10.0, value=4.0, step=0.1)
seed = gr.Slider(label="Seed", info="random seed for noise initialization", minimum=0, maximum=2147483647, step=1, randomize=True)
show_detail = gr.Checkbox(label="Show Detail", info="show the additional visualization results", value=False)
with gr.Column():
gallery = gr.Gallery(label="Output", height=512, preview=True)
with gr.Accordion("Visualization results", open=True):
with gr.Tab(label="Attention Maps"):
gr.Markdown("### Attention maps for each character (extracted from middle blocks at intermediate sampling step):")
attn_map = gr.Image(show_label=False, show_download_button=False)
with gr.Tab(label="Segmentation Maps"):
gr.Markdown("### Character-level segmentation maps (using upscaled attention maps):")
seg_map = gr.AnnotatedImage(height=384, show_label=False)
# examples
examples = []
example_paths = sorted(glob.glob(ospj("./demo/examples", "*")))
for example_path in example_paths:
label = example_path.split(os.sep)[-1].split(".")[0].split("_")[0]
examples.append([example_path, label])
gr.Markdown("## Examples:")
gr.Examples(
examples=examples,
inputs=[input_blk, text]
)
run_button.click(fn=demo_predict, inputs=[input_blk, text, num_samples, steps, scale, seed, show_detail], outputs=[gallery, attn_map, seg_map])
block.launch()
================================================
FILE: metrics.py
================================================
import lpips
import os,glob
from os.path import join as ospj
def calc_fid(fake_dir, real_dir, batch_size=1, gpu='0'):
print(f"evaluating FID score between '{fake_dir}' and '{real_dir}'")
os.system(f"python -m pytorch_fid {fake_dir} {real_dir} --batch-size {batch_size} --device cuda:{gpu}")
def calc_lpips(fake_dir, real_dir):
print(f"evaluating LPIPS score between '{fake_dir}' and '{real_dir}'")
loss_fn = lpips.LPIPS(net='alex').cuda()
fake_paths = sorted(glob.glob(ospj(fake_dir, "*")))
real_paths = sorted(glob.glob(ospj(real_dir, "*")))
dists = []
for fake_path, real_path in zip(fake_paths, real_paths):
fake_img = lpips.im2tensor(lpips.load_image(fake_path)).cuda() # RGB image from [-1,1]
real_img = lpips.im2tensor(lpips.load_image(real_path)).cuda()
dist = loss_fn.forward(fake_img, real_img)
dists.append(dist)
print(f"lpips score: {sum(dists)/len(dists)}")
================================================
FILE: pretrain.py
================================================
import torch
import torch.utils.data as data
import pytorch_lightning as pl
from omegaconf import OmegaConf
from sgm.util import instantiate_from_config
from pytorch_lightning.callbacks import ModelCheckpoint
def get_dataloader(cfgs):
dataset = instantiate_from_config(cfgs.dataset)
dataloader = data.DataLoader(dataset=dataset, batch_size=cfgs.batch_size, shuffle=False, num_workers=cfgs.num_workers)
return dataloader
def get_model(cfgs):
model = instantiate_from_config(cfgs.model)
if "load_ckpt_path" in cfgs:
model.load_state_dict(torch.load(cfgs.load_ckpt_path, map_location="cpu")["state_dict"], strict=False)
return model
def train(cfgs):
dataloader = get_dataloader(cfgs)
model = get_model(cfgs)
checkpoint_callback = ModelCheckpoint(dirpath = cfgs.ckpt_dir, every_n_epochs = cfgs.check_freq)
trainer = pl.Trainer(callbacks = [checkpoint_callback], **cfgs.lightning)
trainer.fit(model = model, train_dataloaders = dataloader)
if __name__ == "__main__":
config_path = 'configs/pretrain.yaml'
cfgs = OmegaConf.load(config_path)
train(cfgs)
================================================
FILE: requirements.txt
================================================
colorlover==0.3.0
einops==0.6.1
gradio==3.41.0
imageio==2.31.2
img2dataset==1.42.0
kornia==0.6.9
lpips==0.1.4
matplotlib==3.7.2
nltk==3.8.1
numpy==1.25.1
omegaconf==2.3.0
open-clip-torch==2.20.0
opencv-python==4.6.0.66
Pillow==9.5.0
pytorch-fid==0.3.0
pytorch-lightning==2.0.1
safetensors==0.3.1
scikit-learn==1.3.0
scipy==1.11.1
seaborn==0.12.2
socksio==1.0.0
tensorboard==2.14.0
timm==0.9.2
tokenizers==0.13.3
tqdm==4.65.0
transformers==4.30.2
xformers==0.0.22.post7
================================================
FILE: scripts/preprocess/laion_ocr_pre.ipynb
================================================
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import os,glob\n",
"import json\n",
"from tqdm import tqdm\n",
"from os.path import join as ospj"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"data_root = \"{your data root}/LAION-OCR\"\n",
"image_root = ospj(data_root, \"image\")\n",
"anno_root = ospj(data_root, \"annotation\")\n",
"cache_root = ospj(data_root, \"cache\")\n",
"os.makedirs(cache_root, exist_ok=True)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"8754781"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"url_txt = \"{your data root}/LAION-OCR/mario_laion_image_url/mario-laion-index-url.txt\"\n",
"with open(url_txt, 'r') as fp:\n",
" res = fp.readlines()\n",
"\n",
"url_lst = []\n",
"for r in res:\n",
" idx, url = r.split(\" \")\n",
" url = url[:-1]\n",
" ex_idx, in_idx = idx.split(\"_\")\n",
" if int(ex_idx) >= 50000: continue\n",
" url_lst.append({\"ex_idx\": ex_idx, \"in_idx\": in_idx, \"url\": url})\n",
"len(url_lst)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[{'ex_idx': '00000',\n",
" 'in_idx': '000000012',\n",
" 'url': 'https://www.rockfordsystems.com/wp-content/uploads/2015/04/kst194-p.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000000061',\n",
" 'url': 'https://s3.reutersmedia.net/resources/r/?m=02&d=20161208&t=2&i=1164715083&w=644&fh=&fw=&ll=&pl=&sq=&r=LYNXMPECB70YK'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000000108',\n",
" 'url': 'https://images.puma.net/images/907235/02/bv/fnd/EEA/w/288/h/288/'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000000146',\n",
" 'url': 'http://www.slicingupeyeballs.com/wp-content/uploads/2009/05/stoneroses452.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000000199',\n",
" 'url': 'https://amheath.com/wp-content/uploads/2016/12/stranger.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000000214',\n",
" 'url': 'https://www.musicalweb.nl/wp-content/uploads/2020/05/singalong_disney.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000000247',\n",
" 'url': 'http://rlv.zcache.ca/the_coolest_people_are_from_maine_cards-r3dc62ebdf5334ecb909eb464787226c8_xvuat_8byvr_324.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000000255',\n",
" 'url': 'https://i.pinimg.com/736x/eb/2e/f4/eb2ef48889d7ccd2c51b914a8e4cb7d5--alphabet-design-alphabet-letters.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000000278',\n",
" 'url': 'http://rlv.zcache.com.au/keep_calm_and_listen_to_the_great_egrets_poster-r65983dd96acd4ca8a7c3fcfe9f761802_wvu_8byvr_324.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000000352',\n",
" 'url': 'https://i1.wp.com/techget.net/wp-content/uploads/2013/04/Best-Apps-for-Movie-lovers.png?fit=560%2C315&'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000000410',\n",
" 'url': 'http://img.wfrcdn.com/lf/49/hash/18584/7768691/1/1/1.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000000599',\n",
" 'url': 'https://dynamic.brandcrowd.com/asset/logo/ca14c463-843d-4df5-9b7b-40dddadef740/logo?v=4'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000000632',\n",
" 'url': 'https://d3v4qu4rwgk1m7.cloudfront.net/wp-content/uploads/2019/06/24100253/Car-Wash-Kits.png'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000000731',\n",
" 'url': 'http://img1.imagesbn.com/p/2940011445422_p0_v2_s260x420.JPG'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000000762',\n",
" 'url': 'https://i.ytimg.com/vi/1sfyKP83vBY/0.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000000791',\n",
" 'url': 'https://img5274.weyesimg.com/uploads/y91cvhn0.allweyes.com/images/928d71a9b0a1bfc2f633671c010d28a1.jpg?imageView2/2/w/1920/q/75'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000000868',\n",
" 'url': 'http://rlv.zcache.ca/appreciate_iphone_case_iphone_4_case-r055f4e6687ea4ed2b4e3563faacab0d4_a4643_8byvr_324.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000000985',\n",
" 'url': 'https://3.bp.blogspot.com/-6rPl3MUmfDw/ViD57JQ9UHI/AAAAAAAAAEc/8sQaECCwOvc/s1600/Atlas%2BAnatomy%2B3d%2Bedit.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000000994',\n",
" 'url': 'https://us.123rf.com/450wm/teamplayfor/teamplayfor1701/teamplayfor170100022/69327415-stock-vector-vector-decorate-cakes-with-cream-from-pastry-bag-isolated-illustration-on-white-backgroung-kitchenwa.jpg?ver=6'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000001019',\n",
" 'url': 'http://cdn.rekkerd.org/img/201503/famousaudio_atmosphericpianothemes3.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000001043',\n",
" 'url': 'https://etsytelemall.com/uploads/169f08c23dc9da2c8df7cd920ee286e0.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000001091',\n",
" 'url': 'http://rlv.zcache.ca/trick_or_treat_spider_print-r3328ccd5fa2147c0a2537824815caecc_6azo_8byvr_324.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000001202',\n",
" 'url': 'https://timtirelli.files.wordpress.com/2015/01/rock-hall-night-bluejpg.jpg?w=490&h=310'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000001210',\n",
" 'url': 'http://2.bp.blogspot.com/-N9nHT7V1J_A/UDqYxlV_q2I/AAAAAAAABXQ/HBNjQOS17L4/s1600/a%2Bblog%2Bby%2Bmischelle%2Bheader.png'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000001231',\n",
" 'url': 'https://capemarkets.co.za/wp-content/uploads/2019/06/Winter-Wonderland-Logo-300x300.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000001252',\n",
" 'url': 'http://images.tvfanatic.com/iu/s--HtSeWKj0--/t_teaser_wide/f_autofl_lossyq_75/v1414435450/attachment/the-walking-dead-rt-depreciated.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000001277',\n",
" 'url': 'http://clould.ohcosplay.com/images/product/acc7895.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000001316',\n",
" 'url': 'https://www.c4dt.org/wp-content/uploads/2019/10/News_CPI_slogan-1.png'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000001396',\n",
" 'url': 'http://i00.i.aliimg.com/wsphoto/v1/1345135562_1/AA-13-multiple-Asdrubal-Cabrera-jersey-Indians-new-white-gray-navy-ivory-authentic-jersey.jpg_350x350.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000001432',\n",
" 'url': 'https://www.anikama.co.il/content/images/thumbs/0005499_im-not-getting-any-younger-magnet_600.jpeg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000001589',\n",
" 'url': 'https://image.spreadshirtmedia.net/image-server/v1/compositions/T635A2PA1289PT17X26Y58D135375903S72/views/1width=300height=300appearanceId=2backgroundColor=E8E8E8/not-without-my-fatbike-maenner-bio-t-shirt.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000001613',\n",
" 'url': 'https://i2.cdn.hhv.de/catalog/475x475/00436/436572.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000001675',\n",
" 'url': 'https://elgurudelbasket.com/wp-content/uploads/2015/07/as17_new_orleans-e1511020319987.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000001682',\n",
" 'url': 'http://www.rapbasement.com/wp-content/uploads/2015/01/spenzo-dripping-in-gold-feat-lep-bogus-boys-300x300.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000001703',\n",
" 'url': 'https://ctl.s6img.com/society6/img/hFwzz_bCCX1PNjeEBKa1071X3vs/h_264w_264/prints/~artwork/s6-original-art-uploads/society6/uploads/misc/b6309341286b42b7afe25334ecd88968/~~/you-did-not-wake-up-today-to-be-mediocre1301106-prints.jpg?wait=0&attempt=0'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000001774',\n",
" 'url': 'http://files1.comics.org//img/gcd/covers_by_id/203/w400/203539.jpg?-4555063407778287876'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000001816',\n",
" 'url': 'https://www.davenportmachine.com/wp-content/uploads/multi-spindle-automatic-lathe.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000001850',\n",
" 'url': 'https://www.monsterbacklinks.com/pics/000/153/279/2bfeec8853935db7688c479e7d9cfd21.png'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000001860',\n",
" 'url': 'http://republicjewelry.com/images/upperdeck_logo2.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000001886',\n",
" 'url': 'https://guide.alibaba.com/image/i1/excellent-shellfish-love-baby-wipes-baby-wipes-ass-dedicated-small-packet-of-skin-cleaning-wipes-8-bags-free-shipping-wholesale-25-pcs/TB19CkiLVXXXXaiaXXXXXXXXXXX_!!0-item_pic.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000001889',\n",
" 'url': 'https://www.acupunctureworld.com/out/pictures/generated/product/thumb/375_375_90/points-series@2x.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000001908',\n",
" 'url': 'https://healthyhomecleaning.websitehabitat.com/wp-content/uploads/sites/49/2015/05/which-norwex-dryer-balls-are-best.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000001920',\n",
" 'url': 'https://cdn.shopify.com/s/files/1/0505/0407/3414/products/100-pioneering-women-book-art-architecture-books-house-home-product-type-select-pricing-0-3000-ikkadukka-store-ikka-dukka-the-eclectic-online_947_740x.jpg?v=1602935507'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000001923',\n",
" 'url': 'https://www.slantmagazine.com/assets/house/5941/books_seenowthen__article-prose-260x.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000001931',\n",
" 'url': 'https://bcassetcdn.com/asset/logo/f016a010-62c1-4105-b0af-f59735620074/logo?v=4&text=Logo+Text+Here'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000001994',\n",
" 'url': 'http://www.minimeandluxury.co.uk/wp-content/uploads/2019/04/Birdland-400x400.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000002015',\n",
" 'url': 'https://ssl.c.photoshelter.com/img-get2/I0000gnsMogy4NUM/fit=1000x750/20110623-0192.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000002055',\n",
" 'url': 'https://i2.wp.com/thepinterestedparent.com/wp-content/uploads/2017/07/ftgj-550x1024.jpg?resize=257%2C478'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000002061',\n",
" 'url': 'http://wwwcache.wral.com/asset/lifestyles/goaskmom/2012/11/21/11802796/craftymomturkeybaster-347x300.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000002196',\n",
" 'url': 'https://static1.bigstockphoto.com/thumbs/2/3/1/large2/132530996.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000002307',\n",
" 'url': 'https://1.bp.blogspot.com/-IzADoO3QH50/X9FHiyLmd5I/AAAAAAAAAG4/8uYW8olwIYcW78LkjqBEgi7JuaaGIY_agCLcBGAsYHQ/w680/o%2Bpapel%2Bdo%2Bmarketing%2Bdigital%2Bpara%2Badvogados.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000002316',\n",
" 'url': 'https://cdn.shopify.com/s/files/1/0076/9258/2997/files/ABP_-_About_Us_51fbde1d-d702-4604-b637-a22a539ec493_grande.jpg?v=1559323856'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000002386',\n",
" 'url': 'https://resources.tidal.com/images/65e8862c/e460/41f0/981e/b25fb974d537/640x640.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000002410',\n",
" 'url': 'https://direct.rhapsody.com/imageserver/images/alb.204079853/500x500.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000002426',\n",
" 'url': 'https://www.selon-l.fr/wp-content/uploads/2019/04/banniere-wp-bx-events.png'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000002433',\n",
" 'url': 'http://upperdeckblog.com/wp-content/uploads/2013/04/Doc-Jacobs-Event-Upper-Deck-Operation-Gratitude-Tommy-Lasorda-Talking-to-Doc.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000002466',\n",
" 'url': 'https://i0.wp.com/www.silkejager.com/wp-content/uploads/2018/06/BronzeAmbassadorJourney.jpg?fit=300%2C300&ssl=1'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000002530',\n",
" 'url': 'http://az721511.vo.msecnd.net/images/544/2724104.JPG?636166319456700257'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000002593',\n",
" 'url': 'https://3.bp.blogspot.com/-h9WhTMJYFZ8/UMgIU8ZJoOI/AAAAAAAAACA/kOX1Ol6n1rs/s320/AIRTEL_F_V_RGB_3D.png'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000002624',\n",
" 'url': 'https://us.123rf.com/450wm/lmv/lmv1302/lmv130200006/17989339-restaurant-menu-design.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000002667',\n",
" 'url': 'https://www.iapa.org/wp-content/uploads/2019/02/Webp.net-resizeimage-2-e1552245032578-370x370.png'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000002740',\n",
" 'url': 'https://thumb7.shutterstock.com/image-photo/stock-vector-beauty-hair-salon-logo-450w-401606989.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000002919',\n",
" 'url': 'https://images.edealer.ca/18/71297032.jpeg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000002935',\n",
" 'url': 'https://i1.wp.com/blognife.com/wp-content/uploads/2017/05/fan-1.png?fit=1024%2C512'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000002946',\n",
" 'url': 'https://syamsulrijal.com/wp-content/uploads/2020/04/header-logo1.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000002963',\n",
" 'url': 'http://rlv.zcache.ca/holiday_recipe_binder_2_size-r62214748d53c48e7a08f16f245cd4baa_xz8lg_8byvr_324.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000002981',\n",
" 'url': 'https://thetalononline.com/wp-content/uploads/2019/10/theatrecollective-900x600.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000002983',\n",
" 'url': 'https://lh4.ggpht.com/vSQLNnu5TCx-YLLW-udrS2Q2bYGa1MlEq3PprqWQS3x4hYK1cX7yPls-i619l6aF_DxZ=h900'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000002989',\n",
" 'url': 'https://itswritenow.com/wp-content/uploads/2018/02/template_358_Alexandra_John.png'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000003025',\n",
" 'url': 'http://d202m5krfqbpi5.cloudfront.net/books/1348717970l/1342556.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000003058',\n",
" 'url': 'http://thephotobrigade.com/wp-content/uploads/2013/02/Photographers_Outlook_on_2013_2.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000003087',\n",
" 'url': 'https://top10cinema.com/dataimages/29548-a.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000003119',\n",
" 'url': 'https://cdn.waterstones.com/bookjackets/large/9780/5712/9780571284184.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000003172',\n",
" 'url': 'http://a.mktgcdn.com/p/o0iwgIPT4C22tIJHrYXOhtZCqklYALxoZSX50aDxiro/280x280.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000003264',\n",
" 'url': 'https://i.ytimg.com/vi/U-9zhay1_hM/hqdefault.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000003314',\n",
" 'url': 'https://media.gettyimages.com/vectors/music-elements-vector-id469890499?s=612x612'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000003333',\n",
" 'url': 'https://rlv.zcache.com/first_coffee_then_tambura_music_lover_button-r092976bd1ff04826b2a6cfd00908cd11_k94rk_500.jpg?rlvnet=1'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000003344',\n",
" 'url': 'https://64.media.tumblr.com/tumblr_m6krabL2Hv1qz5q5oo1_500.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000003508',\n",
" 'url': 'https://cdn.shopify.com/s/files/1/2835/0496/products/Screen_Shot_2019-09-26_at_3.52.05_PM_1024x1024@2x.png?v=1571827904'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000003557',\n",
" 'url': 'https://shafferoffshoresolutions.com/wp-content/uploads/logo-blue-working-copy.png'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000003604',\n",
" 'url': 'https://www.makingmusicfun.net/images/thumbs/scott-joplin-word-search-worksheet.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000003621',\n",
" 'url': 'https://i2.wp.com/invisioncommunity.co.uk/wp-content/uploads/2021/05/SEGA-Announce-Lost-Judgment.jpg?resize=640%2C450&ssl=1'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000003686',\n",
" 'url': 'https://s3.amazonaws.com/lollipuff/media/blog/383/authentic-prada-hardware-logo-authentication.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000003740',\n",
" 'url': 'https://ibizafilmoffice.com/wp-content/uploads/2020/01/the-story-of-plastic-1024x576.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000003771',\n",
" 'url': 'https://printablehappybirthdaycards.com/wp-content/uploads/2019/03/For-Wife-Printable-Happy-Birthday-Cards-825x510.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000003778',\n",
" 'url': 'https://media.moddb.com/cache/images/downloads/1/62/61287/thumb_620x2000/tttt.png'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000003813',\n",
" 'url': 'https://i0.wp.com/finderskeeperscrafting.com/wp-content/uploads/2016/12/pr_ts_ma.jpg?fit=300%2C300'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000003843',\n",
" 'url': 'http://barsuk.com.mx/wp-content/uploads/2016/01/samba-maya-Featured.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000003890',\n",
" 'url': 'https://i1.wp.com/flaviogarcia.es/vlog/wp-content/uploads/2016/01/tendencias-seo-para-2016.jpg?resize=800%2C445&ssl=1'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000003967',\n",
" 'url': 'https://static.wixstatic.com/media/264a63_9b686aa038fd8e13286a3845a02a5783.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000004069',\n",
" 'url': 'https://homesteadsurvivalsite.com/wp-content/uploads/15-ways-to-improve-your-garden-soil-pin-1.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000004070',\n",
" 'url': 'https://i.ytimg.com/vi/YMAzj5T0tUs/0.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000004112',\n",
" 'url': 'https://www.dft-valves.com/img/Adobe-Spark-2-500x281.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000004139',\n",
" 'url': 'http://cdn.pastemagazine.com/www/articles/2014/03/04/PasteSXSW_InteractiveLead.jpg?635300843171398639'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000004158',\n",
" 'url': 'https://i.ibb.co/QDKjzjy/Property-Management-1-65.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000004343',\n",
" 'url': 'https://i.ytimg.com/vi/18ffCe-0fIo/hqdefault.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000004372',\n",
" 'url': 'https://eclecticmomsense.com/wp-content/uploads/2015/10/frankenstein-cupcakes-678x1024.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000004375',\n",
" 'url': 'https://images.sftcdn.net/images/t_optimizedf_auto/p/97bc217b-e1f1-4f32-a877-6229c529c7ea/291508945/rise-of-the-tomb-raider-20-year-celebration-ps-vr-ps4-logo.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000004399',\n",
" 'url': 'https://i.ebayimg.com/images/g/Te8AAOSwa1ZcHpMP/s-l500.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000004468',\n",
" 'url': 'http://images.comiccollectorlive.com/covers/c49/c4997944-611b-4c53-9c47-0db0a2897874.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000004476',\n",
" 'url': 'http://ecx.images-amazon.com/images/I/51635CFGPSL.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000004488',\n",
" 'url': 'https://www.hanaflorists.com/images/zoom_julias-designer-choices-17072792216.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000004519',\n",
" 'url': 'https://i1.wp.com/thetrademarkninja.com/wp-content/uploads/2017/07/T-Mobile-IOT-Trademark-Applications.png?resize=380%2C380'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000004636',\n",
" 'url': 'https://miriamrune.co.uk/content/images/2015/05/novel-ideas-blog-logo.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000004644',\n",
" 'url': 'http://www.game-fort.com/_nw/32/92027781.jpeg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000004729',\n",
" 'url': 'https://images.squarespace-cdn.com/content/56089dfce4b0fb7874bd4c50/1516294695428-PLHOZGEPA8T6DZLD5K31/FINLA_Revision_IQ_LOGO_DESIGN-2.jpg?content-type=image%2Fjpeg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000004792',\n",
" 'url': 'https://4.bp.blogspot.com/-QMboo-_XrI0/V28PKYgX4uI/AAAAAAAAUhw/Nkr57HEEDxwfEsIlNI9UQ9xCWYdFhs9CQCLcB/s400/Slide1.PNG'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000004803',\n",
" 'url': 'https://images.lookhuman.com/render/standard/SoRDxb8l07DddiNxBNerv8VtK4rK45KA/6710-heathered_black-z1-t-yoga-with-the-omies.png'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000004868',\n",
" 'url': 'https://www.peche-leurre-evolution.com/gfx_folders/1301839227267.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000004903',\n",
" 'url': 'http://im.rediff.com/money/2013/apr/18biggest-companies4.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000005089',\n",
" 'url': 'https://i0.wp.com/wayofdharma.com/wp-content/uploads/2018/08/caste-and-hinduism.jpg?resize=665%2C365&'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000005105',\n",
" 'url': 'https://www.mauvais-genres.com/17147-large_default/day-after-french-movie-poster-47x63-81-day-after.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000005127',\n",
" 'url': 'http://1.bp.blogspot.com/-RdNlgePPMsk/UQO56ttd27I/AAAAAAAAGyU/5VeHmid3SvA/s320/pokemon-platine.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000005148',\n",
" 'url': 'http://drh2.img.digitalriver.com/DRHM/Storefront/Company/ubi/images/hero/Rabbids_BlackTshirt_Hero_FR.png'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000005206',\n",
" 'url': 'https://bokklubben.no/servlet/VisBildeServlet?produktId=6996035&width=95'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000005381',\n",
" 'url': 'http://indiecurrent.com/wp-content/uploads/2012/12/Favourite-Canadian-Music-Videos-of-2012-Ride-The-Tempo.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000005394',\n",
" 'url': 'http://cascadiasfault.com/wp-content/uploads/2020/06/free-alphabet-coloring-pictures-disney-pages-printable-for.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000005398',\n",
" 'url': 'https://static.onleihe.de/images/bookwire_inter/20210127/9783863911546/im9783863911546s.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000005426',\n",
" 'url': 'http://3o7tpx32lt6v2lcovs4a53lb.wpengine.netdna-cdn.com/wp-content/uploads/2013/08/Geronimo-Shot-Bar-smaller--500x303.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000005489',\n",
" 'url': 'http://a1.phobos.apple.com/us/r1000/020/Purple/53/f6/b4/mzl.jxdsthto.png'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000005490',\n",
" 'url': 'https://i.pinimg.com/736x/f2/6a/57/f26a57a7472692e5d3b47f47f6cb852e--the-breakfast-club-breakfast-club-quotes.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000005521',\n",
" 'url': 'https://cdn.shopify.com/s/files/1/0204/7208/t/26/assets/logo_accessible360.png?62012'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000005536',\n",
" 'url': 'http://cdn.pastemagazine.com/www/articles/2011/03/21/The-Hobbit-book-cover-square.jpg?635336299397505126'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000005676',\n",
" 'url': 'https://www.miletasigns.co.uk/media/catalog/product/cache/1/thumbnail/300x400/9df78eab33525d08d6e5fb8d27136e95/c/p/cp049_1.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000005705',\n",
" 'url': 'http://1.bp.blogspot.com/-Ivmfcqtq1Kc/UbCpQ_7uU7I/AAAAAAAACIg/SCtecu39WDQ/s1600/96089427449264466617.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000005816',\n",
" 'url': 'https://s3.amazonaws.com/gigsalad_media/t/tumbao_chicago/5a7b3321ea1b3_300_sq'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000005845',\n",
" 'url': 'https://www.inspireflyer.com/img/build-with-skyscanner-badge-footer.png'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000005883',\n",
" 'url': 'https://www.com-sub.biz/uploads/images/full/025930bc60c28c918fc9c5fe5645a3b5.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000005941',\n",
" 'url': 'http://www.quickmeme.com/img/75/751c3ffd668537a299b5f92789aa13ac2f127516425e2426b72c53d72648c698.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000006194',\n",
" 'url': 'https://static.uk.groupon-content.net/app/00/00/default0000.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000006312',\n",
" 'url': 'https://lh3.googleusercontent.com/-YNPcanrd01s/WYCX2nI091I/AAAAAAAAFIc/in9jbS4NS7A6uRFRIqn5PvSbz30-wW1ZgCHMYCw/sinnertitle_thumb%255B2%255D?imgmax=800'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000006317',\n",
" 'url': 'https://cdn.prestosports.com/action/cdn/logos/id/1oz6458b0o827r98.png'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000006322',\n",
" 'url': 'https://images.justlanded.com/classified_images/Ecuador_Pichincha_Quito/Servicios_Ordenadores-Internet/Agencias-De-Inbound-Marketing-Ecuador/photo/big_scaled_1736569_2650086.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000006381',\n",
" 'url': 'http://rlv.zcache.com.au/worlds_greatest_boss_mousepads-rde3e974765ec45b284e201d0fb7ebb33_x74vi_8byvr_324.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000006383',\n",
" 'url': 'http://tse3.mm.bing.net/th?id=OIP.V8QL0RFK5cnF68JAuwnocQHaHa'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000006396',\n",
" 'url': 'https://d3fa68hw0m2vcc.cloudfront.net/9f9/178414816.jpeg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000006399',\n",
" 'url': 'https://i.ytimg.com/vi/dKLJaTMFjY4/0.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000006444',\n",
" 'url': 'http://a.espncdn.com/combiner/i?img=/espn360/images/showassets/ERJJ.jpg&w=640&h=360&20160201093651'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000006559',\n",
" 'url': 'https://p19cdn4static.sharpschool.com/UserFiles/Servers/Server_2434311/Image/26%20Jan%20TMSA%20Board%20Meeting%20Small.png'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000006564',\n",
" 'url': 'https://images.saymedia-content.com/.image/t_share/MTc0NjM5OTU4NDY3MDk0NTE4/repetition-and-the-living-dead-an-analysis-of-james-joyces-the-dead.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000006671',\n",
" 'url': 'https://seoheronews.com/adwords-clicks-620x0.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000006697',\n",
" 'url': 'https://image.spreadshirtmedia.net/image-server/v1/compositions/T631A1PA1280PT17X8Y0D130215843S32/views/1width=300height=300appearanceId=1backgroundColor=E8E8E8/leaf-me-women-s-t-shirt.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000006754',\n",
" 'url': 'https://www.netoingenieria.com/wp-content/uploads/2018/01/congreso-multisectiorial-carreteas.png'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000006838',\n",
" 'url': 'https://i.pinimg.com/736x/4a/10/1d/4a101d10f6c776ac0a90f07ab4d3e7bd.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000006852',\n",
" 'url': 'http://ecx.images-amazon.com/images/I/51G+-ANR8LL._SL300_.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000006899',\n",
" 'url': 'https://www.schlossstrasse-koblenz.de/thumbnail.php?thumb=img/shops/logos/105.jpg&width=300&height=300'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000006904',\n",
" 'url': 'https://andreasnotebook.com/wp-content/uploads/2011/10/Viking-helmet-tutorial.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000006917',\n",
" 'url': 'http://az721511.vo.msecnd.net/images/130/651640.JPG?636237457983790927'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000006941',\n",
" 'url': 'http://canalauthenticgames.com.br/content/uploads/Prime-Authentic-Games-2017-Facebook-166-265x265.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000006981',\n",
" 'url': 'https://static.wixstatic.com/media/45af5e_bdb9587dab814438a8d04dadcf2f17a7~mv2.png/v1/fit/w_500h_500q_90/45af5e_bdb9587dab814438a8d04dadcf2f17a7~mv2.png'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000007039',\n",
" 'url': 'https://www.platformhg.com/media/images/versions/img94joktmu71652.jpg?bev=1362'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000007050',\n",
" 'url': 'https://images.8tracks.com/cover/i/000/772/489/tumblr_mu65k05sDR1rjp4l1o1_500-8945.jpg?rect=00480480&q=98&fm=jpg&fit=max&w=320&h=320'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000007076',\n",
" 'url': 'https://s3.amazonaws.com/media.locally.net/logo-270x270/14590507_1361209293919802_4617975925624903492_n_2017-05-01-10-22-01.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000007137',\n",
" 'url': 'https://www.divyajanani.org/wp-content/uploads/2019/01/happy-mothers-day-coloring-pages-beautiful-happy-mothers-day-coloring-pages-heart-coloring-pages-of-happy-mothers-day-coloring-pages.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000007171',\n",
" 'url': 'http://4.bp.blogspot.com/-015aW2JD4SI/U5tAQXMp6fI/AAAAAAAAPgU/1GsiWnzAJ2k/s1600/capa.jpg%22%22%22%22%22%22%22%22%22%22%22%2222%22%22%22%22%22%22%22%22%22'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000007255',\n",
" 'url': 'https://cdn.shopify.com/s/files/1/1567/1365/products/thumb_fc7cca25-33ce-4d4a-8b68-bf6cd2f13e6e_480x480.jpg?v=1535551974'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000007258',\n",
" 'url': 'https://www.eden.co.uk/images/300/9781631463228.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000007260',\n",
" 'url': 'https://bestlakecountylawyer.com/wp-content/uploads/2019/05/Criminal-Defense-2019-620x380.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000007264',\n",
" 'url': 'https://www.techmelife.com/wp-content/uploads/2021/03/10-Ways-Social-Media-Helps-Your-SEO-Strategies-e1616572147271.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000007321',\n",
" 'url': 'https://cdn4.singleinterface.com/files/offer-images/80/home_page-3929_1521540985_SIBanner434x434compressor.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000007404',\n",
" 'url': 'http://cdn01.ru/files/users/images/ac/c8/acc89416fe58bf7e2d9eb8b1ba58cc42.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000007471',\n",
" 'url': 'http://i00.i.aliimg.com/wsphoto/v0/1316216120_1/Fast-Shipping-Multifunction-Robot-Vacuum-Cleaner-Big-Mop-Low-noise-Home-Aplicances.jpg_350x350.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000007637',\n",
" 'url': 'https://m.media-amazon.com/images/I/61PpqZ8ETqL._SL500_.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000007656',\n",
" 'url': 'http://static.kodajo.com/images/user/fileUp/6c5a0da6437719cfa5d028c7fd21535d.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000007713',\n",
" 'url': 'https://kcmix.com/wp-content/uploads/2019/11/Youth-Crime-What-Can-I-Do-380x285.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000007854',\n",
" 'url': 'http://d202m5krfqbpi5.cloudfront.net/books/1332982516l/13564669.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000007859',\n",
" 'url': 'https://d12swbtw719y4s.cloudfront.net/images/k5r8coRk/7RMlT0x3kJc80NGb9ERG/5BxK2cS4zj.jpeg?w=600'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000007913',\n",
" 'url': 'https://thisdelicioushouse.com/wp-content/uploads/2019/07/Untitled-185-683x1024.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000007918',\n",
" 'url': 'http://direct.rhapsody.com/imageserver/images/Alb.17950649/500x500.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000007920',\n",
" 'url': 'https://consumerqueen.com/wp-content/uploads/2020/03/FREE-ONLINE-FITNESS-STUDIOS.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000007967',\n",
" 'url': 'https://i1.wp.com/sunuptosundown.net/wp-content/uploads/2018/10/ChocolateIce-CreamDay.png?resize=800%2C374&ssl=1'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000008141',\n",
" 'url': 'https://www.jasoncouponking.com/wp-content/uploads/2013/12/target.png'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000008155',\n",
" 'url': 'https://cdn.shopify.com/s/files/1/0656/6139/products/OS_0013_Men_Olive_1024x1024.jpg?v=1488698479'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000008182',\n",
" 'url': 'http://images.slideplayer.com/5/1557963/slides/slide_1.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000008196',\n",
" 'url': 'https://static.wixstatic.com/media/nsplsh_6f775a4137377252416963~mv2_d_4909_3264_s_4_2.jpg/v1/fill/w_454h_333fp_0.50_0.50q_90/nsplsh_6f775a4137377252416963~mv2_d_4909_3264_s_4_2.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000008232',\n",
" 'url': 'https://i1.wp.com/conference.virtualreality.to/wp-content/uploads/2019/05/Cream_1x1_logo-500.png?fit=500%2C500&ssl=1'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000008284',\n",
" 'url': 'https://truthernews.files.wordpress.com/2014/02/nba-ncaa-bio-terror-warning.jpg?w=385&'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000008295',\n",
" 'url': 'http://speed90calgary.com/content/images/thumbs/0001286_samsung_300.jpeg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000008322',\n",
" 'url': 'https://fernyhillretreat.blog/wp-content/uploads/2019/02/FHR-blog-logo-no-blog.png'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000008345',\n",
" 'url': 'https://s3.us-west-2.amazonaws.com/ycbm.production.upload.files/ycbm/NWk5WMYLoHitQCCzphdr/images/logotestforbookingcalendar.png'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000008378',\n",
" 'url': 'https://i.ytimg.com/vi/q9sfOGXWcAA/hqdefault.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000008398',\n",
" 'url': 'https://fonolive.com/US/ca/vannuys/17857513/05041519f02b3dd8b6fa1037c854b4c9.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000008412',\n",
" 'url': 'https://bookstore.firststepspublishing.com/wp-content/uploads/2017/07/SurvivingHitler_th.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000008455',\n",
" 'url': 'https://i2.wp.com/tkcoleman.wpengine.com/wp-content/uploads/2014/05/follow-me-and-i-ll-follow-back-2.png?resize=257%2C300'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000008511',\n",
" 'url': 'http://rlv.zcache.com/peace_love_juggle_round_stickers-r68cd2e9a0bb247f99b9a988d6d8e0d21_v9waf_8byvr_512.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000008560',\n",
" 'url': 'https://photos.bandsintown.com/thumb/6262168.jpeg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000008565',\n",
" 'url': 'https://www.fashionsvp.com/wp-content/uploads/2018/10/svp-logo-social-media.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000008594',\n",
" 'url': 'http://i2.ytimg.com/vi/UX-TX0_P9f4/0.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000008717',\n",
" 'url': 'https://i2.wp.com/asempanews.com/wp-content/uploads/2019/02/Emmanuel-Boateng-has-completed-his-move-to-Dalian-Yifang.jpg?resize=682%2C402&ssl=1'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000008740',\n",
" 'url': 'https://dshgames.ru/wp-content/uploads/2019/11/45178826.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000008763',\n",
" 'url': 'http://rlv.zcache.co.uk/he_loves_me_more_than_videogames_round_sticker-r695b34ab74b040f2b989cb2987bdf6b0_v9waf_8byvr_324.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000008870',\n",
" 'url': 'https://www.idplr.com/components/com_remository_files/file_image_12046/img_12046_01.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000008883',\n",
" 'url': 'https://matsuri.sc/sys/wp-content/uploads/2019/06/ma2k-600x491.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000008985',\n",
" 'url': 'http://a4.mzstatic.com/us/r1000/071/Purple/d0/5f/6e/mzm.caxvphqx.png'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000009070',\n",
" 'url': 'https://knickoftime.net/wp-content/uploads/2016/08/autumn-stencil-give-thanks.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000009122',\n",
" 'url': 'https://images.financialexpress.com/2019/04/upsc-2.jpg?w=660&h=440&imflag=true'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000009162',\n",
" 'url': 'https://images.amain.com/images/large/asc/asc89278.jpg?width=200'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000009228',\n",
" 'url': 'https://static1.squarespace.com/static/559abcdae4b078c942e5c735/t/5d5d4f0c7d731300013b9232/1568920539487/?format=1500w'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000009229',\n",
" 'url': 'http://direct.rhapsody.com/imageserver/images/Alb.169582/500x500.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000009306',\n",
" 'url': 'http://3.bp.blogspot.com/-baNJ0IO7XYM/T-T98u8iTVI/AAAAAAAAGJ0/c3elxsuWRhQ/s400/559b.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000009379',\n",
" 'url': 'http://ecx.images-amazon.com/images/I/51sSN7pB9bL.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000009507',\n",
" 'url': 'https://us.123rf.com/450wm/pinnacleanimates/pinnacleanimates1211/pinnacleanimates121100044/16131281-vector-happy-diwali-greeting-illustration.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000009627',\n",
" 'url': 'https://images.lookhuman.com/render/standard/0842006469058676/iphone7sn-whi-z1-t-i-drink-haterade-all-day.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000009708',\n",
" 'url': 'http://clubjerseys.net/pic/Nike-Dolphins--2325-Xavien-Howard-Orange-Women-27s-Stitched-NFL-Limited-Rush-Jersey-4399-17297.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000009727',\n",
" 'url': 'https://secureservercdn.net/198.71.233.109/zz0.685.myftpupload.com/wp-content/uploads/2019/11/CVS-CAT-DIGITAL.jpg?time=1594677716'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000009750',\n",
" 'url': 'http://ecx.images-amazon.com/images/I/61Glg3X8kXL.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000009813',\n",
" 'url': 'https://static3.bigstockphoto.com/thumbs/1/4/1/large2/141030668.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000009860',\n",
" 'url': 'https://www.challengecoins.ca/wp-content/uploads/2019/05/Manitoba-Correctional-Services-Established-1871-316x316.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000009915',\n",
" 'url': 'https://s3.eu-central-1.amazonaws.com/kidsread-books/bossy-and-the-blue-elephant/thumbs/1.jpg'},\n",
" {'ex_idx': '00000',\n",
" 'in_idx': '000009990',\n",
" 'url': 'http://pic.rutube.ru/video/c8/02/c8026a8d3720e3c779ad2c2f5cdd5b7a.jpg'},\n",
" {'ex_idx': '00001',\n",
" 'in_idx': '000010044',\n",
" 'url': 'https://www.tamilkavithaihal.com/uploads/kadhal-Kavithaigal/kadhal-kavithaigal-photos-idhayam-thudippathu-unakaga-mattum-meera-tamil-kavithai-photos-download.jpg'},\n",
" {'ex_idx': '00001',\n",
" 'in_idx': '000010091',\n",
" 'url': 'https://d7olld39l2hok.cloudfront.net/logo/4214275.png'},\n",
" {'ex_idx': '00001',\n",
" 'in_idx': '000010187',\n",
" 'url': 'https://cdn.shopify.com/s/files/1/0243/7761/products/ScreenShot2020-06-03at4.50.27PM_380x@2x.png?v=1591226983'},\n",
" {'ex_idx': '00001',\n",
" 'in_idx': '000010232',\n",
" 'url': 'https://images.squarespace-cdn.com/content/563cb327e4b03fd23ffc5941/1511024795146-TVJKAJM1ME4G58MYGOXE/Pleasure%2BSnowboard%2BMagazin.jpeg?content-type=image%2Fjpeg'},\n",
" {'ex_idx': '00001',\n",
" 'in_idx': '000010234',\n",
" 'url': 'https://storage.googleapis.com/hipstamp/p/ea887acd95042517885d324fcac9254c-300.jpg'},\n",
" {'ex_idx': '00001',\n",
" 'in_idx': '000010238',\n",
" 'url': 'http://brokenequipment.com/viewer.php?p6Y2ma6u2spDa6P2V8ze8Vz88egg8x88bJYD'},\n",
" {'ex_idx': '00001',\n",
" 'in_idx': '000010277',\n",
" 'url': 'https://i0.wp.com/raksbooks.com/wp-content/uploads/2020/04/false-value-audiobook-by-ben-aaronovitch.jpg?fit=300%2C300&ssl=1'},\n",
" {'ex_idx': '00001',\n",
" 'in_idx': '000010296',\n",
" 'url': 'http://images.slideplayer.com/2/761664/slides/slide_7.jpg'},\n",
" {'ex_idx': '00001',\n",
" 'in_idx': '000010301',\n",
" 'url': 'http://ecx.images-amazon.com/images/I/61lt37IzjiL._SL300_.jpg'},\n",
" {'ex_idx': '00001',\n",
" 'in_idx': '000010303',\n",
" 'url': 'https://1.bp.blogspot.com/-F6lQA6MJvlg/WaR_xzhpzuI/AAAAAAAAHpE/nMkQJQTNHCY49S2FQ3q0J2gSc_FXf35fgCLcBGAs/s320/blog%2Bbutton.png'},\n",
" {'ex_idx': '00001',\n",
" 'in_idx': '000010330',\n",
" 'url': 'http://edtech.wwcsd.net/wp-content/uploads/2017/06/technology-equipment.png'},\n",
" {'ex_idx': '00001',\n",
" 'in_idx': '000010387',\n",
" 'url': 'https://1.bp.blogspot.com/-Vei8-b26r_o/XtjQdMndLyI/AAAAAAAAs-E/X0js5p954gYZ4g1glJXfOMKwS4zrbSevQCLcBGAsYHQ/s1600/Verse-of-the-Day.jpg'},\n",
" {'ex_idx': '00001',\n",
" 'in_idx': '000010420',\n",
" 'url': 'https://www.investbypro.com/wp-content/uploads/2020/03/National-Savings-Certificates-min.jpg'},\n",
" {'ex_idx': '00001',\n",
" 'in_idx': '000010438',\n",
" 'url': 'https://s1.dmcdn.net/v/H0QPw1Nl0vN9hGfMZ/x720'},\n",
" {'ex_idx': '00001',\n",
" 'in_idx': '000010464',\n",
" 'url': 'http://rlv.zcache.ca/i_was_born_to_play_the_drums_mousepads-r0ea790343aa6467085c35e645eedd7f4_x74vi_8byvr_324.jpg'},\n",
" {'ex_idx': '00001',\n",
" 'in_idx': '000010482',\n",
" 'url': 'https://i.pinimg.com/originals/1b/7b/e5/1b7be564de6e47f0e39731cdec34b166.jpg'},\n",
" {'ex_idx': '00001',\n",
" 'in_idx': '000010514',\n",
" 'url': 'https://dynamic.brandcrowd.com/asset/logo/69918387-908c-4f04-be1f-61f5d2bab958/logo?v=4&text=Logo+Text+Here'},\n",
" {'ex_idx': '00001',\n",
" 'in_idx': '000010550',\n",
" 'url': 'https://ss.shayanashop.com/oi/slider/Kaleidoskope/Kaleidoskope_580x319pix_EN.jpg'},\n",
" {'ex_idx': '00001',\n",
" 'in_idx': '000010634',\n",
" 'url': 'https://images.bwbcovers.com/006/The-Art-of-Loving-Fromm-Erich-9780060958282.jpg'},\n",
" {'ex_idx': '00001',\n",
" 'in_idx': '000010677',\n",
" 'url': 'https://images-na.ssl-images-amazon.com/images/S/cmx-images-prod/Item/735067/735067._SX312_QL80_TTD_.jpg'},\n",
" {'ex_idx': '00001',\n",
" 'in_idx': '000010718',\n",
" 'url': 'http://gumps.scene7.com/is/image/Gumps/168992_is?$PIP_Main$'},\n",
" {'ex_idx': '00001',\n",
" 'in_idx': '000010748',\n",
" 'url': 'https://pbcdn1.podbean.com/imglogo/image-logo/2577245/Bad_Reception_Large.png'},\n",
" {'ex_idx': '00001',\n",
" 'in_idx': '000010799',\n",
" 'url': 'https://ducttapeanddenim.com/wp-content/uploads/2018/04/Before-and-after-spring-green-jewelry-cabinet-DuctTapeAndDenim.com_-1024x1024-600x600.jpg'},\n",
" {'ex_idx': '00001',\n",
" 'in_idx': '000010857',\n",
" 'url': 'http://www.playingrockguitar.com/wp-content/uploads/2009/12/Dis_Pedal-300x266.jpg'},\n",
" {'ex_idx': '00001',\n",
" 'in_idx': '000010929',\n",
" 'url': 'http://4.bp.blogspot.com/-x51sJBXY_Ys/U7LkGTKuRrI/AAAAAAAAFPw/qgGCgMLx4e4/s300/summerfest.jpg'},\n",
" {'ex_idx': '00001',\n",
" 'in_idx': '000010931',\n",
" 'url': 'https://img.youtube.com/vi/Y4DoPk0JLvc/0.jpg'},\n",
" {'ex_idx': '00001',\n",
" 'in_idx': '000010957',\n",
" 'url': 'https://purvesinsurance.com/wp-content/uploads/2015/08/Fotolia_87325583_Subscription_Monthly_M-1024x682.jpg'},\n",
" {'ex_idx': '00001',\n",
" 'in_idx': '000010962',\n",
" 'url': 'https://i.ytimg.com/vi/Sh2A48Unh4s/hqdefault.jpg'},\n",
" {'ex_idx': '00001',\n",
" 'in_idx': '000010976',\n",
" 'url': 'https://i0.wp.com/www.theartofcoachingvolleyball.com/wp-content/uploads/2016/06/Attacking-Comprehensive-Course.png?fit=264%2C264&ssl=1'},\n",
" {'ex_idx': '00001',\n",
" 'in_idx': '000011036',\n",
" 'url': 'http://obscure-abhorrence.de/cover/21508trifixionthefirstandthelastcommandment120151208.jpg'},\n",
" {'ex_idx': '00001',\n",
" 'in_idx': '000011053',\n",
" 'url': 'http://img1.imagesbn.com/
gitextract_cem8xir5/ ├── .gitignore ├── LICENSE ├── README.md ├── configs/ │ ├── dataset/ │ │ ├── icd13.yaml │ │ ├── locr.yaml │ │ ├── st.yaml │ │ └── tsg.yaml │ ├── demo.yaml │ ├── pretrain.yaml │ ├── test/ │ │ └── textdesign_sd_2.yaml │ ├── test.yaml │ ├── train/ │ │ └── textdesign_sd_2.yaml │ └── train.yaml ├── dataset/ │ ├── __init__.py │ ├── dataloader.py │ └── utils/ │ └── words.txt ├── demo.py ├── metrics.py ├── pretrain.py ├── requirements.txt ├── scripts/ │ └── preprocess/ │ └── laion_ocr_pre.ipynb ├── sgm/ │ ├── __init__.py │ ├── lr_scheduler.py │ ├── models/ │ │ ├── __init__.py │ │ ├── autoencoder.py │ │ └── diffusion.py │ ├── modules/ │ │ ├── __init__.py │ │ ├── attention.py │ │ ├── autoencoding/ │ │ │ ├── __init__.py │ │ │ ├── losses/ │ │ │ │ └── __init__.py │ │ │ └── regularizers/ │ │ │ └── __init__.py │ │ ├── diffusionmodules/ │ │ │ ├── __init__.py │ │ │ ├── denoiser.py │ │ │ ├── denoiser_scaling.py │ │ │ ├── denoiser_weighting.py │ │ │ ├── discretizer.py │ │ │ ├── guiders.py │ │ │ ├── loss.py │ │ │ ├── model.py │ │ │ ├── openaimodel.py │ │ │ ├── sampling.py │ │ │ ├── sampling_utils.py │ │ │ ├── sigma_sampling.py │ │ │ ├── util.py │ │ │ └── wrappers.py │ │ ├── distributions/ │ │ │ ├── __init__.py │ │ │ └── distributions.py │ │ ├── ema.py │ │ ├── encoders/ │ │ │ ├── __init__.py │ │ │ └── modules.py │ │ └── predictors/ │ │ └── model.py │ └── util.py ├── src/ │ └── parseq/ │ ├── .gitignore │ ├── Datasets.md │ ├── LICENSE │ ├── NOTICE │ ├── README.md │ ├── bench.py │ ├── configs/ │ │ ├── bench.yaml │ │ ├── charset/ │ │ │ ├── 36_lowercase.yaml │ │ │ ├── 62_mixed-case.yaml │ │ │ └── 94_full.yaml │ │ ├── dataset/ │ │ │ ├── real.yaml │ │ │ └── synth.yaml │ │ ├── experiment/ │ │ │ ├── abinet-sv.yaml │ │ │ ├── abinet.yaml │ │ │ ├── crnn.yaml │ │ │ ├── parseq-patch16-224.yaml │ │ │ ├── parseq-tiny.yaml │ │ │ ├── parseq.yaml │ │ │ ├── trba.yaml │ │ │ ├── trbc.yaml │ │ │ ├── tune_abinet-lm.yaml │ │ │ └── vitstr.yaml │ │ ├── main.yaml │ │ ├── model/ │ │ │ ├── abinet.yaml │ │ │ ├── crnn.yaml │ │ │ ├── parseq.yaml │ │ │ ├── trba.yaml │ │ │ └── vitstr.yaml │ │ └── tune.yaml │ ├── hubconf.py │ ├── read.py │ ├── requirements.txt │ ├── setup.cfg │ ├── setup.py │ ├── strhub/ │ │ ├── __init__.py │ │ ├── data/ │ │ │ ├── __init__.py │ │ │ ├── aa_overrides.py │ │ │ ├── augment.py │ │ │ ├── dataset.py │ │ │ ├── module.py │ │ │ └── utils.py │ │ └── models/ │ │ ├── __init__.py │ │ ├── abinet/ │ │ │ ├── LICENSE │ │ │ ├── __init__.py │ │ │ ├── attention.py │ │ │ ├── backbone.py │ │ │ ├── model.py │ │ │ ├── model_abinet_iter.py │ │ │ ├── model_alignment.py │ │ │ ├── model_language.py │ │ │ ├── model_vision.py │ │ │ ├── resnet.py │ │ │ ├── system.py │ │ │ └── transformer.py │ │ ├── base.py │ │ ├── crnn/ │ │ │ ├── LICENSE │ │ │ ├── __init__.py │ │ │ ├── model.py │ │ │ └── system.py │ │ ├── modules.py │ │ ├── parseq/ │ │ │ ├── __init__.py │ │ │ ├── modules.py │ │ │ └── system.py │ │ ├── trba/ │ │ │ ├── __init__.py │ │ │ ├── feature_extraction.py │ │ │ ├── model.py │ │ │ ├── prediction.py │ │ │ ├── system.py │ │ │ └── transformation.py │ │ ├── utils.py │ │ └── vitstr/ │ │ ├── __init__.py │ │ ├── model.py │ │ └── system.py │ ├── test.py │ ├── tools/ │ │ ├── art_converter.py │ │ ├── case_sensitive_str_datasets_converter.py │ │ ├── coco_2_converter.py │ │ ├── coco_text_converter.py │ │ ├── create_lmdb_dataset.py │ │ ├── filter_lmdb.py │ │ ├── lsvt_converter.py │ │ ├── mlt19_converter.py │ │ ├── openvino_converter.py │ │ ├── test_abinet_lm_acc.py │ │ └── textocr_converter.py │ ├── train.py │ └── tune.py ├── test.py ├── train.py └── util.py
SYMBOL INDEX (767 symbols across 73 files)
FILE: dataset/dataloader.py
function region_draw_text (line 21) | def region_draw_text(H, W, r_bbox, text, font_path = "./dataset/utils/ar...
function initialize_word_dict (line 46) | def initialize_word_dict():
class LabelDataset (line 63) | class LabelDataset(data.Dataset):
method __init__ (line 65) | def __init__(self, size, length, font_path, min_len, max_len) -> None:
method __len__ (line 83) | def __len__(self):
method __getitem__ (line 87) | def __getitem__(self, index):
class ICDAR13Dataset (line 123) | class ICDAR13Dataset(data.Dataset):
method __init__ (line 125) | def __init__(self, cfgs, datype) -> None:
method __len__ (line 177) | def __len__(self):
method augment (line 181) | def augment(self, image, bbox):
method __getitem__ (line 242) | def __getitem__(self, index):
class TextSegDataset (line 292) | class TextSegDataset(data.Dataset):
method __init__ (line 294) | def __init__(self, cfgs, datype) -> None:
method __len__ (line 352) | def __len__(self):
method augment (line 356) | def augment(self, image, seg, text, bbox, seg_values):
method __getitem__ (line 436) | def __getitem__(self, index):
class SynthTextDataset (line 494) | class SynthTextDataset(data.Dataset):
method __init__ (line 496) | def __init__(self, cfgs, datype) -> None:
method __len__ (line 562) | def __len__(self):
method augment (line 566) | def augment(self, image, bbox, seg_bboxs):
method __getitem__ (line 645) | def __getitem__(self, index):
class LAIONOCRDataset (line 697) | class LAIONOCRDataset(data.Dataset):
method __init__ (line 699) | def __init__(self, cfgs, datype) -> None:
method __len__ (line 766) | def __len__(self):
method augment (line 770) | def augment(self, image, seg, text, bbox):
method __getitem__ (line 861) | def __getitem__(self, index):
function get_dataloader (line 925) | def get_dataloader(cfgs, datype="train"):
FILE: demo.py
function predict (line 15) | def predict(cfgs, model, sampler, batch):
function demo_predict (line 39) | def demo_predict(input_blk, text, num_samples, steps, scale, seed, show_...
FILE: metrics.py
function calc_fid (line 5) | def calc_fid(fake_dir, real_dir, batch_size=1, gpu='0'):
function calc_lpips (line 12) | def calc_lpips(fake_dir, real_dir):
FILE: pretrain.py
function get_dataloader (line 9) | def get_dataloader(cfgs):
function get_model (line 16) | def get_model(cfgs):
function train (line 24) | def train(cfgs):
FILE: sgm/lr_scheduler.py
class LambdaWarmUpCosineScheduler (line 4) | class LambdaWarmUpCosineScheduler:
method __init__ (line 9) | def __init__(
method schedule (line 26) | def schedule(self, n, **kwargs):
method __call__ (line 47) | def __call__(self, n, **kwargs):
class LambdaWarmUpCosineScheduler2 (line 51) | class LambdaWarmUpCosineScheduler2:
method __init__ (line 57) | def __init__(
method find_in_interval (line 76) | def find_in_interval(self, n):
method schedule (line 83) | def schedule(self, n, **kwargs):
method __call__ (line 109) | def __call__(self, n, **kwargs):
class LambdaLinearScheduler (line 113) | class LambdaLinearScheduler(LambdaWarmUpCosineScheduler2):
method schedule (line 114) | def schedule(self, n, **kwargs):
FILE: sgm/models/autoencoder.py
class AbstractAutoencoder (line 18) | class AbstractAutoencoder(pl.LightningModule):
method __init__ (line 25) | def __init__(
method init_from_ckpt (line 49) | def init_from_ckpt(
method get_input (line 75) | def get_input(self, batch) -> Any:
method on_train_batch_end (line 78) | def on_train_batch_end(self, *args, **kwargs):
method ema_scope (line 84) | def ema_scope(self, context=None):
method encode (line 99) | def encode(self, *args, **kwargs) -> torch.Tensor:
method decode (line 103) | def decode(self, *args, **kwargs) -> torch.Tensor:
method instantiate_optimizer_from_config (line 106) | def instantiate_optimizer_from_config(self, params, lr, cfg):
method configure_optimizers (line 112) | def configure_optimizers(self) -> Any:
class AutoencodingEngine (line 116) | class AutoencodingEngine(AbstractAutoencoder):
method __init__ (line 123) | def __init__(
method get_input (line 145) | def get_input(self, batch: Dict) -> torch.Tensor:
method get_autoencoder_params (line 150) | def get_autoencoder_params(self) -> list:
method get_discriminator_params (line 159) | def get_discriminator_params(self) -> list:
method get_last_layer (line 163) | def get_last_layer(self):
method encode (line 166) | def encode(self, x: Any, return_reg_log: bool = False) -> Any:
method decode (line 173) | def decode(self, z: Any) -> torch.Tensor:
method forward (line 177) | def forward(self, x: Any) -> Tuple[torch.Tensor, torch.Tensor, torch.T...
method training_step (line 182) | def training_step(self, batch, batch_idx, optimizer_idx) -> Any:
method validation_step (line 219) | def validation_step(self, batch, batch_idx) -> Dict:
method _validation_step (line 226) | def _validation_step(self, batch, batch_idx, postfix="") -> Dict:
method configure_optimizers (line 254) | def configure_optimizers(self) -> Any:
method log_images (line 270) | def log_images(self, batch: Dict, **kwargs) -> Dict:
class AutoencoderKL (line 282) | class AutoencoderKL(AutoencodingEngine):
method __init__ (line 283) | def __init__(self, embed_dim: int, **kwargs):
method encode (line 304) | def encode(self, x):
method decode (line 313) | def decode(self, z, **decoder_kwargs):
class AutoencoderKLInferenceWrapper (line 319) | class AutoencoderKLInferenceWrapper(AutoencoderKL):
method encode (line 320) | def encode(self, x):
class IdentityFirstStage (line 324) | class IdentityFirstStage(AbstractAutoencoder):
method __init__ (line 325) | def __init__(self, *args, **kwargs):
method get_input (line 328) | def get_input(self, x: Any) -> Any:
method encode (line 331) | def encode(self, x: Any, *args, **kwargs) -> Any:
method decode (line 334) | def decode(self, x: Any, *args, **kwargs) -> Any:
FILE: sgm/models/diffusion.py
class DiffusionEngine (line 22) | class DiffusionEngine(pl.LightningModule):
method __init__ (line 23) | def __init__(
method init_from_ckpt (line 87) | def init_from_ckpt(
method freeze (line 107) | def freeze(self):
method _init_first_stage (line 112) | def _init_first_stage(self, config):
method get_input (line 119) | def get_input(self, batch):
method decode_first_stage (line 125) | def decode_first_stage(self, z):
method encode_first_stage (line 132) | def encode_first_stage(self, x):
method forward (line 138) | def forward(self, x, batch):
method shared_step (line 144) | def shared_step(self, batch: Dict) -> Any:
method training_step (line 151) | def training_step(self, batch, batch_idx):
method on_train_start (line 174) | def on_train_start(self, *args, **kwargs):
method on_train_batch_end (line 178) | def on_train_batch_end(self, *args, **kwargs):
method ema_scope (line 183) | def ema_scope(self, context=None):
method instantiate_optimizer_from_config (line 197) | def instantiate_optimizer_from_config(self, params, lr, cfg):
method configure_optimizers (line 202) | def configure_optimizers(self):
method sample (line 225) | def sample(
method log_conditionings (line 242) | def log_conditionings(self, batch: Dict, n: int) -> Dict:
method log_images (line 281) | def log_images(
FILE: sgm/modules/attention.py
function exists (line 19) | def exists(val):
function uniq (line 23) | def uniq(arr):
function default (line 27) | def default(val, d):
function max_neg_value (line 33) | def max_neg_value(t):
function init_ (line 37) | def init_(tensor):
class GEGLU (line 44) | class GEGLU(nn.Module):
method __init__ (line 45) | def __init__(self, dim_in, dim_out):
method forward (line 49) | def forward(self, x):
class FeedForward (line 54) | class FeedForward(nn.Module):
method __init__ (line 55) | def __init__(self, dim, dim_out=None, mult=4, glu=False, dropout=0.0):
method forward (line 69) | def forward(self, x):
function zero_module (line 73) | def zero_module(module):
function Normalize (line 82) | def Normalize(in_channels):
class LinearAttention (line 88) | class LinearAttention(nn.Module):
method __init__ (line 89) | def __init__(self, dim, heads=4, dim_head=32):
method forward (line 96) | def forward(self, x):
class CrossAttention (line 111) | class CrossAttention(nn.Module):
method __init__ (line 112) | def __init__(
method forward (line 140) | def forward(
class MemoryEfficientCrossAttention (line 177) | class MemoryEfficientCrossAttention(nn.Module):
method __init__ (line 179) | def __init__(
method forward (line 202) | def forward(
class BasicTransformerBlock (line 265) | class BasicTransformerBlock(nn.Module):
method __init__ (line 267) | def __init__(
method forward (line 314) | def forward(self, x, t_context=None, v_context=None):
class SpatialTransformer (line 344) | class SpatialTransformer(nn.Module):
method __init__ (line 354) | def __init__(
method forward (line 398) | def forward(self, x, t_context=None, v_context=None):
FILE: sgm/modules/autoencoding/losses/__init__.py
function adopt_weight (line 13) | def adopt_weight(weight, global_step, threshold=0, value=0.0):
class LatentLPIPS (line 19) | class LatentLPIPS(nn.Module):
method __init__ (line 20) | def __init__(
method init_decoder (line 38) | def init_decoder(self, config):
method forward (line 43) | def forward(self, latent_inputs, latent_predictions, image_inputs, spl...
class GeneralLPIPSWithDiscriminator (line 87) | class GeneralLPIPSWithDiscriminator(nn.Module):
method __init__ (line 88) | def __init__(
method get_trainable_parameters (line 129) | def get_trainable_parameters(self) -> Any:
method get_trainable_autoencoder_parameters (line 132) | def get_trainable_autoencoder_parameters(self) -> Any:
method calculate_adaptive_weight (line 137) | def calculate_adaptive_weight(self, nll_loss, g_loss, last_layer=None):
method forward (line 154) | def forward(
FILE: sgm/modules/autoencoding/regularizers/__init__.py
class AbstractRegularizer (line 11) | class AbstractRegularizer(nn.Module):
method __init__ (line 12) | def __init__(self):
method forward (line 15) | def forward(self, z: torch.Tensor) -> Tuple[torch.Tensor, dict]:
method get_trainable_parameters (line 19) | def get_trainable_parameters(self) -> Any:
class DiagonalGaussianRegularizer (line 23) | class DiagonalGaussianRegularizer(AbstractRegularizer):
method __init__ (line 24) | def __init__(self, sample: bool = True):
method get_trainable_parameters (line 28) | def get_trainable_parameters(self) -> Any:
method forward (line 31) | def forward(self, z: torch.Tensor) -> Tuple[torch.Tensor, dict]:
function measure_perplexity (line 44) | def measure_perplexity(predicted_indices, num_centroids):
FILE: sgm/modules/diffusionmodules/denoiser.py
class Denoiser (line 6) | class Denoiser(nn.Module):
method __init__ (line 7) | def __init__(self, weighting_config, scaling_config):
method possibly_quantize_sigma (line 13) | def possibly_quantize_sigma(self, sigma):
method possibly_quantize_c_noise (line 16) | def possibly_quantize_c_noise(self, c_noise):
method w (line 19) | def w(self, sigma):
method __call__ (line 22) | def __call__(self, network, input, sigma, cond):
class DiscreteDenoiser (line 31) | class DiscreteDenoiser(Denoiser):
method __init__ (line 32) | def __init__(
method sigma_to_idx (line 49) | def sigma_to_idx(self, sigma):
method idx_to_sigma (line 53) | def idx_to_sigma(self, idx):
method possibly_quantize_sigma (line 56) | def possibly_quantize_sigma(self, sigma):
method possibly_quantize_c_noise (line 59) | def possibly_quantize_c_noise(self, c_noise):
FILE: sgm/modules/diffusionmodules/denoiser_scaling.py
class EDMScaling (line 4) | class EDMScaling:
method __init__ (line 5) | def __init__(self, sigma_data=0.5):
method __call__ (line 8) | def __call__(self, sigma):
class EpsScaling (line 16) | class EpsScaling:
method __call__ (line 17) | def __call__(self, sigma):
class VScaling (line 25) | class VScaling:
method __call__ (line 26) | def __call__(self, sigma):
FILE: sgm/modules/diffusionmodules/denoiser_weighting.py
class UnitWeighting (line 4) | class UnitWeighting:
method __call__ (line 5) | def __call__(self, sigma):
class EDMWeighting (line 9) | class EDMWeighting:
method __init__ (line 10) | def __init__(self, sigma_data=0.5):
method __call__ (line 13) | def __call__(self, sigma):
class VWeighting (line 17) | class VWeighting(EDMWeighting):
method __init__ (line 18) | def __init__(self):
class EpsWeighting (line 22) | class EpsWeighting:
method __call__ (line 23) | def __call__(self, sigma):
FILE: sgm/modules/diffusionmodules/discretizer.py
function generate_roughly_equally_spaced_steps (line 10) | def generate_roughly_equally_spaced_steps(
class Discretization (line 16) | class Discretization:
method __call__ (line 17) | def __call__(self, n, do_append_zero=True, device="cpu", flip=False):
method get_sigmas (line 23) | def get_sigmas(self, n, device):
class EDMDiscretization (line 27) | class EDMDiscretization(Discretization):
method __init__ (line 28) | def __init__(self, sigma_min=0.02, sigma_max=80.0, rho=7.0):
method get_sigmas (line 33) | def get_sigmas(self, n, device="cpu"):
class LegacyDDPMDiscretization (line 41) | class LegacyDDPMDiscretization(Discretization):
method __init__ (line 42) | def __init__(
method get_sigmas (line 57) | def get_sigmas(self, n, device="cpu"):
FILE: sgm/modules/diffusionmodules/guiders.py
class VanillaCFG (line 8) | class VanillaCFG:
method __init__ (line 13) | def __init__(self, scale, dyn_thresh_config=None):
method __call__ (line 25) | def __call__(self, x, sigma):
method prepare_inputs (line 31) | def prepare_inputs(self, x, s, c, uc):
class IdentityGuider (line 43) | class IdentityGuider:
method __call__ (line 44) | def __call__(self, x, sigma):
method prepare_inputs (line 47) | def prepare_inputs(self, x, s, c, uc):
FILE: sgm/modules/diffusionmodules/loss.py
class StandardDiffusionLoss (line 11) | class StandardDiffusionLoss(nn.Module):
method __init__ (line 12) | def __init__(
method __call__ (line 36) | def __call__(self, network, denoiser, conditioner, input, batch, *args...
method get_diff_loss (line 60) | def get_diff_loss(self, model_output, target, w):
class FullLoss (line 71) | class FullLoss(StandardDiffusionLoss):
method __init__ (line 73) | def __init__(
method get_gaussian_kernel (line 103) | def get_gaussian_kernel(self, kernel_size=3, sigma=1, out_channels=3):
method __call__ (line 131) | def __call__(self, network, denoiser, conditioner, input, batch, first...
method get_ocr_loss (line 178) | def get_ocr_loss(self, model_output, r_bbox, label, first_stage_model,...
method get_min_local_loss (line 192) | def get_min_local_loss(self, attn_map_cache, mask, seg_mask):
method get_local_loss (line 237) | def get_local_loss(self, attn_map_cache, seg, seg_mask):
FILE: sgm/modules/diffusionmodules/model.py
function get_timestep_embedding (line 23) | def get_timestep_embedding(timesteps, embedding_dim):
function nonlinearity (line 44) | def nonlinearity(x):
function Normalize (line 49) | def Normalize(in_channels, num_groups=32):
class Upsample (line 55) | class Upsample(nn.Module):
method __init__ (line 56) | def __init__(self, in_channels, with_conv):
method forward (line 64) | def forward(self, x):
class Downsample (line 71) | class Downsample(nn.Module):
method __init__ (line 72) | def __init__(self, in_channels, with_conv):
method forward (line 81) | def forward(self, x):
class ResnetBlock (line 91) | class ResnetBlock(nn.Module):
method __init__ (line 92) | def __init__(
method forward (line 128) | def forward(self, x, temb):
class LinAttnBlock (line 151) | class LinAttnBlock(LinearAttention):
method __init__ (line 154) | def __init__(self, in_channels):
class AttnBlock (line 158) | class AttnBlock(nn.Module):
method __init__ (line 159) | def __init__(self, in_channels):
method attention (line 177) | def attention(self, h_: torch.Tensor) -> torch.Tensor:
method forward (line 194) | def forward(self, x, **kwargs):
class MemoryEfficientAttnBlock (line 201) | class MemoryEfficientAttnBlock(nn.Module):
method __init__ (line 209) | def __init__(self, in_channels):
method attention (line 228) | def attention(self, h_: torch.Tensor) -> torch.Tensor:
method forward (line 258) | def forward(self, x, **kwargs):
class MemoryEfficientCrossAttentionWrapper (line 265) | class MemoryEfficientCrossAttentionWrapper(MemoryEfficientCrossAttention):
method forward (line 266) | def forward(self, x, context=None, mask=None, **unused_kwargs):
function make_attn (line 274) | def make_attn(in_channels, attn_type="vanilla", attn_kwargs=None):
class Model (line 307) | class Model(nn.Module):
method __init__ (line 308) | def __init__(
method forward (line 429) | def forward(self, x, t=None, context=None):
method get_last_layer (line 478) | def get_last_layer(self):
class Encoder (line 482) | class Encoder(nn.Module):
method __init__ (line 483) | def __init__(
method forward (line 571) | def forward(self, x):
class Decoder (line 599) | class Decoder(nn.Module):
method __init__ (line 600) | def __init__(
method _make_attn (line 698) | def _make_attn(self) -> Callable:
method _make_resblock (line 701) | def _make_resblock(self) -> Callable:
method _make_conv (line 704) | def _make_conv(self) -> Callable:
method get_last_layer (line 707) | def get_last_layer(self, **kwargs):
method forward (line 710) | def forward(self, z, **kwargs):
FILE: sgm/modules/diffusionmodules/openaimodel.py
class Timestep (line 22) | class Timestep(nn.Module):
method __init__ (line 23) | def __init__(self, dim):
method forward (line 27) | def forward(self, t):
class TimestepBlock (line 31) | class TimestepBlock(nn.Module):
method forward (line 37) | def forward(self, x, emb):
class TimestepEmbedSequential (line 43) | class TimestepEmbedSequential(nn.Sequential, TimestepBlock):
method forward (line 49) | def forward(
class Upsample (line 66) | class Upsample(nn.Module):
method __init__ (line 75) | def __init__(
method forward (line 89) | def forward(self, x):
class Downsample (line 105) | class Downsample(nn.Module):
method __init__ (line 114) | def __init__(
method forward (line 144) | def forward(self, x):
class ResBlock (line 149) | class ResBlock(TimestepBlock):
method __init__ (line 154) | def __init__(
method forward (line 242) | def forward(self, x, emb):
class UnifiedUNetModel (line 275) | class UnifiedUNetModel(nn.Module):
method __init__ (line 277) | def __init__(
method clear_attn_map (line 552) | def clear_attn_map(self):
method save_attn_map (line 559) | def save_attn_map(self, attn_type="t_attn", save_name="temp", tokens=""):
method forward (line 593) | def forward(self, x, timesteps=None, t_context=None, v_context=None, y...
FILE: sgm/modules/diffusionmodules/sampling.py
class BaseDiffusionSampler (line 28) | class BaseDiffusionSampler:
method __init__ (line 29) | def __init__(
method prepare_sampling_loop (line 48) | def prepare_sampling_loop(self, x, cond, uc=None, num_steps=None):
method denoise (line 61) | def denoise(self, x, model, sigma, cond, uc):
method get_sigma_gen (line 66) | def get_sigma_gen(self, num_sigmas, init_step=0):
class SingleStepDiffusionSampler (line 81) | class SingleStepDiffusionSampler(BaseDiffusionSampler):
method sampler_step (line 82) | def sampler_step(self, sigma, next_sigma, denoiser, x, cond, uc, *args...
method euler_step (line 85) | def euler_step(self, x, d, dt):
class EDMSampler (line 89) | class EDMSampler(SingleStepDiffusionSampler):
method __init__ (line 90) | def __init__(
method sampler_step (line 100) | def sampler_step(self, sigma, next_sigma, denoiser, x, cond, uc=None, ...
method __call__ (line 116) | def __call__(self, denoiser, x, cond, uc=None, num_steps=None):
class AncestralSampler (line 140) | class AncestralSampler(SingleStepDiffusionSampler):
method __init__ (line 141) | def __init__(self, eta=1.0, s_noise=1.0, *args, **kwargs):
method ancestral_euler_step (line 148) | def ancestral_euler_step(self, x, denoised, sigma, sigma_down):
method ancestral_step (line 154) | def ancestral_step(self, x, sigma, next_sigma, sigma_up):
method __call__ (line 162) | def __call__(self, denoiser, x, cond, uc=None, num_steps=None):
class LinearMultistepSampler (line 180) | class LinearMultistepSampler(BaseDiffusionSampler):
method __init__ (line 181) | def __init__(
method __call__ (line 191) | def __call__(self, denoiser, x, cond, uc=None, num_steps=None, **kwargs):
class EulerEDMSampler (line 218) | class EulerEDMSampler(EDMSampler):
method possible_correction_step (line 220) | def possible_correction_step(
method get_c_noise (line 225) | def get_c_noise(self, x, model, sigma):
method attend_and_excite (line 233) | def attend_and_excite(self, x, model, sigma, cond, batch, alpha, iter_...
method save_segment_map (line 254) | def save_segment_map(self, attn_maps, tokens=None, save_name=None):
method get_init_noise (line 264) | def get_init_noise(self, cfgs, model, cond, batch, uc=None):
method sampler_step (line 324) | def sampler_step(self, sigma, next_sigma, model, x, cond, batch=None, ...
method __call__ (line 355) | def __call__(self, model, x, cond, batch=None, uc=None, num_steps=None...
class HeunEDMSampler (line 423) | class HeunEDMSampler(EDMSampler):
method possible_correction_step (line 424) | def possible_correction_step(
class EulerAncestralSampler (line 442) | class EulerAncestralSampler(AncestralSampler):
method sampler_step (line 443) | def sampler_step(self, sigma, next_sigma, denoiser, x, cond, uc):
class DPMPP2SAncestralSampler (line 452) | class DPMPP2SAncestralSampler(AncestralSampler):
method get_variables (line 453) | def get_variables(self, sigma, sigma_down):
method get_mult (line 459) | def get_mult(self, h, s, t, t_next):
method sampler_step (line 467) | def sampler_step(self, sigma, next_sigma, denoiser, x, cond, uc=None, ...
class DPMPP2MSampler (line 492) | class DPMPP2MSampler(BaseDiffusionSampler):
method get_variables (line 493) | def get_variables(self, sigma, next_sigma, previous_sigma=None):
method get_mult (line 504) | def get_mult(self, h, r, t, t_next, previous_sigma):
method sampler_step (line 515) | def sampler_step(
method __call__ (line 549) | def __call__(self, denoiser, x, cond, uc=None, num_steps=None, init_st...
FILE: sgm/modules/diffusionmodules/sampling_utils.py
class NoDynamicThresholding (line 7) | class NoDynamicThresholding:
method __call__ (line 8) | def __call__(self, uncond, cond, scale):
function linear_multistep_coeff (line 12) | def linear_multistep_coeff(order, t, i, j, epsrel=1e-4):
function get_ancestral_step (line 27) | def get_ancestral_step(sigma_from, sigma_to, eta=1.0):
function to_d (line 39) | def to_d(x, sigma, denoised):
function to_neg_log_sigma (line 43) | def to_neg_log_sigma(sigma):
function to_sigma (line 47) | def to_sigma(neg_log_sigma):
FILE: sgm/modules/diffusionmodules/sigma_sampling.py
class EDMSampling (line 6) | class EDMSampling:
method __init__ (line 7) | def __init__(self, p_mean=-1.2, p_std=1.2):
method __call__ (line 11) | def __call__(self, n_samples, rand=None):
class DiscreteSampling (line 16) | class DiscreteSampling:
method __init__ (line 17) | def __init__(self, discretization_config, num_idx, do_append_zero=Fals...
method idx_to_sigma (line 23) | def idx_to_sigma(self, idx):
method __call__ (line 26) | def __call__(self, n_samples, rand=None):
FILE: sgm/modules/diffusionmodules/util.py
function make_beta_schedule (line 19) | def make_beta_schedule(
function extract_into_tensor (line 35) | def extract_into_tensor(a, t, x_shape):
function mixed_checkpoint (line 41) | def mixed_checkpoint(func, inputs: dict, params, flag):
class MixedCheckpointFunction (line 77) | class MixedCheckpointFunction(torch.autograd.Function):
method forward (line 79) | def forward(
method backward (line 119) | def backward(ctx, *output_grads):
function checkpoint (line 153) | def checkpoint(func, inputs, params, flag):
class CheckpointFunction (line 170) | class CheckpointFunction(torch.autograd.Function):
method forward (line 172) | def forward(ctx, run_function, length, *args):
method backward (line 186) | def backward(ctx, *output_grads):
function timestep_embedding (line 206) | def timestep_embedding(timesteps, dim, max_period=10000, repeat_only=Fal...
function zero_module (line 233) | def zero_module(module):
function scale_module (line 242) | def scale_module(module, scale):
function mean_flat (line 251) | def mean_flat(tensor):
function normalization (line 258) | def normalization(channels):
class SiLU (line 268) | class SiLU(nn.Module):
method forward (line 269) | def forward(self, x):
class GroupNorm32 (line 273) | class GroupNorm32(nn.GroupNorm):
method forward (line 274) | def forward(self, x):
function conv_nd (line 278) | def conv_nd(dims, *args, **kwargs):
function linear (line 291) | def linear(*args, **kwargs):
function avg_pool_nd (line 298) | def avg_pool_nd(dims, *args, **kwargs):
FILE: sgm/modules/diffusionmodules/wrappers.py
class IdentityWrapper (line 8) | class IdentityWrapper(nn.Module):
method __init__ (line 9) | def __init__(self, diffusion_model, compile_model: bool = False):
method forward (line 19) | def forward(self, *args, **kwargs):
class OpenAIWrapper (line 23) | class OpenAIWrapper(IdentityWrapper):
method forward (line 24) | def forward(
FILE: sgm/modules/distributions/distributions.py
class AbstractDistribution (line 5) | class AbstractDistribution:
method sample (line 6) | def sample(self):
method mode (line 9) | def mode(self):
class DiracDistribution (line 13) | class DiracDistribution(AbstractDistribution):
method __init__ (line 14) | def __init__(self, value):
method sample (line 17) | def sample(self):
method mode (line 20) | def mode(self):
class DiagonalGaussianDistribution (line 24) | class DiagonalGaussianDistribution(object):
method __init__ (line 25) | def __init__(self, parameters, deterministic=False):
method sample (line 37) | def sample(self):
method kl (line 43) | def kl(self, other=None):
method nll (line 62) | def nll(self, sample, dims=[1, 2, 3]):
method mode (line 71) | def mode(self):
function normal_kl (line 75) | def normal_kl(mean1, logvar1, mean2, logvar2):
FILE: sgm/modules/ema.py
class LitEma (line 5) | class LitEma(nn.Module):
method __init__ (line 6) | def __init__(self, model, decay=0.9999, use_num_upates=True):
method reset_num_updates (line 29) | def reset_num_updates(self):
method forward (line 33) | def forward(self, model):
method copy_to (line 56) | def copy_to(self, model):
method store (line 65) | def store(self, parameters):
method restore (line 74) | def restore(self, parameters):
FILE: sgm/modules/encoders/modules.py
class AbstractEmbModel (line 48) | class AbstractEmbModel(nn.Module):
method __init__ (line 49) | def __init__(self):
method is_trainable (line 57) | def is_trainable(self) -> bool:
method ucg_rate (line 61) | def ucg_rate(self) -> Union[float, torch.Tensor]:
method input_key (line 65) | def input_key(self) -> str:
method emb_key (line 69) | def emb_key(self) -> str:
method is_trainable (line 73) | def is_trainable(self, value: bool):
method ucg_rate (line 77) | def ucg_rate(self, value: Union[float, torch.Tensor]):
method input_key (line 81) | def input_key(self, value: str):
method emb_key (line 85) | def emb_key(self, value: str):
method is_trainable (line 89) | def is_trainable(self):
method ucg_rate (line 93) | def ucg_rate(self):
method input_key (line 97) | def input_key(self):
method emb_key (line 101) | def emb_key(self):
class GeneralConditioner (line 105) | class GeneralConditioner(nn.Module):
method __init__ (line 110) | def __init__(self, emb_models: Union[List, ListConfig]):
method possibly_get_ucg_val (line 145) | def possibly_get_ucg_val(self, embedder: AbstractEmbModel, batch: Dict...
method forward (line 154) | def forward(
method get_unconditional_conditioning (line 203) | def get_unconditional_conditioning(
class InceptionV3 (line 220) | class InceptionV3(nn.Module):
method __init__ (line 224) | def __init__(self, normalize_input=False, **kwargs):
method forward (line 231) | def forward(self, inp):
class IdentityEncoder (line 246) | class IdentityEncoder(AbstractEmbModel):
method encode (line 247) | def encode(self, x):
method freeze (line 249) | def freeze(self):
method forward (line 251) | def forward(self, x):
class ClassEmbedder (line 255) | class ClassEmbedder(AbstractEmbModel):
method __init__ (line 256) | def __init__(self, embed_dim, n_classes=1000, add_sequence_dim=False):
method forward (line 262) | def forward(self, c):
method get_unconditional_conditioning (line 268) | def get_unconditional_conditioning(self, bs, device="cuda"):
class ClassEmbedderForMultiCond (line 277) | class ClassEmbedderForMultiCond(ClassEmbedder):
method forward (line 278) | def forward(self, batch, key=None, disable_dropout=False):
class FrozenT5Embedder (line 289) | class FrozenT5Embedder(AbstractEmbModel):
method __init__ (line 292) | def __init__(
method freeze (line 303) | def freeze(self):
method forward (line 310) | def forward(self, text):
method encode (line 326) | def encode(self, text):
class FrozenByT5Embedder (line 330) | class FrozenByT5Embedder(AbstractEmbModel):
method __init__ (line 335) | def __init__(
method freeze (line 346) | def freeze(self):
method forward (line 351) | def forward(self, text):
method encode (line 367) | def encode(self, text):
class FrozenCLIPEmbedder (line 371) | class FrozenCLIPEmbedder(AbstractEmbModel):
method __init__ (line 376) | def __init__(
method freeze (line 401) | def freeze(self):
method forward (line 407) | def forward(self, text):
method encode (line 432) | def encode(self, text):
class FrozenOpenCLIPEmbedder2 (line 436) | class FrozenOpenCLIPEmbedder2(AbstractEmbModel):
method __init__ (line 443) | def __init__(
method freeze (line 478) | def freeze(self):
method forward (line 484) | def forward(self, text):
method encode_with_transformer (line 495) | def encode_with_transformer(self, text):
method pool (line 512) | def pool(self, x, text):
method text_transformer_forward (line 520) | def text_transformer_forward(self, x: torch.Tensor, attn_mask=None):
method encode (line 535) | def encode(self, text):
class FrozenOpenCLIPEmbedder (line 539) | class FrozenOpenCLIPEmbedder(AbstractEmbModel):
method __init__ (line 546) | def __init__(
method freeze (line 575) | def freeze(self):
method forward (line 580) | def forward(self, text):
method encode_with_transformer (line 586) | def encode_with_transformer(self, text):
method text_transformer_forward (line 595) | def text_transformer_forward(self, x: torch.Tensor, attn_mask=None):
method encode (line 608) | def encode(self, text):
class FrozenOpenCLIPImageEmbedder (line 612) | class FrozenOpenCLIPImageEmbedder(AbstractEmbModel):
method __init__ (line 617) | def __init__(
method preprocess (line 661) | def preprocess(self, x):
method freeze (line 675) | def freeze(self):
method forward (line 681) | def forward(self, image, no_dropout=False):
method encode_with_vision_transformer (line 734) | def encode_with_vision_transformer(self, img):
method encode (line 768) | def encode(self, text):
class FrozenCLIPT5Encoder (line 772) | class FrozenCLIPT5Encoder(AbstractEmbModel):
method __init__ (line 773) | def __init__(
method encode (line 791) | def encode(self, text):
method forward (line 794) | def forward(self, text):
class SpatialRescaler (line 800) | class SpatialRescaler(AbstractEmbModel):
method __init__ (line 801) | def __init__(
method freeze (line 840) | def freeze(self):
method forward (line 843) | def forward(self, x):
method encode (line 859) | def encode(self, x):
class LowScaleEncoder (line 863) | class LowScaleEncoder(nn.Module):
method __init__ (line 864) | def __init__(
method register_schedule (line 883) | def register_schedule(
method q_sample (line 931) | def q_sample(self, x_start, t, noise=None):
method forward (line 939) | def forward(self, x):
method decode (line 953) | def decode(self, z):
class ConcatTimestepEmbedderND (line 958) | class ConcatTimestepEmbedderND(AbstractEmbModel):
method __init__ (line 961) | def __init__(self, outdim):
method freeze (line 966) | def freeze(self):
method forward (line 969) | def forward(self, x):
class GaussianEncoder (line 980) | class GaussianEncoder(Encoder, AbstractEmbModel):
method __init__ (line 981) | def __init__(
method forward (line 989) | def forward(self, x) -> Tuple[Dict, torch.Tensor]:
class LatentEncoder (line 999) | class LatentEncoder(AbstractEmbModel):
method __init__ (line 1001) | def __init__(self, scale_factor, config, *args, **kwargs):
method freeze (line 1007) | def freeze(self):
method forward (line 1011) | def forward(self, x):
class ViTSTREncoder (line 1017) | class ViTSTREncoder(VisionTransformer):
method __init__ (line 1021) | def __init__(self, size=224, ckpt_path=None, freeze=True, *args, **kwa...
method reset_classifier (line 1036) | def reset_classifier(self, num_classes):
method freeze (line 1040) | def freeze(self):
method forward_features (line 1044) | def forward_features(self, x):
method forward (line 1059) | def forward(self, x):
method encode (line 1065) | def encode(self, x):
class PositionalEncoding (line 1069) | class PositionalEncoding(nn.Module):
method __init__ (line 1071) | def __init__(self, d_model, dropout=0.1, max_len=5000):
method forward (line 1083) | def forward(self, x):
class LabelEncoder (line 1088) | class LabelEncoder(AbstractEmbModel, pl.LightningModule):
method __init__ (line 1090) | def __init__(self, max_len, emb_dim, n_heads=8, n_trans_layers=12, ckp...
method freeze (line 1145) | def freeze(self):
method get_index (line 1149) | def get_index(self, labels):
method get_embeddings (line 1160) | def get_embeddings(self, x):
method forward (line 1168) | def forward(self, labels):
method get_loss (line 1175) | def get_loss(self, text_out, visual_out, clip_target, cls_out, pos_out...
method training_step (line 1193) | def training_step(self, batch, batch_idx):
method configure_optimizers (line 1239) | def configure_optimizers(self):
FILE: sgm/modules/predictors/model.py
class ParseqPredictor (line 7) | class ParseqPredictor(nn.Module):
method __init__ (line 9) | def __init__(self, ckpt_path=None, freeze=True, *args, **kwargs):
method freeze (line 22) | def freeze(self):
method forward (line 26) | def forward(self, x):
method img2txt (line 33) | def img2txt(self, x):
method calc_loss (line 40) | def calc_loss(self, x, label):
FILE: sgm/util.py
function disabled_train (line 14) | def disabled_train(self, mode=True):
function get_string_from_tuple (line 20) | def get_string_from_tuple(s):
function is_power_of_two (line 36) | def is_power_of_two(n):
function autocast (line 52) | def autocast(f, enabled=True):
function load_partial_from_config (line 64) | def load_partial_from_config(config):
function log_txt_as_img (line 68) | def log_txt_as_img(wh, xc, size=10):
function partialclass (line 98) | def partialclass(cls, *args, **kwargs):
function make_path_absolute (line 105) | def make_path_absolute(path):
function ismap (line 112) | def ismap(x):
function isimage (line 118) | def isimage(x):
function isheatmap (line 124) | def isheatmap(x):
function isneighbors (line 131) | def isneighbors(x):
function exists (line 137) | def exists(x):
function expand_dims_like (line 141) | def expand_dims_like(x, y):
function default (line 147) | def default(val, d):
function mean_flat (line 153) | def mean_flat(tensor):
function count_params (line 161) | def count_params(model, verbose=False):
function instantiate_from_config (line 168) | def instantiate_from_config(config):
function get_obj_from_str (line 178) | def get_obj_from_str(string, reload=False, invalidate_cache=True):
function append_zero (line 188) | def append_zero(x):
function append_dims (line 192) | def append_dims(x, target_dims):
function load_model_from_config (line 202) | def load_model_from_config(config, ckpt, verbose=True, freeze=True):
FILE: src/parseq/bench.py
function main (line 30) | def main(config: DictConfig):
FILE: src/parseq/hubconf.py
function parseq_tiny (line 7) | def parseq_tiny(pretrained: bool = False, decode_ar: bool = True, refine...
function parseq (line 17) | def parseq(pretrained: bool = False, decode_ar: bool = True, refine_iter...
function abinet (line 27) | def abinet(pretrained: bool = False, iter_size: int = 3, **kwargs):
function trba (line 36) | def trba(pretrained: bool = False, **kwargs):
function vitstr (line 44) | def vitstr(pretrained: bool = False, **kwargs):
function crnn (line 52) | def crnn(pretrained: bool = False, **kwargs):
FILE: src/parseq/read.py
function main (line 28) | def main():
FILE: src/parseq/strhub/data/aa_overrides.py
function rotate_expand (line 22) | def rotate_expand(img, degrees, **kwargs):
function _level_to_arg (line 28) | def _level_to_arg(level, hparams, key, default):
function apply (line 35) | def apply():
FILE: src/parseq/strhub/data/augment.py
function _get_op (line 30) | def _get_op(key, factory):
function _get_param (line 39) | def _get_param(level, img, max_dim_factor, min_level=1):
function gaussian_blur (line 44) | def gaussian_blur(img, radius, **__):
function motion_blur (line 51) | def motion_blur(img, k, **__):
function gaussian_noise (line 58) | def gaussian_noise(img, scale, **_):
function poisson_noise (line 65) | def poisson_noise(img, lam, **_):
function _level_to_arg (line 72) | def _level_to_arg(level, _hparams, max):
function rand_augment_transform (line 99) | def rand_augment_transform(magnitude=5, num_layers=3):
FILE: src/parseq/strhub/data/dataset.py
function build_tree_dataset (line 31) | def build_tree_dataset(root: Union[PurePath, str], *args, **kwargs):
class LmdbDataset (line 49) | class LmdbDataset(Dataset):
method __init__ (line 57) | def __init__(self, root: str, charset: str, max_label_len: int, min_im...
method __del__ (line 69) | def __del__(self):
method _create_env (line 74) | def _create_env(self):
method env (line 79) | def env(self):
method _preprocess_labels (line 84) | def _preprocess_labels(self, charset, remove_whitespace, normalize_uni...
method __len__ (line 118) | def __len__(self):
method __getitem__ (line 121) | def __getitem__(self, index):
FILE: src/parseq/strhub/data/module.py
class SceneTextDataModule (line 26) | class SceneTextDataModule(pl.LightningDataModule):
method __init__ (line 32) | def __init__(self, root_dir: str, train_dir: str, img_size: Sequence[i...
method get_transform (line 55) | def get_transform(img_size: Tuple[int], augment: bool = False, rotatio...
method train_dataset (line 70) | def train_dataset(self):
method val_dataset (line 80) | def val_dataset(self):
method train_dataloader (line 89) | def train_dataloader(self):
method val_dataloader (line 94) | def val_dataloader(self):
method test_dataloaders (line 99) | def test_dataloaders(self, subset):
FILE: src/parseq/strhub/data/utils.py
class CharsetAdapter (line 26) | class CharsetAdapter:
method __init__ (line 29) | def __init__(self, target_charset) -> None:
method __call__ (line 35) | def __call__(self, label):
class BaseTokenizer (line 45) | class BaseTokenizer(ABC):
method __init__ (line 47) | def __init__(self, charset: str, specials_first: tuple = (), specials_...
method __len__ (line 51) | def __len__(self):
method _tok2ids (line 54) | def _tok2ids(self, tokens: str) -> List[int]:
method _ids2tok (line 57) | def _ids2tok(self, token_ids: List[int], join: bool = True) -> str:
method encode (line 62) | def encode(self, labels: List[str], device: Optional[torch.device] = N...
method _filter (line 75) | def _filter(self, probs: Tensor, ids: Tensor) -> Tuple[Tensor, List[in...
method decode (line 79) | def decode(self, token_dists: Tensor, raw: bool = False) -> Tuple[List...
class Tokenizer (line 102) | class Tokenizer(BaseTokenizer):
method __init__ (line 107) | def __init__(self, charset: str) -> None:
method encode (line 113) | def encode(self, labels: List[str], device: Optional[torch.device] = N...
method _filter (line 119) | def _filter(self, probs: Tensor, ids: Tensor) -> Tuple[Tensor, List[in...
class CTCTokenizer (line 131) | class CTCTokenizer(BaseTokenizer):
method __init__ (line 134) | def __init__(self, charset: str) -> None:
method encode (line 139) | def encode(self, labels: List[str], device: Optional[torch.device] = N...
method _filter (line 144) | def _filter(self, probs: Tensor, ids: Tensor) -> Tuple[Tensor, List[in...
FILE: src/parseq/strhub/models/abinet/attention.py
class Attention (line 7) | class Attention(nn.Module):
method __init__ (line 8) | def __init__(self, in_channels=512, max_length=25, n_feature=256):
method forward (line 20) | def forward(self, enc_output):
function encoder_layer (line 35) | def encoder_layer(in_c, out_c, k=3, s=2, p=1):
function decoder_layer (line 41) | def decoder_layer(in_c, out_c, k=3, s=1, p=1, mode='nearest', scale_fact...
class PositionAttention (line 50) | class PositionAttention(nn.Module):
method __init__ (line 51) | def __init__(self, max_length, in_channels=512, num_channels=64,
method forward (line 71) | def forward(self, x):
FILE: src/parseq/strhub/models/abinet/backbone.py
class ResTranformer (line 8) | class ResTranformer(nn.Module):
method __init__ (line 9) | def __init__(self, d_model=512, nhead=8, d_inner=2048, dropout=0.1, ac...
method forward (line 17) | def forward(self, images):
FILE: src/parseq/strhub/models/abinet/model.py
class Model (line 5) | class Model(nn.Module):
method __init__ (line 7) | def __init__(self, dataset_max_length: int, null_label: int):
method _get_length (line 12) | def _get_length(self, logit, dim=-1):
method _get_padding_mask (line 22) | def _get_padding_mask(length, max_length):
method _get_location_mask (line 28) | def _get_location_mask(sz, device=None):
FILE: src/parseq/strhub/models/abinet/model_abinet_iter.py
class ABINetIterModel (line 9) | class ABINetIterModel(nn.Module):
method __init__ (line 10) | def __init__(self, dataset_max_length, null_label, num_classes, iter_s...
method forward (line 24) | def forward(self, images):
FILE: src/parseq/strhub/models/abinet/model_alignment.py
class BaseAlignment (line 7) | class BaseAlignment(Model):
method __init__ (line 8) | def __init__(self, dataset_max_length, null_label, num_classes, d_mode...
method forward (line 14) | def forward(self, l_feature, v_feature):
FILE: src/parseq/strhub/models/abinet/model_language.py
class BCNLanguage (line 8) | class BCNLanguage(Model):
method __init__ (line 9) | def __init__(self, dataset_max_length, null_label, num_classes, d_mode...
method forward (line 23) | def forward(self, tokens, lengths):
FILE: src/parseq/strhub/models/abinet/model_vision.py
class BaseVision (line 9) | class BaseVision(Model):
method __init__ (line 10) | def __init__(self, dataset_max_length, null_label, num_classes,
method forward (line 38) | def forward(self, images):
FILE: src/parseq/strhub/models/abinet/resnet.py
class BasicBlock (line 8) | class BasicBlock(resnet.BasicBlock):
method __init__ (line 10) | def __init__(self, inplanes: int, planes: int, stride: int = 1, downsa...
class ResNet (line 18) | class ResNet(nn.Module):
method __init__ (line 20) | def __init__(self, block, layers):
method _make_layer (line 42) | def _make_layer(self, block, planes, blocks, stride=1):
method forward (line 59) | def forward(self, x):
function resnet45 (line 71) | def resnet45():
FILE: src/parseq/strhub/models/abinet/system.py
class ABINet (line 36) | class ABINet(CrossEntropySystem):
method __init__ (line 38) | def __init__(self, charset_train: str, charset_test: str, max_label_le...
method _pretraining (line 65) | def _pretraining(self):
method no_weight_decay (line 71) | def no_weight_decay(self):
method _add_weight_decay (line 74) | def _add_weight_decay(self, model: nn.Module, skip_list=()):
method configure_optimizers (line 80) | def configure_optimizers(self):
method forward (line 99) | def forward(self, images: Tensor, max_length: Optional[int] = None) ->...
method calc_loss (line 104) | def calc_loss(self, targets, *res_lists) -> Tensor:
method on_train_batch_start (line 118) | def on_train_batch_start(self, batch: Any, batch_idx: int) -> None:
method _prepare_inputs_and_targets (line 126) | def _prepare_inputs_and_targets(self, labels):
method training_step (line 137) | def training_step(self, batch, batch_idx) -> STEP_OUTPUT:
method forward_logits_loss (line 164) | def forward_logits_loss(self, images: Tensor, labels: List[str]) -> Tu...
FILE: src/parseq/strhub/models/abinet/transformer.py
class TransformerDecoderLayer (line 9) | class TransformerDecoderLayer(nn.Module):
method __init__ (line 31) | def __init__(self, d_model, nhead, dim_feedforward=2048, dropout=0.1,
method __setstate__ (line 55) | def __setstate__(self, state):
method forward (line 60) | def forward(self, tgt, memory, tgt_mask=None, memory_mask=None,
class PositionalEncoding (line 102) | class PositionalEncoding(nn.Module):
method __init__ (line 119) | def __init__(self, d_model, dropout=0.1, max_len=5000):
method forward (line 131) | def forward(self, x):
FILE: src/parseq/strhub/models/base.py
class BatchResult (line 34) | class BatchResult:
class BaseSystem (line 44) | class BaseSystem(pl.LightningModule, ABC):
method __init__ (line 46) | def __init__(self, tokenizer: BaseTokenizer, charset_test: str,
method forward (line 57) | def forward(self, images: Tensor, max_length: Optional[int] = None) ->...
method forward_logits_loss (line 70) | def forward_logits_loss(self, images: Tensor, labels: List[str]) -> Tu...
method configure_optimizers (line 84) | def configure_optimizers(self):
method optimizer_zero_grad (line 94) | def optimizer_zero_grad(self, epoch: int, batch_idx: int, optimizer: O...
method _eval_step (line 97) | def _eval_step(self, batch, validation: bool) -> Optional[STEP_OUTPUT]:
method _aggregate_results (line 131) | def _aggregate_results(outputs) -> Tuple[float, float, float]:
method validation_step (line 151) | def validation_step(self, batch, batch_idx) -> Optional[STEP_OUTPUT]:
method validation_epoch_end (line 154) | def validation_epoch_end(self, outputs) -> None:
method test_step (line 161) | def test_step(self, batch, batch_idx) -> Optional[STEP_OUTPUT]:
class CrossEntropySystem (line 165) | class CrossEntropySystem(BaseSystem):
method __init__ (line 167) | def __init__(self, charset_train: str, charset_test: str,
method forward_logits_loss (line 175) | def forward_logits_loss(self, images: Tensor, labels: List[str]) -> Tu...
class CTCSystem (line 185) | class CTCSystem(BaseSystem):
method __init__ (line 187) | def __init__(self, charset_train: str, charset_test: str,
method forward_logits_loss (line 193) | def forward_logits_loss(self, images: Tensor, labels: List[str]) -> Tu...
FILE: src/parseq/strhub/models/crnn/model.py
class CRNN (line 6) | class CRNN(nn.Module):
method __init__ (line 8) | def __init__(self, img_h, nc, nclass, nh, leaky_relu=False):
method forward (line 51) | def forward(self, input):
FILE: src/parseq/strhub/models/crnn/system.py
class CRNN (line 26) | class CRNN(CTCSystem):
method __init__ (line 28) | def __init__(self, charset_train: str, charset_test: str, max_label_le...
method forward (line 36) | def forward(self, images: Tensor, max_length: Optional[int] = None) ->...
method training_step (line 39) | def training_step(self, batch, batch_idx) -> STEP_OUTPUT:
FILE: src/parseq/strhub/models/modules.py
class BidirectionalLSTM (line 5) | class BidirectionalLSTM(nn.Module):
method __init__ (line 8) | def __init__(self, input_size, hidden_size, output_size):
method forward (line 13) | def forward(self, input):
FILE: src/parseq/strhub/models/parseq/modules.py
class DecoderLayer (line 27) | class DecoderLayer(nn.Module):
method __init__ (line 31) | def __init__(self, d_model, nhead, dim_feedforward=2048, dropout=0.1, ...
method __setstate__ (line 51) | def __setstate__(self, state):
method forward_stream (line 56) | def forward_stream(self, tgt: Tensor, tgt_norm: Tensor, tgt_kv: Tensor...
method forward (line 74) | def forward(self, query, content, memory, query_mask: Optional[Tensor]...
class Decoder (line 85) | class Decoder(nn.Module):
method __init__ (line 88) | def __init__(self, decoder_layer, num_layers, norm):
method forward (line 94) | def forward(self, query, content, memory, query_mask: Optional[Tensor]...
class Encoder (line 104) | class Encoder(VisionTransformer):
method __init__ (line 106) | def __init__(self, img_size=224, patch_size=16, in_chans=3, embed_dim=...
method forward (line 113) | def forward(self, x):
class TokenEmbedding (line 118) | class TokenEmbedding(nn.Module):
method __init__ (line 120) | def __init__(self, charset_size: int, embed_dim: int):
method forward (line 125) | def forward(self, tokens: torch.Tensor):
FILE: src/parseq/strhub/models/parseq/system.py
class PARSeq (line 35) | class PARSeq(CrossEntropySystem):
method __init__ (line 37) | def __init__(self, charset_train: str, charset_test: str, max_label_le...
method no_weight_decay (line 74) | def no_weight_decay(self):
method encode (line 79) | def encode(self, img: torch.Tensor):
method decode (line 82) | def decode(self, tgt: torch.Tensor, memory: torch.Tensor, tgt_mask: Op...
method forward (line 95) | def forward(self, images: Tensor, max_length: Optional[int] = None) ->...
method gen_tgt_perms (line 154) | def gen_tgt_perms(self, tgt):
method generate_attn_masks (line 212) | def generate_attn_masks(self, perm):
method training_step (line 228) | def training_step(self, batch, batch_idx) -> STEP_OUTPUT:
FILE: src/parseq/strhub/models/trba/feature_extraction.py
class ResNet_FeatureExtractor (line 6) | class ResNet_FeatureExtractor(nn.Module):
method __init__ (line 9) | def __init__(self, input_channel, output_channel=512):
method forward (line 13) | def forward(self, input):
class ResNet (line 17) | class ResNet(nn.Module):
method __init__ (line 19) | def __init__(self, input_channel, output_channel, block, layers):
method _make_layer (line 59) | def _make_layer(self, block, planes, blocks, stride=1):
method forward (line 76) | def forward(self, x):
FILE: src/parseq/strhub/models/trba/model.py
class TRBA (line 9) | class TRBA(nn.Module):
method __init__ (line 11) | def __init__(self, img_h, img_w, num_class, num_fiducial=20, input_cha...
method forward (line 36) | def forward(self, image, max_label_length, text=None):
FILE: src/parseq/strhub/models/trba/prediction.py
class Attention (line 6) | class Attention(nn.Module):
method __init__ (line 8) | def __init__(self, input_size, hidden_size, num_class, num_char_embedd...
method forward (line 16) | def forward(self, batch_H, text, max_label_length=25):
class AttentionCell (line 53) | class AttentionCell(nn.Module):
method __init__ (line 55) | def __init__(self, input_size, hidden_size, num_embeddings):
method forward (line 63) | def forward(self, prev_hidden, batch_H, char_embeddings):
FILE: src/parseq/strhub/models/trba/system.py
class TRBA (line 30) | class TRBA(CrossEntropySystem):
method __init__ (line 32) | def __init__(self, charset_train: str, charset_test: str, max_label_le...
method no_weight_decay (line 45) | def no_weight_decay(self):
method forward (line 48) | def forward(self, images: Tensor, max_length: Optional[int] = None) ->...
method training_step (line 53) | def training_step(self, batch, batch_idx) -> STEP_OUTPUT:
class TRBC (line 65) | class TRBC(CTCSystem):
method __init__ (line 67) | def __init__(self, charset_train: str, charset_test: str, max_label_le...
method forward (line 79) | def forward(self, images: Tensor, max_length: Optional[int] = None) ->...
method training_step (line 83) | def training_step(self, batch, batch_idx) -> STEP_OUTPUT:
FILE: src/parseq/strhub/models/trba/transformation.py
class TPS_SpatialTransformerNetwork (line 7) | class TPS_SpatialTransformerNetwork(nn.Module):
method __init__ (line 10) | def __init__(self, F, I_size, I_r_size, I_channel_num=1):
method forward (line 28) | def forward(self, batch_I):
class LocalizationNetwork (line 42) | class LocalizationNetwork(nn.Module):
method __init__ (line 45) | def __init__(self, F, I_channel_num):
method forward (line 75) | def forward(self, batch_I):
class GridGenerator (line 86) | class GridGenerator(nn.Module):
method __init__ (line 89) | def __init__(self, F, I_r_size):
method _build_C (line 109) | def _build_C(self, F):
method _build_inv_delta_C (line 119) | def _build_inv_delta_C(self, F, C):
method _build_P (line 141) | def _build_P(self, I_r_width, I_r_height):
method _build_P_hat (line 150) | def _build_P_hat(self, F, C, P):
method build_P_prime (line 160) | def build_P_prime(self, batch_C_prime):
FILE: src/parseq/strhub/models/utils.py
class InvalidModelError (line 10) | class InvalidModelError(RuntimeError):
function _get_config (line 24) | def _get_config(experiment: str, **kwargs):
function _get_model_class (line 46) | def _get_model_class(key):
function get_pretrained_weights (line 64) | def get_pretrained_weights(experiment):
function create_model (line 72) | def create_model(experiment: str, pretrained: bool = False, **kwargs):
function load_from_checkpoint (line 84) | def load_from_checkpoint(checkpoint_path: str, **kwargs):
function parse_model_args (line 94) | def parse_model_args(args):
function init_weights (line 105) | def init_weights(module: nn.Module, name: str = '', exclude: Sequence[st...
FILE: src/parseq/strhub/models/vitstr/model.py
class ViTSTR (line 14) | class ViTSTR(VisionTransformer):
method forward (line 20) | def forward(self, x, seqlen: int = 25):
FILE: src/parseq/strhub/models/vitstr/system.py
class ViTSTR (line 27) | class ViTSTR(CrossEntropySystem):
method __init__ (line 29) | def __init__(self, charset_train: str, charset_test: str, max_label_le...
method no_weight_decay (line 43) | def no_weight_decay(self):
method forward (line 46) | def forward(self, images: Tensor, max_length: Optional[int] = None) ->...
method training_step (line 54) | def training_step(self, batch, batch_idx) -> STEP_OUTPUT:
FILE: src/parseq/test.py
class Result (line 32) | class Result:
function print_results_table (line 41) | def print_results_table(results: List[Result], file=None):
function main (line 65) | def main():
FILE: src/parseq/tools/coco_2_converter.py
function parse_args (line 14) | def parse_args():
function process_img (line 25) | def process_img(args, src_image_root, dst_image_root):
function convert_textocr (line 63) | def convert_textocr(root_path,
function main (line 104) | def main():
FILE: src/parseq/tools/create_lmdb_dataset.py
function checkImageIsValid (line 12) | def checkImageIsValid(imageBin):
function writeCache (line 19) | def writeCache(env, cache):
function createDataset (line 25) | def createDataset(inputPath, gtFile, outputPath, checkValid=True):
FILE: src/parseq/tools/filter_lmdb.py
function main (line 11) | def main():
FILE: src/parseq/tools/lsvt_converter.py
function parse_args (line 14) | def parse_args():
function process_img (line 25) | def process_img(args, src_image_root, dst_image_root):
function convert_lsvt (line 58) | def convert_lsvt(root_path,
function main (line 93) | def main():
FILE: src/parseq/tools/openvino_converter.py
function parse_args (line 14) | def parse_args():
function process_img (line 26) | def process_img(args, src_image_root, dst_image_root):
function convert_openimages (line 53) | def convert_openimages(root_path,
function main (line 91) | def main():
FILE: src/parseq/tools/test_abinet_lm_acc.py
class ABINetLM (line 21) | class ABINetLM(ABINet):
method _encode (line 23) | def _encode(self, labels):
method forward (line 34) | def forward(self, labels: Tensor, max_length: int = None) -> Tensor:
function main (line 39) | def main():
FILE: src/parseq/tools/textocr_converter.py
function parse_args (line 15) | def parse_args():
function rectify_image_pose (line 28) | def rectify_image_pose(image, top_left, points):
function process_img (line 52) | def process_img(args, src_image_root, dst_image_root):
function convert_textocr (line 80) | def convert_textocr(root_path,
function main (line 118) | def main():
FILE: src/parseq/train.py
function main (line 35) | def main(config: DictConfig):
FILE: src/parseq/tune.py
class MetricTracker (line 45) | class MetricTracker(tune.Stopper):
method __init__ (line 48) | def __init__(self, metric, max_t, patience: int = 3, window: int = 3) ...
method gaussian_pdf (line 61) | def gaussian_pdf(x, sigma=1.):
method moving_average (line 65) | def moving_average(x, k):
method __call__ (line 68) | def __call__(self, trial_id, result):
method stop_all (line 93) | def stop_all(self):
class TuneReportCheckpointPruneCallback (line 97) | class TuneReportCheckpointPruneCallback(TuneReportCheckpointCallback):
method _handle (line 99) | def _handle(self, trainer: Trainer, pl_module: LightningModule):
function train (line 108) | def train(hparams, config, checkpoint_dir=None):
function main (line 130) | def main(config: DictConfig):
FILE: test.py
function predict (line 19) | def predict(cfgs, model, sampler, batch):
function test (line 43) | def test(model, sampler, dataloader, cfgs):
FILE: train.py
function train (line 15) | def train():
FILE: util.py
function init_model (line 7) | def init_model(cfgs):
function init_sampling (line 24) | def init_sampling(cfgs):
function deep_copy (line 49) | def deep_copy(batch):
function prepare_batch (line 62) | def prepare_batch(cfgs, batch):
Condensed preview — 142 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (806K chars).
[
{
"path": ".gitignore",
"chars": 52,
"preview": "**/__pycache__\n.vscode\ncheckpoints\nlogs\noutputs\ntemp"
},
{
"path": "LICENSE",
"chars": 1068,
"preview": "MIT License\n\nCopyright (c) 2024 Yiming Zhao\n\nPermission is hereby granted, free of charge, to any person obtaining a cop"
},
{
"path": "README.md",
"chars": 6437,
"preview": "## UDiffText: A Unified Framework for High-quality Text Synthesis in Arbitrary Images via Character-aware Diffusion Mode"
},
{
"path": "configs/dataset/icd13.yaml",
"chars": 185,
"preview": "target: ICDAR13Dataset\nparams:\n\n data_root: '{your data root}'\n\n H: 512\n W: 512\n word_len: [1, 8]\n seq_len: 12\n ma"
},
{
"path": "configs/dataset/locr.yaml",
"chars": 248,
"preview": "target: LAIONOCRDataset\nparams:\n\n data_root: '{your data root}'\n\n H: 512\n W: 512\n word_len: [1, 12]\n seq_len: 12\n "
},
{
"path": "configs/dataset/st.yaml",
"chars": 188,
"preview": "target: SynthTextDataset\nparams:\n\n data_root: '{your data root}'\n\n H: 512\n W: 512\n word_len: [1, 12]\n mask_min_rati"
},
{
"path": "configs/dataset/tsg.yaml",
"chars": 209,
"preview": "target: TextSegDataset\nparams:\n\n data_root: '{your data root}'\n\n H: 512\n W: 512\n word_len: [1, 12]\n seq_len: 12\n m"
},
{
"path": "configs/demo.yaml",
"chars": 436,
"preview": "type: \"demo\"\n\n# path\nload_ckpt_path: \"./checkpoints/{your checkpoint path}.ckpt\"\nmodel_cfg_path: \"./configs/test/textdes"
},
{
"path": "configs/pretrain.yaml",
"chars": 956,
"preview": "# path\nckpt_dir: './checkpoints/encoders/LabelEncoder'\n\ndataset:\n target: dataset.dataloader.LabelDataset\n params:\n "
},
{
"path": "configs/test/textdesign_sd_2.yaml",
"chars": 4226,
"preview": "model:\n target: sgm.models.diffusion.DiffusionEngine\n params:\n opt_keys:\n - t_attn\n input_key: image\n sc"
},
{
"path": "configs/test.yaml",
"chars": 878,
"preview": "type: \"test\"\n\n# path\nload_ckpt_path: \"./checkpoints/{your checkpoint path}.ckpt\"\nmodel_cfg_path: \"./configs/test/textdes"
},
{
"path": "configs/train/textdesign_sd_2.yaml",
"chars": 4613,
"preview": "model:\n target: sgm.models.diffusion.DiffusionEngine\n params:\n opt_keys:\n - t_attn\n - t_norm\n input_ke"
},
{
"path": "configs/train.yaml",
"chars": 532,
"preview": "type: \"train\"\n\n# path\nsave_ckpt_dir: ./checkpoints\nload_ckpt_path: ./checkpoints/pretrained/512-inpainting-ema.ckpt\nmode"
},
{
"path": "dataset/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "dataset/dataloader.py",
"chars": 34758,
"preview": "import os,glob\nimport torch\nimport cv2\nimport scipy\nimport string\nimport json\nimport torchvision.transforms as transform"
},
{
"path": "dataset/utils/words.txt",
"chars": 84314,
"preview": "the of and to in a is was that for as with by on are from be or his were it an at not which have he had this has also th"
},
{
"path": "demo.py",
"chars": 8211,
"preview": "import cv2\nimport torch\nimport os, glob\nimport numpy as np\nimport gradio as gr\nfrom PIL import Image\nfrom omegaconf impo"
},
{
"path": "metrics.py",
"chars": 959,
"preview": "import lpips\nimport os,glob\nfrom os.path import join as ospj\n\ndef calc_fid(fake_dir, real_dir, batch_size=1, gpu='0'):\n\n"
},
{
"path": "pretrain.py",
"chars": 1128,
"preview": "import torch\nimport torch.utils.data as data\nimport pytorch_lightning as pl\nfrom omegaconf import OmegaConf\nfrom sgm.uti"
},
{
"path": "requirements.txt",
"chars": 470,
"preview": "colorlover==0.3.0\neinops==0.6.1\ngradio==3.41.0\nimageio==2.31.2\nimg2dataset==1.42.0\nkornia==0.6.9\nlpips==0.1.4\nmatplotlib"
},
{
"path": "scripts/preprocess/laion_ocr_pre.ipynb",
"chars": 198380,
"preview": "{\n \"cells\": [\n {\n \"cell_type\": \"code\",\n \"execution_count\": 1,\n \"metadata\": {},\n \"outputs\": [],\n \"source\": [\n "
},
{
"path": "sgm/__init__.py",
"chars": 98,
"preview": "from .models import AutoencodingEngine, DiffusionEngine\nfrom .util import instantiate_from_config\n"
},
{
"path": "sgm/lr_scheduler.py",
"chars": 4286,
"preview": "import numpy as np\n\n\nclass LambdaWarmUpCosineScheduler:\n \"\"\"\n note: use with a base_lr of 1.0\n \"\"\"\n\n def __i"
},
{
"path": "sgm/models/__init__.py",
"chars": 83,
"preview": "from .autoencoder import AutoencodingEngine\nfrom .diffusion import DiffusionEngine\n"
},
{
"path": "sgm/models/autoencoder.py",
"chars": 11471,
"preview": "import re\nfrom abc import abstractmethod\nfrom contextlib import contextmanager\nfrom typing import Any, Dict, Tuple, Unio"
},
{
"path": "sgm/models/diffusion.py",
"chars": 11531,
"preview": "from contextlib import contextmanager\nfrom typing import Any, Dict, List, Tuple, Union\n\nimport pytorch_lightning as pl\ni"
},
{
"path": "sgm/modules/__init__.py",
"chars": 159,
"preview": "from .encoders.modules import GeneralConditioner\n\nUNCONDITIONAL_CONFIG = {\n \"target\": \"sgm.modules.GeneralConditioner"
},
{
"path": "sgm/modules/attention.py",
"chars": 11996,
"preview": "import math\nfrom inspect import isfunction\nfrom typing import Any, Optional\n\nimport torch\nimport torch.nn.functional as "
},
{
"path": "sgm/modules/autoencoding/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "sgm/modules/autoencoding/losses/__init__.py",
"chars": 9711,
"preview": "from typing import Any, Union\n\nimport torch\nimport torch.nn as nn\nfrom einops import rearrange\nfrom taming.modules.discr"
},
{
"path": "sgm/modules/autoencoding/regularizers/__init__.py",
"chars": 1683,
"preview": "from abc import abstractmethod\nfrom typing import Any, Tuple\n\nimport torch\nimport torch.nn as nn\nimport torch.nn.functio"
},
{
"path": "sgm/modules/diffusionmodules/__init__.py",
"chars": 275,
"preview": "from .denoiser import Denoiser\nfrom .discretizer import Discretization\nfrom .loss import StandardDiffusionLoss\nfrom .mod"
},
{
"path": "sgm/modules/diffusionmodules/denoiser.py",
"chars": 1960,
"preview": "import torch.nn as nn\n\nfrom ...util import append_dims, instantiate_from_config\n\n\nclass Denoiser(nn.Module):\n def __i"
},
{
"path": "sgm/modules/diffusionmodules/denoiser_scaling.py",
"chars": 945,
"preview": "import torch\n\n\nclass EDMScaling:\n def __init__(self, sigma_data=0.5):\n self.sigma_data = sigma_data\n\n def _"
},
{
"path": "sgm/modules/diffusionmodules/denoiser_weighting.py",
"chars": 516,
"preview": "import torch\n\n\nclass UnitWeighting:\n def __call__(self, sigma):\n return torch.ones_like(sigma, device=sigma.de"
},
{
"path": "sgm/modules/diffusionmodules/discretizer.py",
"chars": 2312,
"preview": "import torch\nimport numpy as np\nfrom functools import partial\nfrom abc import abstractmethod\n\nfrom ...util import append"
},
{
"path": "sgm/modules/diffusionmodules/guiders.py",
"chars": 1402,
"preview": "from functools import partial\n\nimport torch\n\nfrom ...util import default, instantiate_from_config\n\n\nclass VanillaCFG:\n "
},
{
"path": "sgm/modules/diffusionmodules/loss.py",
"chars": 10243,
"preview": "from typing import List, Optional, Union\n\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\nfrom omegac"
},
{
"path": "sgm/modules/diffusionmodules/model.py",
"chars": 23907,
"preview": "# pytorch_diffusion + derived encoder decoder\nimport math\nfrom typing import Any, Callable, Optional\n\nimport numpy as np"
},
{
"path": "sgm/modules/diffusionmodules/openaimodel.py",
"chars": 21233,
"preview": "from abc import abstractmethod\nfrom typing import Iterable\n\nimport numpy as np\nimport torch as th\nimport torch.nn as nn\n"
},
{
"path": "sgm/modules/diffusionmodules/sampling.py",
"chars": 19121,
"preview": "\"\"\"\n Partially ported from https://github.com/crowsonkb/k-diffusion/blob/master/k_diffusion/sampling.py\n\"\"\"\n\n\nfrom ty"
},
{
"path": "sgm/modules/diffusionmodules/sampling_utils.py",
"chars": 1157,
"preview": "import torch\nfrom scipy import integrate\n\nfrom ...util import append_dims\n\n\nclass NoDynamicThresholding:\n def __call_"
},
{
"path": "sgm/modules/diffusionmodules/sigma_sampling.py",
"chars": 906,
"preview": "import torch\n\nfrom ...util import default, instantiate_from_config\n\n\nclass EDMSampling:\n def __init__(self, p_mean=-1"
},
{
"path": "sgm/modules/diffusionmodules/util.py",
"chars": 10180,
"preview": "\"\"\"\nadopted from\nhttps://github.com/openai/improved-diffusion/blob/main/improved_diffusion/gaussian_diffusion.py\nand\nhtt"
},
{
"path": "sgm/modules/diffusionmodules/wrappers.py",
"chars": 1085,
"preview": "import torch\nimport torch.nn as nn\nfrom packaging import version\n\nOPENAIUNETWRAPPER = \"sgm.modules.diffusionmodules.wrap"
},
{
"path": "sgm/modules/distributions/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "sgm/modules/distributions/distributions.py",
"chars": 3095,
"preview": "import torch\nimport numpy as np\n\n\nclass AbstractDistribution:\n def sample(self):\n raise NotImplementedError()\n"
},
{
"path": "sgm/modules/ema.py",
"chars": 3207,
"preview": "import torch\nfrom torch import nn\n\n\nclass LitEma(nn.Module):\n def __init__(self, model, decay=0.9999, use_num_upates="
},
{
"path": "sgm/modules/encoders/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "sgm/modules/encoders/modules.py",
"chars": 41564,
"preview": "from contextlib import nullcontext\nfrom functools import partial\nfrom typing import Dict, List, Optional, Tuple, Union\n\n"
},
{
"path": "sgm/modules/predictors/model.py",
"chars": 1741,
"preview": "import torch\nimport torch.nn as nn\nfrom torchvision import transforms\nfrom torchvision.utils import save_image\n\n\nclass P"
},
{
"path": "sgm/util.py",
"chars": 6863,
"preview": "import functools\nimport importlib\nimport os\nfrom functools import partial\nfrom inspect import isfunction\n\nimport fsspec\n"
},
{
"path": "src/parseq/.gitignore",
"chars": 2119,
"preview": "# Output directories\noutputs/\nmultirun/\nray_results/\n\n# Byte-compiled / optimized / DLL files\n__pycache__/\n*.py[cod]\n*$p"
},
{
"path": "src/parseq/Datasets.md",
"chars": 4426,
"preview": "We use various synthetic and real datasets. More info is in Appendix F of the supplementary material. Some preprocessing"
},
{
"path": "src/parseq/LICENSE",
"chars": 11358,
"preview": "\n Apache License\n Version 2.0, January 2004\n "
},
{
"path": "src/parseq/NOTICE",
"chars": 712,
"preview": "Scene Text Recognition Model Hub\nCopyright 2022 Darwin Bautista\n\nThe Initial Developer of strhub/models/abinet (sans sys"
},
{
"path": "src/parseq/README.md",
"chars": 13538,
"preview": "<div align=\"center\">\n\n# Scene Text Recognition with<br/>Permuted Autoregressive Sequence Models\n[*+,"
},
{
"path": "src/parseq/configs/dataset/real.yaml",
"chars": 44,
"preview": "# @package _global_\ndata:\n train_dir: real\n"
},
{
"path": "src/parseq/configs/dataset/synth.yaml",
"chars": 145,
"preview": "# @package _global_\ndata:\n train_dir: synth\n num_workers: 3\n\ntrainer:\n limit_train_batches: 0.20496 # to match the s"
},
{
"path": "src/parseq/configs/experiment/abinet-sv.yaml",
"chars": 127,
"preview": "# @package _global_\ndefaults:\n - override /model: abinet\n\nmodel:\n name: abinet-sv\n v_num_layers: 2\n v_attention: att"
},
{
"path": "src/parseq/configs/experiment/abinet.yaml",
"chars": 58,
"preview": "# @package _global_\ndefaults:\n - override /model: abinet\n"
},
{
"path": "src/parseq/configs/experiment/crnn.yaml",
"chars": 80,
"preview": "# @package _global_\ndefaults:\n - override /model: crnn\n\ndata:\n num_workers: 5\n"
},
{
"path": "src/parseq/configs/experiment/parseq-patch16-224.yaml",
"chars": 158,
"preview": "# @package _global_\ndefaults:\n - override /model: parseq\n\nmodel:\n img_size: [ 224, 224 ] # [ height, width ]\n patch_"
},
{
"path": "src/parseq/configs/experiment/parseq-tiny.yaml",
"chars": 141,
"preview": "# @package _global_\ndefaults:\n - override /model: parseq\n\nmodel:\n name: parseq-tiny\n embed_dim: 192\n enc_num_heads: "
},
{
"path": "src/parseq/configs/experiment/parseq.yaml",
"chars": 58,
"preview": "# @package _global_\ndefaults:\n - override /model: parseq\n"
},
{
"path": "src/parseq/configs/experiment/trba.yaml",
"chars": 80,
"preview": "# @package _global_\ndefaults:\n - override /model: trba\n\ndata:\n num_workers: 3\n"
},
{
"path": "src/parseq/configs/experiment/trbc.yaml",
"chars": 155,
"preview": "# @package _global_\ndefaults:\n - override /model: trba\n\nmodel:\n name: trbc\n _target_: strhub.models.trba.system.TRBC\n"
},
{
"path": "src/parseq/configs/experiment/tune_abinet-lm.yaml",
"chars": 204,
"preview": "# @package _global_\ndefaults:\n - override /model: abinet\n\nmodel:\n name: abinet-lm\n lm_only: true\n\ndata:\n augment: fa"
},
{
"path": "src/parseq/configs/experiment/vitstr.yaml",
"chars": 155,
"preview": "# @package _global_\ndefaults:\n - override /model: vitstr\n\nmodel:\n img_size: [ 32, 128 ] # [ height, width ]\n patch_s"
},
{
"path": "src/parseq/configs/main.yaml",
"chars": 1330,
"preview": "defaults:\n - _self_\n - model: parseq\n - charset: 94_full\n - dataset: real\n\nmodel:\n _convert_: all\n img_size: [ 32,"
},
{
"path": "src/parseq/configs/model/abinet.yaml",
"chars": 419,
"preview": "name: abinet\n_target_: strhub.models.abinet.system.ABINet\n\n# Shared Transformer configuration\nd_model: 512\nnhead: 8\nd_in"
},
{
"path": "src/parseq/configs/model/crnn.yaml",
"chars": 126,
"preview": "name: crnn\n_target_: strhub.models.crnn.system.CRNN\n\n# Architecture\nhidden_size: 256\nleaky_relu: false\n\n# Training\nlr: 5"
},
{
"path": "src/parseq/configs/model/parseq.yaml",
"chars": 376,
"preview": "name: parseq\n_target_: strhub.models.parseq.system.PARSeq\n\n# Data\npatch_size: [ 4, 8 ] # [ height, width ]\n\n# Architect"
},
{
"path": "src/parseq/configs/model/trba.yaml",
"chars": 145,
"preview": "name: trba\n_target_: strhub.models.trba.system.TRBA\n\n# Architecture\nnum_fiducial: 20\noutput_channel: 512\nhidden_size: 25"
},
{
"path": "src/parseq/configs/model/vitstr.yaml",
"chars": 221,
"preview": "name: vitstr\n_target_: strhub.models.vitstr.system.ViTSTR\n\n# Data\nimg_size: [ 224, 224 ] # [ height, width ]\npatch_size"
},
{
"path": "src/parseq/configs/tune.yaml",
"chars": 271,
"preview": "defaults:\n - main\n - _self_\n\ntrainer:\n gpus: 1 # tuning with DDP is not yet supported.\n\ntune:\n num_samples: 10\n gp"
},
{
"path": "src/parseq/hubconf.py",
"chars": 1990,
"preview": "from strhub.models.utils import create_model\n\n\ndependencies = ['torch', 'pytorch_lightning', 'timm']\n\n\ndef parseq_tiny(p"
},
{
"path": "src/parseq/read.py",
"chars": 1754,
"preview": "#!/usr/bin/env python3\n# Scene Text Recognition Model Hub\n# Copyright 2022 Darwin Bautista\n#\n# Licensed under the Apache"
},
{
"path": "src/parseq/requirements.txt",
"chars": 234,
"preview": "torch>=1.10.2\ntorchvision>=0.11.3\npytorch-lightning~=1.6.5\ntimm~=0.6.5\nnltk~=3.7.0\nlmdb~=1.3.0\nPillow~=9.2.0\nimgaug~=0.4"
},
{
"path": "src/parseq/setup.cfg",
"chars": 905,
"preview": "[tool:pytest]\nnorecursedirs =\n .git\n dist\n build\naddopts =\n --strict\n --doctest-modules\n --durations=0"
},
{
"path": "src/parseq/setup.py",
"chars": 471,
"preview": "#!/usr/bin/env python\n\nfrom setuptools import setup, find_packages\n\nsetup(\n name='strhub',\n version='1.1.0',\n d"
},
{
"path": "src/parseq/strhub/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "src/parseq/strhub/data/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "src/parseq/strhub/data/aa_overrides.py",
"chars": 1713,
"preview": "# Scene Text Recognition Model Hub\n# Copyright 2022 Darwin Bautista\n#\n# Licensed under the Apache License, Version 2.0 ("
},
{
"path": "src/parseq/strhub/data/augment.py",
"chars": 3588,
"preview": "# Scene Text Recognition Model Hub\n# Copyright 2022 Darwin Bautista\n#\n# Licensed under the Apache License, Version 2.0 ("
},
{
"path": "src/parseq/strhub/data/dataset.py",
"chars": 5365,
"preview": "# Scene Text Recognition Model Hub\n# Copyright 2022 Darwin Bautista\n#\n# Licensed under the Apache License, Version 2.0 ("
},
{
"path": "src/parseq/strhub/data/module.py",
"chars": 5083,
"preview": "# Scene Text Recognition Model Hub\n# Copyright 2022 Darwin Bautista\n#\n# Licensed under the Apache License, Version 2.0 ("
},
{
"path": "src/parseq/strhub/data/utils.py",
"chars": 5751,
"preview": "# Scene Text Recognition Model Hub\n# Copyright 2022 Darwin Bautista\n#\n# Licensed under the Apache License, Version 2.0 ("
},
{
"path": "src/parseq/strhub/models/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "src/parseq/strhub/models/abinet/LICENSE",
"chars": 1328,
"preview": "ABINet for non-commercial purposes\n\nCopyright (c) 2021, USTC\nAll rights reserved.\n\nRedistribution and use in source and "
},
{
"path": "src/parseq/strhub/models/abinet/__init__.py",
"chars": 595,
"preview": "r\"\"\"\nFang, Shancheng, Hongtao, Xie, Yuxin, Wang, Zhendong, Mao, and Yongdong, Zhang.\n\"Read Like Humans: Autonomous, Bidi"
},
{
"path": "src/parseq/strhub/models/abinet/attention.py",
"chars": 4082,
"preview": "import torch\nimport torch.nn as nn\n\nfrom .transformer import PositionalEncoding\n\n\nclass Attention(nn.Module):\n def __"
},
{
"path": "src/parseq/strhub/models/abinet/backbone.py",
"chars": 1032,
"preview": "import torch.nn as nn\nfrom torch.nn import TransformerEncoderLayer, TransformerEncoder\n\nfrom .resnet import resnet45\nfro"
},
{
"path": "src/parseq/strhub/models/abinet/model.py",
"chars": 1064,
"preview": "import torch\nimport torch.nn as nn\n\n\nclass Model(nn.Module):\n\n def __init__(self, dataset_max_length: int, null_label"
},
{
"path": "src/parseq/strhub/models/abinet/model_abinet_iter.py",
"chars": 1931,
"preview": "import torch\nfrom torch import nn\n\nfrom .model_alignment import BaseAlignment\nfrom .model_language import BCNLanguage\nfr"
},
{
"path": "src/parseq/strhub/models/abinet/model_alignment.py",
"chars": 1010,
"preview": "import torch\nimport torch.nn as nn\n\nfrom .model import Model\n\n\nclass BaseAlignment(Model):\n def __init__(self, datase"
},
{
"path": "src/parseq/strhub/models/abinet/model_language.py",
"chars": 2304,
"preview": "import torch.nn as nn\nfrom torch.nn import TransformerDecoder\n\nfrom .model import Model\nfrom .transformer import Positio"
},
{
"path": "src/parseq/strhub/models/abinet/model_vision.py",
"chars": 1746,
"preview": "from torch import nn\n\nfrom .attention import PositionAttention, Attention\nfrom .backbone import ResTranformer\nfrom .mode"
},
{
"path": "src/parseq/strhub/models/abinet/resnet.py",
"chars": 2637,
"preview": "import math\nfrom typing import Optional, Callable\n\nimport torch.nn as nn\nfrom torchvision.models import resnet\n\n\nclass B"
},
{
"path": "src/parseq/strhub/models/abinet/system.py",
"chars": 8407,
"preview": "# Scene Text Recognition Model Hub\n# Copyright 2022 Darwin Bautista\n#\n# Licensed under the Apache License, Version 2.0 ("
},
{
"path": "src/parseq/strhub/models/abinet/transformer.py",
"chars": 6351,
"preview": "import math\n\nimport torch\nimport torch.nn.functional as F\nfrom torch import nn\nfrom torch.nn.modules.transformer import "
},
{
"path": "src/parseq/strhub/models/base.py",
"chars": 8669,
"preview": "# Scene Text Recognition Model Hub\n# Copyright 2022 Darwin Bautista\n#\n# Licensed under the Apache License, Version 2.0 ("
},
{
"path": "src/parseq/strhub/models/crnn/LICENSE",
"chars": 1097,
"preview": "The MIT License (MIT)\n\nCopyright (c) 2017 Jieru Mei <meijieru@gmail.com>\n\nPermission is hereby granted, free of charge, "
},
{
"path": "src/parseq/strhub/models/crnn/__init__.py",
"chars": 543,
"preview": "r\"\"\"\nShi, Baoguang, Xiang Bai, and Cong Yao.\n\"An end-to-end trainable neural network for image-based sequence recognitio"
},
{
"path": "src/parseq/strhub/models/crnn/model.py",
"chars": 2107,
"preview": "import torch.nn as nn\n\nfrom strhub.models.modules import BidirectionalLSTM\n\n\nclass CRNN(nn.Module):\n\n def __init__(se"
},
{
"path": "src/parseq/strhub/models/crnn/system.py",
"chars": 1741,
"preview": "# Scene Text Recognition Model Hub\n# Copyright 2022 Darwin Bautista\n#\n# Licensed under the Apache License, Version 2.0 ("
},
{
"path": "src/parseq/strhub/models/modules.py",
"chars": 859,
"preview": "r\"\"\"Shared modules used by CRNN and TRBA\"\"\"\nfrom torch import nn\n\n\nclass BidirectionalLSTM(nn.Module):\n \"\"\"Ref: https"
},
{
"path": "src/parseq/strhub/models/parseq/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "src/parseq/strhub/models/parseq/modules.py",
"chars": 5730,
"preview": "# Scene Text Recognition Model Hub\n# Copyright 2022 Darwin Bautista\n#\n# Licensed under the Apache License, Version 2.0 ("
},
{
"path": "src/parseq/strhub/models/parseq/system.py",
"chars": 13425,
"preview": "# Scene Text Recognition Model Hub\n# Copyright 2022 Darwin Bautista\n#\n# Licensed under the Apache License, Version 2.0 ("
},
{
"path": "src/parseq/strhub/models/trba/__init__.py",
"chars": 620,
"preview": "r\"\"\"\nBaek, Jeonghun, Geewook Kim, Junyeop Lee, Sungrae Park, Dongyoon Han, Sangdoo Yun, Seong Joon Oh, and Hwalsuk Lee.\n"
},
{
"path": "src/parseq/strhub/models/trba/feature_extraction.py",
"chars": 4430,
"preview": "import torch.nn as nn\n\nfrom torchvision.models.resnet import BasicBlock\n\n\nclass ResNet_FeatureExtractor(nn.Module):\n "
},
{
"path": "src/parseq/strhub/models/trba/model.py",
"chars": 2417,
"preview": "import torch.nn as nn\n\nfrom strhub.models.modules import BidirectionalLSTM\nfrom .feature_extraction import ResNet_Featur"
},
{
"path": "src/parseq/strhub/models/trba/prediction.py",
"chars": 3608,
"preview": "import torch\nimport torch.nn as nn\nimport torch.nn.functional as F\n\n\nclass Attention(nn.Module):\n\n def __init__(self,"
},
{
"path": "src/parseq/strhub/models/trba/system.py",
"chars": 4073,
"preview": "# Scene Text Recognition Model Hub\n# Copyright 2022 Darwin Bautista\n#\n# Licensed under the Apache License, Version 2.0 ("
},
{
"path": "src/parseq/strhub/models/trba/transformation.py",
"chars": 8265,
"preview": "import numpy as np\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\n\n\nclass TPS_SpatialTransformerNetw"
},
{
"path": "src/parseq/strhub/models/utils.py",
"chars": 4779,
"preview": "from pathlib import PurePath\nfrom typing import Sequence\n\nimport torch\nfrom torch import nn\n\nimport yaml\n\n\nclass Invalid"
},
{
"path": "src/parseq/strhub/models/vitstr/__init__.py",
"chars": 483,
"preview": "r\"\"\"\nAtienza, Rowel. \"Vision Transformer for Fast and Efficient Scene Text Recognition.\"\nIn International Conference on "
},
{
"path": "src/parseq/strhub/models/vitstr/model.py",
"chars": 665,
"preview": "\"\"\"\nImplementation of ViTSTR based on timm VisionTransformer.\n\nTODO:\n1) distilled deit backbone\n2) base deit backbone\n\nC"
},
{
"path": "src/parseq/strhub/models/vitstr/system.py",
"chars": 2646,
"preview": "# Scene Text Recognition Model Hub\n# Copyright 2022 Darwin Bautista\n#\n# Licensed under the Apache License, Version 2.0 ("
},
{
"path": "src/parseq/test.py",
"chars": 5576,
"preview": "#!/usr/bin/env python3\n# Scene Text Recognition Model Hub\n# Copyright 2022 Darwin Bautista\n#\n# Licensed under the Apache"
},
{
"path": "src/parseq/tools/art_converter.py",
"chars": 806,
"preview": "#!/usr/bin/env python3\n\nimport json\n\nwith open('train_task2_labels.json', 'r', encoding='utf8') as f:\n d = json.load("
},
{
"path": "src/parseq/tools/case_sensitive_str_datasets_converter.py",
"chars": 701,
"preview": "#!/usr/bin/env python3\n\nimport os.path\nimport sys\nfrom pathlib import Path\n\nd = sys.argv[1]\np = Path(d)\n\ngt = []\n\nnum_sa"
},
{
"path": "src/parseq/tools/coco_2_converter.py",
"chars": 4336,
"preview": "#!/usr/bin/env python3\nimport argparse\nimport html\nimport math\nimport os\nimport os.path as osp\nfrom functools import par"
},
{
"path": "src/parseq/tools/coco_text_converter.py",
"chars": 533,
"preview": "#!/usr/bin/env python3\n\nfor s in ['train', 'val']:\n with open('{}_words_gt.txt'.format(s), 'r', encoding='utf8') as f"
},
{
"path": "src/parseq/tools/create_lmdb_dataset.py",
"chars": 2383,
"preview": "#!/usr/bin/env python3\n\"\"\" a modified version of CRNN torch repository https://github.com/bgshih/crnn/blob/master/tool/c"
},
{
"path": "src/parseq/tools/filter_lmdb.py",
"chars": 2556,
"preview": "#!/usr/bin/env python3\nimport io\nimport os\nfrom argparse import ArgumentParser\n\nimport numpy as np\nimport lmdb\nfrom PIL "
},
{
"path": "src/parseq/tools/lsvt_converter.py",
"chars": 3520,
"preview": "#!/usr/bin/env python3\nimport argparse\nimport os\nimport os.path as osp\nimport re\nfrom functools import partial\n\nimport m"
},
{
"path": "src/parseq/tools/mlt19_converter.py",
"chars": 370,
"preview": "#!/usr/bin/env python3\n\nimport sys\n\nroot = sys.argv[1]\n\nwith open(root + '/gt.txt', 'r') as f:\n d = f.readlines()\n\nwi"
},
{
"path": "src/parseq/tools/openvino_converter.py",
"chars": 3953,
"preview": "#!/usr/bin/env python3\nimport math\nimport os\nimport os.path as osp\nfrom argparse import ArgumentParser\nfrom functools im"
},
{
"path": "src/parseq/tools/test_abinet_lm_acc.py",
"chars": 3846,
"preview": "#!/usr/bin/env python3\nimport argparse\nimport string\nimport sys\n\nimport torch\nimport torch.nn.functional as F\nfrom torch"
},
{
"path": "src/parseq/tools/textocr_converter.py",
"chars": 4846,
"preview": "#!/usr/bin/env python3\n# Copyright (c) OpenMMLab. All rights reserved.\nimport argparse\nimport math\nimport os\nimport os.p"
},
{
"path": "src/parseq/train.py",
"chars": 3503,
"preview": "#!/usr/bin/env python3\n# Scene Text Recognition Model Hub\n# Copyright 2022 Darwin Bautista\n#\n# Licensed under the Apache"
},
{
"path": "src/parseq/tune.py",
"chars": 7624,
"preview": "#!/usr/bin/env python3\n# Scene Text Recognition Model Hub\n# Copyright 2022 Darwin Bautista\n#\n# Licensed under the Apache"
},
{
"path": "test.py",
"chars": 4609,
"preview": "import torch\nimport random\nimport numpy as np\nimport os\n\nfrom PIL import Image\nfrom tqdm import tqdm\nfrom contextlib imp"
},
{
"path": "train.py",
"chars": 1109,
"preview": "import os, sys\nimport torch\nimport random\nimport pytorch_lightning as pl\n\nfrom omegaconf import OmegaConf\nfrom dataset.d"
},
{
"path": "util.py",
"chars": 1956,
"preview": "import torch\nfrom omegaconf import OmegaConf\nfrom sgm.util import instantiate_from_config\nfrom sgm.modules.diffusionmodu"
}
]
About this extraction
This page contains the full source code of the ZYM-PKU/UDiffText GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 142 files (749.6 KB), approximately 212.2k tokens, and a symbol index with 767 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.