repo stringlengths 1 99 | file stringlengths 13 215 | code stringlengths 12 59.2M | file_length int64 12 59.2M | avg_line_length float64 3.82 1.48M | max_line_length int64 12 2.51M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
BoB | BoB-main/xlibs/convert_roberta_original_pytorch_checkpoint_to_pytorch.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... | 7,974 | 45.098266 | 117 | py |
BoB | BoB-main/xlibs/tokenization_bert.py | # coding=utf-8
# Copyright 2018 The Google AI Language 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/LICEN... | 24,812 | 43.388193 | 167 | py |
BoB | BoB-main/xlibs/modeling_fsmt.py | # coding=utf-8
# Copyright 2020 The Facebook AI Research 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/LIC... | 50,127 | 39.198877 | 270 | py |
BoB | BoB-main/xlibs/retrieval_rag.py | # coding=utf-8
# Copyright 2020, The RAG 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
#
# Unless r... | 27,733 | 43.877023 | 170 | py |
BoB | BoB-main/xlibs/modeling_flax_bert.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
... | 16,654 | 37.732558 | 120 | py |
BoB | BoB-main/xlibs/modeling_auto.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... | 72,496 | 43.2865 | 147 | py |
BoB | BoB-main/xlibs/convert_bart_original_pytorch_checkpoint_to_pytorch.py | # coding=utf-8
# Copyright 2020 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... | 5,484 | 37.090278 | 117 | py |
BoB | BoB-main/xlibs/modeling_bert_generation.py | # coding=utf-8
# Copyright 2020 The Google AI Language 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/LICEN... | 23,891 | 45.034682 | 145 | py |
BoB | BoB-main/xlibs/modeling_funnel.py | # coding=utf-8
# Copyright 2020-present Google Brain and Carnegie Mellon University 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.a... | 65,784 | 41.06202 | 168 | py |
BoB | BoB-main/xlibs/modeling_t5.py | # coding=utf-8
# Copyright 2018 Mesh TensorFlow authors, T5 Authors and 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... | 56,854 | 43.005418 | 213 | py |
BoB | BoB-main/xlibs/convert_marian_to_pytorch.py | import argparse
import json
import os
import socket
import time
import warnings
from pathlib import Path
from typing import Dict, List, Union
from zipfile import ZipFile
import numpy as np
import torch
from tqdm import tqdm
from transformers import MarianConfig, MarianMTModel, MarianTokenizer
from transformers.hf_api... | 22,851 | 35.917609 | 119 | py |
BoB | BoB-main/xlibs/convert_marian_tatoeba_to_pytorch.py | import argparse
import os
from pathlib import Path
from typing import List, Tuple
from transformers.convert_marian_to_pytorch import (
FRONT_MATTER_TEMPLATE,
_parse_readme,
convert_all_sentencepiece_models,
get_system_metadata,
remove_prefix,
remove_suffix,
)
try:
import pandas as pd
exce... | 33,252 | 25.496414 | 175 | py |
BoB | BoB-main/xlibs/training_args.py | import dataclasses
import json
import os
import warnings
from dataclasses import dataclass, field
from enum import Enum
from typing import Any, Dict, List, Optional, Tuple
from .file_utils import cached_property, is_torch_available, is_torch_tpu_available, torch_required
from .trainer_utils import EvaluationStrategy
f... | 23,541 | 49.089362 | 142 | py |
BoB | BoB-main/xlibs/generation_utils.py | # Revised by Haoyu Song
# coding=utf-8
# Copyright 2020 The Google AI Language Team Authors, Facebook AI Research authors and The HuggingFace Inc. team.
# Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except ... | 58,306 | 46.173948 | 167 | py |
BoB | BoB-main/xlibs/modeling_xlm_roberta.py | # coding=utf-8
# Copyright 2019 Facebook AI Research 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 copy of the Licens... | 5,864 | 34.762195 | 119 | py |
BoB | BoB-main/xlibs/modeling_camembert.py | # coding=utf-8
# Copyright 2019 Inria, Facebook AI Research 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 copy of the... | 5,721 | 34.540373 | 119 | py |
BoB | BoB-main/xlibs/modeling_flax_roberta.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
... | 17,686 | 38.925508 | 120 | py |
BoB | BoB-main/xlibs/convert_prophetnet_original_pytorch_checkpoint_to_pytorch.py | # coding=utf-8
# Copyright 2020 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... | 7,181 | 43.06135 | 118 | py |
BoB | BoB-main/xlibs/modeling_flax_utils.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
... | 7,226 | 36.252577 | 140 | py |
BoB | BoB-main/xlibs/integrations.py | # Integrations with other Python libraries
import math
import os
from .utils import logging
logger = logging.get_logger(__name__)
# Import 3rd-party integrations before ML frameworks:
try:
# Comet needs to be imported before any ML frameworks
import comet_ml # noqa: F401
if hasattr(comet_ml, "config... | 21,147 | 38.602996 | 130 | py |
BoB | BoB-main/xlibs/convert_dpr_original_checkpoint_to_pytorch.py | import argparse
import collections
from pathlib import Path
import torch
from torch.serialization import default_restore_location
from transformers import BertConfig, DPRConfig, DPRContextEncoder, DPRQuestionEncoder, DPRReader
CheckpointState = collections.namedtuple(
"CheckpointState", ["model_dict", "optimize... | 5,460 | 42.34127 | 228 | py |
BoB | BoB-main/xlibs/convert_fsmt_original_pytorch_checkpoint_to_pytorch.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... | 11,262 | 39.225 | 131 | py |
BoB | BoB-main/xlibs/tokenization_deberta.py | # coding=utf-8
# Copyright 2020 Microsoft and the HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required... | 24,330 | 35.045926 | 119 | py |
BoB | BoB-main/xlibs/convert_xlm_original_pytorch_checkpoint_to_pytorch.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... | 2,983 | 36.3 | 117 | py |
BoB | BoB-main/xlibs/modeling_dpr.py | # coding=utf-8
# Copyright 2018 DPR 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 law or agreed ... | 28,447 | 42.565084 | 168 | py |
BoB | BoB-main/xlibs/convert_dialogpt_original_pytorch_checkpoint_to_pytorch.py | import argparse
import os
import torch
from transformers.file_utils import WEIGHTS_NAME
DIALOGPT_MODELS = ["small", "medium", "large"]
OLD_KEY = "lm_head.decoder.weight"
NEW_KEY = "lm_head.weight"
def convert_dialogpt_checkpoint(checkpoint_path: str, pytorch_dump_folder_path: str):
d = torch.load(checkpoint_... | 935 | 27.363636 | 85 | py |
BoB | BoB-main/xlibs/modeling_reformer.py | # coding=utf-8
# Copyright 2020 The Trax 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 copy of the License at... | 109,788 | 41.636505 | 251 | py |
BoB | BoB-main/xlibs/modeling_bart.py | # coding=utf-8
# Copyright 2020 The Facebook AI Research 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/LIC... | 57,590 | 40.914847 | 209 | py |
BoB | BoB-main/xlibs/file_utils.py | # Revised by Haoyu Song
"""
Utilities for working with the local dataset cache. This file is adapted from the AllenNLP library at
https://github.com/allenai/allennlp Copyright by the AllenNLP authors.
"""
import fnmatch
import io
import json
import os
import re
import shutil
import sys
import tarfile
import tempfile
f... | 46,712 | 34.523194 | 139 | py |
BoB | BoB-main/xlibs/tokenization_dpr_fast.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... | 20,184 | 50.75641 | 152 | py |
BoB | BoB-main/xlibs/activations.py | import math
import torch
import torch.nn.functional as F
from packaging import version
from .utils import logging
logger = logging.get_logger(__name__)
def _gelu_python(x):
"""
Original Implementation of the GELU activation function in Google BERT repo when initially created. For
information: OpenAI G... | 2,486 | 28.258824 | 119 | py |
BoB | BoB-main/xlibs/tokenization_bert_fast.py | # coding=utf-8
# Copyright 2018 The Google AI Language 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/LICEN... | 14,390 | 54.35 | 172 | py |
BoB | BoB-main/xlibs/__init__.py | # flake8: noqa
# There's no way to ignore "F401 '...' imported but unused" warnings in this
# module, but to preserve other warnings. So, don't check this module at all.
__version__ = "3.5.1"
# Work around to update TensorFlow's absl.logging threshold which alters the
# default Python logging output behavior when pre... | 23,467 | 35.841444 | 117 | py |
BoB | BoB-main/xlibs/generation_beam_search.py | # coding=utf-8
# Copyright 2020 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 ... | 15,808 | 43.159218 | 180 | py |
BoB | BoB-main/xlibs/tokenization_bart.py | # coding=utf-8
# Copyright 2020 The Facebook AI Research 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/LIC... | 7,914 | 49.414013 | 155 | py |
BoB | BoB-main/xlibs/modeling_prophetnet.py | # coding=utf-8
# Copyright 2020 The Microsoft 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
#
# Unl... | 102,492 | 48.418033 | 213 | py |
BoB | BoB-main/xlibs/modeling_mobilebert.py | # MIT License
#
# Copyright (c) 2020 The Google AI Language Team Authors, The HuggingFace Inc. team and github/lonePatient
#
# 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 restricti... | 68,519 | 40.857056 | 168 | py |
BoB | BoB-main/xlibs/trainer_utils.py | # Revised by Haoyu Song
# coding=utf-8
# 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
#... | 5,518 | 29.15847 | 116 | py |
BoB | BoB-main/xlibs/tokenization_bart_fast.py | # coding=utf-8
# Copyright 2020 The Facebook AI Research 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/LIC... | 7,966 | 51.414474 | 155 | py |
BoB | BoB-main/xlibs/modeling_retribert.py | # coding=utf-8
# Copyright 2019-present, the HuggingFace Inc. team, The Google AI Language Team and Facebook, 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.or... | 9,241 | 42.389671 | 120 | py |
BoB | BoB-main/xlibs/modeling_pegasus.py | # coding=utf-8
# Copyright 2020 Google and The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by... | 2,824 | 46.083333 | 309 | py |
BoB | BoB-main/xlibs/modeling_transfo_xl.py | # coding=utf-8
# Copyright 2018 Google AI, Google Brain and Carnegie Mellon University 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 Lice... | 46,625 | 40.929856 | 168 | py |
BoB | BoB-main/xlibs/modeling_albert.py | # coding=utf-8
# Copyright 2018 Google AI, Google Brain 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
#
# U... | 53,432 | 39.602584 | 168 | py |
BoB | BoB-main/xlibs/modeling_blenderbot.py | #!/usr/bin/env python3
# coding=utf-8
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the;
# 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
#
... | 2,378 | 40.736842 | 119 | py |
BoB | BoB-main/xlibs/modeling_xlnet.py | # coding=utf-8
# Copyright 2018 Google AI, Google Brain and Carnegie Mellon University 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 Lice... | 89,699 | 43.187192 | 197 | py |
BoB | BoB-main/xlibs/modeling_xlm.py | # coding=utf-8
# Copyright 2019-present, Facebook, Inc 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
#
# Un... | 52,117 | 39.97327 | 197 | py |
BoB | BoB-main/xlibs/modeling_lxmert.py | # coding=utf-8
# Copyright 2018 Hao Tan, Mohit Bansal, and the HuggingFace 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 r... | 64,250 | 43.649757 | 177 | py |
BoB | BoB-main/xlibs/modeling_ctrl.py | # coding=utf-8
# Copyright 2018 Salesforce and 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
#
# h... | 24,651 | 40.086667 | 124 | py |
BoB | BoB-main/xlibs/trainer.py | # coding=utf-8
# 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 ap... | 73,931 | 45.792405 | 188 | py |
BoB | BoB-main/xlibs/tokenization_transfo_xl.py | # coding=utf-8
# Copyright 2018 Google AI, Google Brain and Carnegie Mellon University 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 Lice... | 30,918 | 37.697121 | 119 | py |
BoB | BoB-main/xlibs/modeling_transfo_xl_utilities.py | # coding=utf-8
# Copyright 2018 Google AI, Google Brain and Carnegie Mellon University 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 Lice... | 10,607 | 41.432 | 126 | py |
BoB | BoB-main/xlibs/convert_reformer_trax_checkpoint_to_pytorch.py | # coding=utf-8
# Copyright 2020 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... | 7,830 | 34.595455 | 118 | py |
BoB | BoB-main/xlibs/modeling_deberta.py | # coding=utf-8
# Copyright 2020 Microsoft and the Hugging Face 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 require... | 41,848 | 38.780418 | 126 | py |
BoB | BoB-main/xlibs/configuration_rag.py | # coding=utf-8
# Copyright 2020, The RAG 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
#
# Unless r... | 8,599 | 45.486486 | 119 | py |
BoB | BoB-main/xlibs/modeling_xlm_prophetnet.py | # coding=utf-8
# Copyright 2020 The Microsoft 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
#
# Unl... | 7,429 | 43.491018 | 158 | py |
BoB | BoB-main/xlibs/generation_logits_process.py | # coding=utf-8
# Copyright 2020 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 ... | 16,656 | 43.418667 | 132 | py |
BoB | BoB-main/xlibs/modeling_roberta.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... | 55,562 | 40.066519 | 159 | py |
BoB | BoB-main/xlibs/tokenization_utils.py | # coding=utf-8
# Copyright 2020 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... | 37,096 | 43.215733 | 155 | py |
BoB | BoB-main/xlibs/commands/convert.py | from argparse import ArgumentParser, Namespace
from transformers.commands import BaseTransformersCLICommand
from ..utils import logging
def convert_command_factory(args: Namespace):
"""
Factory function used to convert a model TF 1.0 checkpoint in a PyTorch checkpoint.
Returns: ServeCommand
"""
... | 6,580 | 40.13125 | 117 | py |
BoB | BoB-main/xlibs/commands/train.py | import os
from argparse import ArgumentParser, Namespace
from transformers import SingleSentenceClassificationProcessor as Processor
from transformers import TextClassificationPipeline, is_tf_available, is_torch_available
from transformers.commands import BaseTransformersCLICommand
from ..utils import logging
if no... | 5,794 | 38.421769 | 117 | py |
BoB | BoB-main/xlibs/commands/env.py | import platform
from argparse import ArgumentParser
from transformers import __version__ as version
from transformers import is_tf_available, is_torch_available
from transformers.commands import BaseTransformersCLICommand
def info_command_factory(_):
return EnvironmentCommand()
class EnvironmentCommand(BaseTra... | 2,027 | 33.372881 | 105 | py |
BoB | BoB-main/xlibs/benchmark/benchmark.py | # coding=utf-8
# Copyright 2018 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... | 10,617 | 38.619403 | 181 | py |
BoB | BoB-main/xlibs/benchmark/benchmark_utils.py | # This file is adapted from the AllenNLP library at https://github.com/allenai/allennlp
# Copyright by the AllenNLP authors.
"""
Utilities for working with the local dataset cache.
"""
import copy
import csv
import linecache
import os
import platform
import sys
from abc import ABC, abstractmethod
from collections impo... | 36,755 | 39.749446 | 204 | py |
BoB | BoB-main/xlibs/benchmark/benchmark_args.py | # coding=utf-8
# Copyright 2018 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,777 | 31.568966 | 127 | py |
BoB | BoB-main/xlibs/utils/dummy_pt_objects.py | # This file is autogenerated by the command `make fix-copies`, do not edit.
from ..file_utils import requires_pytorch
class PyTorchBenchmark:
def __init__(self, *args, **kwargs):
requires_pytorch(self)
class PyTorchBenchmarkArguments:
def __init__(self, *args, **kwargs):
requires_pytorch(sel... | 44,972 | 20.85277 | 75 | py |
BoB | BoB-main/xlibs/utils/dummy_flax_objects.py | # This file is autogenerated by the command `make fix-copies`, do not edit.
from ..file_utils import requires_flax
class FlaxBertModel:
def __init__(self, *args, **kwargs):
requires_flax(self)
@classmethod
def from_pretrained(self, *args, **kwargs):
requires_flax(self)
class FlaxRoberta... | 490 | 22.380952 | 75 | py |
BoB | BoB-main/xlibs/data/data_collator.py | import random
import warnings
from dataclasses import dataclass
from typing import Any, Callable, Dict, List, NewType, Optional, Tuple, Union
import torch
from torch.nn.utils.rnn import pad_sequence
from ..tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTrainedTokenizerBase
InputDataClass = NewTyp... | 30,791 | 48.825243 | 181 | py |
BoB | BoB-main/xlibs/data/test_generation_utils.py | import random
import unittest
import timeout_decorator
from transformers import is_torch_available
from transformers.file_utils import cached_property
from transformers.testing_utils import require_torch
if is_torch_available():
import torch
from transformers import MarianConfig, MarianMTModel
@require_t... | 2,874 | 31.670455 | 94 | py |
BoB | BoB-main/xlibs/data/datasets/glue.py | import os
import time
import warnings
from dataclasses import dataclass, field
from enum import Enum
from typing import List, Optional, Union
import torch
from torch.utils.data.dataset import Dataset
from filelock import FileLock
from ...tokenization_utils_base import PreTrainedTokenizerBase
from ...utils import log... | 5,620 | 35.738562 | 119 | py |
BoB | BoB-main/xlibs/data/datasets/squad.py | import os
import time
from dataclasses import dataclass, field
from enum import Enum
from typing import Dict, List, Optional, Union
import torch
from torch.utils.data.dataset import Dataset
from filelock import FileLock
from ...modeling_auto import MODEL_FOR_QUESTION_ANSWERING_MAPPING
from ...tokenization_utils impo... | 8,519 | 39.188679 | 129 | py |
BoB | BoB-main/xlibs/data/datasets/language_modeling.py | import json
import os
import pickle
import random
import time
import warnings
from typing import Dict, List, Optional
import torch
from torch.utils.data.dataset import Dataset
from filelock import FileLock
from ...tokenization_utils import PreTrainedTokenizer
from ...utils import logging
logger = logging.get_logge... | 22,216 | 42.392578 | 119 | py |
BoB | BoB-main/xlibs/data/processors/squad.py | import json
import os
from functools import partial
from multiprocessing import Pool, cpu_count
import numpy as np
from tqdm import tqdm
from ...file_utils import is_tf_available, is_torch_available
from ...tokenization_bert import whitespace_tokenize
from ...tokenization_utils_base import PreTrainedTokenizerBase, Tr... | 32,438 | 38.272397 | 125 | py |
BoB | BoB-main/xlibs/data/processors/utils.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... | 13,911 | 38.410765 | 119 | py |
rad | rad-master/curl_sac.py | import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
import copy
import math
import utils
from encoder import make_encoder
import data_augs as rad
LOG_FREQ = 10000
def gaussian_logprob(noise, log_std):
"""Compute Gaussian log probability."""
residual = (-0.5 * noise... | 17,255 | 32.184615 | 114 | py |
rad | rad-master/data_augs.py | import numpy as np
import matplotlib.pyplot as plt
import torch
import torch.nn as nn
from TransformLayer import ColorJitterLayer
def random_crop(imgs, out=84):
"""
args:
imgs: np.array shape (B,C,H,W)
out: output size (e.g. 84)
returns np.array
"""
n, c, h, w = imgs.shape
... | 9,414 | 28.700315 | 107 | py |
rad | rad-master/TransformLayer.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import math
import numpy as np
import numbers
import random
import time
def rgb2hsv(rgb, eps=1e-8):
# Reference: https://www.rapidtables.com/convert/color/rgb-to-hsv.html
# Reference: https://github.com/scikit-image/scikit-image/blob/master/ski... | 7,657 | 37.29 | 105 | py |
rad | rad-master/utils.py | import torch
import numpy as np
import torch.nn as nn
import gym
import os
from collections import deque
import random
from torch.utils.data import Dataset, DataLoader
import time
from skimage.util.shape import view_as_windows
class eval_mode(object):
def __init__(self, *models):
self.models = models
... | 10,187 | 32.077922 | 103 | py |
rad | rad-master/encoder.py | import torch
import torch.nn as nn
def tie_weights(src, trg):
assert type(src) == type(trg)
trg.weight = src.weight
trg.bias = src.bias
OUT_DIM = {2: 39, 4: 35, 6: 31}
OUT_DIM_64 = {2: 29, 4: 25, 6: 21}
OUT_DIM_108 = {4: 47}
class PixelEncoder(nn.Module):
"""Convolutional encoder of pixels observ... | 3,911 | 27.977778 | 134 | py |
rad | rad-master/logger.py | from torch.utils.tensorboard import SummaryWriter
from collections import defaultdict
import json
import os
import shutil
import torch
import torchvision
import numpy as np
from termcolor import colored
FORMAT_CONFIG = {
'rl': {
'train': [
('episode', 'E', 'int'), ('step', 'S', 'int'),
... | 5,486 | 32.457317 | 79 | py |
rad | rad-master/train.py | import numpy as np
import torch
import argparse
import os
import math
import gym
import sys
import random
import time
import json
import dmc2gym
import copy
import utils
from logger import Logger
from video import VideoRecorder
from curl_sac import RadSacAgent
from torchvision import transforms
import data_augs as ra... | 12,211 | 37.282132 | 149 | py |
OdomBeyondVision | OdomBeyondVision-main/benchmark/milliEgo/test_double.py | """
Test the model with DOUBLE sensor modalities using h5 files as the input
"""
from keras import backend as K
from utility.networks import build_model_cross_att
from utility.test_util import convert_rel_to_44matrix, iround
from utility.data_loader import load_data_multi_timestamp
from utility import plot_util
import... | 10,601 | 45.095652 | 128 | py |
OdomBeyondVision | OdomBeyondVision-main/benchmark/milliEgo/train.py | """
Training deep mmwave+imu odometry from pseudo ground truth
"""
from utility.data_loader import load_data_multi, validation_stack
from utility.networks import build_model_cross_att
import math
from keras import backend as K
import keras
from keras.callbacks import TensorBoard
from keras.callbacks import EarlyStoppi... | 7,597 | 39.849462 | 132 | py |
OdomBeyondVision | OdomBeyondVision-main/benchmark/milliEgo/utility/data_loader.py | import os
from os.path import join
os.environ['KERAS_BACKEND'] = 'tensorflow'
from keras.models import Model, Sequential # Sequential, Graph
from keras.models import model_from_json, model_from_yaml, load_model
from keras.layers import (Input, Dense, Convolution2D, Activation, Flatten, Dropout, AveragePooling1D, MaxPo... | 15,039 | 39.869565 | 146 | py |
OdomBeyondVision | OdomBeyondVision-main/benchmark/milliEgo/utility/networks.py | from keras import backend as K
import keras
from keras.layers.advanced_activations import LeakyReLU, ELU
from keras.layers import (Input, Dense, Convolution2D, Activation, Flatten, Dropout, AveragePooling1D, MaxPooling2D,
GlobalAveragePooling1D, ZeroPadding2D, Merge, Reshape, merge, Multiply, ... | 9,753 | 60.734177 | 175 | py |
OdomBeyondVision | OdomBeyondVision-main/benchmark/DeepTIO/train.py | """
Training deep Visual-Inertial odometry from pseudo ground truth
"""
import json
from keras.callbacks import TensorBoard
from keras.callbacks import ModelCheckpoint
from keras import backend as K
import tensorflow as tf
from utility.data_tools import odom_validation_stack_hallucination, load_hallucination_data, loa... | 9,793 | 48.21608 | 139 | py |
OdomBeyondVision | OdomBeyondVision-main/benchmark/DeepTIO/utility/test_deeptio.py | """
Test the model using h5 files as the input
"""
from data_tools import load_odom_data, load_data_multi_timestamp
from networks import build_deeptio
from keras import backend as K
import tensorflow as tf
import mdn
from os.path import join
import plot_util
import math
from eulerangles import mat2euler, euler2quat, e... | 9,834 | 38.497992 | 120 | py |
OdomBeyondVision | OdomBeyondVision-main/benchmark/DeepTIO/utility/test_deepvio_save_features.py | """
Test the model using h5 files as the input and generate the the feature as the output
"""
from data_tools import load_odom_data
from networks import build_model_vanilla_vio_save_features
from keras import backend as K
from keras.models import Model
import keras
import yaml
from os.path import join, dirname
import ... | 5,448 | 35.326667 | 122 | py |
OdomBeyondVision | OdomBeyondVision-main/benchmark/DeepTIO/utility/networks.py | """
Network definitions
"""
from keras.initializers import glorot_uniform, he_uniform
from os.path import join
from keras import initializers, layers
import tensorflow as tf
from keras.utils import plot_model, normalize
import mdn
from keras import backend as K
from keras.regularizers import l2
from keras.engine.topol... | 16,514 | 55.365188 | 146 | py |
CloudFast-DL4PuDe | CloudFast-DL4PuDe-main/cloud-fast-system/RAFT/evaluate.py | import sys
sys.path.append('core')
from PIL import Image
import argparse
import os
import time
import numpy as np
import torch
import torch.nn.functional as F
import matplotlib.pyplot as plt
import datasets
from utils import flow_viz
from utils import frame_utils
from raft import RAFT
from utils.utils import InputPa... | 6,618 | 32.429293 | 112 | py |
CloudFast-DL4PuDe | CloudFast-DL4PuDe-main/cloud-fast-system/RAFT/train.py | from __future__ import print_function, division
import sys
sys.path.append('core')
import argparse
import os
import cv2
import time
import numpy as np
import matplotlib.pyplot as plt
import torch
import torch.nn as nn
import torch.optim as optim
import torch.nn.functional as F
from torch.utils.data import DataLoader... | 7,987 | 31.340081 | 103 | py |
CloudFast-DL4PuDe | CloudFast-DL4PuDe-main/cloud-fast-system/RAFT/core/corr.py | import torch
import torch.nn.functional as F
from utils.utils import bilinear_sampler, coords_grid
try:
import alt_cuda_corr
except:
# alt_cuda_corr is not compiled
pass
class CorrBlock:
def __init__(self, fmap1, fmap2, num_levels=4, radius=4):
self.num_levels = num_levels
self.radius... | 3,085 | 32.543478 | 74 | py |
CloudFast-DL4PuDe | CloudFast-DL4PuDe-main/cloud-fast-system/RAFT/core/update.py | import torch
import torch.nn as nn
import torch.nn.functional as F
class FlowHead(nn.Module):
def __init__(self, input_dim=128, hidden_dim=256):
super(FlowHead, self).__init__()
self.conv1 = nn.Conv2d(input_dim, hidden_dim, 3, padding=1)
self.conv2 = nn.Conv2d(hidden_dim, 2, 3, padding=1)
... | 5,227 | 36.342857 | 87 | py |
CloudFast-DL4PuDe | CloudFast-DL4PuDe-main/cloud-fast-system/RAFT/core/extractor.py | import torch
import torch.nn as nn
import torch.nn.functional as F
class ResidualBlock(nn.Module):
def __init__(self, in_planes, planes, norm_fn='group', stride=1):
super(ResidualBlock, self).__init__()
self.conv1 = nn.Conv2d(in_planes, planes, kernel_size=3, padding=1, stride=stride)
s... | 8,847 | 32.014925 | 93 | py |
CloudFast-DL4PuDe | CloudFast-DL4PuDe-main/cloud-fast-system/RAFT/core/datasets.py | # Data loading based on https://github.com/NVIDIA/flownet2-pytorch
import numpy as np
import torch
import torch.utils.data as data
import torch.nn.functional as F
import os
import math
import random
from glob import glob
import os.path as osp
from utils import frame_utils
from utils.augmentor import FlowAugmentor, S... | 9,245 | 38.177966 | 111 | py |
CloudFast-DL4PuDe | CloudFast-DL4PuDe-main/cloud-fast-system/RAFT/core/raft.py | import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from update import BasicUpdateBlock, SmallUpdateBlock
from extractor import BasicEncoder, SmallEncoder
from corr import CorrBlock, AlternateCorrBlock
from utils.utils import bilinear_sampler, coords_grid, upflow8
try:
autocast =... | 4,924 | 32.965517 | 102 | py |
CloudFast-DL4PuDe | CloudFast-DL4PuDe-main/cloud-fast-system/RAFT/core/utils/utils.py | import torch
import torch.nn.functional as F
import numpy as np
from scipy import interpolate
class InputPadder:
""" Pads images such that dimensions are divisible by 8 """
def __init__(self, dims, mode='sintel'):
self.ht, self.wd = dims[-2:]
pad_ht = (((self.ht // 8) + 1) * 8 - self.ht) % 8
... | 2,489 | 29 | 93 | py |
CloudFast-DL4PuDe | CloudFast-DL4PuDe-main/cloud-fast-system/RAFT/core/utils/augmentor.py | import numpy as np
import random
import math
from PIL import Image
import cv2
cv2.setNumThreads(0)
cv2.ocl.setUseOpenCL(False)
import torch
from torchvision.transforms import ColorJitter
import torch.nn.functional as F
class FlowAugmentor:
def __init__(self, crop_size, min_scale=-0.2, max_scale=0.5, do_flip=Tru... | 9,108 | 35.878543 | 97 | py |
CloudFast-DL4PuDe | CloudFast-DL4PuDe-main/cloud-fast-system/RAFT/alt_cuda_corr/setup.py | from setuptools import setup
from torch.utils.cpp_extension import BuildExtension, CUDAExtension
setup(
name='correlation',
ext_modules=[
CUDAExtension('alt_cuda_corr',
sources=['correlation.cpp', 'correlation_kernel.cu'],
extra_compile_args={'cxx': [], 'nvcc': ['-O3']}),
]... | 381 | 22.875 | 67 | py |
document-image-binarization | document-image-binarization-master/binarize/binarize.py | #!/usr/bin/python
# -*- coding: utf-8 -*-
from __future__ import print_function
import sys, os
import time
import argparse
import cv2
import warnings
import numpy as np
from keras import backend as K
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
import util, utilDataGenerator, utilModelREDNet
util.init(... | 7,073 | 39.890173 | 133 | py |
document-image-binarization | document-image-binarization-master/binarize/utilModelREDNet.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from keras.layers import Input, Dropout, Activation, MaxPooling2D, UpSampling2D
from keras.layers import Conv2D, Conv2DTranspose
from keras.layers.normalization import BatchNormalization
from keras import layers
from keras.models import Model
import keras.backend as K
# --... | 1,673 | 33.875 | 123 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.