sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
aa03740aff7f597b2a5dfe9038189cd42f86263bae8bbf1f9136e9f146fa89b6 | Python | 2,335 | 58 | from pathlib import Path
import os
from deep_events.database import extract_yaml
from deep_events.database import ome_to_yaml
from deep_events.database import folder_benedict
FILEPATH = Path(__file__).parents[1]
def test_recursive_folder():
file = FILEPATH / "data/220927_mitotrackergreen_cos7_ZEISS_fl/GFP_1/2... |
f31f705fc0ad102cd1e4dd4e4b033fe724593f9352e638a1773d393107d37852 | Python | 2,335 | 64 | """Regression tests for executed-tool extraction in agent.turn.
Guards against counting a *named non-tool message* (e.g. a named AIMessage or
HumanMessage in a multi-agent flow) as an executed tool.
"""
from langchain_core.messages import AIMessage, HumanMessage, ToolMessage
from chemgraph.agent.turn import _execute... |
a3378531930c91ae285214aeb5ef8eea0f9a8e1b78f8ce9ed88055bd2e62e58d | Python | 2,337 | 65 | import torch
import torch.nn as nn
import torch.nn.functional as F
# 论文题目:PlainUSR: Chasing Faster ConvNet for Efficient Super-Resolution
# 中文题目: PlainUSR: 追求更快的卷积神经网络以实现高效的超分辨率
# 论文链接:https://openaccess.thecvf.com/content/ACCV2024/papers/Wang_PlainUSR_Chasing_Faster_ConvNet_for_Efficient_Super-Resolution_ACCV_2024_... |
485e0368415ab111ecebca61ff305d6d9b5f6fd9178eae65d25d95c101b6f156 | Python | 2,338 | 70 | import argparse
import utils
from model_zoo import DeepSTARR
from dynamic_aug import DynamicAugModel
import keras
from keras.models import load_model
from os.path import join
import numpy as np
import h5py
import gc
import yaml
'''
For OOD sequences (provided in h5 file), use DeepSTARR models to make predictions
'''... |
d2b13b3288099ccbf0d2191f40961171163797e96f551abdb1e384ccc030c2d8 | Python | 2,338 | 67 | import torchvision
import torchvision.transforms as transforms
from torch.utils.data import DataLoader
from analogainas.search_spaces.dataloaders.cutout import Cutout
import importlib.util
pyvww = importlib.util.find_spec("pyvww")
found = pyvww is not None
def load_cifar10(batch_size):
transform_train = transform... |
7b065cf6016dd65176ebee56d48a7ffd50dc98d6b60adaee2fb2136a197c038b | Python | 2,339 | 76 | import re
import shutil
import subprocess
import sys
import tomllib
from pathlib import Path
from typing import Final
import pytest
from ruamel.yaml import YAML
_REPO_ROOT: Final = Path(__file__).parents[1]
@pytest.mark.skipif(sys.platform != "darwin", reason="requires BSD sed")
def test_release_without_version_sug... |
ef778a893a4587627621b7a5f9bbe3172cf434078ad1318e75371444572e857d | Python | 2,339 | 73 | # This file is part of Mooney computational modeling project.
#
# Mooney computational modeling project is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) an... |
31384de245219cd016c447787d337a3882f2c60ed8eeecccf733472b8fb581c5 | Python | 2,340 | 76 | # !/usr/bin/env python
# coding: utf-8
# @Time : 2022/10/28 20:45
# @Author : Z.-H. G.
# @Email_0 : guozhenhao17@mails.ucas.ac.cn
# @Email_1 : guozhenhao@tongji.edu.cn
# @File : integration_metircs.py
# @IDE : PyCharm
import scanpy as sc
import scanpy.external as sce
import scib
import pandas as pd
import os... |
3a1ed95fb8c802d2e78e77731ba98a1b04524a9e89986e95f6857f2fb558255d | Python | 2,340 | 84 | # Copyright (c) 2015 Tobias Neumann, Philipp Rescheneder.
#
# This file is part of Slamdunk.
#
# Slamdunk is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your o... |
4c15af8796b58ba70ecaa73d21b6dbb1f698cbc4780ea47b3e06b7488aef5a59 | Python | 2,340 | 81 | # -*- coding: utf-8 -*-
# python standard library inputs
import os
# external inputs
import numpy as np
import nibabel as nb
from scipy.ndimage.filters import gaussian_filter
def map2stack(file_data, file_grid, sigma, path_output):
"""Map to stack.
This function allows you to sample surface data to a patch... |
f24729cd8ef25f99738fbfe4f22036c1af893f8301e6fc9714355fd6ff0d64bc | Python | 2,340 | 76 | from enum import Enum
from typing import Dict
from brainglobe_atlasapi.list_atlases import get_all_atlases_lastversions
from skimage import filters as filters
def get_available_atlases() -> Dict[str, str]:
"""
Get the available BrainGlobe atlases.
This function fetches the available atlases from the Bra... |
6043592a4a8757628950bfb1d6ef6453c0782b6fff13513029b217f80b94b8aa | Python | 2,341 | 85 | import itertools
import torch
VALID_BASES = ["A", "G", "C", "T"]
UNKNOWN_TOKEN = "[UNKNW]"
MASK_TOKEN = "[MASK]"
PADDING_TOKEN = "[PAD]"
CLASSIFIER_TOKEN = "[CLS]"
REGRESSION_TOKEN = "[REG]"
SEPARATOR_TOKEN = "[SEP]"
SPECIAL_TOKENS = [UNKNOWN_TOKEN, MASK_TOKEN, PADDING_TOKEN, CLASSIFIER_TOKEN, REGRESSION_TOKEN, SEP... |
718a6d29c24c532445f9468a0400bc4ac307ebb975414817ef279ac5027642f4 | Python | 2,341 | 74 |
import numpy as np
import cv2
def blur_detect(image, channel='g', chunk_size=3, method='laplacian', top_svd=30,
outfile=None, show_in_rgb=None, show_in_grey=None):
"""
Calculte blur values with stepwise slide chunks for RGB image
Parameters
------------------------------
image: np.ndarra... |
14aa906d125cbaf1def42e02c209339cc578748c390a72570fe5bda288529c10 | Python | 2,342 | 64 | import user_features as uf
import csv
import time
import pandas as pd
import json
def get_user_vector(user):
user_vector = {
"user_id": uf.get_user_id(user),
"profile_description": uf.has_description(user),
"profile_location": uf.has_location(user),
"profile_url": uf.has_url(user),... |
50ef35802c0d38769c0119bdd0a2bbc29df1a31d45cddd614f0276485ff79a2c | Python | 2,342 | 64 | import user_features as uf
import csv
import time
import pandas as pd
import json
def get_user_vector(user):
user_vector = {
"user_id": uf.get_user_id(user),
"profile_description": uf.has_description(user),
"profile_location": uf.has_location(user),
"profile_url": uf.has_url(user),... |
8c73679f637858e4df83609f13d0b07d5256f412b95d334dcb36aa13de5df535 | Python | 2,342 | 64 | from qtpy.QtCore import Qt, QPointF
from qtpy.QtWidgets import QGraphicsEllipseItem
class DotObject(QGraphicsEllipseItem):
def __init__(self, x, y, r):
super().__init__(0, 0, r, r)
self.size = r
# self.app = app
self.setPos(x-int(r/2), y-int(r/2))
self.setBrush(Qt.blue)
... |
b22e6e1e2058a25d7d8beb330c8a70253d6cc4800b025543f534e9cce166e6f8 | Python | 2,342 | 90 | # -*- coding: utf-8 -*-
# python standard library inputs
import os
import copy
# external inputs
import numpy as np
import nibabel as nb
def get_mean(file_in, path_output, name_output, method="mean"):
"""Get mean.
This function computes the mean image of one or more time series.
Parameters
-------... |
249493a17528e557211d0f1980baa6f67204e2402fe0e63b9ba963a9a5cb8c49 | Python | 2,344 | 64 | from PyQt5.QtCore import Qt, QPointF
from PyQt5.QtWidgets import QGraphicsEllipseItem
class DotObject(QGraphicsEllipseItem):
def __init__(self, x, y, r):
super().__init__(0, 0, r, r)
self.size = r
# self.app = app
self.setPos(x-int(r/2), y-int(r/2))
self.setBrush(Qt.blue)
... |
3854c7480ae0fd6092e7794b28daa919167dda602e0d4ba0f9efd94e5cf9350c | Python | 2,344 | 84 | #save clustering labels in som's hdf5
import sys
import yaml
import os
import numpy as np
import h5py
pathpath,myrun = sys.argv[1:]
#pathpath = 'PATHS/filepaths_carlen.yml'
#myrun = 'runC00dMP3_brain'
nclustvec = np.arange(2,11)
overwrite_cmethod = True
with open(pathpath) as yfile: pathdict = yaml.safe_load(yfile... |
454f8714cfe30b971a4918b27b3b9f2e8efde8ce4fbc8de0970b5fea4bdc3857 | Python | 2,344 | 68 | # flake8: noqa
import inspect
from functools import wraps
from time import perf_counter
DO_TIMING = False
DISPLAY_LESS_PROGRESS = False
timer_dict = {}
counter = 0
def time(f):
@wraps(f)
def wrap(*args, **kw):
if DO_TIMING:
# Run function with timing
ts = perf_counter()
... |
746be243f7a86a620275639eb55a1ae24dcf78b59052414bdfdaba91a3903537 | Python | 2,344 | 68 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Replace the fiber response function in the FRF file.
Use this script when you want to use a fixed response function
and keep the mean b0.
The FRF file is obtained from scil_frf_ssst or scil_frf_msmt in the case
of multi-shell data.
"""
import argparse
import logging... |
cc968e8afb0c897ba2b4cc919716aa08e128efc827502ea81b1b1b3d833402df | Python | 2,344 | 43 | import os
from nipype.interfaces.base import (TraitedSpec, CommandLineInputSpec, CommandLine, File, Str, Directory)
from traits.api import Bool
class AvpSegInputSpec(CommandLineInputSpec):
t1w = File(exists=True, mandatory=True, desc='Input T1-weighted image', argstr='%s', position=0)
synthseg = File(exists=Tr... |
f12cf7ec64d356a8287d200ee4ea2b3480dc73e134d1d4bd33dcbeaf35e6e9be | Python | 2,345 | 67 | # -*- coding: utf-8 -*-
"""
Created on Fri Nov 19 00:54:15 2021
@author: Yoshi
"""
import os
import shutil
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from modulation_index_mapper import *
def modulation_index_histogram(path,excel_writer,indices_set,intensities,intensity_unit,title,canv... |
3e4807d50918973cdfbc6bdf12c1a709e63c6c498420c7fbb0ff09a5444ea721 | Python | 2,346 | 65 | # Copyright (c) DP Technology.
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import math
import torch
import torch.nn.functional as F
from unicore import metrics
from unicore.losses import... |
bf2718e3f77d840cc98743432e7e064051b02aec0ba006b20503d08fe2475169 | Python | 2,346 | 59 | #!/usr/bin/env python
import pdb
import math
import numpy as np
import torch
from torch import nn
from .utils import build_montage, normalize
# GaborLayer and GaborNet from https://github.com/addy1997/mfn-pytorch/blob/main/model/MultiplicativeFilterNetworks.py
class GaborLayer(nn.Module):
def __init__(sel... |
9e0e2f3712c4480562f2917f8f0bce112158517b500f52ecb93b623ee9fad605 | Python | 2,347 | 64 | from pathlib import Path
from typing import Optional
import click
import numpy as np
import skimage
from simple_mri import SimpleMRI, assert_same_space, load_mri, save_mri
from gmri2fem.utils import largest_island
def intracranial_mask(csf_mask: SimpleMRI, segmentation: SimpleMRI):
assert_same_space(csf_mask, s... |
d9a789bf4ef7f442c02630bd827592a61a0d188340ddcc27eee7b08e52ddb691 | Python | 2,347 | 56 | from brainscore_core.supported_data_standards.brainio.assemblies import BehavioralAssembly
from brainscore_vision import data_registry, stimulus_set_registry, load_stimulus_set
from brainscore_core.supported_data_standards.brainio.s3 import load_assembly_from_s3, load_stimulus_set_from_s3
BIBTEX = """@article{rajali... |
f88d5aedc90b0f2edfe0bb236c3bd4b7be98f74b9bfec43fb82dea5f1107cf96 | Python | 2,347 | 59 | import re
import glob
import matplotlib.pyplot as plt
import numpy as np
def remove_slurm_part(text):
pattern = r'slurm-\d+_'
result = re.sub(pattern, '', text)
return result
def extract_losses(log):
pattern = r'\[epoch=(\d+)\] (train|val) rec loss: (\d+\.\d+)'
results = re.findall(p... |
73da1c0d8e6e2ffd6eebd16889f86dbdb92aa342218da6db063b7bc901d59954 | Python | 2,348 | 74 | """
Description:
CLI for variant effect prediction using the Sei deep learning model,
given an input VCF file.
Outputs Sei chromatin profile predictions.
Usage:
1_variant_effect_prediction.py <vcf> <output-dir> [--genome=<hg>] [--cuda]
1_variant_effect_prediction.py -h | --help
Options:
-h --h... |
2669e0ec60abc4f2ac52b123743b7dc637ac6a76d1b077fc277937abf134f8e9 | Python | 2,349 | 92 | import re
import datetime
import calendar
import sys
def get_user_id(user):
return user['id']
def get_longevity(user):
name = sys.argv[2]
if user['created_at'] is None or user['created_at'][-1]=='L':
return 0
if name == 'Twibot-22':
create = user['created_at'].split(' ')[0].split('-')... |
d6736970fcdd2e04b344f8de2e1ba762f90eb57363217fe00ed2b9b3ab6376ca | Python | 2,349 | 72 | # type: ignore
# Ignored mypy pre-commit hook in this file
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup -----------... |
1594c52644a69f2956e9831b84e13fb33f69489e6cd0363a1dac4948b06ad96b | Python | 2,350 | 52 | # Copyright (c) 2022, Kwanhyung Lee, AITRICS. All rights reserved.
#
# Licensed under the MIT License;
# you may not use this file except in compliance with the License.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT ... |
cddea8e9f9580a80f01278dd0dfa067732249e165e0592d34541357824051244 | Python | 2,350 | 87 | import os
import functools
import contextlib
import numpy as np
@contextlib.contextmanager
def chdir(dir):
old = os.getcwd()
os.chdir(dir)
try:
yield
finally:
os.chdir(old)
def once(function):
def wrapper(self):
attr = '_{}_value'.format(function.__name__)
try:
... |
b88e5cc2aceb71ee4459ceb4b27d1c2ccf7b4bf8ee469e53f28cbddeb237fdc0 | Python | 2,351 | 62 | import torch
import os
from models.unet.openaiunet import EncoderUNetModel
import blobfile as bf
import io
from diffusers import DDPMScheduler
import torch.nn.functional as F
class Classifier(EncoderUNetModel):
def __init__(self, linear_start, linear_end, timesteps, ckpt_path=None, *args, **kwargs):
super(... |
c955e895e4dccc3380012c016535f89ba65e66d612115dacdf942aff5ba48c9b | Python | 2,351 | 86 | import torch
from torch_geometric.data import Batch, Data
from torch_geometric.loader import DataLoader
from graphs import chem2dataset
from utils import set_seed
def collate_graphs(samples):
samples = [s for s in samples
if s is not None and hasattr(s, 'y')]
if len(samples) == 0:
... |
fe76b26fa8319982fc4519ae1e55f69ca6d95305385857c60e3e7cfea28fc7ce | Python | 2,351 | 71 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Convert a SH file between the two of the following basis choices:
'descoteaux07', 'descoteaux07_legacy', 'tournier07' or 'tournier07_legacy'.
Using the sh_basis argument, both the input and the output SH bases must be
given, in the order. For more information about the... |
37f9b60bcfcc9a4de6c3b59e1dce03b98026abbbb97df8cc0ed969cc4d7d5c89 | Python | 2,352 | 40 | # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
from __future__ import annotations
import torch
from ultralytics.data.utils import check_det_dataset, convert_ndjson_to_yolo_if_needed
from ultralytics.models.yolo.detect import DetectionValidator
from ultralytics.utils.torch_utils import select_dev... |
be7ddc3ddde46564d9e2aa9f5f1c27fde60929c45b6be52dc9ea0fc914123947 | Python | 2,352 | 61 | from pathlib import Path
import csv
from brainscore_core.supported_data_standards.brainio.stimuli import StimulusSet
from brainscore_core.supported_data_standards.brainio.packaging import package_stimulus_set
'''
dataset Meta Info
- curve length: values from 20-200 in steps of 10
- n_cross: number of times the line... |
f287a2f321bc2bd32a23ebe58c56613c9eb0222f8f7dd1cb1a7c3b3053b8ca4a | Python | 2,352 | 63 | # Copyright (C) 2021-2022 Intel Corporation
# Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
import zipfile
from pathlib import Path
from typing import BinaryIO
from datumaro.components.dataset import Dataset
from datumaro.components.transformer import ItemTransform
from cvat.apps.dataset_manager... |
12f7df6a63cdc8681580dc234a06904a375ee6ee85d03ae47652965633406793 | Python | 2,353 | 75 | # The ImpedanceFitter is a package to fit impedance spectra to
# equivalent-circuit models using open-source software.
#
# Copyright (C) 2018, 2019 Leonard Thiele, leonard.thiele[AT]uni-rostock.de
# Copyright (C) 2018, 2019, 2020 Julius Zimmermann, julius.zimmermann[AT]uni-rostock.de
#
# This program is ... |
2c6466975a63f3a2d0c051a123ffb680513e9b95049b5501a0661196d12f482d | Python | 2,353 | 52 | import os
import shutil
def convert_to_bids(input_dir, output_dir, subject_id, session_id, subject_prefix="AF"):
# 添加前缀
new_subject_id = f"{subject_prefix}{subject_id}"
# Create the BIDS directory structure
bids_subject_dir = os.path.join(output_dir, f"sub-{new_subject_id}", f"ses-{session_id}")
... |
c7c8213ea790be06a2528fe638701de52ed86787e4bbe6616b890af8a57a9b83 | Python | 2,354 | 72 | #cd Desktop/GCN/pygcn/env2/
import os,csv,re
import pandas as pd
import numpy as np
import scanpy as sc
from scipy.sparse import issparse
from anndata import AnnData
import torch
from sklearn.decomposition import PCA
import math
import matplotlib.colors as clr
import matplotlib.pyplot as plt
from models import *
class... |
007e669a566dfc4ee75242e3abed51b0d2dd03e5f0a1fbc7f56053fdfa0df904 | Python | 2,355 | 69 | # fmt: off
# flake8: noqa
import inspect
from functools import wraps
from time import perf_counter
DO_TIMING = False
DISPLAY_LESS_PROGRESS = False
timer_dict = {}
counter = 0
def time(f):
@wraps(f)
def wrap(*args, **kw):
if DO_TIMING:
# Run function with timing
ts = perf_coun... |
bd93db549ca3c348de17776f6ae931aff5b08d861413cb1a649547e2cd204039 | Python | 2,355 | 85 | import os
import numpy as np
import nibabel as nib
from matplotlib import pyplot as plt
from skimage.transform import resize
import os
import numpy as np
import nibabel as nib
from skimage.transform import resize
def normalize(image):
"""Basic min max scaler.
"""
min_ = np.min(image)
max_ = np.max(ima... |
315a135bfc9ba60afdb5eaa6f4fb357993ca391913dd054a640cd6de070262b2 | Python | 2,356 | 65 | from brainscore_vision.model_helpers.check_submission import check_models
import functools
import os
from urllib.request import urlretrieve
import torchvision.models
from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper
from brainscore_vision.model_helpers.activations.pytorch import load_prepro... |
38b0a93b695a5b1ec12d788030865cb0102e1d0c455d6589202efbf992bf353b | Python | 2,356 | 65 | from brainscore_vision.model_helpers.check_submission import check_models
import functools
import os
from urllib.request import urlretrieve
import torchvision.models
from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper
from brainscore_vision.model_helpers.activations.pytorch import load_prepro... |
d85476d3941e725bbee045d5738f39c971a33c6c56a562f63cd86163f04d4f0e | Python | 2,356 | 65 | from brainscore_vision.model_helpers.check_submission import check_models
import functools
import os
from urllib.request import urlretrieve
import torchvision.models
from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper
from brainscore_vision.model_helpers.activations.pytorch import load_prepro... |
50d7203ad5528939a9d18a63e24dae82886b52a841df10923a2d303d8e3fbefd | Python | 2,357 | 73 | #!/usr/bin/python
#
## @file
#
# A standalone script for determining the conversion between
# QPD offset and stage z position. Saves the corrected offset
# (in nm) for each frame of the movie.
#
# Hazen 10/14
#
import matplotlib
import matplotlib.pyplot as pyplot
import numpy
import sys
if (len(sys.argv)!=3):
pri... |
a062bf563c4bad5aec04e8db270510cd015e48c798504cb74ce53c7e63328603 | Python | 2,358 | 74 | # -*- coding: utf-8 -*-
# external inputs
import numpy as np
from numpy.linalg import norm
from nibabel.freesurfer.io import write_morph_data, read_geometry
def calculate_area(filename_surf, filename_area=""):
"""Calculate area.
The function calculates vertex-wise surface area. The code is taken from the
... |
f5a3a2e5a1811730a4936ae469d122ae1a76f87a01f0f0d15f0ab43ea3f76920 | Python | 2,358 | 71 | import numpy as np
from typing import Literal
from argclz import AbstractParser, argument, int_tuple_type, union_type
from neuralib.plot import plot_figure
from neuralib.suite2p import dff_signal, Suite2PResult, sync_s2p_rigevent
from rscvp.util.cli import StimpyOptions, Suite2pOptions
class RawTraceOptions(Abstract... |
73f4210009db99a23253d4f38caa46bcae1f3def3fcaa16ea223fc555a3d0c00 | Python | 2,359 | 72 | from torch.utils.data import DataLoader
from geoseg.losses import *
from geoseg.datasets.potsdam_dataset import *
from geoseg.models.UNetFormer import UNetFormer
from catalyst.contrib.nn import Lookahead
from catalyst import utils
# training hparam
max_epoch = 45
ignore_index = len(CLASSES)
train_batch_size = 16
val_b... |
38a2350e7e99c47e2bf352ce97feab1cd46b04e20f3913a717c4fd2405b50884 | Python | 2,360 | 82 | """
utils.losses
────────────
自定义损失函数集合(目前仅包含多标签 Focal Loss)。
Focal Loss (Lin et al. ICCV 2017) 能在类别不平衡场景下
专注 Hard 样本,提高少数类召回率。
公式:
FL(p_t) = - α · (1 - p_t)^γ · log(p_t)
其中
p_t = p (y = 1)
p_t = 1 - p (y = 0)
"""
from __future__ import annotations
import torch
import torch.nn as nn
import torch.nn.... |
cb402b20a8a2c04462b2e06e91dfa509064258c2ad122f056db32723873c3d3b | Python | 2,360 | 77 | """
This module implements linear subspace methods
Author:
Zhengguo Tan <zhengguo.tan@gmail.com>
"""
import torch
from torch import Tensor
from torch.linalg import norm, svd
# from torch.nn import functional as F
def get_relative_error(reco_sig, orig_sig):
return norm(orig_sig - reco_sig).item() \
... |
4b2b77223d919219d2e0d2109058c006ae133a15223c002109aa70efa814f27d | Python | 2,361 | 66 | import copy
import importlib
import six
def get_class(str_or_class, default_mod=None):
if isinstance(str_or_class, six.string_types):
parts = str_or_class.split(".")
mod_name = ".".join(parts[:-1])
class_name = parts[-1]
if mod_name:
mod = importlib.import_module(mod_na... |
6234c685d4e765602d3e3cda397eba8f473725b818a73b9d387ccb3e18ae0112 | Python | 2,361 | 67 | from typing import Literal
import pytest
import torch
from hypothesis import given, settings
from hypothesis.strategies import integers, sampled_from
from torch import nn
from eir.models.layers.lcl_layers import LCL, LCLResidualBlock
from eir.models.layers.projection_layers import get_1d_projection_layer
def test_g... |
8db73dff350fe8698816dc649240db200bf1bc81f520d41026504ebb545c6529 | Python | 2,361 | 75 | #!/usr/bin/python3
#
import os
import sys
import argparse
import numpy as np
from sklearn.neighbors import NearestNeighbors
from uac import utils
# Create the parser
my_parser = argparse.ArgumentParser(description="Calculating PV nodes")
# Add the arguments
my_parser.add_argument("target_path", metavar="path", type=... |
c24781d3b3a7e04b7bdaeb451d1c1b771aa3f27cec274328b377c93bebc3f07e | Python | 2,361 | 67 | import torch
from torch import nn, Tensor
import numpy as np
class RobustCrossEntropyLoss(nn.CrossEntropyLoss):
"""
this is just a compatibility layer because my target tensor is float and has an extra dimension
input must be logits, not probabilities!
"""
def forward(self, input: Tensor, target:... |
ed61c95d2badba5e12874f563788a4510a09271a8de1ec73581fd6bda41bdf44 | Python | 2,361 | 76 | #!/usr/bin/env python
import pdb
import math
import numpy as np
import torch
from torch import nn
class GaussLayer(nn.Module):
'''
Drop in replacement for SineLayer but with Gaussian non linearity
'''
def __init__(self, in_features, out_features, bias=True,
is_first=False, ome... |
f67f0ba518301bd17192ef63aa4061793edfc86a5b04dfda1675b3a4c7304813 | Python | 2,361 | 56 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import tempfile
from scilpy import SCILPY_HOME
from scilpy.io.fetcher import fetch_data, get_testing_files_dict
# If they already exist, this only takes 5 seconds (check md5sum)
fetch_data(get_testing_files_dict(), keys=['commit_amico.zip',
... |
93cc7757321bc71274d9b3a5ecbd639b5e6eeb6aa3e8bc34dd1872cacba17e45 | Python | 2,362 | 75 | #!/usr/bin/env python
from __future__ import print_function
from logging import info
from keras.models import Model
from keras.layers import Input, Embedding, merge, Flatten, Dense
from keras.layers import Dropout
from ltlib import filelog
from ltlib import conlldata
from ltlib import viterbi
from ltlib.features i... |
16defe43273345bfeafd224158debac80dbd073fd8eea77db181b2bcdcb3a2c2 | Python | 2,363 | 77 | """Shared fixtures.
The mini-CCF fixtures build a miniature but structurally faithful atlas into a
temporary directory, so the projector and boundary classes can be constructed
through their real public interface with no large data files and no mocking.
See ``tests/mini_ccf.py`` for the format and the reasoning.
The ... |
30763100b958478b49f42e35fa76bcd69d49492d5f42080b2f42f8a0b406f08e | Python | 2,364 | 65 | from brainscore_vision.model_helpers.check_submission import check_models
import functools
import os
from urllib.request import urlretrieve
import torchvision.models
from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper
from brainscore_vision.model_helpers.activations.pytorch import load_prepro... |
450ccbe54fb69e0e984bf7c0134fc1d5848f617e339d4b6cee6e7f0b5d62acdb | Python | 2,364 | 65 | from brainscore_vision.model_helpers.check_submission import check_models
import functools
import os
from urllib.request import urlretrieve
import torchvision.models
from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper
from brainscore_vision.model_helpers.activations.pytorch import load_prepro... |
4807955a4895189c02b7f3698f9d6e33641097c49f24111637c785806137610f | Python | 2,364 | 65 | from brainscore_vision.model_helpers.check_submission import check_models
import functools
import os
from urllib.request import urlretrieve
import torchvision.models
from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper
from brainscore_vision.model_helpers.activations.pytorch import load_prepro... |
64fddd40388e4da9a69e12a61270e4039a49d1872af8975df7d6d4c0ae559a2f | Python | 2,364 | 65 | from brainscore_vision.model_helpers.check_submission import check_models
import functools
import os
from urllib.request import urlretrieve
import torchvision.models
from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper
from brainscore_vision.model_helpers.activations.pytorch import load_prepro... |
80c4e1a1a3706515d99c85b9f70da41ed7fb19daeb00154abf6dd7134abfcecb | Python | 2,364 | 65 | from brainscore_vision.model_helpers.check_submission import check_models
import functools
import os
from urllib.request import urlretrieve
import torchvision.models
from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper
from brainscore_vision.model_helpers.activations.pytorch import load_prepro... |
8f9051d9e591c99c89cb36d7e0f82519937c203c4aa8abd76410e140523482aa | Python | 2,364 | 65 | from brainscore_vision.model_helpers.check_submission import check_models
import functools
import os
from urllib.request import urlretrieve
import torchvision.models
from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper
from brainscore_vision.model_helpers.activations.pytorch import load_prepro... |
a1a2a4a3a240eb846fddc9eb1fa7b1659149a4fdbd89c64bc15fa4642d101b21 | Python | 2,364 | 65 | from brainscore_vision.model_helpers.check_submission import check_models
import functools
import os
from urllib.request import urlretrieve
import torchvision.models
from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper
from brainscore_vision.model_helpers.activations.pytorch import load_prepro... |
b4b32e3618e62cc46e9b5c8da3863d1a56dc34305c7fb86ea94cc6c2bca940ed | Python | 2,364 | 65 | from brainscore_vision.model_helpers.check_submission import check_models
import functools
import os
from urllib.request import urlretrieve
import torchvision.models
from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper
from brainscore_vision.model_helpers.activations.pytorch import load_prepro... |
b68aabb2069fef34bd11d618fa41e4e5d0b1b8ae1a0806d0646b6a5e6f863c30 | Python | 2,364 | 65 | from brainscore_vision.model_helpers.check_submission import check_models
import functools
import os
from urllib.request import urlretrieve
import torchvision.models
from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper
from brainscore_vision.model_helpers.activations.pytorch import load_prepro... |
e67fdb5cf8668c65a3b52c23e5c3f99c27ea26143c5278d0b922ab812ea14ea6 | Python | 2,364 | 65 | from brainscore_vision.model_helpers.check_submission import check_models
import functools
import os
from urllib.request import urlretrieve
import torchvision.models
from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper
from brainscore_vision.model_helpers.activations.pytorch import load_prepro... |
e6b89dd36be3cba49ad819b35bd5ef36a387819e25d5a2304bfcac95bf5a7fc5 | Python | 2,364 | 65 | from brainscore_vision.model_helpers.check_submission import check_models
import functools
import os
from urllib.request import urlretrieve
import torchvision.models
from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper
from brainscore_vision.model_helpers.activations.pytorch import load_prepro... |
f891b36621b7ab1d040bbf1491b3b4fd8cb49bdb1e28f8b2492fbe05f4f0aa03 | Python | 2,364 | 65 | from brainscore_vision.model_helpers.check_submission import check_models
import functools
import os
from urllib.request import urlretrieve
import torchvision.models
from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper
from brainscore_vision.model_helpers.activations.pytorch import load_prepro... |
b04b6d97de6a738002b9559ccda4e1fed286eb0aa647f1afaa57344007956c11 | Python | 2,365 | 62 | import user_features as uf
import csv
import time
import pandas as pd
import json
def get_user_vector(user):
user_vector = {
"id": uf.get_user_id(user),
"profile_description": uf.has_description(user),
"profile_location": uf.has_location(user),
"profile_url": uf.has_url(user),
... |
ebf0ee0cd241438af97f4b27f2f269890be84a6844a35a68af375737e2eb3cdd | Python | 2,365 | 57 | import numpy as np
from pytest import approx
from brainscore_core.supported_data_standards.brainio.assemblies import BehavioralAssembly
from brainscore_vision import load_metric
def test_score():
assembly = _make_data()
metric = load_metric('accuracy_distance')
score = metric(assembly.sel(subject='A'), a... |
95ffb4662e5725b1d8885faae10574dfca021754858039e112888175ac376f69 | Python | 2,366 | 67 | import functools
from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper
from brainscore_vision.model_helpers.check_submission import check_models
from brainscore_vision.model_helpers.activations.pytorch import load_preprocess_images
from brainscore_core.supported_data_standards.brainio.s3 import... |
be3bba777efd90f54849e9aa6e49583418403aba78db93e240e11110d09a7fc5 | Python | 2,366 | 75 | import os
import pytest
import tempfile
from scilpy import SCILPY_HOME
from scilpy.io.fetcher import fetch_data, get_testing_files_dict
# If they already exist, this only takes 5 seconds (check md5sum)
fetch_data(get_testing_files_dict(), keys=['tracking.zip'])
tmp_dir = tempfile.TemporaryDirectory()
@pytest.mark.m... |
80f623bec74ee7d9ddc606b6bb390704df34fe736c6f5a0d020213db4f5ab277 | Python | 2,367 | 61 | from euler_gpu.gncc import batched_calculate_gncc
from euler_gpu.transform import transform_image
import torch
def grid_search(memory_dict):
"""
Compute GNCC values for all possible combinations of dx, dy, and theta in batches.
Args:
- memory_dict: dictionary of preallocated tensors containing input ... |
98a7b0dd51ff953959c76500dd76f8f804c9661e1fbc9e0c7f27e53c8abfee2e | Python | 2,367 | 77 | import json as _json
import logging as _logging
import os as _os
from pathlib import Path as _Path
from urllib.parse import urljoin as _urljoin
from importlib.metadata import version as _version
__all__ = [
"cache_root",
"cache_data_root",
"cache_model_root",
"remote_root",
"remote_data_root",
... |
e7002787f59bc47414050d8f2691a73bfddcd1897c61c011228dd5e5db050ad9 | Python | 2,367 | 70 | import scanpy as sc
class CellChat:
def __init__(self):
# set up to run the R code
try:
from rpy2 import robjects
from rpy2.robjects.packages import importr
import anndata2ri
except ImportError:
raise ImportError(
"Optional de... |
3835ee217564ea1defc642c066e9940eb32d1c1ba784519c79e5ec144a2c433d | Python | 2,368 | 72 | """Bayesian Optimizer."""
import numpy as np
class BOptimizer:
def __init__(self, max_iter):
self.max_iter = max_iter
# surrogate or approximation for the objective function
def surrogate(self, model, X):
# catch any warning generated when making a prediction
return model.predict(X... |
38fd5483e76ac31131831e65e3db27d5c44f0e3037598423aa73714756ebea74 | Python | 2,368 | 76 | # This file is part of connectome-manipulator.
#
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2024 Blue Brain Project/EPFL
"""Main CLI entry point for parallel processing"""
import logging
import os
import resource
import socket
import dask
from dask_mpi import initialize
from .cli import app, manipulate_c... |
73d6249ed8ad071150606978ae3e7dfecbd45bfafdadb623eeb2c0eea6ae3eb9 | Python | 2,368 | 65 | from brainscore_vision.model_helpers.check_submission import check_models
import functools
import os
from urllib.request import urlretrieve
import torchvision.models
from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper
from brainscore_vision.model_helpers.activations.pytorch import load_prepro... |
9b6aa9d6949317f578f12b99896da51a304352b16bb0d504afe5667624fdb053 | Python | 2,368 | 65 | from brainscore_vision.model_helpers.check_submission import check_models
import functools
import os
from urllib.request import urlretrieve
import torchvision.models
from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper
from brainscore_vision.model_helpers.activations.pytorch import load_prepro... |
b1b3a747a5ffedcadeddcc9154917f2f58371304e2cdf42a340f1291ba7f8268 | Python | 2,368 | 60 | from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper
from brainscore_vision.model_helpers.activations.pytorch import load_images, load_preprocess_images
from brainscore_vision.model_helpers.check_submission import check_models
import ssl
from transformers import MobileNetV2ForImageClassificati... |
b8c01f5a6163cdaecbcdf2c6dac4ee8a17f36ca1393b9b832459b0a11e6ddf2d | Python | 2,368 | 65 | from brainscore_vision.model_helpers.check_submission import check_models
import functools
import os
from urllib.request import urlretrieve
import torchvision.models
from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper
from brainscore_vision.model_helpers.activations.pytorch import load_prepro... |
bb921f0a95856856eefc51948e80d31a6fb6865e4be427dce07ff0177d275e59 | Python | 2,368 | 65 | from brainscore_vision.model_helpers.check_submission import check_models
import functools
import os
from urllib.request import urlretrieve
import torchvision.models
from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper
from brainscore_vision.model_helpers.activations.pytorch import load_prepro... |
38e97b3d06745624e6add4465d56265a00c7521ef55ba191fa1b866a323f0d50 | Python | 2,370 | 50 | import nighres
import os
import nibabel
import numpy
import glob
import scipy.ndimage
indir = '/home/pilou/Projects/Cerebellum/Cerebellar-segmentation-ABC/sereno/topology/'
prevdir = '/home/pilou/Projects/Cerebellum/Cerebellar-segmentation-ABC/sereno/tissues/'
outdir = '/home/pilou/Projects/Cerebellum/Cerebellar-segme... |
70834ca61f8a1d59963de41c36f02e2852819a235de8f009cbd900ff7aace2b5 | Python | 2,370 | 61 | import numpy as np
import torch
import torchio
from torchio.transforms import Transform
class SignalCuration(Transform):
def __init__(self, qmri_application, **kwargs):
self.qmri_application = qmri_application
super().__init__(**kwargs)
def apply_transform(self, subject):
"""
... |
7cdf0acdd52399c4552dc5c29afe2d52183725ac9fd7df32d7a1a6e53cba25ee | Python | 2,370 | 90 | #!/usr/bin/env python3
import arbor as A
from arbor import units as U
import pandas
import seaborn
import sys
try:
from bluepyopt import ephys
except ImportError:
print("Please install bluepyopt to run this example.")
exit(-42)
# (1) Read the cell JSON description referencing morphology, label dictionary... |
cc38c87dac524a53028e36be011495a56243f49bdf0e3c8cb4ccc74ae1ae4670 | Python | 2,370 | 65 | from brainscore_vision.model_helpers.check_submission import check_models
import functools
import os
from urllib.request import urlretrieve
import torchvision.models
from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper
from brainscore_vision.model_helpers.activations.pytorch import load_prepro... |
f4b0a334a12b8a11acb46f6f4ad3bfb50c5ec24710317dda7e8630288edcb1c2 | Python | 2,370 | 75 | #!/usr/bin/env python3
import shlex
import subprocess
from pathlib import Path
from typing import Optional
import click
@click.command()
@click.option("-t1", type=Path, required=True)
@click.option("-o", "output", type=Path, required=True)
@click.option("-l", "license", type=Path, required=True)
@click.option("--fl... |
f59c65b2b35f73d7775306fe6fb159e43646ba64b4705f276e0aac88b47f3e4d | Python | 2,370 | 65 | from brainscore_vision.model_helpers.check_submission import check_models
import functools
import os
from urllib.request import urlretrieve
import torchvision.models
from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper
from brainscore_vision.model_helpers.activations.pytorch import load_prepro... |
153ddc523374c70832146df0f7f20c85f43af18a2db471fce2f9e0bdf81c2523 | Python | 2,371 | 61 | import functools
from brainscore_vision.model_helpers.activations.pytorch import load_preprocess_images
from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper
from brainscore_vision.model_helpers.check_submission import check_models
from types import MethodType
from transformers import AutoModel... |
a65d20e25ba1a46d9b2ec347c3805c8f99aa0e7e0e7962d133a90397b31b6f07 | Python | 2,371 | 61 | """Jieba command line interface."""
import sys
import jieba
from argparse import ArgumentParser
from ._compat import *
parser = ArgumentParser(usage="%s -m jieba [options] filename" % sys.executable, description="Jieba command line interface.", epilog="If no filename specified, use STDIN instead.")
parser.add_argument... |
a8f422e73bd3c801da1f8a72aae4537b3ab7e247a0b4327b89f6fc8e7aca113e | Python | 2,371 | 60 | from brainscore_vision.model_helpers.check_submission import check_models
import functools
from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper
from brainscore_vision.model_helpers.activations.pytorch import load_preprocess_images
import torch
import numpy as np
from brainscore_vision.model_he... |
290a69e41d6a92e99b2687190c9011104d07d5ed49fe9ebb434ebbb78b0ee2eb | Python | 2,372 | 65 | from brainscore_vision.model_helpers.check_submission import check_models
import functools
import os
from urllib.request import urlretrieve
import torchvision.models
from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper
from brainscore_vision.model_helpers.activations.pytorch import load_prepro... |
d6c9858a89ee385fef21278674944ce4dc556f20f1dfab8feb8354d5d3c7a7a6 | Python | 2,372 | 65 | from brainscore_vision.model_helpers.check_submission import check_models
import functools
import os
from urllib.request import urlretrieve
import torchvision.models
from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper
from brainscore_vision.model_helpers.activations.pytorch import load_prepro... |
0340d88c50bede9def9f8ddc9c5d77d99f22b4532aa0f66a30b752e3d6486c0b | Python | 2,373 | 69 | # TODO add typing and docs
from abc import abstractmethod, ABC
from pathlib import Path
from typing import Union
from auxiliary.io import read_image, write_image
class BrainExtractor(ABC):
@abstractmethod
def extract(
self,
input_image_path: Union[str, Path],
masked_image_path: Union[... |
ddd22a1b43a3eee721d59b4b5bdbab372a028d22c218e1e40cae8f901b32ecef | Python | 2,373 | 63 | import user_features as uf
import csv
import time
import pandas as pd
import json
def get_user_vector(user):
user_vector = {
"user_id": uf.get_user_id(user),
"profile_description": uf.has_description(user),
"profile_location": uf.has_location(user),
"profile_url": uf.has_url(user),... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.