sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
2339095770e0e774e4ccb18b738d1b6ab3c28c2da70342573fc5bbdc0e181958 | Python | 4,735 | 88 | #!/usr/bin/env python3
import argparse
import sys
import subprocess
import os
import pandas as pd
from datetime import datetime
def shapeit(vcf, pir, prefix, seed=1, num_threads=1, start=None, end=None, sex=None, force=True):
"""
Wrapper for SHAPEIT
start, end: limit to this interval if provided
sex: ... |
bed2a5a51eb1ddadf991b7308f8aa998954917851d19cffd6a3bd6703b1b1cb6 | Python | 4,736 | 100 | #!/usr/bin/env python
"""
evaluate.py
──────────────────────────────────────────────────────────
1. 读取模型权重 (--ckpt)
2. 读取温度标定文件 (--temp)
3. 读取逐标签阈值文件 (--thr)
4. 在测试集 (--csv-test) 上计算多标签指标并保存 JSON
"""
from __future__ import annotations
import argparse, json, numpy as np, torch
from pathlib import Path
from torch.utils.d... |
8686c39628fb10fda8b5f6a8642ec83ecf70935f0e4af245b7f8028f25ddedf2 | Python | 4,737 | 124 | # Copyright 2024 Google LLC
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... |
cc78233765310df94da293ae85ea1cff8015eb4187fbb6fb23ca4e6803433dbe | Python | 4,737 | 93 | import nighres
import os
import nibabel
import numpy
import glob
inpath = '/home/public/InSitu/Processed/insitu_03_152017_female_75/release/'
outdir = '/home/pilou/Projects/Cerebellum/Cerebellar-segmentation-ABC/ahead2/coreg/'
bf_img = inpath+'Ahead_brain_152017_blockface-image.nii.gz'
thio_img = inpath+'Ahead_brain... |
03cd249f978ca4241e0e7ccfa114a5c87c16e9630df3ed9a480d071f2ca1e95b | Python | 4,739 | 92 | import json
from chemgraph.schemas.agent_response import ResponseFormatter
_ASK_HUMAN_PROMPT_BLOCK = """\
7. **Use the `ask_human` tool** in the following situations instead of guessing or failing silently:
- A required input is missing and the selected tool's schema provides no default, or a user-supplied value i... |
63f7f49ed91c3cad3318c7dfc8a71a18232ebf06d5748787a1f222d12897b254 | Python | 4,739 | 148 | """ general utility functions used throughput codebase """
import os
from os.path import join, isfile, isdir, basename
import numpy as np
import pandas as pd
import constants
import encode
def mkdir(d):
""" creates given dir if it does not already exist """
if not isdir(d):
os.makedirs(d)
def load... |
00489f5b258e6b54c082581200d6c9b964833fd29311430f3681b0da2e30d3ae | Python | 4,742 | 110 | import functools
import numpy as np
import torch
from transformers import AutoModelForImageSegmentation
from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper
from PIL import Image
import torch.nn.functional as F
from brainscore_vision.model_helpers.check_submission import check_models
class br... |
8974462a736bb8ea18e2ca4730031e15c6122b17ad3f354baaaef1556df97800 | Python | 4,742 | 148 | from preprocess import get_directdata, text_feature
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import accuracy_score, f1_score, recall_score, precision_score,roc_auc_score
import numpy as np
from sklearn.preprocessing import StandardScaler
from sklearn.svm import SVC, LinearSVC
import sys
... |
9cb8e3f4f942ced1eee36de392583842a817b9bc93a016afdc02cd6dce0b0cb4 | Python | 4,742 | 115 | # Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
"""Read a task's annotations, edit them, and write the edit back: move every
object from one label to another (--relabel) or delete every object with a
given label (--delete-label).
Steps:
1. Retrieve the task and map its label names to ids.
2. ... |
159edbd09ff30c1cf321224d4288c68087c71f81361f11b988a3dd0b70e9b211 | Python | 4,743 | 130 | #!/usr/bin/env python
import pdb
import math
import numpy as np
import torch
from torch import nn
from .utils import build_montage, normalize
class ReLULayer(nn.Module):
'''
Drop in replacement for SineLayer but with ReLU non linearity
'''
def __init__(self, in_features, out_features, bias=... |
10d7ee862ba56312e7db48efcaabec1967c700e864d9d246b01307e49b108f97 | Python | 4,744 | 94 | """Bar plot and significance test of en vs zh prediction accuracy.
Figure 2B.
"""
import matplotlib.pyplot as plt
import numpy as np
import os
from collections import defaultdict
from matplotlib.lines import Line2D
from matplotlib.patches import Patch
from utils import (
color_en,
color_zh,
get_voxels_fo... |
16f56bbbde4c4c657161e1ba147024583ba00d1730c4242038c525e7457efdbe | Python | 4,744 | 163 | from __future__ import annotations
import io
import sys
import typing
import pathlib
import argparse
import threading
import subprocess
from thalamus.thalamus_pb2 import StorageRecord, Image
from thalamus.record_reader2 import RecordReader
EXECUTABLE_EXTENSION = '.exe' if sys.platform == 'win32' else ''
FRAMERATES ... |
195f98fa5c82dccf57feb0086e826dc8409d671c23581e3dafa75ecc9ae0f203 | Python | 4,744 | 127 | # Copyright (C) 2021-2022 Intel Corporation
#
# SPDX-License-Identifier: MIT
import argparse
import logging
import os
from glob import glob
import numpy as np
from PIL import Image
from pydicom import dcmread
from pydicom.pixel_data_handlers.util import convert_color_space
from tqdm import tqdm
# Script configurati... |
a86aca27dba88e5f45015b1778aaca1daf66a0fff0219442b73309a51933c817 | Python | 4,744 | 122 | import numpy as np
import tensorflow as tf
class LogImages(tf.keras.callbacks.Callback):
def __init__(self, log_dir, image_generator, val_generator, freq=1, overlay_alpha=0.5, nrows=3, ncols=10, downscale=2):
super().__init__()
self.log_dir = str(log_dir)
self.image_generator = image_genera... |
b72962359259270933b392de0f2438424430e5920759635d0ea555ea0d8895fb | Python | 4,744 | 144 | import torch
import torch.nn.functional as F
def get_support_matrix(pcloud1, pcloud2, scale_factor=2.0):
pairwise_dist1 = torch.cdist(pcloud1, pcloud1, p=2)
pairwise_dist2 = torch.cdist(pcloud2, pcloud2, p=2)
# Compute the mean distance as the global threshold
global_thresh1 = pairwise_dist1.mean(di... |
fc3f639c9ea104f1c79a56ce9b8737fed467e5edf411433c16fd9c9c9487e8c1 | Python | 4,744 | 128 | # Copyright 2024 Google LLC
# 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
# https://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, sof... |
2d3c29364ae938c9af481389cf3b89de7d171e236d480a1319e7c694dc24c26f | Python | 4,745 | 134 |
import torch
import torch.nn as nn
import pytorch_lightning as pl
class CNNDoubleResidual(pl.LightningModule):
"""
Residual 'double' CNN as described by Hannun et al. converting a multi channel input to some flat output dimension
"""
def __init__(
self,
num_layers: int = ... |
3c2bd888c1bc33f234f4b4b374fc24acd966bde7248d95c78bade79da6809514 | Python | 4,745 | 132 | # 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.
from functools import lru_cache
import numpy as np
import torch
from unicore.data import Dictionary, data_util... |
4b2ce014aa4a607860c027cee3223924287c539769c11f0bca48963a265ab01e | Python | 4,745 | 153 |
######################################################
## Template script to train a MOFA+ model in Python ##
######################################################
from mofapy2.run.entry_point import entry_point
import pandas as pd
import io
import requests # to download the online data
###############
## Load data... |
5ee08e2e958553d1bee01ec6ac2994134313dffd530824caf576238b899c72e3 | Python | 4,745 | 131 | """
Train LightGBM classifier with 5-fold cross-validation.
This script performs the complete training and evaluation pipeline:
1. Load embeddings from HGNN
2. Prepare training data (positive + negative samples)
3. Train LightGBM with 5-fold cross-validation
4. Compute comprehensive metrics
5. Save results and trained... |
ea3960e89bab96b1aea30d6410ce16a9d775da350ccf1eb0f54fccda50646332 | Python | 4,745 | 301 | import numpy as np
F = 96485.3329
R = 8.314462618
T_STD = 298.15
P_STD = 101325.0
N_A = 6.02214076e23
class PEMFCParams:
E0_STANDARD = 1.229
n_electrons = 2
dE0_dT = -0.00085
alpha_cathode = 0.5
alpha_anode = 0.5
i0_cath... |
5c534e75fabb2ece94df929e6113a5b8280ce12c3f5907493221c3c56ac56bfc | Python | 4,746 | 122 | #!/usr/bin/env python
"""
10-Fold CV + 保存每折 y_true / y_prob
支持 FocalLoss 与可选 Classifier-Chain Head (--use_cc)
"""
from __future__ import annotations
import argparse, json
from pathlib import Path
import numpy as np
import pandas as pd
import torch
from iterstrat.ml_stratifiers import MultilabelStratifiedKFold
from ... |
d6e864fba9ec6e4aecd4ac946085403b6d596fa3d4c595e76653481dae115013 | Python | 4,748 | 116 | import unittest
from unittest.mock import MagicMock, patch
from pathlib import Path
from brainles_preprocessing.transform import Transform
from brainles_preprocessing.registration import ANTsRegistrator
from brainles_preprocessing.registration.registrator import Registrator
class TestTransform(unittest.TestCase):
... |
97224b3613c2a096530e3500b0ca68ee83756e32929fa0a4739b5232d1129351 | Python | 4,749 | 124 | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch_geometric.nn import GCNConv, GATConv, SAGEConv
class HierarchicalGNN(nn.Module):
def __init__(self, input_dim=1280, output_dim=1024, seq_len=41):
super().__init__()
self.seq_len = seq_len
self._init_graph_constru... |
87f5b011f32e8c0b507c2e60328e96d5aee997dd8cb5ea811a1f4ba8a6c76a3c | Python | 4,752 | 143 | """
Classes to support "biological sequence" files.
:Author: Bob Harris (rsharris@bx.psu.edu)
"""
# DNA reverse complement table
DNA_COMP = (
" - "
" TVGH CD M KN YSA BWXR tvgh cd m kn ysa bwxr "
" ... |
f0f897793605fdebea090cf288255105ef22cdb6f215be642a9aa92596ea5790 | Python | 4,752 | 112 | import torch
from torch import Tensor, nn
from torch.nn import init
from custom_layers.custom_module import BatchEvalModule
class EnsembleModel2(BatchEvalModule):
def __init__(self, encoder, model_class, model_params=None, ensemble_size=10):
super(EnsembleModel2, self).__init__()
self.encoder = ... |
7fd46fbaf3a308cb26532c02cc896320d2093491c81e2f75dedcb2bc404c5e8f | Python | 4,754 | 126 | #! /usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Visualize collisions given by scil_tractogram_filter_collisions with
the --save_colliding parameter.
"""
import argparse
from dipy.io.streamline import load_tractogram
from scilpy.io.streamlines import load_tractogram_with_reference
from fury import window, actor
fr... |
dd8fcadac0e9c867af54265836d37a7202bf4a454d074861188aca9f1dc08e8a | Python | 4,754 | 124 | # This file is part of connectome-manipulator.
#
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2024 Blue Brain Project/EPFL
"""Manipulation base module.
Description: This module contains the Manipulation abstract base class of which all manipulation
classes must inherit and implement its methods.
"""
from ab... |
ce498766b74114a93b3a1bfcb559e7d830aa725001d7f78d0acb7e1b2fc14e57 | Python | 4,755 | 107 | import numpy as np
import torch
from torch.nn import functional as F
def create_grid(um_sizes, desired_res=1):
""" Create a grid corresponding to the sample position of each pixel/voxel in a FOV of
um_sizes at resolution desired_res. The center of the FOV is (0, 0, 0).
In our convention, samples are tak... |
c27aaca8720d1f0bf3f8fb756c9383a687521e17cc771df8ab7a76a1cdde47b2 | Python | 4,757 | 118 | import shutil
from pathlib import Path
import click
import pandas as pd
import yaml
from click import confirm
from PIL import Image
from tqdm import tqdm
from brainways.project.brainways_project import BrainwaysProject
@click.command()
@click.option(
"--input",
type=Path,
required=True,
help=(
... |
f851f6f303b2fb37fa3a736c86b33a1fd39537393b904285fb2900ac594f3de1 | Python | 4,758 | 146 | #!/usr/bin/env python
"""
RS232 interface to a Marzhauser stage.
Hazen 04/17
"""
import traceback
import storm_control.sc_hardware.serial.RS232 as RS232
import storm_control.sc_library.hdebug as hdebug
class MarzhauserRS232(RS232.RS232):
"""
Marzhauser RS232 interface class.
"""
def ... |
3ebecf702068f0f1a70c1861306ce83e2a45ee1e3f88dfebbca4e259da04c4dd | Python | 4,759 | 135 | # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
from __future__ import annotations
import argparse
from typing import Any
import cv2.dnn
import numpy as np
from ultralytics.utils import ASSETS, ROOT, YAML
CLASSES = YAML.load(ROOT / "cfg/datasets/coco8.yaml")["names"]
colors = np.random.uniform(... |
986e11b35fbe1ab5a2270cbaeea6455abe8265cfe684995560a89a86cfe449e3 | Python | 4,759 | 168 | from functools import cached_property
from pathlib import Path
from typing import ClassVar
from argclz import argument, int_tuple_type
from neuralib.locomotion import CircularPosition
from stimpyp import Session
from .cli_stimpy import StimpyOptions
__all__ = ['TreadmillOptions']
class TreadmillOptions(StimpyOption... |
495e243e07e48944fab05b82e358d204199a7d5be9fd7381b2fe42b1ac615436 | Python | 4,761 | 161 | """
Semi-random access to bz2 compressed data.
"""
import bisect
from ._seekbzip2 import SeekBzip2
class SeekableBzip2File:
"""
Filelike object supporting read-only semi-random access to bz2 compressed
files for which an offset table (bz2t) has been generated by `bzip-table`.
"""
def __init__(s... |
f8d09bf0233f3635f1a4d52c049390d8c115a501461f839631757616eda70519 | Python | 4,761 | 146 | # -*- coding: utf-8 -*-
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
from functools import partial
from pathlib import Path
import urllib.request
import torch
from .mo... |
943031462f3750dbb30104a3ddebbd2b6b1085e38853ac2a4797a54baa03b3dd | Python | 4,764 | 112 | import logging
import warnings
from itertools import chain
import torch
from torch_geometric.data import Batch
from torch_geometric.utils import cumsum
class DataParallel(torch.nn.DataParallel):
r"""Implements data parallelism at the module level.
This container parallelizes the application of the given :a... |
daa47c8272311d7d403cc13066837a22391831a60e3cc2dd6b6c1486320d1631 | Python | 4,765 | 159 | import os
import sys
import json
import datetime
import torch
############################################################################################################################################
CWD = r"C:\Users"
DATA_DIR = r"D:\Askivit Daten\ASKIVIT_1_5"
SAVE_DIR = r"C:\Users"
MODEL_SAVE_DIR = S... |
0996da6d1cad1de94a0486e3b072c54f071b9a220e42cf29ce7d69ce4bbd1707 | Python | 4,767 | 154 | from collections import OrderedDict
from collections.abc import Sequence
from dataclasses import dataclass, field
from typing import TYPE_CHECKING
import torch
from torch import nn
from eir.models.fusion.fusion_default import al_features, default_fuse_features
from eir.models.layers.mlp_layers import MLPResidualBlock... |
cb8ccac6e0aa9675ceb3d4305aabd20e803a00084df6dd2969d93029714fed1c | Python | 4,767 | 117 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Uniformize streamlines' endpoints according to a defined axis.
Useful for tractometry or models creation.
The --auto option will automatically calculate the main orientation.
If the input bundle is poorly defined, it is possible heuristic will be wrong.
The default i... |
460325e62df0466cfdd41baa80efbbe4a0449cf569e53220eaa2aea04da3e0c6 | Python | 4,768 | 134 | import numpy as np
import matplotlib.pyplot as plt
import yaml
import sys
import os
import matplotlib as mpl
#'''
pathpath = 'PATHS/filepath_IBL.yml'#
myrun = 'runIBLPasdMP3_brain_pj'
ncluststr = '8'
cmethod = 'ward'
#'''
ncl = int(ncluststr)
with open(pathpath, 'r') as myfile: pathdict = yaml.safe_load(myfile)
sys.... |
a99699c0e6ea051789496e16d5186f3f967e00c464441b0829435547d1b4b2df | Python | 4,769 | 151 | """
convert the data for
"Uncertainty-Driven 6D Pose Estimation of Objects and Scenes from a Single RGB Image"
@author: Pavel Rojtberg <https://github.com/paroj>
"""
import os.path
import glob
import numpy as np
import cv2
import read
RENDER_OBJCOORDS = True
# convert from the lineMOD coordinate system to the Open... |
900ca6af25a1183cb3a97dc58f9f38cc11120050b7f56d0cf01d730668d8a41b | Python | 4,770 | 161 | ###############################################################################
#################### Boilerplate ########################
###############################################################################
import pandas as pd
import matplotlib.pyplot as plt
import os
import matplotlib... |
f652691aaff2f6f88c9bead6e095a0b6f28cfc188fdf36e14ac9576e503685eb | Python | 4,770 | 134 | import torch
import pandas as pd
from datasets import Dataset, DatasetDict, ClassLabel, load_dataset
from transformers import Wav2Vec2ForSequenceClassification, Wav2Vec2FeatureExtractor, TrainingArguments, Trainer
from sklearn.metrics import accuracy_score, roc_auc_score
import numpy as np
import torchaudio
from Straif... |
fb1b2a13715953b63d80c6ee70894627814cfb79e4f28d00401c4874df907c4c | Python | 4,770 | 137 | import multiprocessing as mp
import warnings
from typing import Optional
import numpy as np
import torch
from torch import Tensor
def geodesic_distance( # noqa: D417
pos: Tensor,
face: Tensor,
src: Optional[Tensor] = None,
dst: Optional[Tensor] = None,
norm: bool = True,
max_distance: Option... |
80a885d74332c493e4cdb379686360348256497a61aae41f759cee6410b76f24 | Python | 4,771 | 145 | from types import SimpleNamespace
import numpy as np
import pandas as pd
from napari_dmc_brainmap.results.results_helpers.results_creator import (
_scale_positions,
)
from napari_dmc_brainmap.segment.processing.native_presegmentation import (
smooth_slices,
)
from napari_dmc_brainmap.visualization.vis_plots.b... |
08cd94e4d38a61c7682526a3a8c2719a442ced10ed470f38d2ccc019698ad915 | Python | 4,772 | 125 | import pytest
import numpy as np
from nems.layers.weight_channels import WeightChannels
from nems.layers.filter import FiniteImpulseResponse, STRF, PoleZeroFIR
from nems.tools.debug import generate_random_input, compare_layer_eval
def test_constructor():
with pytest.raises(TypeError):
# No shape
f... |
50943fa162200d44ccdd5218476ed9294cbfce2266a1c5bb73293c83d8409d0a | Python | 4,773 | 136 | # -*- coding: utf-8 -*-
"""
Created on Sun Nov 27 11:43:52 2022
@author: DODO
"""
import numpy as np
import sys
import os
from os.path import getsize
import time
def jobSub_organoid_inter(filename, getcoord = True): # inpID
# job
print('submit job-%s'%(filename))
start = time.tim... |
6123862fe261dacc8ca0457acaa1a104a5560f8abc97e14f8e6476b4f37e289d | Python | 4,773 | 100 | # Copyright 2021 HIP Applied Computer Vision Lab, Division of Medical Image Computing, German Cancer Research Center
# (DKFZ), Heidelberg, Germany
#
# 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... |
6fa2ccd3e00ba7cda8c70924f367bde5a67e19a8911d0e532801c011fb200ee7 | Python | 4,775 | 130 | '''
ArNO
'''
import numpy as np
import sys
def intro():
print("""
SHORT List of potential energy surfaces for ArNO:
P: potential energy, G: Gradient, D: Nonadiabatic coupling vector
This is listed at the end of description to show the availability.
For example: P/G means both potential energy and... |
89e08cafd8ac7f1fec82effc416ff7cfc7d275e6debfd6f755f6c76a15e52eb0 | Python | 4,775 | 136 | """
Generate observer-ignoring behavior from single player dataset and
compare with social condition data.
"""
import sys
import os
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from pathlib import Path
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from u... |
b3cd5b8b4b7731882bc067d8e1bdccf024af2f6df4c5ac0db0496f0952b224bb | Python | 4,775 | 159 | import numpy as np
import pytest
from napari_dmc_brainmap.stitching.layout import (
AcquisitionOrder,
TILE_OVERLAP_PX,
TILE_SIZE_PX,
TILE_STRIDE_PX,
acquisition_cells,
classify_acquisition_order,
describe_layout,
layout_from_grid_metadata,
layout_from_stage_positions,
legacy_ser... |
c9dbe4dd7510d4e10e1f6584cd8328ff0b71756ab94bdd34ca2fd5d5d8c5e8d6 | Python | 4,775 | 159 | # Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import torch
from functools import partial
from .modeling import ImageEncoderViT, MaskDecoder, PromptEncoder, Sam, TwoWa... |
37b5c0cdfc7b38d4b1e26cf2efdb104cd9e19ee1528c6d5ea188704e6db95e3e | Python | 4,776 | 133 | '''
FH2O
'''
import numpy as np
import sys
def intro():
print("""
SHORT List of potential energy surfaces for FH2O:
P: potential energy, G: Gradient, D: Nonadiabatic coupling vector
This is listed at the end of description to show the availability.
For example: P/G means both potential energy and... |
8f0ed9336bf862d592ccd88eebafaeb0c516eeaf1d9fc49afb38b1d257eef8e4 | Python | 4,776 | 142 | """Losses for tf models."""
import tensorflow as tf
from tensorflow.keras import backend as K
def mask_nan(y_true, y_pred):
"""Mask nans and return tensors for use by loss functions
"""
notnan_true = K.cast(~tf.math.is_nan(y_true), "float32")
num_notnan = K.sum(K.flatten(notnan_true))
y_pred = tf.m... |
2fd30f4195f282c517175f9f5945981a957269a53acdc27963e9cc5cb9637d2c | Python | 4,777 | 136 | """
Static: Power Analysis
======================
In this tutorial we will perform static power analysis on source space MEG data. This tutorial covers:
1. Getting the data
2. Calculating power from spectra
"""
#%%
# Getting the data
# ^^^^^^^^^^^^^^^^
# We will use resting-state MEG data that has already been sourc... |
dfb9f14523f26a5750faf2d66981d0f39e7743e1ceb4d7bd5a3079e62587de26 | Python | 4,777 | 115 | """Let MolNexTR and MolScribe run on timm 1.x instead of their pinned 0.4.12.
Both vendor a Swin Transformer written against timm 0.4.12 internals, and the two
copies share 98% of their lines, so they break on exactly the same imports:
from timm.data import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD
from tim... |
904b8479f845c9746ae594f9b1528dd909c755ed14b532129fcdfc349a5ab9df | Python | 4,778 | 148 | """
Visual Encoder for AVPENet.
ResNet-50 with spatial attention augmentation.
Input: (B, 3, 224, 224) — RGB face image
Output: (B, 512) — visual embedding
Reference: Section "Visual Encoder Architecture" of the paper.
Implements Equations 4–8.
"""
import torch
import torch.nn as nn
import torch.nn.funct... |
a5bea7d5d47604744e44626e9b1cbffeae41a19f0da962a5f86720522f05aac1 | Python | 4,779 | 99 | from functools import partial
import datajoint as dj
import numpy as np
from neuro_data.static_images.configs import DataConfig
from neuro_data.static_images.data_schemas import StaticMultiDataset
# from neuro_data.static_images import zd_neurodata
from . import logger as log
from .utils import correlation_closure, ... |
b2ea88cd4cf78028b34b24bf419e03d3b121a10b55c13b5480bc7f8f172c54ce | Python | 4,779 | 146 | """Regress out motion and CSF fluctuations"""
import nibabel as nb
import numpy as np
import os
import glob
from nilearn import signal
import pandas as pd
ROOT = '/Users/sebastiandresbach/data/s1Anfunco/Nifti/derivatives'
# Set subjects to work on
subs = ['sub-05', 'sub-06', 'sub-07', 'sub-09', 'sub-10', 'sub-12', '... |
c981992e26fe8ab5dcf9d7c49dc43d80fd75f2efe5cd907cab65378cbb29e4ae | Python | 4,780 | 150 | """
Evaluation script for AVPENet.
Runs full evaluation on a test set and reports all metrics from the paper.
Supports age-stratification, per-intensity analysis, and bootstrap CI.
Usage:
python scripts/evaluate.py \
--config configs/avpenet_base.yaml \
--checkpoint outputs/checkpoints/avpenet_bes... |
4801aa3ce23c1013422a26c3a82bfe9d2db830e4c26885bbd55035ff93b1247a | Python | 4,782 | 156 | # Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import torch
from functools import partial
from .modeling import ImageEncoderViT, MaskDecoder, PromptEncoder, Sam, TwoWa... |
58f81fbedc17efb96c885e7842d195c8295b2315afebe18bee7a263a2f883156 | Python | 4,782 | 147 | #!/usr/bin/env python3
# Copyright (C) 2021-2022 Intel Corporation
# Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
import os
import sys
if __name__ == "__main__":
# fix types.py import
# Remove the script directory from the path, it can be appended by the interpreter
script_dir = os... |
5e569d202df247cc03e64082cb40ef9d3279ccda43cd7a299a9c3705282186ad | Python | 4,782 | 122 | """Create mask to minimaze storage demands of resting state analysis"""
import subprocess
import os
import nibabel as nb
import numpy as np
from scipy.ndimage import morphology, generate_binary_structure
from nipype.interfaces.fsl import ExtractROI
# Set rough outlines of the post-central sulcus (visually defined)
b... |
6804834571c0f5e09111943906fa8fb2b5e04de6e2ed7ecc0cc3102f45e4df7a | Python | 4,783 | 151 | from typing import Any, Dict
import hydra
import numpy as np
import omegaconf
import torch
import pytorch_lightning as pl
import torch.nn as nn
from torch.nn import functional as F
from torch_scatter import scatter
from tqdm import tqdm
from xrdsol.common.utils import PROJECT_ROOT
from xrdsol.common.data_utils import... |
abf7a9482a88903ed5195cbe569203b8a8fce34c6ff74eba5c2f4ba78d9b3607 | Python | 4,783 | 133 | import argparse
import os
import sys
import pandas as pd
import torch
import torch.nn as nn
from torch.utils.data import DataLoader
from model.VGGNet3D import VGGNet3D
from model.densenet3D import DenseNet3D
from model.efficientnet3D import EfficientNet3D
from model.resnet3D import ResNet18
from utils.da... |
b6f93ec47addab19adb7177385fa5814283ca15c2ff84257726ba10b4d708ce9 | Python | 4,783 | 138 | import pytest
import pandas as pd
import numpy as np
from unittest.mock import patch
from metaprivBIDS.corelogic import metapriv_corelogic
@pytest.fixture
def mock_data():
# Create a simple mock dataset for testing
return pd.DataFrame({
'salary': [50000, 60000, 70000, 50000, 60000],
'city': ['... |
c976a0a0c861cacdf1323bbb317769f12b153987b57b34ec4eb5f6c92ca2190b | Python | 4,783 | 135 | import numpy as np
# Image processing tools
import skimage.io
import glob
# Plotting tools
import bokeh
from bokeh.models.widgets import Panel, Tabs
from bokeh.io import output_file, show
from bokeh.plotting import figure
from bokeh.models import BasicTicker, ColorBar, LinearColorMapper, ColumnDataSource, PrintfTickF... |
66e2cf2fddb21918bb97196ab143f02ff11555717b3f690c72f793b56efdbe90 | Python | 4,784 | 152 | from math import sqrt
from typing import Any, List, Optional
import torch
from torch import Tensor
BACKENDS = {'graphviz', 'networkx'}
def has_graphviz() -> bool:
try:
import graphviz
except ImportError:
return False
try:
graphviz.Digraph().pipe()
except graphviz.backend.Exe... |
e65066eb36b4047a8e8f316ec0ae8eb27e028e075c45ea999f9e6dd328278561 | Python | 4,785 | 114 | # @UIService ui
# @PlotService plotService
"""
file: Analysis_Demo.py
author: Tiago Ferreira, Cameron Arshadi
version: 20190610
info: A Jython demo of how SNT can analyze neuronal reconstructions fetched
from online databases such as MouseLight, NeuroMorpho or FlyCircuit.
Thi... |
aa3273d88038ed18783a56eb4295624c0f013952386e1a49872bf8de9adbbe6b | Python | 4,786 | 128 | """
Adapted from the NSuite benchmarking framework (https://github.com/arbor-sim/nsuite.git)
"""
import numpy as np
from neuron import h
class cell_parameters:
def __repr__(self):
return 'branchy cell parameters: depth {}; branch_probs {}; compartments {}; lengths {}'\
.format(self.max_dep... |
edbab46983bc1a05ad4d069f4115757ade84ad3e53e427a74895793727d5b262 | Python | 4,786 | 112 | from scipy.io import loadmat
import numpy as np
import matplotlib.pyplot as plt
from LocationRegression.LocationRegressor.LocationRegressionHelper import loadData
from pathlib import Path
from warnings import warn
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis
from sklearn.decomposition import PC... |
f0ecff1f28e0c14cb1fe5d51f9f50678e123bf0b40ae1935a92750c12a77b859 | Python | 4,787 | 150 | import logging
import numpy as np
import numpy.matlib
import scipy.fftpack
logger = logging.getLogger(__name__)
def cwt_morlet(dt, signal, f_min, f_max, nb=35, f0=1.0):
"""
Calculate CWT using Morlet wavelet for a given signal.
Parameters
----------
dt : float
Sampling period in seconds... |
0f0e55c903e3d268c5b89aeb3b17996f61e4916337e0bb5478d0491f57221d5d | Python | 4,790 | 114 | import numpy as np
from dipy.core.gradients import gradient_table
from src.wrappers.OsipiBase import OsipiBase
from src.original.fitting.IAR_LundUniversity.ivim_fit_method_segmented_2step import IvimModelSegmented2Step
class IAR_LU_segmented_2step(OsipiBase):
"""
Bi-exponential fitting algorithm by Ivan A. Ra... |
3d4f36e8ab52db0c3083b655859a1aec8f2eadf4a468972baf09353396b1d74a | Python | 4,790 | 155 | #!/usr/bin/env python
#
# collect.py
#
# Copyright F. Nedelec, 2007--2018
"""
Synopsis:
Rename files or folders following a pattern containing an integer index,
as in 'image0001.png'. The file will be moved in the current directory
The number in the file name is incremented automatically for eac... |
b4876e9cc7a42afe8a9f9def7cb8d129388f3f6517dfd637cda9ea230cbcbc14 | Python | 4,792 | 152 | import numpy as np
from matplotlib.axes import Axes
from neuralib.plot.colormap import insert_colorbar
from stimpyp import RigEvent
__all__ = [
'plot_velocity_heatmap',
'plot_velocity_line',
#
'plot_peri_reward_lick_raster',
'plot_peri_reward_lick_hist',
#
'plot_lap_time_interval',
#
... |
451496f7ca7c54206b2e4664b90cbcaed3be07c8f71cd6176406e03ded07c87c | Python | 4,793 | 140 | import numpy as np
import torch
from brainCT.main import parse_config, get_model
from brainCT.train_utils.data_loader import BrainXLDataset, VotingDataset, MultiModalDataset
from monai.transforms import (
Compose,
ToTensord,
ScaleIntensityd,
AsDiscrete
)
import os
from monai.data import DataLoader
from ... |
c9adea0738c7b80f8bffb0efdd5359c2035e882e8fcd0ad77818ee7065018459 | Python | 4,793 | 154 | import torch
import numpy as np
import glob
import os
from deepcardio.neuralop_core.transforms import UnitGaussianNormalizer
from data_processing import CustomDataProcessorGINO
from torch_geometric.loader import DataLoader
from torch_geometric.data import Data, Dataset
class MeshDataset(Dataset):
def __init__(s... |
c801b771d08543ba2780013815de67e898d596b36867a7b368f1ff610b476f2f | Python | 4,794 | 119 | import xarray as xr
import numpy as np
from brainscore_vision.benchmark_helpers.neural_common import Score
from brainscore_vision.metric_helpers.transformations import standard_error_of_the_mean
from .xarray_utils import apply_over_dims, recursive_op
# take the mean of scores (medians of single neuron scores) over ... |
fa9afa2ad4512195dd1feb2ff67aa7ea7951062ea65df2e0b9b32443cd84c334 | Python | 4,794 | 159 | """shufflenetv2 in pytorch
[1] Ningning Ma, Xiangyu Zhang, Hai-Tao Zheng, Jian Sun
ShuffleNet V2: Practical Guidelines for Efficient CNN Architecture Design
https://arxiv.org/abs/1807.11164
"""
import torch
import torch.nn as nn
import torch.nn.functional as F
def channel_split(x, split):
"""split a ... |
54c51257e7e54cf29e2a6a0adb328c9a3ab3fb2ecee805920a42b3d69b759e9c | Python | 4,795 | 138 | # %%
import argparse
import gmsh
from mpi4py import MPI
from dolfinx.io import gmshio
import numpy as np
from dolfinx import fem, default_scalar_type
import ufl
from dolfinx.fem.petsc import LinearProblem
from pathlib import Path
# %%
def main(case_ID):
np.random.seed(case_ID)
gmsh.initialize()
gmsh.optio... |
6d62feee4f6d0e78166449089b84a71192d7c69b0ceec1d36589ae71f1f3addf | Python | 4,797 | 166 | """Launcher for the ChemGraph web UI.
Used by ``chemgraph ui`` (and installable as a standalone entry point)
so users can start the Streamlit app without knowing where the package
is installed.
"""
from __future__ import annotations
import argparse
import os
import subprocess
import sys
from pathlib import Path
from... |
76567f5fb56a1b65037eaabd7d2af8d57d85fdadb59b52b415e77abf913aabf0 | Python | 4,798 | 133 | def scale_vol(in_file):
import nibabel as nb
import numpy as np
import os
img = nb.load(in_file)
data = img.get_fdata()
std = np.std(data, axis=3)
std[std == 0] = 1 # divide with 1
mean = np.mean(data, axis=3)
for i in range(data.shape[3]):
data[:, :, :, i] = (data[:, :, :... |
6edc4a8667e22a6191d8313f6c4f232f77c731a2029251761d22755bb45a2889 | Python | 4,799 | 120 | # This file is part of connectome-manipulator.
#
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2024 Blue Brain Project/EPFL
"""Module for building (deterministic) connection probability models based on adjacency matrices"""
import os.path
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd... |
d4e36923709f15e8bbdee3fb994d1901937996e486b833c27333b256ab2b9078 | Python | 4,800 | 131 | import os
import sys
import pprint
import torch
from torchdrug import core
from torchdrug.utils import comm
sys.path.append(os.path.dirname(os.path.dirname(__file__)))
from biopathnet import dataset, layer, model, task, util
def solver_load(checkpoint, load_optimizer=True):
if comm.get_rank() == 0:
... |
98c2e3f1b0917c6306e87638b0455d76d827b14e55078aa3a663bebed5fa0829 | Python | 4,801 | 100 | import os
import re
import subprocess
import numpy as np
def parse_compare_score_file(file_path=None, file=None, flag="file"):
"""
Parse TM-score output and extract best RMSD and TM-score for each structure pair.
"""
if flag == "file_path":
with open(file_path, "r") as fh:
content =... |
3d30032d55bd3f66ffcea81070cf75ccde6fca43fda040e98e93f0e51d2c3c54 | Python | 4,802 | 110 | # ==============================================================================================================================
# Script used to plot comparison the state-vector traces from two distinct simulations that uses the 'save_as_text_or_binary'
# [save_result].
# 1) Run the simulations and store the 'V_it_<... |
67022dcbb5413541ab89ebb73d22bf982040a3bd95d65b637c9ecee9db67bd0b | Python | 4,802 | 109 | import torch
from torch import nn
import torchvision
def get_resnet_backend(
num_classes:int,
p_channels:int,
m_channels:int,
layers:int=18,
with_voneblock:bool=False,
tiny:bool=False
):
"""Returns ResNet18 or ResNet50 backend.
:param num_classes (int): number of classes in the cla... |
8e612b0f641bfd16f3369044fb4bc042564f908a9dbca09cd22bcb4a56041504 | Python | 4,802 | 173 | ###############################################################################
#################### Boilerplate ########################
###############################################################################
import pandas as pd
import matplotlib.pyplot as plt
import os
import matplotlib... |
d80bf8f103a6fcea76d132216f162d5821e9cab9393be270b0858452cafa3c0d | Python | 4,802 | 136 |
import typing
import asyncio
import logging
import traceback
import grpc
from .. import task_controller_pb2
from .. import task_controller_pb2_grpc
from .. import util_pb2
from .util import TaskContextProtocol
LOGGER = logging.getLogger(__name__)
class ExecutorLostError(RuntimeError):
def __init__(self):
sup... |
9d821f6eb454887215d312dfd57104bf364bdb6ee693a3cadfe62a36277d8aa0 | Python | 4,803 | 151 | import logging
import numpy as np
import pandas as pd
import sklearn.decomposition as decomposition
import scipy.stats as stats
def calculate_pca_transforms_and_loadings(X, min_explained_variance=0.05):
""" Get PCA-transformed depth profiles and loadings
Parameters
----------
X : array (n_samples, n_... |
b91fb81ef39ba684f28e461b1cf4eb517ff5b8122cd8ae633eb2dd21983b20d5 | Python | 4,803 | 102 | from __future__ import annotations
import pandas as pd
from causallib.preprocessing.transformers import MatchingTransformer
from causallib.positivity import BasePositivity
from typing import Union, Optional
import sklearn.neighbors
import sklearn.base
class Matching(BasePositivity):
def __init__(
self,
... |
26db0f3e43ce0c3137aab442e6738e74342933848a88bfac4e07c89e246a677a | Python | 4,804 | 98 | #encoding=utf-8
from __future__ import print_function
import sys
sys.path.append("../")
import jieba
def cuttest(test_sent):
result = jieba.cut_for_search(test_sent)
for word in result:
print(word, "/", end=' ')
print("")
if __name__ == "__main__":
cuttest("这是一个伸手不见五指的黑夜。我叫孙悟空,我爱北京,我爱Python和... |
359630e6ae1719aee1a0bb26a936ec9f68d9fe77cb1c8107758642a8efead763 | Python | 4,806 | 134 | import numpy as np
from torch import nn, Tensor
import torch
import my_setup
from custom_layers.custom_module import BatchEvalModule
class MultiHeadAttention(BatchEvalModule):
def __init__(self, dq, dv=None, num_heads=1, n_dq=None, n_dv=None, bias=False):
super(MultiHeadAttention, self).__init__()
... |
b56ee1c28bda84f0179ff95a43ee505ab6d040ba98901f7799e3ec8cce81eb0d | Python | 4,806 | 128 | # Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved
from typing import Dict, List
import numpy as np
import torch
try:
from pycocotools import mask as mask_utils
except Exception:
mask_utils = None
def mask_intersection(
masks1: torch.Tensor, masks2: torch.Tensor, block_size: int =... |
0319c5eb6b7e31a61b6760a4284e8eb575cb41a26f2fc7f78eb00070393897ce | Python | 4,808 | 113 | # -*- coding: utf-8 -*-
"""
Created on 16.5.2023
@author: jevrih
Command line utility for preparing summary reports of stimulations and guides
for electrode placement. The only thing the user needs to change is the
directory in the sys.path.append() a few lines below. Use the command line
parameters described below t... |
429d1ad162180a7cab7555318b01219c433d91bc82aaf90cd2bf2c1b31cec1eb | Python | 4,808 | 116 | import torch
import shap
import numpy as np
import pickle
import os
from Functions import loadtrain
from Functions import loadtest
from Functions import loadmodel
def ImfExtrat():
# Extract important features and activation values
## Find important features
# Need to update your model layers
# Choose... |
b5ff97b6bd26bd2b9e96bcaf2a8c45cd334f2ad7d156c1b732908548f6a8db84 | Python | 4,808 | 116 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import tempfile
from scilpy import SCILPY_HOME
from scilpy.io.fetcher import get_testing_files_dict, fetch_data
# If they already exist, this only takes 5 seconds (check md5sum)
fetch_data(get_testing_files_dict(), keys=[
'atlas.zip', 'tractograms.... |
c65739247918b47cc64e793edb7700970734b288dd2b6bc9ebfb625389ab65ae | Python | 4,808 | 124 | # Copyright 2024 Google LLC
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... |
0ae07adf269939ab69aeb7523e4fc35ac27ed0a35e64f6fc8df2d1d49775c189 | Python | 4,810 | 135 | import glob
import os
import nilearn
import scipy
import copy
import pandas as pd
from joblib import Parallel, delayed, cpu_count
from scipy import ndimage
from nilearn import plotting
from nilearn.glm.thresholding import threshold_stats_img
import numpy as np
import gc
from nilearn.image import new_img_like
impo... |
5e9a64f9893a3b7d2c5c8c2662ac09f57b72fdb7d41059f5dc74e7fa32ef60d7 | Python | 4,810 | 138 | # -*- coding: utf-8 -*-
# @Author : NaiChuan
# @Time : 2025/7/16 9:10
# @File : GFNet.py
# @Software: PyCharm
import torch
from torch import nn
import math
from timm.models.layers import DropPath, to_2tuple
# 论文地址:https://arxiv.org/pdf/2107.00645
# 论文:Global Filter Networks for Image Classification
# 微信公众号:AI缝合... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.