repo
stringlengths
2
99
file
stringlengths
13
225
code
stringlengths
0
18.3M
file_length
int64
0
18.3M
avg_line_length
float64
0
1.36M
max_line_length
int64
0
4.26M
extension_type
stringclasses
1 value
NORPPA
NORPPA-main/datasets.py
import os from pathlib import Path from tools import read_image import csv import numpy as np from torch.utils.data import Dataset import os class DatasetSlice(Dataset): def __init__(self, dataset, slice=None): self.dataset = dataset self.slice = (0, len(self.dataset)) if slice is None else slice ...
8,014
29.708812
106
py
NORPPA
NORPPA-main/vis_new_pattern.py
import os # import sys # sys.path.append('/ekaterina/work/src/NORPPA/repository/NORPPA') os.environ["CUDA_VISIBLE_DEVICES"]="1" from config_whaleshark import config import matplotlib.pyplot as plt from pathlib import Path import numpy as np import zipfile import tensorflow as tf import wget import pickle physical_dev...
3,022
34.564706
136
py
NORPPA
NORPPA-main/config_whaleshark.py
import sys from pathlib import Path import cv2 import numpy as np file_folder = Path(__file__).resolve().parent sys.path.append(str(file_folder / "reidentification/hesaff_pytorch")) from HessianAffinePatches import init_affnet, init_orinet, init_hardnet from segmentation.detectron_segment import create_predicto...
4,166
41.520408
131
py
NORPPA
NORPPA-main/codebooks_whaleshark.py
import os # import sys # sys.path.append('/ekaterina/work/src/NORPPA/repository/NORPPA') os.environ["CUDA_VISIBLE_DEVICES"]="1" from config_whaleshark import config import matplotlib.pyplot as plt from pathlib import Path import numpy as np import zipfile import tensorflow as tf import wget import pickle physical_dev...
1,668
30.490566
111
py
NORPPA
NORPPA-main/segmentation/train_dataset.py
from pathlib import Path import os import pycocotools from PIL import Image import numpy as np from detectron2.structures import BoxMode def create_dataset_json(full_dir, segmented_dir, keyword="", suffix=".result.png"): full_dir = Path(full_dir) segmented_dir = Path(segmented_dir) result = [] counter ...
1,616
34.933333
93
py
NORPPA
NORPPA-main/segmentation/segmentation.py
from segmentation.detectron_segment import detectron_segment def add_instance_info(label, instance, num_instances): if type(label) is dict: label["instance"] = instance label["num_instances"] = num_instances return label else: return (label, instance) def segment(input, predic...
733
30.913043
108
py
NORPPA
NORPPA-main/segmentation/detectron_segment.py
from argparse import ArgumentParser from PIL import Image from detectron2 import model_zoo from detectron2.config import get_cfg from detectron2.engine import DefaultPredictor import numpy as np import cv2 import rawpy from pathlib import Path def is_raw_image(filename): return filename.lower().endswith(('cr2', 'p...
3,654
32.842593
105
py
NORPPA
NORPPA-main/reidentification/geometric.py
from skimage.measure import label from sklearn.decomposition import KernelPCA from skimage.morphology import convex_hull_image, skeletonize from cyvlfeat.fisher import fisher from PIL import Image import math from sql import * import torch from torchvision import transforms import pickle from reidentification.encodi...
4,128
32.298387
111
py
NORPPA
NORPPA-main/reidentification/visualisation.py
from PIL import Image import matplotlib.pyplot as plt import numpy as np from reidentification.identify import fisher_single, do_matching from reidentification.encoding_utils import calculate_dists def rescale_img(img, scale): return img.resize([int(s*scale) for s in img.size], Image.Resampling.LANCZOS) def resi...
6,875
43.36129
282
py
NORPPA
NORPPA-main/reidentification/encoding_utils.py
from scipy.spatial.distance import cdist from sklearn.decomposition import IncrementalPCA from cyvlfeat.gmm import gmm from cyvlfeat.fisher import fisher from scipy.spatial.distance import cdist, cosine import numpy as np import os import shutil from PIL import Image import io from base64 import encodebytes from sklear...
4,071
29.616541
149
py
NORPPA
NORPPA-main/reidentification/find_matches.py
from PIL import Image import matplotlib.pyplot as plt import numpy as np from reidentification.identify import fisher_single, do_matching from reidentification.encoding_utils import calculate_dists def find_matches(identification_result, cfg): matches, query_labels = identification_result query_images = query...
1,666
38.690476
101
py
NORPPA
NORPPA-main/reidentification/identify.py
from skimage.measure import label from sklearn.decomposition import KernelPCA from skimage.morphology import convex_hull_image, skeletonize from cyvlfeat.fisher import fisher from PIL import Image import math from sql import * import torch from torchvision import transforms import pickle from reidentification.encodi...
16,717
33.328542
155
py
NORPPA
NORPPA-main/reidentification/hesaff_pytorch/HandCraftedModules.py
import torch import torch.nn as nn import torch.nn.functional as F from torch.autograd import Variable import math import numpy as np from Utils import GaussianBlur, CircularGaussKernel from LAF import abc2A,rectifyAffineTransformationUpIsUp, sc_y_x2LAFs from Utils import generate_2dgrid, generate_2dgrid, generate_3dg...
13,280
43.27
145
py
NORPPA
NORPPA-main/reidentification/hesaff_pytorch/HardNet.py
import sys import torch import torch.nn as nn import torch.nn.functional as F from torch.autograd import Variable import torch.backends.cudnn as cudnn import time import os import math import numpy as np class L2Norm(nn.Module): def __init__(self): super(L2Norm,self).__init__() self.eps = 1e-8 ...
3,589
34.544554
155
py
NORPPA
NORPPA-main/reidentification/hesaff_pytorch/HessianAffinePatches.py
import torch import torch.nn as nn import numpy as np from torch.autograd import Variable from SparseImgRepresenter import ScaleSpaceAffinePatchExtractor from LAF import denormalizeLAFs, LAFs2ell from Utils import line_prepender from architectures import AffNetFast, OriNetFast from skimage.filters import unsharp_mask...
3,848
36.735294
111
py
NORPPA
NORPPA-main/reidentification/hesaff_pytorch/LAF.py
import numpy as np import matplotlib.pyplot as plt from copy import deepcopy from scipy.spatial.distance import cdist from numpy.linalg import inv from scipy.linalg import schur, sqrtm import torch from torch.autograd import Variable import torch.nn.functional as F ##########numpy def invSqrt(a,b,c): eps = 1e-...
17,704
36.352321
142
py
NORPPA
NORPPA-main/reidentification/hesaff_pytorch/SparseImgRepresenter.py
import torch import torch.nn as nn import numpy as np import math import torch.nn.functional as F from torch.autograd import Variable from copy import deepcopy from Utils import GaussianBlur, batch_eig2x2, line_prepender, batched_forward from LAF import LAFs2ell,abc2A, angles2A, generate_patch_grid_from_normalized_LAFs...
10,911
49.753488
231
py
NORPPA
NORPPA-main/reidentification/hesaff_pytorch/ReprojectonStuff.py
import torch from torch.autograd import Variable import numpy as np from LAF import rectifyAffineTransformationUpIsUp from Utils import zeros_like def distance_matrix_vector(anchor, positive): """Given batch of anchor descriptors and positive descriptors calculate distance matrix""" d1_sq = torch.sum(anchor * ...
6,844
45.25
177
py
NORPPA
NORPPA-main/reidentification/hesaff_pytorch/Utils.py
import torch import torch.nn.init import torch.nn as nn import torch.nn.functional as F from torch.autograd import Variable import cv2 import numpy as np # resize image to size 32x32 cv2_scale = lambda x: cv2.resize(x, dsize=(32, 32), interpolation=cv2.INTER_LINEAR) # reshape image np_...
6,244
33.125683
144
py
NORPPA
NORPPA-main/reidentification/hesaff_pytorch/architectures.py
from __future__ import division, print_function import os import errno import numpy as np import sys from copy import deepcopy import math import torch import torch.nn.init import torch.nn as nn import torch.optim as optim import torch.nn.functional as F import torchvision.transforms as transforms from torch.autograd i...
36,272
45.32567
223
py
NORPPA
NORPPA-main/reidentification/hesaff_pytorch/extract_features_oxaff.py
import torch import torch.nn as nn import numpy as np import sys import time from PIL import Image from torch.autograd import Variable from SparseImgRepresenter import ScaleSpaceAffinePatchExtractor from LAF import denormalizeLAFs, LAFs2ell from Utils import line_prepender USE_CUDA = False try: input_img_fname =...
1,140
27.525
107
py
NORPPA
NORPPA-main/reidentification/hesaff_pytorch/pytorch_sift.py
import torch import math import torch.nn.init import torch.nn as nn from torch.autograd import Variable import torch.backends.cudnn as cudnn import numpy as np class L2Norm(nn.Module): def __init__(self): super(L2Norm,self).__init__() self.eps = 1e-10 def forward(self, x): norm = torch....
4,815
42.781818
129
py
NORPPA
NORPPA-main/tonemapping/tonemapping.py
""" The script peforms tone mapping. Usage: python correct.py -s <source_dir_path> -d <dest_dir_path> There is no need to create the directory for the results manually since it will be generated automatically preseving the structure of the source directory. """ from argparse import ArgumentParser import json import...
2,371
25.065934
195
py
NORPPA
NORPPA-main/pattern_extraction/extract_pattern.py
from math import ceil, floor import numpy as np from PIL import ImageFile import tensorflow as tf from math import ceil, floor from pattern_extraction.model import * from pattern_extraction.utils import * from pathlib import Path import skimage.transform as trans file_folder = Path(__file__).resolve().parent ImageFi...
1,445
27.92
109
py
NORPPA
NORPPA-main/pattern_extraction/utils.py
import numpy as np import skimage.transform as trans from skimage.morphology import skeletonize from PIL import Image from math import ceil, floor def crop(img_path, flag_multi_class=False): img = np.asarray(Image.open(img_path).convert('L')) size_y, size_x = img.shape where = np.where(img!=0) y1, ...
2,283
28.662338
113
py
NORPPA
NORPPA-main/pattern_extraction/model.py
import numpy as np import os import skimage.io as io import skimage.transform as trans import numpy as np from tensorflow.keras.models import * from tensorflow.keras.layers import * from tensorflow.keras.optimizers import * from tensorflow.keras.callbacks import ModelCheckpoint, LearningRateScheduler from tensorflow.k...
3,797
56.545455
132
py
llm_expository
llm_expository-main/ChatGPT_generated_code_01.py
import numpy as np import matplotlib.pyplot as plt def ewma(x, y, alpha): return (1 - alpha) * x + alpha * y def simulate_ewma(n, alpha, k, num_simulations): arls = [] for i in range(num_simulations): x = np.random.normal(0, 1, n) ewma_stat = np.zeros(n) ewma_stat[0] = x[0] ...
792
24.580645
60
py
robust-transformers
robust-transformers-main/conftest.py
# Copyright 2020 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
2,846
35.037975
107
py
robust-transformers
robust-transformers-main/setup.py
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
14,253
33.019093
259
py
robust-transformers
robust-transformers-main/hubconf.py
# Copyright 2020 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
8,496
51.450617
189
py
robust-transformers
robust-transformers-main/examples/research_projects/longform-qa/eli5_app.py
import datasets import numpy as np import streamlit as st import torch from elasticsearch import Elasticsearch import faiss import transformers from eli5_utils import ( embed_questions_for_retrieval, make_qa_s2s_model, qa_s2s_generate, query_es_index, query_qa_dense_index, ) from transformers impor...
13,474
37.28125
159
py
robust-transformers
robust-transformers-main/examples/research_projects/longform-qa/eli5_utils.py
import functools import math import os # noqa: F401 from random import choice, randint from time import time import datasets # noqa: F401 import numpy as np import pandas as pd import torch import torch.utils.checkpoint as checkpoint from elasticsearch import Elasticsearch # noqa: F401 from elasticsearch.helpers im...
28,299
40.07402
119
py
robust-transformers
robust-transformers-main/examples/research_projects/codeparrot/scripts/preprocessing.py
import gzip import multiprocessing import os import shutil import time import numpy as np from datasets import load_dataset from arguments import PreprocessingArguments from transformers import HfArgumentParser def get_hash(example): """Get hash of content field.""" return {"hash": hash(example["content"])}...
3,864
30.422764
100
py
robust-transformers
robust-transformers-main/examples/research_projects/codeparrot/scripts/arguments.py
from dataclasses import dataclass, field from typing import Optional @dataclass class TrainingArguments: """ Configuration for training model. """ model_ckpt: Optional[str] = field( default="lvwerra/codeparrot", metadata={"help": "Model name or path of model to be trained."}, ) ...
8,452
44.446237
174
py
robust-transformers
robust-transformers-main/examples/research_projects/codeparrot/scripts/codeparrot_training.py
import logging from argparse import Namespace from pathlib import Path import datasets import torch from datasets import load_dataset from torch.utils.data import IterableDataset from torch.utils.data.dataloader import DataLoader from torch.utils.tensorboard import SummaryWriter import transformers import wandb from ...
9,194
37.153527
119
py
robust-transformers
robust-transformers-main/examples/research_projects/codeparrot/scripts/initialize_model.py
from arguments import InitializationArguments from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer, HfArgumentParser # Configuration parser = HfArgumentParser(InitializationArguments) args = parser.parse_args() # Load codeparrot tokenizer trained for Python code tokenization tokenizer = AutoToken...
857
36.304348
112
py
robust-transformers
robust-transformers-main/examples/research_projects/codeparrot/scripts/validation_loss.py
import logging import torch from datasets import load_dataset from torch.utils.data import IterableDataset from torch.utils.data.dataloader import DataLoader from accelerate import Accelerator from arguments import EvaluationArguments from transformers import AutoModelForCausalLM, AutoTokenizer, HfArgumentParser, set...
3,496
33.97
114
py
robust-transformers
robust-transformers-main/examples/research_projects/codeparrot/scripts/human_eval.py
import json import multiprocessing import os import re from datasets import load_dataset, load_metric from tqdm import tqdm import transformers from arguments import HumanEvalArguments from transformers import ( AutoModelForCausalLM, AutoTokenizer, HfArgumentParser, StoppingCriteria, StoppingCrite...
4,789
36.716535
147
py
robust-transformers
robust-transformers-main/examples/research_projects/codeparrot/scripts/bpe_training.py
from datasets import load_dataset from tqdm import tqdm from arguments import TokenizerTrainingArguments from transformers import AutoTokenizer, HfArgumentParser from transformers.models.gpt2.tokenization_gpt2 import bytes_to_unicode # Iterator for Training def batch_iterator(batch_size=10): for _ in tqdm(range(...
1,015
29.787879
80
py
robust-transformers
robust-transformers-main/examples/research_projects/bertology/run_prune_gpt.py
#!/usr/bin/env python3 """ This script is adapted from the Bertology pruning code (https://github.com/huggingface/transformers/blob/783d7d2629e97c5f0c5f9ef01b8c66410275c204/examples/research_projects/bertology/run_bertology.py) to prune GPT-like models. The author is @altsoph. """ import argparse import logging import...
15,469
38.666667
204
py
robust-transformers
robust-transformers-main/examples/research_projects/bertology/run_bertology.py
#!/usr/bin/env python3 # Copyright 2018 CMU and The HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless requir...
18,572
40.181818
118
py
robust-transformers
robust-transformers-main/examples/research_projects/rag/use_own_knowledge_dataset.py
import logging import os from dataclasses import dataclass, field from functools import partial from pathlib import Path from tempfile import TemporaryDirectory from typing import List, Optional import torch from datasets import Features, Sequence, Value, load_dataset import faiss from transformers import ( DPRCo...
8,174
38.878049
152
py
robust-transformers
robust-transformers-main/examples/research_projects/rag/consolidate_rag_checkpoint.py
""" A script creating a RAG checkpoint from a generator and a question encoder checkpoints. """ import argparse from pathlib import Path from transformers import AutoConfig, AutoTokenizer, RagConfig, RagSequenceForGeneration, RagTokenForGeneration def consolidate( model_type, generator_name_or_path: str, ...
3,640
35.41
124
py
robust-transformers
robust-transformers-main/examples/research_projects/rag/utils_rag.py
import itertools import json import linecache import os import pickle import re import socket import string from collections import Counter from logging import getLogger from pathlib import Path from typing import Callable, Dict, Iterable, List import git import torch from torch.utils.data import Dataset from transfo...
8,114
32.122449
118
py
robust-transformers
robust-transformers-main/examples/research_projects/rag/finetune_rag.py
"""Finetuning script for RAG models. Adapted from examples.seq2seq.finetune.py""" import argparse import logging import os import sys import time from collections import defaultdict from pathlib import Path from typing import Any, Dict, List, Tuple import numpy as np import pytorch_lightning as pl import torch import...
25,623
40.462783
197
py
robust-transformers
robust-transformers-main/examples/research_projects/rag/distributed_pytorch_retriever.py
import logging import os from typing import List, Tuple import numpy as np import psutil import torch import torch.distributed as dist from transformers import RagRetriever logger = logging.getLogger(__name__) class RagPyTorchDistributedRetriever(RagRetriever): """ A distributed retriever built on top of ...
6,539
46.05036
155
py
robust-transformers
robust-transformers-main/examples/research_projects/rag/test_distributed_retriever.py
import json import os import shutil import sys import tempfile import unittest from unittest import TestCase from unittest.mock import patch import numpy as np from datasets import Dataset import faiss from transformers import BartConfig, BartTokenizer, DPRConfig, DPRQuestionEncoderTokenizer, RagConfig from transform...
13,794
39.693215
118
py
robust-transformers
robust-transformers-main/examples/research_projects/rag/eval_rag.py
""" Evaluation script for RAG models.""" import argparse import ast import logging import os import sys import pandas as pd import torch from tqdm import tqdm from transformers import BartForConditionalGeneration, RagRetriever, RagSequenceForGeneration, RagTokenForGeneration from transformers import logging as trans...
11,101
34.469649
132
py
robust-transformers
robust-transformers-main/examples/research_projects/rag/lightning_base.py
import argparse import logging import os from pathlib import Path from typing import Any, Dict import pytorch_lightning as pl from pytorch_lightning.utilities import rank_zero_info from transformers import ( AdamW, AutoConfig, AutoModel, AutoModelForPreTraining, AutoModelForQuestionAnswering, ...
15,609
37.734491
124
py
robust-transformers
robust-transformers-main/examples/research_projects/rag/callbacks_rag.py
import logging from pathlib import Path import numpy as np import pytorch_lightning as pl import torch from pytorch_lightning.callbacks import EarlyStopping, ModelCheckpoint from pytorch_lightning.utilities import rank_zero_only from utils_rag import save_json def count_trainable_parameters(model): model_parame...
4,428
36.854701
126
py
robust-transformers
robust-transformers-main/examples/research_projects/rag/parse_dpr_relevance_data.py
""" This script reads DPR retriever training data and parses each datapoint. We save a line per datapoint. Each line consists of the query followed by a tab-separated list of Wikipedia page titles constituting positive contexts for a given query. """ import argparse import json from tqdm import tqdm def main(): ...
1,353
27.208333
102
py
robust-transformers
robust-transformers-main/examples/research_projects/rag/_test_finetune_rag.py
import json import logging import os import sys from pathlib import Path import finetune_rag from transformers.file_utils import is_apex_available from transformers.testing_utils import ( TestCasePlus, execute_subprocess_async, require_ray, require_torch_gpu, require_torch_multi_gpu, ) logging.ba...
3,969
34.765766
85
py
robust-transformers
robust-transformers-main/examples/research_projects/rag/__init__.py
import os import sys sys.path.insert(1, os.path.dirname(os.path.realpath(__file__)))
87
13.666667
63
py
robust-transformers
robust-transformers-main/examples/research_projects/rag/distributed_ray_retriever.py
import logging import random import ray from transformers import RagConfig, RagRetriever, RagTokenizer from transformers.models.rag.retrieval_rag import CustomHFIndex logger = logging.getLogger(__name__) class RayRetriever: def __init__(self): self.initialized = False def create_rag_retriever(self...
7,185
46.276316
132
py
robust-transformers
robust-transformers-main/examples/research_projects/pplm/run_pplm.py
#! /usr/bin/env python3 # coding=utf-8 # Copyright (c) 2019 Uber Technologies, Inc. # # 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 ...
29,044
34.078502
182
py
robust-transformers
robust-transformers-main/examples/research_projects/pplm/run_pplm_discrim_train.py
#! /usr/bin/env python3 # coding=utf-8 # Copyright (c) 2019 Uber Technologies, Inc. # # 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 ...
18,788
34.92543
117
py
robust-transformers
robust-transformers-main/examples/research_projects/pplm/pplm_classification_head.py
from torch import nn class ClassificationHead(nn.Module): """Classification Head for transformer encoders""" def __init__(self, class_size, embed_size): super().__init__() self.class_size = class_size self.embed_size = embed_size # self.mlp1 = nn.Linear(embed_size, embed_size...
651
31.6
68
py
robust-transformers
robust-transformers-main/examples/research_projects/deebert/test_glue_deebert.py
import argparse import logging import sys from unittest.mock import patch import run_glue_deebert from transformers.testing_utils import TestCasePlus, get_gpu_count, require_torch_non_multi_gpu, slow logging.basicConfig(level=logging.DEBUG) logger = logging.getLogger() def get_setup_file(): parser = argparse....
3,690
34.152381
109
py
robust-transformers
robust-transformers-main/examples/research_projects/deebert/run_glue_deebert.py
from __future__ import absolute_import, division, print_function import argparse import glob import logging import os import random import time import numpy as np import torch from torch import nn from torch.utils.data import DataLoader, RandomSampler, SequentialSampler, TensorDataset from torch.utils.data.distribute...
31,693
42.297814
150
py
robust-transformers
robust-transformers-main/examples/research_projects/deebert/src/modeling_highway_bert.py
import torch from torch import nn from torch.nn import CrossEntropyLoss, MSELoss from transformers.file_utils import add_start_docstrings, add_start_docstrings_to_model_forward from transformers.models.bert.modeling_bert import ( BERT_INPUTS_DOCSTRING, BERT_START_DOCSTRING, BertEmbeddings, BertLayer, ...
17,668
43.506297
172
py
robust-transformers
robust-transformers-main/examples/research_projects/deebert/src/__init__.py
0
0
0
py
robust-transformers
robust-transformers-main/examples/research_projects/deebert/src/modeling_highway_roberta.py
from __future__ import absolute_import, division, print_function, unicode_literals from torch import nn from torch.nn import CrossEntropyLoss, MSELoss from transformers import RobertaConfig from transformers.file_utils import add_start_docstrings, add_start_docstrings_to_model_forward from transformers.models.roberta...
6,791
42.261146
172
py
robust-transformers
robust-transformers-main/examples/research_projects/lxmert/modeling_frcnn.py
""" coding=utf-8 Copyright 2018, Antonio Mendoza Hao Tan, Mohit Bansal Adapted From Facebook Inc, Detectron2 && Huggingface Co. 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...
73,726
37.359521
152
py
robust-transformers
robust-transformers-main/examples/research_projects/lxmert/extracting_data.py
import getopt import json import os # import numpy as np import sys from collections import OrderedDict import datasets import numpy as np import torch from modeling_frcnn import GeneralizedRCNN from processing_image import Preprocess from utils import Config """ USAGE: ``python extracting_data.py -i <img_dir> -o ...
5,254
34.033333
109
py
robust-transformers
robust-transformers-main/examples/research_projects/lxmert/utils.py
""" coding=utf-8 Copyright 2018, Antonio Mendoza Hao Tan, Mohit Bansal, Huggingface team :) Adapted From Facebook Inc, Detectron2 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://w...
18,199
31.5
143
py
robust-transformers
robust-transformers-main/examples/research_projects/lxmert/visualizing_image.py
""" coding=utf-8 Copyright 2018, Antonio Mendoza Hao Tan, Mohit Bansal Adapted From Facebook Inc, Detectron2 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/license...
13,420
25.842
100
py
robust-transformers
robust-transformers-main/examples/research_projects/lxmert/processing_image.py
""" coding=utf-8 Copyright 2018, Antonio Mendoza Hao Tan, Mohit Bansal Adapted From Facebook Inc, Detectron2 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/license...
5,678
36.86
114
py
robust-transformers
robust-transformers-main/examples/research_projects/bertabs/modeling_bertabs.py
# MIT License # Copyright (c) 2019 Yang Liu and the HuggingFace team # 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, c...
38,263
35.1322
114
py
robust-transformers
robust-transformers-main/examples/research_projects/bertabs/configuration_bertabs.py
# coding=utf-8 # Copyright 2019 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 copy of the License at # # http://www.a...
3,261
32.285714
147
py
robust-transformers
robust-transformers-main/examples/research_projects/bertabs/convert_bertabs_original_pytorch_checkpoint.py
# coding=utf-8 # Copyright 2018 The HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
6,523
34.075269
117
py
robust-transformers
robust-transformers-main/examples/research_projects/bertabs/utils_summarization.py
import os from collections import deque import torch from torch.utils.data import Dataset # ------------ # Data loading # ------------ class CNNDMDataset(Dataset): """Abstracts the dataset used to train seq2seq models. The class will process the documents that are located in the specified folder. The ...
5,753
33.25
106
py
robust-transformers
robust-transformers-main/examples/research_projects/bertabs/test_utils_summarization.py
# coding=utf-8 # Copyright 2019 HuggingFace Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or ag...
4,419
43.646465
99
py
robust-transformers
robust-transformers-main/examples/research_projects/bertabs/__init__.py
0
0
0
py
robust-transformers
robust-transformers-main/examples/research_projects/bertabs/run_summarization.py
#! /usr/bin/python3 import argparse import logging import os import sys from collections import namedtuple import torch from torch.utils.data import DataLoader, SequentialSampler from tqdm import tqdm from modeling_bertabs import BertAbs, build_predictor from transformers import BertTokenizer from .utils_summarizati...
10,188
28.278736
137
py
robust-transformers
robust-transformers-main/examples/research_projects/fsner/setup.py
import setuptools with open("README.md", "r", encoding="utf-8") as fh: long_description = fh.read() setuptools.setup( name="fsner", version="0.0.1", author="msi sayef", author_email="msi.sayef@gmail.com", description="Few-shot Named Entity Recognition", long_description=long_description, ...
866
29.964286
99
py
robust-transformers
robust-transformers-main/examples/research_projects/fsner/src/fsner/tokenizer_utils.py
import torch from transformers import AutoTokenizer class FSNERTokenizerUtils(object): def __init__(self, pretrained_model_name_or_path): self.tokenizer = AutoTokenizer.from_pretrained(pretrained_model_name_or_path) def tokenize(self, x): """ Wrapper function for tokenizing query and...
3,974
37.970588
182
py
robust-transformers
robust-transformers-main/examples/research_projects/fsner/src/fsner/model.py
import torch from transformers import AutoModel class FSNERModel(torch.nn.Module): """ The FSNER model implements a few-shot named entity recognition method from the paper `Example-Based Named Entity Recognition <https://arxiv.org/abs/2008.10570>`__ by Morteza Ziyadi, Yuting Sun, Abhishek Goswami, Jade H...
3,100
37.283951
169
py
robust-transformers
robust-transformers-main/examples/research_projects/fsner/src/fsner/__init__.py
from .model import FSNERModel from .tokenizer_utils import FSNERTokenizerUtils __all__ = ["FSNERModel", "FSNERTokenizerUtils"]
129
20.666667
48
py
robust-transformers
robust-transformers-main/examples/research_projects/adversarial/run_hans.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...
8,213
33.225
133
py
robust-transformers
robust-transformers-main/examples/research_projects/adversarial/utils_hans.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...
11,767
33.510264
118
py
robust-transformers
robust-transformers-main/examples/research_projects/robust-speech-event/run_speech_recognition_ctc_streaming.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2022 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LI...
27,868
41.225758
158
py
robust-transformers
robust-transformers-main/examples/research_projects/robust-speech-event/run_speech_recognition_ctc_bnb.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2021 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LI...
31,246
40.006562
158
py
robust-transformers
robust-transformers-main/examples/research_projects/robust-speech-event/eval.py
#!/usr/bin/env python3 import argparse import re from typing import Dict import torch from datasets import Audio, Dataset, load_dataset, load_metric from transformers import AutoFeatureExtractor, pipeline def log_results(result: Dataset, args: Dict[str, str]): """DO NOT CHANGE. This function computes and logs t...
4,716
33.181159
147
py
robust-transformers
robust-transformers-main/examples/research_projects/performer/run_mlm_performer.py
# coding=utf-8 # Copyright 2020 The HuggingFace Team All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless require...
28,527
40.586006
119
py
robust-transformers
robust-transformers-main/examples/research_projects/performer/modeling_flax_performer.py
# coding=utf-8 # Copyright 2018 The Google Flax Team Authors and The HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 ...
21,123
37.129964
120
py
robust-transformers
robust-transformers-main/examples/research_projects/performer/modeling_flax_performer_utils.py
# coding=utf-8 # Copyright 2020 The Google Research 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 applicab...
25,683
37.856278
119
py
robust-transformers
robust-transformers-main/examples/research_projects/rag-end2end-retriever/use_own_knowledge_dataset.py
import logging import os from dataclasses import dataclass, field from functools import partial from pathlib import Path from tempfile import TemporaryDirectory from typing import List, Optional import torch from datasets import Features, Sequence, Value, load_dataset import faiss from transformers import DPRContextE...
6,909
39.174419
152
py
robust-transformers
robust-transformers-main/examples/research_projects/rag-end2end-retriever/utils_rag.py
import itertools import json import linecache import os import pickle import re import socket import string from collections import Counter from logging import getLogger from pathlib import Path from typing import Callable, Dict, Iterable, List import git import torch from torch.utils.data import Dataset from transfo...
8,114
32.122449
118
py
robust-transformers
robust-transformers-main/examples/research_projects/rag-end2end-retriever/finetune_rag.py
"""Finetuning script for RAG models. Adapted from examples.seq2seq.finetune.py""" import argparse import copy import json import logging import multiprocessing import os import random import shutil import sys import time from collections import defaultdict from pathlib import Path from typing import Any, Dict, List, T...
33,046
40.831646
197
py
robust-transformers
robust-transformers-main/examples/research_projects/rag-end2end-retriever/eval_rag.py
""" Evaluation script for RAG models.""" import argparse import ast import logging import os import sys import pandas as pd import torch from tqdm import tqdm from transformers import BartForConditionalGeneration, RagRetriever, RagSequenceForGeneration, RagTokenForGeneration from transformers import logging as trans...
11,101
34.469649
132
py
robust-transformers
robust-transformers-main/examples/research_projects/rag-end2end-retriever/lightning_base.py
import argparse import logging import os from pathlib import Path from typing import Any, Dict import pytorch_lightning as pl from pytorch_lightning.plugins.training_type import DDPPlugin from pytorch_lightning.utilities import rank_zero_info from transformers import ( AdamW, AutoConfig, AutoModel, Au...
16,400
38.425481
124
py
robust-transformers
robust-transformers-main/examples/research_projects/rag-end2end-retriever/callbacks_rag.py
import logging from pathlib import Path import numpy as np import pytorch_lightning as pl import torch from pytorch_lightning.callbacks import EarlyStopping, ModelCheckpoint from pytorch_lightning.utilities import rank_zero_only from utils_rag import save_json def count_trainable_parameters(model): model_parame...
4,463
36.2
126
py
robust-transformers
robust-transformers-main/examples/research_projects/rag-end2end-retriever/kb_encode_utils.py
import os from functools import partial from glob import glob from datasets import Features, Sequence, Value, concatenate_datasets, load_dataset, load_from_disk import faiss from transformers import DPRContextEncoder, DPRContextEncoderTokenizerFast def split_text(text, n=100, character=" "): """Split the text e...
3,179
37.780488
112
py
robust-transformers
robust-transformers-main/examples/research_projects/rag-end2end-retriever/distributed_ray_retriever.py
import logging import random import ray from transformers import RagConfig, RagRetriever, RagTokenizer from transformers.models.rag.retrieval_rag import CustomHFIndex logger = logging.getLogger(__name__) class RayRetriever: def __init__(self): self.initialized = False def create_rag_retriever(self...
8,211
43.150538
132
py
robust-transformers
robust-transformers-main/examples/research_projects/movement-pruning/counts_parameters.py
# Copyright 2020-present, the HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law o...
3,395
35.516129
124
py
robust-transformers
robust-transformers-main/examples/research_projects/movement-pruning/masked_run_glue.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...
40,528
41.662105
156
py
robust-transformers
robust-transformers-main/examples/research_projects/movement-pruning/bertarize.py
# Copyright 2020-present, the HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law o...
5,086
37.24812
155
py
robust-transformers
robust-transformers-main/examples/research_projects/movement-pruning/masked_run_squad.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...
47,575
41.214729
156
py
robust-transformers
robust-transformers-main/examples/research_projects/movement-pruning/emmental/modeling_bert_masked.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...
47,084
45.161765
152
py
robust-transformers
robust-transformers-main/examples/research_projects/movement-pruning/emmental/__init__.py
# flake8: noqa from .configuration_bert_masked import MaskedBertConfig from .modeling_bert_masked import ( MaskedBertForMultipleChoice, MaskedBertForQuestionAnswering, MaskedBertForSequenceClassification, MaskedBertForTokenClassification, MaskedBertModel, ) from .modules import *
301
26.454545
55
py