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
transformers
transformers-main/utils/check_config_docstrings.py
# coding=utf-8 # Copyright 2022 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...
3,279
34.268817
105
py
transformers
transformers-main/utils/notification_service_doc_tests.py
# Copyright 2022 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...
12,860
32.755906
117
py
transformers
transformers-main/utils/custom_init_isort.py
# coding=utf-8 # Copyright 2021 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...
10,282
39.644269
116
py
transformers
transformers-main/utils/check_self_hosted_runner.py
import argparse import json import subprocess def get_runner_status(target_runners, token): offline_runners = [] cmd = ( f'curl -H "Accept: application/vnd.github+json" -H "Authorization: Bearer {token}"' " https://api.github.com/repos/huggingface/transformers/actions/runners" ) outpu...
1,538
28.037736
106
py
transformers
transformers-main/utils/update_tiny_models.py
# coding=utf-8 # Copyright 2023 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,272
35.18408
119
py
transformers
transformers-main/utils/check_doc_toc.py
# coding=utf-8 # Copyright 2022 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...
3,385
33.20202
116
py
transformers
transformers-main/utils/tests_fetcher.py
# coding=utf-8 # Copyright 2021 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...
36,418
40.574201
120
py
transformers
transformers-main/utils/check_doctest_list.py
# coding=utf-8 # Copyright 2023 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...
1,574
38.375
111
py
transformers
transformers-main/utils/get_modified_files.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...
1,506
39.72973
122
py
transformers
transformers-main/utils/print_env.py
#!/usr/bin/env python3 # 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 # # Unles...
1,723
28.724138
86
py
transformers
transformers-main/utils/create_dummy_models.py
# 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/LICENSE-2.0 # # Unless r...
67,548
42.834523
120
py
transformers
transformers-main/utils/check_copies.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...
23,859
40.067126
126
py
transformers
transformers-main/utils/check_tf_ops.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...
3,574
34.04902
119
py
transformers
transformers-main/utils/get_github_job_time.py
import argparse import math import traceback import dateutil.parser as date_parser import requests def extract_time_from_single_job(job): """Extract time info from a single job in a GitHub Actions workflow run""" job_info = {} start = job["started_at"] end = job["completed_at"] start_datetime ...
2,190
29.430556
115
py
transformers
transformers-main/utils/check_inits.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...
12,878
41.088235
117
py
transformers
transformers-main/utils/check_model_tester.py
# coding=utf-8 # Copyright 2023 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,598
39.609375
120
py
transformers
transformers-main/utils/sort_auto_mappings.py
# coding=utf-8 # Copyright 2022 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...
3,313
35.822222
119
py
transformers
transformers-main/utils/past_ci_versions.py
import argparse import os past_versions_testing = { "pytorch": { "1.13": { "torch": "1.13.1", "torchvision": "0.14.1", "torchaudio": "0.13.1", "python": 3.9, "cuda": "cu116", "install": ( "python3 -m pip install --no-c...
4,995
38.338583
114
py
transformers
transformers-main/utils/release.py
# coding=utf-8 # 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 requir...
6,207
38.044025
115
py
transformers
transformers-main/utils/get_previous_daily_ci.py
import os import zipfile import requests from get_ci_error_statistics import download_artifact, get_artifacts_links def get_daily_ci_runs(token, num_runs=7): """Get the workflow runs of the scheduled (daily) CI. This only selects the runs triggered by the `schedule` event on the `main` branch. """ h...
2,763
37.929577
110
py
transformers
transformers-main/utils/get_test_info.py
# coding=utf-8 # Copyright 2023 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,048
35.905759
118
py
transformers
transformers-main/utils/download_glue_data.py
""" Script for downloading all GLUE data. Original source: https://gist.github.com/W4ngatang/60c2bdb54d156a41194446737ce03e2e Note: for legal reasons, we are unable to host MRPC. You can either use the version hosted by the SentEval team, which is already tokenized, or you can download the original data from (https://...
8,285
51.443038
615
py
transformers
transformers-main/utils/extract_warnings.py
import argparse import json import os import time import zipfile from get_ci_error_statistics import download_artifact, get_artifacts_links from transformers import logging logger = logging.get_logger(__name__) def extract_warnings_from_single_artifact(artifact_path, targets): """Extract warnings from a downl...
4,692
33.762963
112
py
transformers
transformers-main/utils/notification_service.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...
41,883
39.545983
119
py
transformers
transformers-main/utils/add_pipeline_model_mapping_to_test.py
# coding=utf-8 # Copyright 2023 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...
13,870
40.038462
117
py
transformers
transformers-main/utils/check_repo.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...
48,398
41.492537
128
py
transformers
transformers-main/utils/check_build.py
# coding=utf-8 # Copyright 2023 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...
1,807
35.897959
117
py
transformers
transformers-main/utils/get_ci_error_statistics.py
import argparse import json import math import os import time import traceback import zipfile from collections import Counter import requests def get_job_links(workflow_run_id, token=None): """Extract job names and their job links in a GitHub Actions workflow run""" headers = None if token is not None: ...
10,403
36.42446
120
py
transformers
transformers-main/utils/check_config_attributes.py
# coding=utf-8 # Copyright 2023 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...
12,599
42.298969
118
py
transformers
transformers-main/utils/update_metadata.py
# coding=utf-8 # Copyright 2021 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...
12,459
42.114187
118
py
transformers
transformers-main/utils/check_dummies.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...
6,221
35.816568
118
py
transformers
transformers-main/utils/check_table.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,490
40.159341
116
py
transformers
transformers-main/utils/test_module/custom_image_processing.py
from transformers import CLIPImageProcessor class CustomImageProcessor(CLIPImageProcessor): pass
103
16.333333
47
py
transformers
transformers-main/utils/test_module/custom_tokenization_fast.py
from transformers import BertTokenizerFast from .custom_tokenization import CustomTokenizer class CustomTokenizerFast(BertTokenizerFast): slow_tokenizer_class = CustomTokenizer pass
193
20.555556
48
py
transformers
transformers-main/utils/test_module/custom_pipeline.py
import numpy as np from transformers import Pipeline def softmax(outputs): maxes = np.max(outputs, axis=-1, keepdims=True) shifted_exp = np.exp(outputs - maxes) return shifted_exp / shifted_exp.sum(axis=-1, keepdims=True) class PairClassificationPipeline(Pipeline): def _sanitize_parameters(self, **...
1,110
31.676471
89
py
transformers
transformers-main/utils/test_module/custom_tokenization.py
from transformers import BertTokenizer class CustomTokenizer(BertTokenizer): pass
88
13.833333
38
py
transformers
transformers-main/utils/test_module/__init__.py
0
0
0
py
transformers
transformers-main/utils/test_module/custom_processing.py
from transformers import ProcessorMixin class CustomProcessor(ProcessorMixin): feature_extractor_class = "AutoFeatureExtractor" tokenizer_class = "AutoTokenizer"
172
23.714286
52
py
transformers
transformers-main/utils/test_module/custom_feature_extraction.py
from transformers import Wav2Vec2FeatureExtractor class CustomFeatureExtractor(Wav2Vec2FeatureExtractor): pass
117
18.666667
55
py
transformers
transformers-main/utils/test_module/custom_modeling.py
import torch from transformers import PreTrainedModel from .custom_configuration import CustomConfig, NoSuperInitConfig class CustomModel(PreTrainedModel): config_class = CustomConfig def __init__(self, config): super().__init__(config) self.linear = torch.nn.Linear(config.hidden_size, conf...
772
21.735294
77
py
transformers
transformers-main/utils/test_module/custom_configuration.py
from transformers import PretrainedConfig class CustomConfig(PretrainedConfig): model_type = "custom" def __init__(self, attribute=1, **kwargs): self.attribute = attribute super().__init__(**kwargs) class NoSuperInitConfig(PretrainedConfig): model_type = "custom" def __init__(self,...
380
21.411765
46
py
tiny-faces-pytorch
tiny-faces-pytorch-master/main.py
import argparse import os import os.path as osp import torch from torch import optim from torchvision import transforms import trainer from datasets import get_dataloader from models.loss import DetectionCriterion from models.model import DetectionModel def arguments(): parser = argparse.ArgumentParser() p...
3,338
33.78125
92
py
tiny-faces-pytorch
tiny-faces-pytorch-master/evaluate.py
import argparse import json import os import os.path as osp import numpy as np import torch from PIL import Image from torch.utils import data from torchvision import transforms from tqdm import tqdm import trainer from datasets import get_dataloader from datasets.wider_face import WIDERFace from models.model import ...
3,789
31.393162
83
py
tiny-faces-pytorch
tiny-faces-pytorch-master/trainer.py
from pathlib import Path import numpy as np import torch from torch.nn import functional as nnfunc from torchvision import transforms from models.utils import get_bboxes from utils.nms import nms def print_state(idx, epoch, size, loss_cls, loss_reg): if epoch >= 0: message = "Epoch: [{0}][{1}/{2}]\t".fo...
4,459
29.972222
89
py
tiny-faces-pytorch
tiny-faces-pytorch-master/models/loss.py
import numpy as np import torch from torch import nn from .utils import balance_sampling class AvgMeter: def __init__(self): self.average = 0 self.num_averaged = 0 def update(self, loss, size): n = self.num_averaged m = n + size self.average = ((n * self.average) + fl...
3,298
32.663265
91
py
tiny-faces-pytorch
tiny-faces-pytorch-master/models/utils.py
import numpy as np def get_bboxes(score_cls, score_reg, prob_cls, templates, prob_thresh, rf, scale=1, refine=True): """ Convert model output tensor to a set of bounding boxes and their corresponding scores """ num_templates = templates.shape[0] # template to evaluate at every scale (Type A templ...
5,274
32.386076
97
py
tiny-faces-pytorch
tiny-faces-pytorch-master/models/model.py
import numpy as np import torch from torch import nn from torchvision.models import resnet50, resnet101 class DetectionModel(nn.Module): """ Hybrid Model from Tiny Faces paper """ def __init__(self, base_model=resnet101, num_templates=1, num_objects=1): super().__init__() # 4 is for t...
3,496
32.304762
97
py
tiny-faces-pytorch
tiny-faces-pytorch-master/models/__init__.py
0
0
0
py
tiny-faces-pytorch
tiny-faces-pytorch-master/datasets/processor.py
import numpy as np from copy import deepcopy from utils.visualize import draw_bounding_box, render_and_save_bboxes, visualize_bboxes from utils.nms import nms from utils.metrics import rect_dist from utils.dense_overlap import compute_dense_overlap import logging logger = logging.getLogger("detector") class DataPr...
12,457
39.448052
115
py
tiny-faces-pytorch
tiny-faces-pytorch-master/datasets/__init__.py
import numpy as np import os import os.path as osp import json from utils.cluster import compute_kmedoids from .wider_face import WIDERFace from torch.utils import data def get_dataloader(datapath, args, num_templates=25, template_file="templates.json", img_transforms=None, train...
1,585
38.65
100
py
tiny-faces-pytorch
tiny-faces-pytorch-master/datasets/wider_face.py
from pathlib import Path import numpy as np import torch from PIL import Image from torch.utils.data import dataset from torchvision import transforms from utils import visualize from .processor import DataProcessor class WIDERFace(dataset.Dataset): """The WIDERFace dataset is generated using MATLAB, so a ...
8,229
34.938865
96
py
tiny-faces-pytorch
tiny-faces-pytorch-master/utils/nms.py
import numpy as np def nms(dets, thresh): """ Courtesy of Ross Girshick [https://github.com/rbgirshick/py-faster-rcnn/blob/master/lib/nms/py_cpu_nms.py] """ x1 = dets[:, 0] y1 = dets[:, 1] x2 = dets[:, 2] y2 = dets[:, 3] scores = dets[:, 4] areas = (x2 - x1 + 1) * (y2 - y1 + 1...
921
24.611111
84
py
tiny-faces-pytorch
tiny-faces-pytorch-master/utils/test_dense_overlap.py
from .dense_overlap import compute_dense_overlap from scipy.io import loadmat import numpy as np d = loadmat("dense_overlap.mat") ofx, ofy = d['ofx'][0, 0], d['ofy'][0, 0] stx, sty = d['stx'][0, 0], d['sty'][0, 0] vsx, vsy = d['vsx'][0, 0], d['vsy'][0, 0] dx1, dy1, dx2, dy2 = d['dx1'], d['dy1'], d['dx2'], d['dy2'] d...
1,076
29.771429
65
py
tiny-faces-pytorch
tiny-faces-pytorch-master/utils/dense_overlap.py
import numpy as np def compute_dense_overlap(ofx, ofy, stx, sty, vsx, vsy, dx1, dy1, dx2, dy2, gx1, gy1, gx2, gy2, zmx=1, zmy=1): """ Compute the dense IoU """ num_templates = dx1.shape[0] num_gt = gx1.shape[0] ty, tx = (vsy - 1) * zmy + 1, ...
1,997
31.754098
96
py
tiny-faces-pytorch
tiny-faces-pytorch-master/utils/cluster.py
import argparse from datetime import datetime from pathlib import Path import numpy as np from PIL import Image, ImageDraw from pyclust import KMedoids from pyclustering.cluster.kmedoids import kmedoids import joblib from tqdm import tqdm from .k_medoids import kMedoids from .metrics import jaccard_index, rect_dist ...
4,972
30.878205
117
py
tiny-faces-pytorch
tiny-faces-pytorch-master/utils/k_medoids.py
import numpy as np import warnings def kMedoids(distances, k): """ https://github.com/salspaugh/machine_learning/blob/master/clustering/kmedoids.py :param distances: :param k: :return: """ n = distances.shape[0] medoid_idxs = np.random.choice(n, size=k, replace=False) old_medoids_...
2,203
32.393939
93
py
tiny-faces-pytorch
tiny-faces-pytorch-master/utils/metrics.py
import json import warnings import numpy as np from tqdm import tqdm def jaccard_index(box_a, box_b, indices=[]): """ Compute the Jaccard Index (Intersection over Union) of 2 boxes. Each box is (x1, y1, x2, y2). :param box_a: :param box_b: :param indices: The indices of box_a and box_b as [box_a_...
5,812
27.777228
116
py
tiny-faces-pytorch
tiny-faces-pytorch-master/utils/__init__.py
"""Utils module""" from . import metrics from . import nms from . import dense_overlap from . import k_medoids
112
15.142857
27
py
tiny-faces-pytorch
tiny-faces-pytorch-master/utils/test_metrics.py
import numpy as np from scipy.io import loadmat from .metrics import jaccard_index, rect_dist def test_rect_dist(x, y, gt_dist): d = rect_dist(x, y) print("Is my rect_dist code correct?", np.array_equal(d, gt_dist)) def main(): truth = loadmat('rect_dist.mat') gt_dist = truth['d'][:, 0] x = trut...
476
20.681818
70
py
tiny-faces-pytorch
tiny-faces-pytorch-master/utils/visualize.py
from PIL import Image, ImageDraw, ImageFont import json from pathlib import Path import numpy as np def draw_bounding_box(img, bbox, labels): draw = ImageDraw.Draw(img) font = ImageFont.load_default() color = tuple(np.random.choice(range(100, 256), size=3)) draw.rectangle((bbox[0], bbox[1], bbox[2], ...
1,696
27.762712
94
py
TSCP2
TSCP2-main/src/main.py
import sys import numpy as np import argparse import os import tensorflow as tf import matplotlib.pyplot as plt # dataset import TSCP2 as cp2 import losses as ls from utils.DataHelper import load_dataset from utils.estimate_CPD import estimate_CPs parser = argparse.ArgumentParser(description='interface of running expe...
6,984
43.775641
173
py
TSCP2
TSCP2-main/src/losses.py
from tensorflow.keras import backend as K import tensorflow as tf import numpy as np cosine_sim_1d = tf.keras.losses.CosineSimilarity(axis=1, reduction=tf.keras.losses.Reduction.NONE) cosine_sim_2d = tf.keras.losses.CosineSimilarity(axis=2, reduction=tf.keras.losses.Reduction.NONE) def _cosine_simililarity_dim1(x, y)...
8,998
36.032922
161
py
TSCP2
TSCP2-main/src/TSCP2.py
import os from tensorflow.keras.layers import * from tensorflow.keras.models import * from tqdm import tqdm import tensorflow as tf from tcn import TCN import numpy as np import losses as ls from utils.usc_ds_helper import ts_samples #@tf.function def train_step(xis, xjs, amodel, optimizer, criterion, temperature, s...
4,665
41.036036
176
py
TSCP2
TSCP2-main/src/helpers.py
import tensorflow as tf import numpy as np #from augmentation.gaussian_filter import GaussianBlur def get_mask(batch_size): # return a mask that removes the similarity score of equal/similar images. # this function ensures that only distinct pair of images get their similarity scores # passed as negative e...
1,000
39.04
89
py
TSCP2
TSCP2-main/src/utils/wsdm_ds_helper.py
import numpy as np from pandas import read_csv import pandas as pd import csv import os def ts_samples(mbatch, win): x = mbatch[:,1:win+1] y = mbatch[:,-win:] lbl = mbatch[:,0] return x, y, lbl def load_wsdm_ds(path, window, mode='train', part=1): save_path = os.path.join("../data/slidingwindow"...
3,412
30.601852
120
py
TSCP2
TSCP2-main/src/utils/DataHelper.py
import numpy as np import tensorflow as tf from .hasc_helper import load_hasc_ds from .usc_ds_helper import load_usc_ds def load_dataset(path, ds_name, win, bs, mode="train"): if ds_name == 'HASC': trainx, trainlbl = load_hasc_ds(path, window = 2 * win, mode=mode) elif ds_name == "USC": trainx,...
883
34.36
96
py
TSCP2
TSCP2-main/src/utils/FastDTW.py
#!/usr/bin/env python # coding: utf-8 # In[10]: from __future__ import absolute_import, division import numbers import numpy as np from collections import defaultdict def __reduce_by_half(x): return [(x[i] + x[1+i]) / 2 for i in range(0, len(x) - len(x) % 2, 2)] # In[11]: def __expand_window(path, len_x, le...
5,152
25.425641
80
py
TSCP2
TSCP2-main/src/utils/yahoo_ds_helper.py
from math import floor import numpy as np from pandas import read_csv import pandas as pd import csv import os def ts_samples(mbatch, win): x = mbatch[:,1:win+1] y = mbatch[:,-win:] lbl = mbatch[:,0] return x, y, lbl def load_yahoo_ds(path, window, mode='train'): save_path = os.path.join("../d...
2,906
28.363636
120
py
TSCP2
TSCP2-main/src/utils/analysis_helper.py
import csv import os import numpy as np from numpy import mean from numpy import std import matplotlib.pyplot as plt from scipy import signal from sklearn.metrics import mean_squared_error from utils.FastDTW import fastdtw def getMSE(Yt, y_pred, sq = False): y_hat = y_pred.reshape((Yt.shape[0], Yt.shape[1], Yt....
3,827
35.457143
171
py
TSCP2
TSCP2-main/src/utils/usc_ds_helper.py
from math import floor import numpy as np import pandas as pd import scipy.io as sio import csv def ts_samples(mbatch, win): x = mbatch[:,1:win+1] y = mbatch[:,-win:] lbl = mbatch[:,0] return x, y, lbl def load_usc_ds(path, window, mode='train'): X, lbl = extract_windows(path, window, mode) ...
1,866
26.057971
113
py
TSCP2
TSCP2-main/src/utils/logger.py
import logging import logging.config import yaml import os def get_logger(mod_name, log_dir): if not os.path.exists(log_dir): os.mkdir(log_dir) config_filepath = os.path.join(os.path.realpath(os.path.dirname(__file__)), 'logger_config.yml') if os.path.exists(config_filepath): with open(co...
721
31.818182
100
py
TSCP2
TSCP2-main/src/utils/hasc_helper.py
from math import floor import numpy as np from pandas import read_csv import pandas as pd import csv import os def ts_samples(mbatch, win): x = mbatch[:,1:win+1] y = mbatch[:,-win:] lbl = mbatch[:,0] return x, y, lbl def load_hasc_ds(path, window, mode='train'): X, lbl = extract_windows(path,...
1,878
24.739726
111
py
TSCP2
TSCP2-main/src/utils/estimate_CPD.py
import numpy as np from sklearn.metrics import confusion_matrix,f1_score from matplotlib import pyplot as plt from losses import _cosine_simililarity_dim1 def estimate_CPs(sim, gt, name, train_name, metric='cosine', threshold=0.5): #if metric == "cosine": # sim = _cosine_simililarity_dim1(h, f) est_cp...
1,741
30.672727
178
py
TSCP2
TSCP2-main/src/utils/__init__.py
0
0
0
py
DG-Font
DG-Font-main/main.py
import argparse import warnings from datetime import datetime from glob import glob from shutil import copyfile from collections import OrderedDict import torch.nn import torch.nn.parallel import torch.backends.cudnn as cudnn import torch.distributed as dist import torch.optim import torch.multiprocessing as mp import...
17,653
43.024938
1,912
py
DG-Font
DG-Font-main/font2img.py
from PIL import Image,ImageDraw,ImageFont import matplotlib.pyplot as plt import os import numpy as np import pathlib import argparse parser = argparse.ArgumentParser(description='Obtaining characters from .ttf') parser.add_argument('--ttf_path', type=str, default='../ttf_folder',help='ttf directory') parser.add_argu...
2,167
37.714286
128
py
DG-Font
DG-Font-main/functions/modulated_deform_conv_func.py
#!/usr/bin/env python from __future__ import absolute_import from __future__ import print_function from __future__ import division import math import torch from torch import nn from torch.autograd import Function from torch.nn.modules.utils import _pair from torch.autograd.function import once_differentiable import D...
2,484
42.596491
83
py
DG-Font
DG-Font-main/functions/__init__.py
from .modulated_deform_conv_func import ModulatedDeformConvFunction
68
33.5
67
py
DG-Font
DG-Font-main/tools/utils.py
import os import torch class Logger(object): def __init__(self, log_dir): self.last = None def scalar_summary(self, tag, value, step): if self.last and self.last['step'] != step: print(self.last) self.last = None if self.last is None: self.last = {'...
1,968
25.608108
88
py
DG-Font
DG-Font-main/tools/ops.py
from torch import autograd import torch import torch.distributed as dist from torch.nn import functional as F def compute_grad_gp(d_out, x_in, is_patch=False): batch_size = x_in.size(0) grad_dout = autograd.grad( outputs=d_out.sum() if not is_patch else d_out.mean(), inputs=x_in, create_graph=...
4,639
28.367089
97
py
DG-Font
DG-Font-main/modules/modulated_deform_conv.py
#!/usr/bin/env python from __future__ import absolute_import from __future__ import print_function from __future__ import division import torch import math from torch import nn from torch.nn import init from torch.nn.modules.utils import _pair from functions.modulated_deform_conv_func import ModulatedDeformConvFuncti...
5,186
44.902655
119
py
DG-Font
DG-Font-main/modules/__init__.py
from .modulated_deform_conv import ModulatedDeformConv, _ModulatedDeformConv, ModulatedDeformConvPack
101
101
101
py
DG-Font
DG-Font-main/models/guidingNet.py
from torch import nn import torch.nn.functional as F try: from models.blocks import Conv2dBlock, FRN except: from blocks import Conv2dBlock, FRN cfg = { 'vgg11': [64, 'M', 128, 'M', 256, 256, 'M', 512, 512, 'M', 512, 512, 'M'], 'vgg13': [64, 64, 'M', 128, 128, 'M', 256, 256, 'M', 512, 512, 'M', 512, ...
2,977
31.725275
120
py
DG-Font
DG-Font-main/models/discriminator.py
import torch import torch.nn as nn import torch.nn.functional as F import numpy as np import torch.nn.init as init import math try: from models.blocks import FRN, ActFirstResBlk except: from blocks import FRN, ActFirstResBlk class Discriminator(nn.Module): """Discriminator: (image x, domain y) -> (logit...
3,132
34.202247
87
py
DG-Font
DG-Font-main/models/inception.py
import torch import torch.nn as nn import torch.nn.functional as F from torchvision import models try: from torchvision.models.utils import load_state_dict_from_url except ImportError: from torch.utils.model_zoo import load_url as load_state_dict_from_url # Inception weights ported to Pytorch from # http://do...
11,623
36.376206
126
py
DG-Font
DG-Font-main/models/generator.py
from torch import nn import torch import torch.nn.functional as F import torch.nn.init as init import scipy.io as io import math import numpy as np try: from models.blocks import LinearBlock, Conv2dBlock, ResBlocks except: from blocks import LinearBlock, Conv2dBlock, ResBlocks import sys sys.path.append('..')...
7,688
38.229592
168
py
DG-Font
DG-Font-main/models/blocks.py
import torch import torch.nn.functional as F from torch import nn class ResBlocks(nn.Module): def __init__(self, num_blocks, dim, norm, act, pad_type, use_sn=False): super(ResBlocks, self).__init__() self.model = nn.ModuleList() for i in range(num_blocks): self.model.append(Res...
7,518
33.64977
118
py
DG-Font
DG-Font-main/datasets/custom_dataset.py
import torch.utils.data as data from PIL import Image import os import os.path import sys def has_file_allowed_extension(filename, extensions): """Checks if a file is an allowed extension. Args: filename (string): path to a file extensions (iterable of strings): extensions to consider (lowe...
9,235
33.207407
131
py
DG-Font
DG-Font-main/datasets/datasetgetter.py
import torch from torchvision.datasets import ImageFolder import os import torchvision.transforms as transforms from datasets.custom_dataset import ImageFolerRemap, CrossdomainFolder class Compose(object): def __init__(self, tf): self.tf = tf def __call__(self, img): for t in self.tf: ...
2,435
27.325581
91
py
DG-Font
DG-Font-main/train/train.py
from tqdm import trange import torch.nn import torch.nn.parallel import torch.optim import torch.utils.data import torch.utils.data.distributed from tools.utils import * from tools.ops import compute_grad_gp, update_average, copy_norm_params, queue_data, dequeue_data, \ average_gradients, calc_adv_loss, calc_contra...
5,671
30.511111
158
py
DG-Font
DG-Font-main/validation/validation.py
import torch.nn import torch.nn.parallel import torch.optim import torch.utils.data import torch.utils.data.distributed import torchvision.utils as vutils import torch.nn.functional as F import numpy as np try: from tqdm import tqdm except ImportError: # If not tqdm is not available, provide a mock version of...
4,643
46.387755
161
py
FPConv
FPConv-master/tools/test_scannet.py
import torch from torch.utils.data import DataLoader import numpy as np import argparse import importlib import os import sys import json from utils.switchnorm import convert_sn from datasets.scannet_dataset_rgb_test import ScannetDatasetWholeScene_evaluation np.seterr(divide='ignore', invalid='ignore') parser = arg...
7,024
36.367021
139
py
FPConv
FPConv-master/tools/test_s3dis.py
import os, sys import json import numpy as np import argparse import importlib import torch from torch.utils.data import DataLoader from datasets.s3dis_dataset_test import S3DISWholeScene_evaluation np.seterr(divide='ignore', invalid='ignore') parser = argparse.ArgumentParser(description="Arg parser") parser.add_arg...
5,981
35.036145
87
py
FPConv
FPConv-master/tools/train_scannet.py
import torch import torch.nn as nn from torch.utils.data import DataLoader import torch.distributed as dist import os, sys import argparse import importlib import numpy as np import json import tensorboard_logger as tb_log from datasets.scannet_dataset_rgb import ScannetDataset, ScannetDatasetWholeScene from utils.sa...
11,795
37.423453
137
py
FPConv
FPConv-master/tools/train_s3dis.py
import os, sys import argparse import importlib import numpy as np import json import time import tensorboard_logger as tb_log import torch import torch.nn as nn from torch.utils.data import DataLoader from datasets.s3dis_dataset import S3DIS from utils.saver import Saver np.seterr(divide='ignore', invalid='ignore')...
12,945
35.162011
125
py
FPConv
FPConv-master/tools/vis_scannet.py
import numpy as np import open3d as o3d import os import argparse import sys parser = argparse.ArgumentParser(description='Visualize point cloud') parser.add_argument('--file_dir', type=str, help=None) parser.add_argument('--scene_id', type=str, help=None) args = parser.parse_args() print(args) color_map = [[ 0, 0...
2,015
31.516129
84
py
FPConv
FPConv-master/models/fpcnn_scannet.py
import torch import torch.nn as nn from fpconv.pointnet2.pointnet2_modules import PointnetFPModule import fpconv.pointnet2.pytorch_utils as pt_utils from fpconv.base import AssemRes_BaseBlock from fpconv.fpconv import FPConv4x4_BaseBlock, FPConv6x6_BaseBlock NPOINT = 8192 NPOINTS = [NPOINT // 2, NPOINT // 8, NPOINT ...
4,571
37.1
94
py
FPConv
FPConv-master/models/fpcnn_s3dis.py
import torch import torch.nn as nn from fpconv.pointnet2.pointnet2_modules import PointnetFPModule, PointnetSAModule import fpconv.pointnet2.pytorch_utils as pt_utils from fpconv.base import AssemRes_BaseBlock from fpconv.fpconv import FPConv4x4_BaseBlock, FPConv6x6_BaseBlock NPOINTS = [8192, 2048, 512, 128] RADIUS =...
4,378
37.412281
94
py
FPConv
FPConv-master/fpconv/base.py
import torch import torch.nn as nn import torch.nn.functional as F from torch.nn.parameter import Parameter from fpconv.pointnet2 import pointnet2_utils from fpconv.pointnet2 import pytorch_utils as pt_utils relu_alpha = 0.2 class PointNet(nn.Module): def __init__(self, mlp, pool='max', bn=True): super()...
8,204
40.649746
125
py
FPConv
FPConv-master/fpconv/fpconv.py
import torch import torch.nn as nn import torch.nn.functional as F from torch.nn.parameter import Parameter from fpconv.pointnet2 import pointnet2_utils from fpconv.pointnet2 import pytorch_utils as pt_utils from fpconv import base relu_alpha = 0.2 class FPConv4x4_BaseBlock(nn.Module): def __init__(self, npoint,...
8,087
41.793651
133
py