sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
9e2d7d843fd256310d7e54c9b5ff8376a268be36221c69ca4992ccea1c63be44 | Python | 6,786 | 210 | from multiprocessing import shared_memory
# import multiprocessing
# if hasattr(multiprocessing, "shared_memory"):
# from multiprocessing import shared_memory
# else:
# # workaround for single gpu inference on colab
# shared_memory = None
import random
import pickle
import time
import copy
import torch
imp... |
0222df0354a248ccc7f8525eda9bda9da815e5d60106f611a5f4750d1ba7f321 | Python | 6,799 | 191 | import functools
import numpy as np
from scipy.signal import resample_poly
EPS = np.finfo("float").eps
def _resample_window_oct(p, q):
"""Port of Octave code to Python"""
gcd = np.gcd(p, q)
if gcd > 1:
p /= gcd
q /= gcd
# Properties of the antialiasing filter
log10_rejection = ... |
90b099323a0626599c4250d3dca1921c30ee573804ab965bbd150a4fd12c3c76 | Python | 6,804 | 209 | # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source... |
e36615d37420c2a657f688439200300738dfa09340e80a5ad56f4deffd7b71d7 | Python | 6,804 | 186 | # -*- coding: utf-8 -*-
"""
Created on Mon Jan 24 20:31:08 2022
@author: Daniel
"""
import sqlite3
import os
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
from scipy.stats import ttest_rel, ttest_ind
import numpy as np
import scipy.optimize
from statsmodels.formula.api import ols
from stat... |
7fdf9276a4933fd65f669b9254f70cf64741f26e68ac28bf1a30076a2bdc14c2 | Python | 6,806 | 197 | # Copyright (c) OpenMMLab. All rights reserved.
from collections.abc import Sequence
import numpy as np
from mmcv.utils import print_log
from terminaltables import AsciiTable
from .bbox_overlaps import bbox_overlaps
def _recalls(all_ious, proposal_nums, thrs):
img_num = all_ious.shape[0]
total_gt_num = sum... |
a84a18eda909f2ad7eb1c6f61a3418f7b2c031a21621665b8797a71baaafc5e4 | Python | 6,807 | 183 | import ete3
import numpy as np
import pandas as pd
import argparse
# argument parser
arp = argparse.ArgumentParser()
# Add the arguments to the parser
arp.add_argument("-tree", "--tree", required=True, help="newick file with species tree")
arp.add_argument("-ort", "--ort", required=True, ... |
42d577963d6ad80efdc3bf2bed868d966887b218c9f6dba2ffdb0a5b67b68f0e | Python | 6,813 | 187 | '''
The code deeply follows and taken from the MRQy (https://github.com/ccipd/MRQy)
@article{sadri2020mrqy,
title={MRQy—An open-source tool for quality control of MR imaging data},
author={Sadri, Amir Reza and Janowczyk, Andrew and Zhou, Ren and Verma, Ruchika and Beig, Niha and Antunes, Jacob and Madabhushi, A... |
efd18d7d9cd35b94c72ead530b80c66f37dfcffa9276ddfef39ad0fd7d3db6f8 | Python | 6,818 | 191 | # Copyright (c) OpenMMLab. All rights reserved.
import copy
import warnings
from abc import ABCMeta, abstractmethod
import numpy as np
from torch.utils.data import Dataset
from xtcocotools.coco import COCO
from mmpose.datasets import DatasetInfo
from mmpose.datasets.pipelines import Compose
class Kpt2dSviewRgbVidTo... |
7dd6f0fc138d508d72bae38435822fa3b2d487bbce5a89124b5bf3c1643e3897 | Python | 6,819 | 198 | """
Base dataset class for loading polysomnography (PSG) data from HDF5 files.
This module defines the abstract base class for all dataset implementations in
the AnySleep framework. It handles HDF5 file access, data filtering by
train/validation/test splits, and provides common utilities for channel selection.
The HD... |
bd53afef8b033b88d21b0ea270b626aec2a37f8704ead5dd347504f6004f1c9d | Python | 6,831 | 146 | import argparse
import sys
import h5py
from pytorch_fid import fid_score
import os
import PIL.Image
from shutil import rmtree
import numpy as np
def adjust_dynamic_range(data, drange_in, drange_out):
if drange_in != drange_out:
scale = (np.float32(drange_out[1]) - np.float32(drange_out[0])) / (np.float32(... |
ac2d38fd1d825b478e76c7ab2600310ca9e529f72f0e0d930867cd6578614cfb | Python | 6,839 | 199 | # %%
import pandas as pd
import numpy as np
import pickle
import matplotlib.pyplot as plt
from rdkit import Chem
from serenityff.charge.tree.dash_tools import init_neighbor_dict
from serenityff.charge.tree.dash_tree import DASHTree
from tqdm import tqdm
# %%
plt.rcParams.update({"font.size": 16})
# %%
main_folder = "... |
1ab07b211c5a2ec2cb35b762e73d4697ed08ca69b347f19322983ce9fe176af0 | Python | 6,848 | 210 | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
import re
import tempfile
from collections import OrderedDict
import torch
from mmcv import Config
def is_head(key):
valid_head_list = [
'bbox_head', 'mask_head', 'semantic_head', 'grid_head', 'mask_iou_head'
]
return any(key.starts... |
af3b8606f28d3ba91d5eb2046799fc727e3c961e17e0932a35623e7345492300 | Python | 6,862 | 192 | _base_ = [
'../../../../_base_/default_runtime.py',
'../../../../_base_/datasets/mpi_inf_3dhp.py'
]
evaluation = dict(
interval=10,
metric=['mpjpe', 'p-mpjpe', '3dpck', '3dauc'],
save_best='MPJPE')
# optimizer settings
optimizer = dict(
type='Adam',
lr=1e-3,
)
optimizer_config = dict(grad_c... |
745d125a9082c6cd8327a89005df29cd5d8edbf0a4dcd5fb64dafc909b4bb802 | Python | 6,863 | 156 | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from ..builder import BBOX_ASSIGNERS
from ..iou_calculators import build_iou_calculator
from .assign_result import AssignResult
from .base_assigner import BaseAssigner
@BBOX_ASSIGNERS.register_module()
class GridAssigner(BaseAssigner):
"""Assign a corr... |
d7a3df33d4f2ed35d230166c21de23e64ba017fd6828c78865eef4d06f901e16 | Python | 6,865 | 191 |
import os
os.environ['XLA_PYTHON_CLIENT_PREALLOCATE'] = 'false'
from pprint import pprint
import jax
import jax.numpy as jnp
import jax.tree_util as tree
import numpy as np
from functools import partial
import haiku as hk
import optax
from absl import app, flags, logging
from collections import namedtuple
from tqdm i... |
d8b90e105e61550f3deb369595855a211ec0019703f598a407aaa55660a78fcb | Python | 6,870 | 217 | import datetime
import shutil
import getpass
from pathlib import Path
import numpy as np
import pandas as pd
from eegml import experimentlog as explog
from eegml import preprocessing as pp
from eegml import sampen_eeg as smpen
from eegml import toolkit as tk
USER_ID = getpass.getuser()
config = tk.parse_config("con... |
180d86681522f0258fdb9a982938729a09d259c885b38e9b7f6eb4773b515bac | Python | 6,874 | 191 | # Copyright (c) OpenMMLab. All rights reserved.
import os.path as osp
import pickle
import shutil
import tempfile
import time
import mmcv
import torch
import torch.distributed as dist
from mmcv.image import tensor2imgs
from mmcv.runner import get_dist_info
from mmdet.core import encode_mask_results
def single_gpu_t... |
289bb0d8d6ef50abd27f50df89ae500de6da8159a7b25609235703f0905ebc6b | Python | 6,876 | 182 | # This file is part of sbi, a toolkit for simulation-based inference. sbi is licensed
# under the Apache License Version 2.0, see <https://www.apache.org/licenses/>
from typing import Optional, Tuple, Union
import torch
from torch import Tensor, nn
from torch.distributions import Distribution
from sbi.inference.pote... |
971017d073884e05d9fffbbfd90341a7d40a7b905f0212d640b11bc836e1e888 | Python | 6,876 | 189 | # Copyright Universitat Pompeu Fabra 2020-2023 https://www.compscience.org
# Distributed under the MIT License.
# (See accompanying file README.md file or copy at http://opensource.org/licenses/MIT)
import hashlib
import h5py
import numpy as np
import os
import torch as pt
from torchmdnet.datasets.memdataset import M... |
53d09d936785d43d41150c20b28953bfee0e940a98d023206873b236d73b434f | Python | 6,880 | 150 | # Copyright (c) 2023 IBM Research. All Rights Reserved.
#
# Code accompanying a manuscript entitled:
# "On the visual analytic intelligence of neural networks"
from random import shuffle
import os
import random
import collections
import hashlib
from PIL import Image, ImageDraw
import sys
from generators im... |
86eddea45e9ea20e9c29a5b9e97f76fccef62708846371a1c660581b8e2fef15 | Python | 6,881 | 190 | import torch
import numpy as np
#from mpi4py import MPI
import socket
import argparse
import os
import json
import subprocess
from hps import Hyperparams, parse_args_and_update_hparams, add_vae_arguments
from utils import (logger,
local_mpi_rank,
mpi_size,
maybe_... |
d891b6f86523922a24b8a6222a93607e3ff088df440afba3f7c242722561618f | Python | 6,888 | 172 | import logging
import numpy as np
import torch
from sklearn.metrics import precision_recall_fscore_support
from sklearn.metrics import roc_auc_score, accuracy_score
from torch import optim, nn
class GuestTrainer(object):
def __init__(self, client_num, device, X_train, y_train, X_test, y_test, model_feature_extra... |
6b245afdae6ee6a89b3723fe0decf27aa31154fd41b0122529d1fa12ff48a3b3 | Python | 6,897 | 199 | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
import os.path as osp
import mmcv
import numpy as np
from mmcv import Config, DictAction
from mmdet.core.evaluation import eval_map
from mmdet.core.visualization import imshow_gt_det_bboxes
from mmdet.datasets import build_dataset, get_loading_pipeline
... |
f18127c92dd298168adb56cc60141bd57be446a324b3b3d65c993e6ac934fa2e | Python | 6,897 | 189 | # Copyright (c) OpenMMLab. All rights reserved.
import copy
from abc import ABCMeta, abstractmethod
import numpy as np
import xtcocotools
from torch.utils.data import Dataset
from xtcocotools.coco import COCO
from mmpose.datasets import DatasetInfo
from mmpose.datasets.pipelines import Compose
class Kpt2dSviewRgbIm... |
1e9d2b1cba6d7560c87bd62ea543e088f6bd7fa2f9fba55edf5e1eee7d698b6c | Python | 6,899 | 190 | # Copyright (c) OpenMMLab. All rights reserved.
import os.path as osp
import tempfile
import warnings
from collections import OrderedDict
import numpy as np
from mmcv import Config, deprecated_api_warning
from mmpose.datasets.builder import DATASETS
from ..base import Kpt2dSviewRgbImgTopDownDataset
@DATASETS.regist... |
f9fc7f0ebbaa7de25a775904b43d51974bdc7884c77212ad79b3d53404be2f4a | Python | 6,901 | 134 | # -*- coding: utf-8 -*-
"""
Created on Mon Jul 5 12:46:20 2021
@author: fhu14
Module to run organic molecules from ANI-1 through DFTB+ with new skf files.
"""
#%% Imports, definitions
from .run_dftbplus import compute_results_torch, add_dftb, load_ani1, compute_results_torch_newrep
from .util import find_all_used_c... |
0fb8c5688ea96a738f8c779544d5b0339c0b3d942d53b97a792b388320f05f43 | Python | 6,903 | 174 | # Copyright (c) OpenMMLab. All rights reserved.
import copy
import mmcv
import numpy as np
from mmcv.utils import build_from_cfg
from numpy.testing import assert_array_equal
from mmdet.datasets.builder import PIPELINES
from .utils import construct_toy_data
def test_adjust_color():
results = construct_toy_data()... |
5bd4cef7864f3c91c633475d7507708f5796b96c22eae6283c6198f5324bfab4 | Python | 6,903 | 228 | _base_ = [
'../../../../_base_/default_runtime.py',
'../../../../_base_/datasets/h36m.py'
]
checkpoint_config = dict(interval=20)
evaluation = dict(
interval=10, metric=['mpjpe', 'p-mpjpe', 'n-mpjpe'], save_best='MPJPE')
# optimizer settings
optimizer = dict(
type='Adam',
lr=1e-3,
)
optimizer_confi... |
0ba47f7021d726d48f2e69a75d038bd8cd36fc104d2c172120342347616c0f4b | Python | 6,906 | 168 | import numpy as np
import torch
from torch.utils.data import Dataset
from tqdm import trange
import os
from pycocotools.coco import COCO
from pycocotools import mask
from torchvision import transforms
import deeplab_utils
from PIL import Image, ImageFile
ImageFile.LOAD_TRUNCATED_IMAGES = True
class COCOSegmentation(... |
543f74fe5b0df7fcb27d5d328c5627c48f079d6fb8a4b7d4a9df2beb0cf84fdd | Python | 6,926 | 188 | # Copyright (c) OpenMMLab. All rights reserved.
import itertools
import numpy as np
import torch
from .general_data import GeneralData
class InstanceData(GeneralData):
"""Data structure for instance-level annnotations or predictions.
Subclass of :class:`GeneralData`. All value in `data_fields`
should h... |
76da52e7cdebe7c85dad43ac45e853153e22b27f6494e3ae14c784afc5f6a9e6 | Python | 6,931 | 173 | from collections import Counter
from itertools import combinations
from multiprocessing import Pool
import numpy as np
from scipy.spatial.distance import pdist
from .dataset import Dataset, Gammas
from .options import Options
from .tfspline import spline_linear_model
# TODO: compatibility with different models
clas... |
5a0acc8da0749ffc0b6920737fdd519f301bd32c0bb9f538a9a7a617343c4d8e | Python | 6,938 | 163 | import logging, time
import numpy as np
import torch
try:
from fedml_core.trainer.model_trainer import ModelTrainer
except ImportError:
from FedML.fedml_core.trainer.model_trainer import ModelTrainer
from .utils import EvaluationMetricsKeeper, float_to_uint_img
def convert_to_img(A, B, fake_B):
nc ... |
5f84bd9a6d077a45ff0b0f623ee97b5f5facb9471cbde2592266740ed5177f38 | Python | 6,940 | 219 | from typing import Optional
from .gradient_descent_base import L1BaseGradientDescent, AdamOptimizer, Optimizer
from .gradient_descent_base import L2BaseGradientDescent
from .gradient_descent_base import LinfBaseGradientDescent
import eagerpy as ep
class L1ProjectedGradientDescentAttack(L1BaseGradientDescent):
""... |
18dc76bea69578ed9ec4a777a98bff8840c20189d25ce8f24df8f8a42ad1e6ea | Python | 6,945 | 179 | # Copyright (c) OpenMMLab. All rights reserved.
import mmcv
import numpy as np
from ..builder import PIPELINES
@PIPELINES.register_module()
class LoadImageFromFile:
"""Loading image(s) from file.
Required key: "image_file".
Added key: "img".
Args:
to_float32 (bool): Whether to convert the ... |
fbcc35259dad1302f383876b002f5c401e164b4039aed1e9d8f40bddb6c57562 | Python | 6,945 | 215 | """A collection of useful helper functions"""
import os
import json
from typing import Dict, Tuple, List
import time
import librosa
import soundfile as sf
import random
import numpy as np
import noisereduce as nr
import torch
import torchaudio
import torch.nn.functional as F
from sep.helpers.constants import SPEED_O... |
ff05f26f0433458ee635661fa95fd8ffd981cf4b3aa86e3602d8ea3c9f90b945 | Python | 6,945 | 181 | import os
import pandas as pd
import numpy as np
from tqdm import tqdm
import SimpleITK as sitk
import torch
import torch.optim as optim
from torch import nn
from torch.utils.data import Dataset
from torch.utils.data import DataLoader
from nets.classification import CleftNet, CleftSegNet
from loaders.cleft_dataset... |
7df93ff42884126738dc49beed9bf81e6ed7ce649ae53463038047a4c08d709c | Python | 6,947 | 162 | import copy
import logging
import time
import torch
import wandb
import numpy as np
from torch import nn
from fedml_api.distributed.turboaggregate.utils import transform_list_to_tensor
class TA_Aggregator(object):
def __init__(self, train_global, test_global, all_train_data_num,
train_data_loca... |
d4353d092c21dfbbe8cf9beada10940292e36b8995a40e889cc067ef0a5cbf23 | Python | 6,947 | 180 | #!usr/bin/env python
#coding:utf-8
"""
@author: Haidong Zhang
@contact: haidong_zhang14@yahoo.com
@time: 2021/1/29 13:59
@project: MalariaDetection
@description:
"""
import math
from typing import Union, Callable, Optional
import numpy as np
import keras
from keras.layers import Layer, Add, Activation... |
4bb51659d6e8e5a9922dab9addb186db117edd2462cf67cffe3c737aa3f310ea | Python | 6,952 | 147 | """General-purpose test script for image-to-image translation.
Once you have trained your model with train.py, you can use this script to test the model.
It will load a saved model from --checkpoints_dir and save the results to --results_dir.
It first creates model and dataset given the option. It will hard-code some... |
9064b58a282333c6fd41265c2003b83b1dff5e8bbe7efdcf62d5a5f8be59145c | Python | 6,954 | 207 | from typing import Union, List, Tuple
import eagerpy as ep
def rescale_jax(x: ep.JAXTensor, target_shape: List[int]) -> ep.JAXTensor:
# img must be in channel_last format
# modified according to https://github.com/google/jax/issues/862
import jax.numpy as np
img = x.raw
resize_rates = (target_s... |
c5c8f6707be059796362874e99e3c6d2077e7daa32418f8c14d6d4d4fc90fcb5 | Python | 6,961 | 170 | # Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import torch
from mmdet.core import bbox2result, bbox2roi
from ..builder import HEADS, build_head, build_roi_extractor
from .standard_roi_head import StandardRoIHead
@HEADS.register_module()
class GridRoIHead(StandardRoIHead):
"""Grid roi head fo... |
db315f1911ca595ced4f3814a166f7a30e594ea93682d94eb353e071b37f938b | Python | 6,971 | 201 | # Copyright Universitat Pompeu Fabra 2020-2023 https://www.compscience.org
# Distributed under the MIT License.
# (See accompanying file README.md file or copy at http://opensource.org/licenses/MIT)
from torchmdnet.priors.base import BasePrior
from torchmdnet.models.utils import OptimizedDistance, scatter
import torc... |
a03c2a28390f9c3bcf6f1be2eafe2dae1eec610f8575012eb9e2c64ab583e56a | Python | 6,987 | 168 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 15 22:56:48 2022
@author: tungdang
"""
import argparse
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from tqdm import tqdm
import time
from sklearn.model_selection import train_test_split
from sklearn.... |
2933f16dc8febadf2a73fc2898d9c361cfedbf3983d6b1cdb11128974b017114 | Python | 6,989 | 163 | ############################################
# imports
############################################
import itertools
import random
from math import comb
from typing import cast
import pandas as pd
from oligo_designer_toolsuite._exceptions import DatabaseError
from oligo_designer_toolsuite.database import OligoDataba... |
b8a9f35bb6566dfdf05aeb15603567559f45d69c45d85914ebccbf19ac5150ff | Python | 6,990 | 171 | import sys
sys.path.append('..')
import os
import datetime
import torch
import contextlib
from utils_mixture import *
from layers.BBBLinear import BBBLinear
@contextlib.contextmanager
def print_to_logfile(file):
# capture all outputs to a log file while still printing it
class Logger:
def __init__(s... |
75e12ef85148daedd8aba337d77c4ba3cedd10325c8c3930c3bc8bd52f1f527f | Python | 6,992 | 181 | # Copyright (c) OpenMMLab. All rights reserved.
import copy
import os.path as osp
from collections import defaultdict
import json_tricks as json
import numpy as np
from numpy.testing import assert_array_almost_equal
from mmpose.datasets.pipelines import (CenterSpatialCrop, CropValidClip,
... |
eaa474f8edfb6ee3adc0f109b573d89125937604cd5c83da6d2b4ce08056151e | Python | 6,992 | 172 | """Utility functions that may be used during data processing.
Because many datasets differ slightly, not all utility functions may work with
each dataset. However, the modifications are typically only minor, and thus the
functions provided within this module can be adapted easily.
"""
from .data.dataset import... |
1207d9c699851c84d3ce9b64e79a681c26b15fdd585a5f72644ad49efcaa84d6 | Python | 6,993 | 163 | import logging, time
# import numpy as np
import torch
try:
from fedml_core.trainer.model_trainer import ModelTrainer
except ImportError:
from FedML.fedml_core.trainer.model_trainer import ModelTrainer
from .utils import EvaluationMetricsKeeper, float_to_uint_img
def convert_to_img(A, B, fake_B):
n... |
c00b8ce3a8382d14c599789507e1a34e6485780768459b260d07a490d9d878d9 | Python | 6,997 | 143 | import numpy as np
from typing import List
import cv2
import potrace
from configs import config
from utils.utils import erase_elements, euclidean_distance, isolate_patches, HoughLinesP
from reactiondataextractor.configs import Config, ExtractorConfig
class DiagramVectoriser:
"""Diagram vectorisation class. This... |
70cc23a866fffc174cd042c02dbfa7fe61ea7ae71cbef443548d427370599265 | Python | 6,998 | 235 | """
Misc functions, including distributed helpers.
Mostly copy-paste from torchvision references.
"""
import io
import os
import time
from collections import defaultdict, deque
import datetime
import torch
import torch.distributed as dist
class SmoothedValue(object):
"""Track a series of values and provide acces... |
48b322d6823c007b197261c4615ef772acd8ec43193f5f937a427613d86d6140 | Python | 7,004 | 180 | import argparse
import json
import keyword
import numpy as np
import os
import glob
import importlib
import librosa
import matplotlib.pyplot as plt
import matplotlib
from scipy import signal
import torch
import torch.nn as nn
import sep.helpers.utils as utils
from sep.helpers.eval_utils import si_sdr
from sep.helpers.... |
007c46591e9b3c1d0cf99a714e34159c54375b3d58ec8835cd7ca563054b9623 | Python | 7,012 | 181 | #!usr/bin/env python
#coding:utf-8
"""
@author: Haidong Zhang
@contact: haidong_zhang14@yahoo.com
@time: 2021/1/29 13:59
@project: MalariaDetection
@description:
"""
import math
from typing import Union, Callable, Optional
import numpy as np
import keras
from keras.layers import Layer, Add, Activation... |
034408a15f62b484fbd9fa1e8ced1862ec68ce82af85a745ec98e9b17c0846fe | Python | 7,015 | 203 | # Copyright (c) OpenMMLab. All rights reserved.
from functools import wraps
from queue import Queue
from typing import Any, Dict, List, Optional
from mmcv import is_seq_of
__all__ = ['BufferManager']
def check_buffer_registered(exist=True):
"""A function wrapper to check the buffer existence before it is being ... |
11944672a64950068df5850585f6f52a468ef4b0dacda90a9e0263b01a2cefc9 | Python | 7,022 | 201 | # Copyright (c) OpenMMLab. All rights reserved.
import os.path as osp
import tempfile
import warnings
from collections import OrderedDict
import json_tricks as json
import numpy as np
from mmcv import Config, deprecated_api_warning
from ...builder import DATASETS
from ..base import Kpt2dSviewRgbImgTopDownDataset
@D... |
aaadb130f508c326c0124fcf28f44b33926b509042bddc0e280382f8c2f3dd76 | Python | 7,024 | 148 | import time
from glob import glob
import numpy as np
import os
from run_type import RunType
from predict import predict_accuracy
from sklearn.model_selection import train_test_split
from tensorflow.keras import backend as K
from tensorflow.keras import callbacks
from tensorflow.keras.losses import binary_cross... |
22ba921ed996ee67cc939e87c0901d2660b30ef9d8a35962b2e765aebeb21e00 | Python | 7,028 | 211 |
import os
os.environ['XLA_PYTHON_CLIENT_PREALLOCATE'] = 'false'
from pprint import pprint
import jax
import jax.numpy as jnp
import jax.tree_util as tree
import numpy as np
from functools import partial
import haiku as hk
import optax
from absl import app, flags, logging
from collections import namedtuple
from tqdm i... |
7b632fb56be95d59b4bbfcaeaf4c3a1a62f04873bce863b26662728194fb6099 | Python | 7,031 | 143 | import logging
import traceback
import time
from fedml_api.distributed.asdgan.message_define import MyMessage
from fedml_core.distributed.communication.message import Message
from fedml_core.distributed.server.server_manager import ServerManager
class AsDGanServerManager(ServerManager):
def __init__(self, args, a... |
85402f22cfcecf19e09cd8748377b399dcc2046b5ccd6ef507e5e0e3ea003618 | Python | 7,031 | 135 | """General-purpose training script for image-to-image translation.
This script works for various models (with option '--model': e.g., pix2pix, cyclegan, colorization) and
different datasets (with option '--dataset_mode': e.g., aligned, unaligned, single, colorization).
You need to specify the dataset ('--dataroot'), e... |
4bd8987a141af22f07c590dbfe2aa75823aa6cecd61a34730046505914bd9cf6 | Python | 7,037 | 210 | """
neat implementation of transformers in flax
adapted from here (changed significantly):
https://github.com/satojkovic/vit-jax-flax/blob/main/vit_jax_flax/vit.py
"""
import jax
import jax.numpy as jnp
from flax import linen as nn
import jax.tree_util as tree
from typing import Optional
from attention_module import ... |
ca60c44997edbf7760254ef20b9b222058955ddc90ce3231fc687a25dcd0db3c | Python | 7,049 | 202 | """
Variance partition between interpretable features and SSS representations
on brain responses.
"""
#### ChatGPT was used to assist writing code. The authors reviewed, edited, and take full responsibility for the content.
import os
PODCAST_ROOT = os.environ.get("PODCAST_ROOT", "/engram/naplab/users/rs4613/Podcast")... |
660e6f80ead07e5a3a81c35e277cc95f2f0277cd0e7ff820a08ee920a2c310f0 | Python | 7,051 | 125 | # -*- coding: utf-8 -*-
"""
Created on Wed Jun 9 18:02:59 2021
@author: fhu14
This should take care of loading the data in for the training loop
"""
#%% Imports, definitions
from DataManager import load_combined_fold
from typing import Dict
from DFTBLayer import model_loss_initialization, model_range_correction,\
... |
cf04cbae95570bc3a7786ca1510ff149c8d165ce1021c1130ad2275362503674 | Python | 7,052 | 177 | # Copyright (c) OpenMMLab. All rights reserved.
import copy
import warnings
import torch
import torch.nn as nn
import torch.nn.functional as F
from mmcv import ConfigDict
from mmcv.ops import nms
from ..builder import HEADS
from .guided_anchor_head import GuidedAnchorHead
@HEADS.register_module()
class GARPNHead(Gu... |
86a31fd1771e7db29dded4de7ff2d411156975d751a61fc7940ebc890468056b | Python | 7,054 | 209 | # This file is part of sbi, a toolkit for simulation-based inference. sbi is licensed
# under the Apache License Version 2.0, see <https://www.apache.org/licenses/>
import copy
from abc import ABCMeta, abstractmethod
from typing import Optional, Protocol, Union
import torch
from torch import Tensor, nn
from torch.dis... |
3df95afd2187deba44b4356ce6668625439c09f9d09c83aa639fdc675c92d8e3 | Python | 7,056 | 181 | import os
from glob import glob
import numpy as np
import pyedflib
from preprocess import preprocess_data
from run_type import RunType
"""
@input - Optional args - the number of subjects to use from the dataset (int); the trial type (Executed, Imagined or Combined movements);
the number of chunks t... |
19196f5618f5e73ff4e68f05a87212b8af511dd18d3e60c9d4e2db139780c9cd | Python | 7,057 | 215 | """Offline contracts for genetics; Allen downloads are an opt-in integration test."""
import inspect
import os
from pathlib import Path
import subprocess
import sys
import abagen.images
import nibabel as nib
import numpy as np
import pandas as pd
import pytest
from brainspace.mesh.mesh_creation import build_polydata
... |
6ae5e0b212f9f0abd983dbbff6a5cb7ceab3a8338f73dbec52334d250f9df7f5 | Python | 7,062 | 185 | import typing
from dataclasses import dataclass
from typing import Dict, Optional, Tuple
import numpy as np
from osgeo import gdal, gdal_array, osr
from georeferenced_data import GeoreferencedRaster, RasterScope
from scope_utils import Scope, Extent
from geotransformations import pix_to_geo, geo_to_pix
from models.ab... |
77cf6b96cd7c6be5bad5d82051f2a52a7d4accf5719554e2fabc91963c5faa89 | Python | 7,063 | 195 | import os
import os.path as osp
import platform
import shutil
import sys
import warnings
from setuptools import find_packages, setup
def readme():
with open('README.md', encoding='utf-8') as f:
content = f.read()
return content
version_file = 'mmpose/version.py'
def get_version():
with open(ve... |
ffa3c3d357e32293fc249b28cc7bda1a14c9ba1e23ab365f284e0e4d75561e0c | Python | 7,070 | 206 | """Utilities for BrainStat developers."""
import json
import logging
import logging.config
import shutil
import urllib.request
import warnings
from pathlib import Path
from tempfile import TemporaryDirectory
from typing import Callable
import brainstat
json_file = Path(brainstat.__file__).parent / "data" / "data_urls... |
78c96a4a2d97c10bf29f8ef18b5ec8f41b6a29c4c4772c554411387c3e049e9c | Python | 7,073 | 181 | """make_test_suite.py
This file is part of keras2c
Copyright 2020 Rory Conlin
Licensed under MIT License
https://github.com/f0uriest/keras2c
Generates automatic test suite for converted code
"""
# imports
import numpy as np
from keras2c.io_parsing import get_model_io_names
from keras2c.weights2c import Weights2C
impo... |
94776c9e7103be7dbf4b2057e3f7fbe8dc7207f110f7ee695eba5fec4b2cd087 | Python | 7,075 | 184 | import argparse
import torch
import numpy as np
import pandas as pd
import seaborn as sns
from PIL import Image
import torchvision
from torch.nn import functional as F
import torchvision.transforms as transforms
import matplotlib.pyplot as plt
import data
from main_bayesian import getModel
import config_bayesian as cf... |
b042dac2369cd852f3995782ac3d2236c8052d3304143c65166075f7ee0dda99 | Python | 7,080 | 200 | # Copyright (c) OpenMMLab. All rights reserved.
import os.path as osp
import tempfile
import warnings
from collections import OrderedDict
import numpy as np
from mmcv import Config, deprecated_api_warning
from mmpose.datasets.builder import DATASETS
from ..base import Kpt2dSviewRgbImgTopDownDataset
@DATASETS.regist... |
80bad5e61c21329aa22c06ddff4f9a50200a64ed72d617ab51db8e642c366369 | Python | 7,081 | 176 | # This file is part of sbi, a toolkit for simulation-based inference. sbi is licensed
# under the Apache License Version 2.0, see <https://www.apache.org/licenses/>
from typing import Optional, Union
import torch
from torch import Tensor
from tqdm.auto import tqdm
from sbi.samplers.score.correctors import Corrector,... |
64a61d2e73f3ba3ed82e481220d7047872b36451079f5087815b44e408d8a0b6 | Python | 7,082 | 193 | """
author: mathildelpx
creationTime: 22/02/2022
goal: load calcium imaging data output from suite2p, behavior pre-processed data and compute map of recruitment and
regressor analysis.
"""
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from scipy.stats.mstats import zsco... |
c502ac8c9a268d612c6d4ab8a6a026333f8af839266bd687684e5c50d5b4be32 | Python | 7,090 | 198 | ############################################
# imports
############################################
import os
import shutil
import subprocess
import sys
import tempfile
import unittest
from abc import ABC, abstractmethod
from typing import Any
import yaml
from oligo_designer_toolsuite.config.pipelines.oligo_seq_prob... |
48c4bc030ce2d5ee1d06d78e66ee1de65bad791c9dc1e92f9a5320b8c1b535c8 | Python | 7,094 | 177 | import os.path
import random
import sys
import cv2
import h5py
import numpy as np
import scipy.ndimage as ndimage
from pytictoc import TicToc
import PIL.Image as Image
from data.base_dataset import BaseDataset, get_params, get_transform, get_transform_v2
class Brats4chDataset(BaseDataset):
"""A dataset class for... |
a6eaffe233f32f5ef786dca89af42f1ad0aa6809a38649e3511582e135bdd966 | Python | 7,105 | 303 | import sys
from VCF import VCF
from VCF import VCF_filter
ZYG={'0/1':'HET', '1/1':'HOMO', './.':'UNKNOWN', '0/0':'REF'}
class MANTA (VCF):
def __init__ (self, name):
super (MANTA, self).__init__(name)
def filter_func(self, chrom, beg, end, type, E):
if int(end) - int (beg) < 50: return Tru... |
98600fd7ea6fef2b41e7c5e8c69680251006647a4f6b6d1e2ae70eb251668011 | Python | 7,106 | 185 | """
pretrain_foundation.py
Trains the Universal Foundation Model (MVLM) on the 473,000-interaction
BindingDB master dataset. Evaluates performance using a strict 10%
Cold-Drug (zero-shot) split.
"""
import os
import torch
import warnings
import numpy as np
import pandas as pd
import torch.nn as nn
import torch.nn.f... |
a9925e6a7ae7401bd59da5176593f0add6ca557cf92bc75347fb7ca6d4908838 | Python | 7,108 | 167 | from plotly.subplots import make_subplots
import plotly.express as px
from operator import itemgetter
from app_main.constants import color_types_title, marker_size, font_size
def scatter2d(df1, df2, x, y, color_type, metadata_type, label_1, label_2, size_key='default'):
"""
Plot two 2D plots side by side
... |
ab57c4e94a269b569616d2d2b9890f9ed27b4290f5d29538723fe4208f0d523f | Python | 7,109 | 208 | import math
from typing import Optional, Tuple
import numpy as np
import torch
from torch import Tensor, nn
import torch.nn.functional as F
from torchvision import models
from torchvision import transforms
import torchmetrics
import monai
from monai.networks.nets import AutoEncoder
from monai.networks.blocks impor... |
e6633b8b7327a48e99f3d538bfb8579c0e0f888d7b8c18f388e812ea99bf9af3 | Python | 7,113 | 180 | _base_ = [
'../../../../_base_/default_runtime.py',
'../../../../_base_/datasets/deepfashion2.py'
]
evaluation = dict(interval=10, metric='PCK', save_best='PCK')
optimizer = dict(
type='Adam',
lr=5e-4,
)
optimizer_config = dict(grad_clip=None)
# learning policy
lr_config = dict(
policy='step',
... |
0b8b31a6ae931d6ea72b46ad014b4883e2450055e2a41a21ef1c3ac5c40d970c | Python | 7,116 | 180 | _base_ = [
'../../../../_base_/default_runtime.py',
'../../../../_base_/datasets/deepfashion2.py'
]
evaluation = dict(interval=10, metric='PCK', save_best='PCK')
optimizer = dict(
type='Adam',
lr=5e-4,
)
optimizer_config = dict(grad_clip=None)
# learning policy
lr_config = dict(
policy='step',
... |
d3ad898c98a19cfc0d0b1398094ca12c710c53096705e44faf0980d778c9ed83 | Python | 7,116 | 180 | _base_ = [
'../../../../_base_/default_runtime.py',
'../../../../_base_/datasets/deepfashion2.py'
]
evaluation = dict(interval=10, metric='PCK', save_best='PCK')
optimizer = dict(
type='Adam',
lr=5e-4,
)
optimizer_config = dict(grad_clip=None)
# learning policy
lr_config = dict(
policy='step',
... |
5edbcd7b837ff7377e4a34503118615191af7c274fadfd754420dece240b2b06 | Python | 7,118 | 195 | import numpy as np
from scipy.spatial.distance import euclidean
def batch_trajectory_generator(batch_size=64, seq_len=20, *args, **kwargs):
"""Mini-batch trajectory generator"""
tgen = trajectory_generator(*args, **kwargs)
mb_pos, mb_vel = np.zeros((batch_size, seq_len + 1, 2)), np.zeros(
(batch_s... |
884a62aabf52dc23d7cfb5d27f7e0131c798566728ad9a66eb9cc2880ff4928a | Python | 7,119 | 180 | _base_ = [
'../../../../_base_/default_runtime.py',
'../../../../_base_/datasets/deepfashion2.py'
]
evaluation = dict(interval=10, metric='PCK', save_best='PCK')
optimizer = dict(
type='Adam',
lr=5e-4,
)
optimizer_config = dict(grad_clip=None)
# learning policy
lr_config = dict(
policy='step',
... |
098b951273582710b65f4559b1f51b8729a557f5cfe2f2623d1e4a67179361c2 | Python | 7,122 | 192 | import torch
import torch.nn as nn
import numpy as np
from math import sqrt
from utils.masking import TriangularCausalMask, ProbMask
from reformer_pytorch import LSHSelfAttention
class FullAttention(nn.Module):
def __init__(self, mask_flag=True, factor=5, scale=None, attention_dropout=0.1, output_attention=False... |
b8df37ff29c242bc588347f5ef2a0327e325b4f6568ccc50fe5eb2409b97fd56 | Python | 7,128 | 176 | import argparse
import torch
import os, random
import numpy as np
# from torchvision.utils import save_image
import skimage.morphology as morph
from skimage import measure, io
# from tqdm import tqdm
# import data_loader.data_loaders as module_data
# import loss.loss as module_loss
import metric.metric_nuclei_seg as mo... |
77ad731be30a7efd135398a981962b56ac795b32d058060d2a9779106378f0db | Python | 7,130 | 213 | # Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import pytest
from numpy.testing import assert_array_almost_equal
from mmpose.core import (keypoint_auc, keypoint_epe, keypoint_pck_accuracy,
keypoints_from_heatmaps, keypoints_from_heatmaps3d,
multilab... |
816f85d50b0a90592fe7c4476833d1e9efeb5f483bcfc411b5db37ff84003c7b | Python | 7,130 | 154 | # ----------------------------------------------------------------------- #
# Copyright (c) 2023, UChicago Argonne, LLC. All rights reserved. #
# #
# Software Name: Fast Autonomous Scanning Toolkit (FAST) #
# By: Argonne Na... |
3d51645f1aaafa3b491d87510dd6e0006721e3f47d8e0822c2d4cacea990b019 | Python | 7,134 | 151 | #!/usr/bin/python3
from optparse import OptionParser
import random
import numpy as np
import pandas as pd
import requests
random.seed(8)
from zipfile import ZipFile
import os
import gzip
import shutil
import gdown
from Bio import SeqIO
from tqdm import tqdm
import sys
import subprocess
def find(na... |
28abf0c138011c4d4d576e106186317f598b267701ce6d6cc103d9dba27f49d2 | Python | 7,135 | 196 | # Copyright (c) OpenMMLab. All rights reserved.
import os.path as osp
import tempfile
import warnings
from collections import OrderedDict
import numpy as np
from mmcv import Config, deprecated_api_warning
from mmpose.datasets.builder import DATASETS
from ..base import Kpt2dSviewRgbImgTopDownDataset
@DATASETS.regist... |
9f6a11bc65d20b0d8a137afadf05b5461fc6ccd6baf4b90cf625a58a13193c4f | Python | 7,135 | 167 | import logging
import torch.utils.data as data
import numpy as np
import h5py
import os
from .data_utility import init_transform, count_samples, get_img_list_h5
logging.basicConfig()
logger = logging.getLogger()
logger.setLevel(logging.INFO)
def get_transforms():
transforms_train = ["Windowfilter","Unsqueeze"... |
925e1e9f0d066cbaabcf94bec0690277cedbbf7bd222367cc380034cc63466f9 | Python | 7,137 | 170 | import numpy as np
import nengo
import nengo.spa.action_build
from nengo.spa.action_objects import Symbol, Source, Convolution
from nengo.spa.module import Module
from nengo.utils.compat import iteritems
class Cortical(Module):
"""A SPA module for forming connections between other modules.
Parameters
--... |
6fcb9d6ddeac7dbed43b5981179d034bb72fa486bc570bdcf40e28b7655e72c0 | Python | 7,140 | 200 | # --------------------------------------------------------
# Fast/er R-CNN
# Licensed under The MIT License [see LICENSE for details]
# Written by Bharath Hariharan
# --------------------------------------------------------
import xml.etree.ElementTree as ET
import os
import cPickle
import numpy as np
def ... |
8b0d39c7165b3b2724ab15cf03193d396867e1b468c37a540a6ccc53e9e39b24 | Python | 7,140 | 163 | import tensorflow as tf
import numpy as np
from matplotlib import pyplot as plt
def positional_encoding(pos, d_model):
def get_angles(position, i):
# return shape=[position_num, d_model]
return position / np.power(10000., 2. * (i // 2.) / np.float(d_model))
angle_rates = get_angles... |
d6a4f7afa2c6ad6af4a0cb195fef1bb2cff66b47b7791e5c82f578b9af8695ac | Python | 7,142 | 200 | from typing import Literal
from pydantic import BaseModel, ConfigDict, Field, PositiveInt, model_validator
from typing_extensions import Self
from oligo_designer_toolsuite.config._general_models import (
BlastnHitParameters,
BlastnSearchParameters,
General,
HomopolymericRunThreshold,
TmChemCorrect... |
80d4bede9b62f9b93b8891a453230c37c8b80aa15b1bbe8101dc6c1c76d648fa | Python | 7,147 | 208 | # Copyright (c) OpenMMLab. All rights reserved.
from functools import partial
import numpy as np
import torch
from six.moves import map, zip
from ..mask.structures import BitmapMasks, PolygonMasks
def multi_apply(func, *args, **kwargs):
"""Apply function to a list of arguments.
Note:
This function ... |
645179f412eda378ea8294e4998e78468641e9b04791745a1922e9cd8573bedd | Python | 7,148 | 201 | # Copyright (c) OpenMMLab. All rights reserved.
import os.path as osp
import tempfile
import warnings
from collections import OrderedDict
import numpy as np
from mmcv import Config, deprecated_api_warning
from mmpose.datasets.builder import DATASETS
from ..base import Kpt2dSviewRgbImgTopDownDataset
@DATASETS.regist... |
ef1f29d4be82eed830312e19a75da9dba341b244ed0619fe2ead255ed6001fac | Python | 7,152 | 163 | from pathlib import Path
import itertools
import json
import os
import numpy as np
def save_model_specs(config, modelSettings):
"""
Save the settings of each single model to be tested
:param config:
:param modelSettings:
:return: -
"""
#### Configuration setting from config
runID = 0
... |
58bdbca73311e6d8bd6ad98630b783ef3e552816b6baff47cff33d21b075922f | Python | 7,153 | 179 | import torch
import torch.nn as nn
import numpy as np
from functools import partial
from lib.model_zoo.common.get_model import register
version = '0'
symbol = 'clip'
class AbstractEncoder(nn.Module):
def __init__(self):
super().__init__()
def encode(self, *args, **kwargs):
raise NotImplemente... |
95fcf77ef357cd7f3c21975a519f334254244ef6d0063f0636cf9b11c4937ed3 | Python | 7,155 | 207 | """test_pooling_layers.py
This file is part of the test suite for keras2c
Implements tests for pooling layers
"""
#!/usr/bin/env python3
import unittest
from tensorflow.keras.layers import (
Input, MaxPooling1D, AveragePooling1D, MaxPooling2D, AveragePooling2D,
GlobalAveragePooling1D, GlobalMaxPooling1D, Glob... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.