python_code
stringlengths
0
4.04M
repo_name
stringlengths
8
58
file_path
stringlengths
5
147
from __future__ import print_function, unicode_literals, division import os import re import codecs import platform from subprocess import check_output from tempfile import mkdtemp from functools import partial try: from configparser import ConfigParser except ImportError: from ConfigParser import ConfigPars...
data2vec_vision-main
s2s-ft/evaluations/bs_pyrouge.py
"""BERT finetuning runner.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import os import logging import glob import json import argparse import math import string from multiprocessing import Pool, cpu_count from tqdm import tqdm, trange from pathlib i...
data2vec_vision-main
s2s-ft/evaluations/eval_for_cnndm.py
from __future__ import absolute_import, division, print_function, unicode_literals import logging from transformers import BertConfig, RobertaConfig from s2s_ft.configuration_unilm import UnilmConfig logger = logging.getLogger(__name__) class BertForSeq2SeqConfig(BertConfig): def __init__(self, label_smoothing=...
data2vec_vision-main
s2s-ft/s2s_ft/config.py
# coding=utf-8 # The MIT License (MIT) # Copyright (c) Microsoft Corporation # 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 # t...
data2vec_vision-main
s2s-ft/s2s_ft/configuration_minilm.py
# coding=utf-8 """PyTorch BERT model.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import os import copy import json import math import logging import tarfile import tempfile import shutil import numpy as np import torch from torch import nn from tor...
data2vec_vision-main
s2s-ft/s2s_ft/modeling_decoding.py
import numpy as np from random import randint, shuffle, choice from random import random as rand import math import logging import torch import torch.utils.data logger = logging.getLogger(__name__) def get_random_word(vocab_words): i = randint(0, len(vocab_words)-1) return vocab_words[i] def batch_list_t...
data2vec_vision-main
s2s-ft/s2s_ft/s2s_loader.py
import torch import logging from transformers.modeling_utils import cached_path, WEIGHTS_NAME, TF2_WEIGHTS_NAME, TF_WEIGHTS_NAME logger = logging.getLogger(__name__) def get_checkpoint_from_transformer_cache( archive_file, pretrained_model_name_or_path, pretrained_model_archive_map, cache_dir, force...
data2vec_vision-main
s2s-ft/s2s_ft/convert_state_dict.py
# coding=utf-8 # The MIT License (MIT) # Copyright (c) Microsoft Corporation # 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 # t...
data2vec_vision-main
s2s-ft/s2s_ft/tokenization_unilm.py
# coding=utf-8 # The MIT License (MIT) # Copyright (c) Microsoft Corporation # 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 # t...
data2vec_vision-main
s2s-ft/s2s_ft/configuration_unilm.py
from __future__ import absolute_import, division, print_function import logging import os import json import random import glob import torch import tqdm import torch.utils.data logger = logging.getLogger(__name__) class Seq2seqDatasetForBert(torch.utils.data.Dataset): def __init__( self, features, ...
data2vec_vision-main
s2s-ft/s2s_ft/utils.py
# coding=utf-8 # The MIT License (MIT) # Copyright (c) Microsoft Corporation # 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 # t...
data2vec_vision-main
s2s-ft/s2s_ft/tokenization_minilm.py
from __future__ import absolute_import, division, print_function, unicode_literals import logging import math import os import torch from torch import nn from torch.nn.modules.loss import _Loss import torch.nn.functional as F from transformers.modeling_bert import \ BertPreTrainedModel, BertSelfOutput, BertInter...
data2vec_vision-main
s2s-ft/s2s_ft/modeling.py
# -------------------------------------------------------- # BEIT: BERT Pre-Training of Image Transformers (https://arxiv.org/abs/2106.08254) # Github source: https://github.com/microsoft/unilm/tree/master/beit # Copyright (c) 2021 Microsoft # Licensed under The MIT License [see LICENSE for details] # By Hangbo Bao # B...
data2vec_vision-main
beit/engine_for_finetuning.py
""" Originally inspired by impl at https://github.com/zhunzhong07/Random-Erasing, Apache 2.0 Copyright Zhun Zhong & Liang Zheng Hacked together by / Copyright 2020 Ross Wightman Modified by Hangbo Bao, for generating the masked position for visual image transformer """ # ----------------------------------------------...
data2vec_vision-main
beit/masking_generator.py
# -------------------------------------------------------- # BEIT: BERT Pre-Training of Image Transformers (https://arxiv.org/abs/2106.08254) # Github source: https://github.com/microsoft/unilm/tree/master/beit # Copyright (c) 2021 Microsoft # Licensed under The MIT License [see LICENSE for details] # By Hangbo Bao # B...
data2vec_vision-main
beit/modeling_discrete_vae.py
# -------------------------------------------------------- # BEIT: BERT Pre-Training of Image Transformers (https://arxiv.org/abs/2106.08254) # Github source: https://github.com/microsoft/unilm/tree/master/beit # Copyright (c) 2021 Microsoft # Licensed under The MIT License [see LICENSE for details] # By Hangbo Bao # B...
data2vec_vision-main
beit/transforms.py
# -------------------------------------------------------- # BEIT: BERT Pre-Training of Image Transformers (https://arxiv.org/abs/2106.08254) # Github source: https://github.com/microsoft/unilm/tree/master/beit # Copyright (c) 2021 Microsoft # Licensed under The MIT License [see LICENSE for details] # By Hangbo Bao # B...
data2vec_vision-main
beit/engine_for_pretraining.py
# -------------------------------------------------------- # BEIT: BERT Pre-Training of Image Transformers (https://arxiv.org/abs/2106.08254) # Github source: https://github.com/microsoft/unilm/tree/master/beit # Copyright (c) 2021 Microsoft # Licensed under The MIT License [see LICENSE for details] # By Hangbo Bao # B...
data2vec_vision-main
beit/engine_for_cyclical_joint.py
# -------------------------------------------------------- # BEIT: BERT Pre-Training of Image Transformers (https://arxiv.org/abs/2106.08254) # Github source: https://github.com/microsoft/unilm/tree/master/beit # Copyright (c) 2021 Microsoft # Licensed under The MIT License [see LICENSE for details] # By Hangbo Bao # B...
data2vec_vision-main
beit/modeling_pretrain.py
# -------------------------------------------------------- # BEIT: BERT Pre-Training of Image Transformers (https://arxiv.org/abs/2106.08254) # Github source: https://github.com/microsoft/unilm/tree/master/beit # Copyright (c) 2021 Microsoft # Licensed under The MIT License [see LICENSE for details] # By Hangbo Bao # B...
data2vec_vision-main
beit/modeling_cyclical.py
# -------------------------------------------------------- # BEIT: BERT Pre-Training of Image Transformers (https://arxiv.org/abs/2106.08254) # Github source: https://github.com/microsoft/unilm/tree/master/beit # Copyright (c) 2021 Microsoft # Licensed under The MIT License [see LICENSE for details] # By Hangbo Bao # B...
data2vec_vision-main
beit/datasets.py
# -------------------------------------------------------- # BEIT: BERT Pre-Training of Image Transformers (https://arxiv.org/abs/2106.08254) # Github source: https://github.com/microsoft/unilm/tree/master/beit # Copyright (c) 2021 Microsoft # Licensed under The MIT License [see LICENSE for details] # By Hangbo Bao # B...
data2vec_vision-main
beit/modeling_cyclical_joint.py
# -------------------------------------------------------- # BEIT: BERT Pre-Training of Image Transformers (https://arxiv.org/abs/2106.08254) # Github source: https://github.com/microsoft/unilm/tree/master/beit # Copyright (c) 2021 Microsoft # Licensed under The MIT License [see LICENSE for details] # By Hangbo Bao # B...
data2vec_vision-main
beit/engine_for_cyclical.py
# -------------------------------------------------------- # BEIT: BERT Pre-Training of Image Transformers (https://arxiv.org/abs/2106.08254) # Github source: https://github.com/microsoft/unilm/tree/master/beit # Copyright (c) 2021 Microsoft # Licensed under The MIT License [see LICENSE for details] # By Hangbo Bao # B...
data2vec_vision-main
beit/run_cyclical.py
# -------------------------------------------------------- # BEIT: BERT Pre-Training of Image Transformers (https://arxiv.org/abs/2106.08254) # Github source: https://github.com/microsoft/unilm/tree/master/beit # Copyright (c) 2021 Microsoft # Licensed under The MIT License [see LICENSE for details] # By Hangbo Bao # B...
data2vec_vision-main
beit/run_class_finetuning.py
# -------------------------------------------------------- # BEIT: BERT Pre-Training of Image Transformers (https://arxiv.org/abs/2106.08254) # Github source: https://github.com/microsoft/unilm/tree/master/beit # Copyright (c) 2021 Microsoft # Licensed under The MIT License [see LICENSE for details] # By Hangbo Bao # M...
data2vec_vision-main
beit/dataset_folder.py
# -------------------------------------------------------- # BEIT: BERT Pre-Training of Image Transformers (https://arxiv.org/abs/2106.08254) # Github source: https://github.com/microsoft/unilm/tree/master/beit # Copyright (c) 2021 Microsoft # Licensed under The MIT License [see LICENSE for details] # By Hangbo Bao # B...
data2vec_vision-main
beit/run_beit_pretraining.py
# -------------------------------------------------------- # BEIT: BERT Pre-Training of Image Transformers (https://arxiv.org/abs/2106.08254) # Github source: https://github.com/microsoft/unilm/tree/master/beit # Copyright (c) 2021 Microsoft # Licensed under The MIT License [see LICENSE for details] # By Hangbo Bao # B...
data2vec_vision-main
beit/utils.py
# -------------------------------------------------------- # BEIT: BERT Pre-Training of Image Transformers (https://arxiv.org/abs/2106.08254) # Github source: https://github.com/microsoft/unilm/tree/master/beit # Copyright (c) 2021 Microsoft # Licensed under The MIT License [see LICENSE for details] # By Hangbo Bao # B...
data2vec_vision-main
beit/run_cyclical_joint.py
# -------------------------------------------------------- # BEIT: BERT Pre-Training of Image Transformers (https://arxiv.org/abs/2106.08254) # Github source: https://github.com/microsoft/unilm/tree/master/beit # Copyright (c) 2021 Microsoft # Licensed under The MIT License [see LICENSE for details] # By Hangbo Bao # B...
data2vec_vision-main
beit/modeling_finetune.py
# -------------------------------------------------------- # BEIT: BERT Pre-Training of Image Transformers (https://arxiv.org/abs/2106.08254) # Github source: https://github.com/microsoft/unilm/tree/master/beit # Copyright (c) 2021 Microsoft # Licensed under The MIT License [see LICENSE for details] # By Hangbo Bao # B...
data2vec_vision-main
beit/optim_factory.py
import attr import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from collections import OrderedDict from functools import partial from dall_e.utils import Conv2d @attr.s(eq=False, repr=False) class DecoderBlock(nn.Module): n_in: int = attr.ib(validator=lambda i, a, x: x >= ...
data2vec_vision-main
beit/dall_e/decoder.py
import io, requests import torch import torch.nn as nn from dall_e.encoder import Encoder from dall_e.decoder import Decoder from dall_e.utils import map_pixels, unmap_pixels def load_model(path: str, device: torch.device = None) -> nn.Module: if path.startswith('http://') or path.startswith('https://'): ...
data2vec_vision-main
beit/dall_e/__init__.py
import attr import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from collections import OrderedDict from functools import partial from dall_e.utils import Conv2d @attr.s(eq=False, repr=False) class EncoderBlock(nn.Module): n_in: int = attr.ib(validator=lambda i, a, x: x >= ...
data2vec_vision-main
beit/dall_e/encoder.py
import attr import math import torch import torch.nn as nn import torch.nn.functional as F logit_laplace_eps: float = 0.1 @attr.s(eq=False) class Conv2d(nn.Module): n_in: int = attr.ib(validator=lambda i, a, x: x >= 1) n_out: int = attr.ib(validator=lambda i, a, x: x >= 1) kw: int = attr.ib(validator=lambda i...
data2vec_vision-main
beit/dall_e/utils.py
import argparse import os import mmcv import torch from mmcv.parallel import MMDataParallel, MMDistributedDataParallel from mmcv.runner import get_dist_info, init_dist, load_checkpoint from mmcv.utils import DictAction from mmseg.apis import multi_gpu_test, single_gpu_test from mmseg.datasets import build_dataloader,...
data2vec_vision-main
beit/semantic_segmentation/tools/test.py
import argparse import copy import os import os.path as osp import time import mmcv import mmcv_custom import torch from mmcv.runner import init_dist from mmcv.utils import Config, DictAction, get_git_hash from mmseg import __version__ from mmseg.apis import set_random_seed from mmcv_custom import train_segmentor fro...
data2vec_vision-main
beit/semantic_segmentation/tools/train.py
import json from mmcv.runner import OPTIMIZER_BUILDERS, DefaultOptimizerConstructor from mmcv.runner import get_dist_info def get_num_layer_for_vit(var_name, num_max_layer): if var_name in ("backbone.cls_token", "backbone.mask_token", "backbone.pos_embed"): return 0 elif var_name.startswith("backbone....
data2vec_vision-main
beit/semantic_segmentation/mmcv_custom/layer_decay_optimizer_constructor.py
import random import warnings import numpy as np import torch from mmcv.parallel import MMDataParallel, MMDistributedDataParallel from mmcv.runner import build_optimizer, build_runner from mmseg.core import DistEvalHook, EvalHook from mmseg.datasets import build_dataloader, build_dataset from mmseg.utils import get_r...
data2vec_vision-main
beit/semantic_segmentation/mmcv_custom/train_api.py
import mmcv import numpy as np from mmseg.datasets.builder import PIPELINES @PIPELINES.register_module() class SETR_Resize(object): """Resize images & seg. This transform resizes the input image to some scale. If the input dict contains the key "scale", then the scale in the input dict is used, othe...
data2vec_vision-main
beit/semantic_segmentation/mmcv_custom/resize_transform.py
# Copyright (c) Open-MMLab. All rights reserved. import io import os import os.path as osp import pkgutil import time import warnings from collections import OrderedDict from importlib import import_module from tempfile import TemporaryDirectory import torch import torchvision from torch.optim import Optimizer from to...
data2vec_vision-main
beit/semantic_segmentation/mmcv_custom/checkpoint.py
# -*- coding: utf-8 -*- from .checkpoint import load_checkpoint from .layer_decay_optimizer_constructor import LayerDecayOptimizerConstructor from .resize_transform import SETR_Resize from .apex_runner.optimizer import DistOptimizerHook from .train_api import train_segmentor __all__ = ['load_checkpoint', 'LayerDecayO...
data2vec_vision-main
beit/semantic_segmentation/mmcv_custom/__init__.py
# Copyright (c) Open-MMLab. All rights reserved. import os.path as osp import platform import shutil import torch from torch.optim import Optimizer import mmcv from mmcv.runner import RUNNERS, IterBasedRunner from .checkpoint import save_checkpoint try: import apex except: print('apex is not installed') @R...
data2vec_vision-main
beit/semantic_segmentation/mmcv_custom/apex_runner/apex_iter_based_runner.py
# Copyright (c) Open-MMLab. All rights reserved. import os.path as osp import time from tempfile import TemporaryDirectory import torch from torch.optim import Optimizer import mmcv from mmcv.parallel import is_module_wrapper from mmcv.runner.checkpoint import weights_to_cpu, get_state_dict try: import apex exce...
data2vec_vision-main
beit/semantic_segmentation/mmcv_custom/apex_runner/checkpoint.py
# Copyright (c) Open-MMLab. All rights reserved. from .checkpoint import save_checkpoint from .apex_iter_based_runner import IterBasedRunnerAmp __all__ = [ 'save_checkpoint', 'IterBasedRunnerAmp', ]
data2vec_vision-main
beit/semantic_segmentation/mmcv_custom/apex_runner/__init__.py
from mmcv.runner import OptimizerHook, HOOKS try: import apex except: print('apex is not installed') @HOOKS.register_module() class DistOptimizerHook(OptimizerHook): """Optimizer hook for distributed training.""" def __init__(self, update_interval=1, grad_clip=None, coalesce=True, bucket_size_mb=-1, ...
data2vec_vision-main
beit/semantic_segmentation/mmcv_custom/apex_runner/optimizer.py
# yapf:disable log_config = dict( interval=50, hooks=[ dict(type='TextLoggerHook', by_epoch=False), # dict(type='TensorboardLoggerHook') ]) # yapf:enable dist_params = dict(backend='nccl') log_level = 'INFO' load_from = None resume_from = None workflow = [('train', 1)] cudnn_benchmark = True...
data2vec_vision-main
beit/semantic_segmentation/configs/_base_/default_runtime.py
# dataset settings dataset_type = 'ADE20KDataset' data_root = 'data/ade/ADEChallengeData2016' img_norm_cfg = dict( mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) crop_size = (640, 640) train_pipeline = [ dict(type='LoadImageFromFile'), dict(type='LoadAnnotations', reduce_zero_labe...
data2vec_vision-main
beit/semantic_segmentation/configs/_base_/datasets/ade20k_640x640.py
# dataset settings dataset_type = 'ADE20KDataset' data_root = 'data/ade/ADEChallengeData2016' img_norm_cfg = dict( mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) crop_size = (512, 512) train_pipeline = [ dict(type='LoadImageFromFile'), dict(type='LoadAnnotations', reduce_zero_labe...
data2vec_vision-main
beit/semantic_segmentation/configs/_base_/datasets/ade20k.py
# -------------------------------------------------------- # BEIT: BERT Pre-Training of Image Transformers (https://arxiv.org/abs/2106.08254) # Github source: https://github.com/microsoft/unilm/tree/master/beit # Copyright (c) 2021 Microsoft # Licensed under The MIT License [see LICENSE for details] # By Hangbo Bao # B...
data2vec_vision-main
beit/semantic_segmentation/configs/_base_/models/upernet_beit.py
# optimizer optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0005) optimizer_config = dict() # learning policy lr_config = dict(policy='poly', power=0.9, min_lr=1e-4, by_epoch=False) # runtime settings runner = dict(type='IterBasedRunner', max_iters=160000) checkpoint_config = dict(by_epoch=False, int...
data2vec_vision-main
beit/semantic_segmentation/configs/_base_/schedules/schedule_160k.py
# optimizer optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0005) optimizer_config = dict() # learning policy lr_config = dict(policy='poly', power=0.9, min_lr=1e-4, by_epoch=False) # runtime settings runner = dict(type='IterBasedRunner', max_iters=320000) checkpoint_config = dict(by_epoch=False, int...
data2vec_vision-main
beit/semantic_segmentation/configs/_base_/schedules/schedule_320k.py
# -------------------------------------------------------- # BEIT: BERT Pre-Training of Image Transformers (https://arxiv.org/abs/2106.08254) # Github source: https://github.com/microsoft/unilm/tree/master/beit # Copyright (c) 2021 Microsoft # Licensed under The MIT License [see LICENSE for details] # By Hangbo Bao # B...
data2vec_vision-main
beit/semantic_segmentation/configs/beit/upernet/upernet_beit_large_24_640_slide_160k_ade20k.py
# -------------------------------------------------------- # BEIT: BERT Pre-Training of Image Transformers (https://arxiv.org/abs/2106.08254) # Github source: https://github.com/microsoft/unilm/tree/master/beit # Copyright (c) 2021 Microsoft # Licensed under The MIT License [see LICENSE for details] # By Hangbo Bao # B...
data2vec_vision-main
beit/semantic_segmentation/configs/beit/upernet/upernet_beit_large_24_512_slide_160k_ade20k.py
# -------------------------------------------------------- # BEIT: BERT Pre-Training of Image Transformers (https://arxiv.org/abs/2106.08254) # Github source: https://github.com/microsoft/unilm/tree/master/beit # Copyright (c) 2021 Microsoft # Licensed under The MIT License [see LICENSE for details] # By Hangbo Bao # B...
data2vec_vision-main
beit/semantic_segmentation/configs/beit/upernet/upernet_beit_base_12_512_slide_160k_ade20k.py
# -------------------------------------------------------- # BEIT: BERT Pre-Training of Image Transformers (https://arxiv.org/abs/2106.08254) # Github source: https://github.com/microsoft/unilm/tree/master/beit # Copyright (c) 2021 Microsoft # Licensed under The MIT License [see LICENSE for details] # By Hangbo Bao # B...
data2vec_vision-main
beit/semantic_segmentation/configs/beit/upernet/upernet_beit_base_12_512_slide_160k_ade20k_ms.py
# -------------------------------------------------------- # BEIT: BERT Pre-Training of Image Transformers (https://arxiv.org/abs/2106.08254) # Github source: https://github.com/microsoft/unilm/tree/master/beit # Copyright (c) 2021 Microsoft # Licensed under The MIT License [see LICENSE for details] # By Hangbo Bao # B...
data2vec_vision-main
beit/semantic_segmentation/configs/beit/upernet/upernet_beit_large_24_512_slide_160k_ade20k_ms.py
# -------------------------------------------------------- # BEIT: BERT Pre-Training of Image Transformers (https://arxiv.org/abs/2106.08254) # Github source: https://github.com/microsoft/unilm/tree/master/beit # Copyright (c) 2021 Microsoft # Licensed under The MIT License [see LICENSE for details] # By Hangbo Bao # B...
data2vec_vision-main
beit/semantic_segmentation/configs/beit/upernet/upernet_beit_base_12_640_slide_160k_ade20k_ms.py
# -------------------------------------------------------- # BEIT: BERT Pre-Training of Image Transformers (https://arxiv.org/abs/2106.08254) # Github source: https://github.com/microsoft/unilm/tree/master/beit # Copyright (c) 2021 Microsoft # Licensed under The MIT License [see LICENSE for details] # By Hangbo Bao # B...
data2vec_vision-main
beit/semantic_segmentation/configs/beit/upernet/upernet_beit_large_24_640_slide_160k_ade20k_ms.py
# -------------------------------------------------------- # BEIT: BERT Pre-Training of Image Transformers (https://arxiv.org/abs/2106.08254) # Github source: https://github.com/microsoft/unilm/tree/master/beit # Copyright (c) 2021 Microsoft # Licensed under The MIT License [see LICENSE for details] # By Hangbo Bao # B...
data2vec_vision-main
beit/semantic_segmentation/configs/beit/upernet/upernet_beit_base_12_640_slide_160k_ade20k.py
# -------------------------------------------------------- # BEIT: BERT Pre-Training of Image Transformers (https://arxiv.org/abs/2106.08254) # Github source: https://github.com/microsoft/unilm/tree/master/beit # Copyright (c) 2021 Microsoft # Licensed under The MIT License [see LICENSE for details] # By Hangbo Bao # B...
data2vec_vision-main
beit/semantic_segmentation/backbone/beit.py
#!/usr/bin/env python3 import torch from setuptools import find_packages, setup torch_ver = [int(x) for x in torch.__version__.split(".")[:2]] assert torch_ver >= [1, 4], "Requires PyTorch >= 1.4" setup( name="layoutlm", version="0.0", author="Yiheng Xu", url="https://github.com/microsoft/unilm/tree/m...
data2vec_vision-main
layoutlm/deprecated/setup.py
# coding=utf-8 from __future__ import absolute_import, division, print_function import argparse import glob import logging import os import random import numpy as np import torch from torch.utils.data import DataLoader, RandomSampler, SequentialSampler from torch.utils.data.distributed import DistributedSampler from ...
data2vec_vision-main
layoutlm/deprecated/examples/classification/run_classification.py
import argparse import json import os from PIL import Image from transformers import AutoTokenizer def bbox_string(box, width, length): return ( str(int(1000 * (box[0] / width))) + " " + str(int(1000 * (box[1] / length))) + " " + str(int(1000 * (box[2] / width))) +...
data2vec_vision-main
layoutlm/deprecated/examples/seq_labeling/preprocess.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a cop...
data2vec_vision-main
layoutlm/deprecated/examples/seq_labeling/run_seq_labeling.py
# flake8: noqa from .data.funsd import FunsdDataset from .modeling.layoutlm import ( LayoutlmConfig, LayoutlmForSequenceClassification, LayoutlmForTokenClassification, )
data2vec_vision-main
layoutlm/deprecated/layoutlm/__init__.py
data2vec_vision-main
layoutlm/deprecated/layoutlm/modeling/__init__.py
import logging import torch from torch import nn from torch.nn import CrossEntropyLoss, MSELoss from transformers import BertConfig, BertModel, BertPreTrainedModel from transformers.modeling_bert import BertLayerNorm logger = logging.getLogger(__name__) LAYOUTLM_PRETRAINED_MODEL_ARCHIVE_MAP = {} LAYOUTLM_PRETRAINED...
data2vec_vision-main
layoutlm/deprecated/layoutlm/modeling/layoutlm.py
# coding=utf-8 import copy import json import logging import os import re from multiprocessing import Pool import torch from lxml import html from torch.utils.data import TensorDataset from tqdm import tqdm from transformers import DataProcessor logger = logging.getLogger(__name__) def get_text(node): textnodes...
data2vec_vision-main
layoutlm/deprecated/layoutlm/data/rvl_cdip.py
# flake8: noqa from .funsd import FunsdDataset
data2vec_vision-main
layoutlm/deprecated/layoutlm/data/__init__.py
import logging import os import torch from torch.utils.data import Dataset logger = logging.getLogger(__name__) class FunsdDataset(Dataset): def __init__(self, args, tokenizer, labels, pad_token_label_id, mode): if args.local_rank not in [-1, 0] and mode == "train": torch.distributed.barrier...
data2vec_vision-main
layoutlm/deprecated/layoutlm/data/funsd.py
from setuptools import setup, find_packages setup( name = "adalm", version = "0.0", author = "Microsoft", author_email = "", description = "domain adaptation toolkit", keywords = "domain adaptation with extended vocab", license='Apache', url = "https://github.com/littlefive5/AdaLM", ...
data2vec_vision-main
adalm/setup.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a cop...
data2vec_vision-main
adalm/finetune/run_ner.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a cop...
data2vec_vision-main
adalm/finetune/utils_ner.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a cop...
data2vec_vision-main
adalm/finetune/run_pico.py
data2vec_vision-main
adalm/finetune/__init__.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a cop...
data2vec_vision-main
adalm/finetune/run_classifier.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a cop...
data2vec_vision-main
adalm/finetune/utils_for_glue.py
from __future__ import absolute_import from __future__ import division from numpy.core.fromnumeric import argsort from text_encoder import SubwordTextEncoder import tokenizer import tempfile import argparse from transformers import BertTokenizer import random import math import numpy as np def merge_output_file_with_b...
data2vec_vision-main
adalm/incr_bpe/vocab_extend.py
# coding=utf-8 # Copyright 2018 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
data2vec_vision-main
adalm/incr_bpe/text_encoder.py
# coding=utf-8 # Copyright 2018 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
data2vec_vision-main
adalm/incr_bpe/tokenizer.py
#-*- coding: utf-8 -*- from __future__ import absolute_import from __future__ import division from text_encoder import SubwordTextEncoder import tokenizer import os import tempfile import tensorflow as tf tf.flags.DEFINE_string('output_filename', '/tmp/my.subword_text_encoder', 'where to store...
data2vec_vision-main
adalm/incr_bpe/subword_builder.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. import logging from typing import List, Optional import numpy as np from base import BaseModel from stats import DirichletMultinomial, DirichletPrior, NormalInverseGammaNormal logging.basicConfig(level=logging.INFO) logger = logging.getLogg...
clara-main
gibbs.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. import logging import math from collections import defaultdict from typing import Dict, Generic, List, Optional, TypeVar import numpy as np from scipy.special import loggamma from scipy.stats import norm logger = logging.getLogger(__name__) ...
clara-main
stats.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. import logging import numpy as np import pandas as pd logger = logging.getLogger(__name__) def generate_score( true_ratings: np.array, score_means: np.array, score_stdvs: np.array ): num_items = len(true_ratings) num_ones = np....
clara-main
simulator.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. from abc import ABC, abstractmethod class BaseModel(ABC): def __init__(self, name: str, **kwargs): self.name = name @abstractmethod def fit(self, **kwargs): pass @abstractmethod def predict(self, **kwargs...
clara-main
base.py
from collections import defaultdict from typing import Dict, List, NamedTuple import numpy as np import pandas as pd def generate_common_cm(L: int, h: float, gamma: float) -> np.ndarray: """ Generates the L x L common confusion matrix using the heterogeneity factor, h and the lower bound on accuracy, gam...
clara-main
mapping-aware-model/simulator.py
stan_code=""" data { int<lower=1> A; // number of annotators int<lower=2> K; // number of categories int<lower=1> N; // number of annotations int<lower=1> I; // number of items int<lower=1> L; // total number of flat labels (L i...
clara-main
mapping-aware-model/mapping_aware_model.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import argparse import json import logging import os from utils import file_tqdm logging.basicCon...
code-prediction-transformer-main
generate_new_trees.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import argparse import json import logging import pickle from collections import Counter from utils...
code-prediction-transformer-main
generate_vocab.py
#!/usr/bin/env python3 # Copyright (c) 2019 OpenAI, HugginFace Inc. team. and TaeHwan Jung # Copyright (c) Facebook, Inc. and its affiliates. # ---------------------------------------------------------------------------- # MIT LICENSE # # Permission is hereby granted, free of charge, to any person obtaining a copy # of...
code-prediction-transformer-main
model.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import json import logging import os import pickle import torch import utils logging.basicConfig(...
code-prediction-transformer-main
dataset.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import math import multiprocessing as mp from tqdm import tqdm def line_positions(file_path): ...
code-prediction-transformer-main
utils.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import json import logging from functools import partial from typing import Set import torch tor...
code-prediction-transformer-main
train.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import LSTMModel import Dataset, Vocab import json import os import torch import argparse import...
code-prediction-transformer-main
demo.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import argparse import json import logging import pickle import re from collections import Counter ...
code-prediction-transformer-main
code2seq/generate_vocab.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import json import logging import torch import utils logging.basicConfig(level=logging.INFO) UN...
code-prediction-transformer-main
code2seq/dataset.py
import argparse import json import os import pickle import random import re from collections import defaultdict from itertools import chain, combinations, product from utils import get_ancestors, get_terminal_nodes, parallelize, tokenize from tqdm import tqdm PLACEHOLDER = "<placeholder_token>" UNK = "<unk_token>" ...
code-prediction-transformer-main
code2seq/generate_data.py
#!/usr/bin/env python3 # Copyright (c) 2019 Technion # Copyright (c) Facebook, Inc. and its affiliates. # ---------------------------------------------------------------------------- # MIT License # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documenta...
code-prediction-transformer-main
code2seq/code2seq_model.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import torch from dataset.dataset import BaseDataset, BaseSetup, BaseVocab class Setup(BaseSetup):...
code-prediction-transformer-main
models/path_trans_variation/dataset.py