repo stringlengths 1 99 | file stringlengths 13 215 | code stringlengths 12 59.2M | file_length int64 12 59.2M | avg_line_length float64 3.82 1.48M | max_line_length int64 12 2.51M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
kraken | kraken-main/kraken/ketos/recognition.py | #
# Copyright 2022 Benjamin Kiessling
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | 26,702 | 52.087475 | 151 | py |
kraken | kraken-main/kraken/contrib/heatmap_overlay.py | #! /usr/bin/env python
"""
Produces semi-transparent neural segmenter output overlays
"""
import click
@click.command()
@click.option('-i', '--model', default=None, show_default=True, type=click.Path(exists=True),
help='Baseline detection model to use.')
@click.argument('files', nargs=-1)
def cli(model,... | 1,903 | 31.271186 | 98 | py |
kraken | kraken-main/kraken/contrib/baselineset_overlay.py | #! /usr/bin/env python
"""
Produces semi-transparent neural segmenter output overlays
"""
import click
@click.command()
@click.argument('files', nargs=-1)
def cli(files):
import torch
from PIL import Image
from os.path import splitext
import torchvision.transforms as tf
from kraken.lib import dat... | 1,640 | 33.1875 | 100 | py |
kraken | kraken-main/kraken/contrib/hyperparameters/tune_pretraining.py | #!/usr/bin/env python
"""
A script for a grid search over pretraining hyperparameters.
"""
import click
from functools import partial
from ray import tune
from ray.tune.integration.pytorch_lightning import TuneReportCallback
from kraken.lib.default_specs import RECOGNITION_PRETRAIN_HYPER_PARAMS, RECOGNITION_SPEC
fro... | 3,872 | 43.011364 | 142 | py |
kraken | kraken-main/kraken/contrib/hyperparameters/tune_training.py | #!/usr/bin/env python
"""
A script for a grid search over pretraining hyperparameters.
"""
import sys
from functools import partial
from ray import tune
from ray.tune.integration.pytorch_lightning import TuneReportCallback
from kraken.lib.default_spec import RECOGNITION_PRETRAIN_HYPER_PARAMS, RECOGNITION_SPEC
from k... | 2,190 | 37.438596 | 164 | py |
kraken | kraken-main/kraken/lib/codec.py | #
# Copyright 2017 Benjamin Kiessling
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | 11,105 | 40.909434 | 135 | py |
kraken | kraken-main/kraken/lib/progress.py | # Copyright Benjamin Kiessling
# Copyright The PyTorch Lightning team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required b... | 6,470 | 39.698113 | 135 | py |
kraken | kraken-main/kraken/lib/ctc_decoder.py | #
# Copyright 2017 Benjamin Kiessling
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | 6,701 | 39.131737 | 113 | py |
kraken | kraken-main/kraken/lib/vgsl.py | """
VGSL plumbing
"""
import re
import json
import torch
import logging
import warnings
from torch import nn
from os import PathLike
from typing import Sequence, List, Tuple, Union, Optional, Iterable, Callable, Dict, Any
from kraken.lib import layers
from kraken.lib.codec import PytorchCodec
from kraken.lib.exceptio... | 35,478 | 43.740227 | 181 | py |
kraken | kraken-main/kraken/lib/layers.py | """
Layers for VGSL models
"""
import torch
import numpy as np
from typing import List, Tuple, Optional, Iterable
from torch.nn import Module, Sequential
from torch.nn import functional as F
from torch.nn.utils.rnn import pad_packed_sequence, pack_padded_sequence
from coremltools.proto import NeuralNetwork_pb2
# all ... | 41,375 | 42.416579 | 200 | py |
kraken | kraken-main/kraken/lib/util.py | """
Ocropus's magic PIL-numpy array conversion routines. They express slightly
different behavior from PIL.Image.toarray().
"""
import torch
import unicodedata
import numpy as np
from PIL import Image
from typing import Union
__all__ = ['pil2array', 'array2pil', 'is_bitonal', 'make_printable', 'get_im_str']
def pi... | 2,723 | 27.375 | 82 | py |
kraken | kraken-main/kraken/lib/models.py | """
kraken.lib.models
~~~~~~~~~~~~~~~~~
Wrapper around TorchVGSLModel including a variety of forward pass helpers for
sequence classification.
"""
from os import PathLike
from os.path import expandvars, expanduser, abspath
import torch
import numpy as np
import kraken.lib.lineest
import kraken.lib.ctc_decoder
from t... | 8,040 | 35.058296 | 122 | py |
kraken | kraken-main/kraken/lib/functional_im_transforms.py | #
# Copyright 2015 Benjamin Kiessling
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | 2,764 | 25.84466 | 108 | py |
kraken | kraken-main/kraken/lib/train.py | #
# Copyright 2015 Benjamin Kiessling
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | 57,490 | 49.742277 | 171 | py |
kraken | kraken-main/kraken/lib/dataset/utils.py | #
# Copyright 2015 Benjamin Kiessling
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | 12,846 | 34.00545 | 128 | py |
kraken | kraken-main/kraken/lib/dataset/segmentation.py | #
# Copyright 2015 Benjamin Kiessling
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | 14,843 | 44.673846 | 137 | py |
kraken | kraken-main/kraken/lib/dataset/recognition.py | #
# Copyright 2015 Benjamin Kiessling
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | 23,940 | 40.277586 | 137 | py |
kraken | kraken-main/kraken/lib/pretrain/model.py | #
# Copyright 2022 Benjamin Kiessling
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | 21,793 | 44.404167 | 133 | py |
kraken | kraken-main/kraken/lib/pretrain/layers.py | """
Layers for VGSL models
"""
import torch
from typing import Tuple, Optional
from torch.nn import Module, Embedding, Linear
from kraken.lib.vgsl import VGSLBlock
from kraken.lib.pretrain.util import compute_mask_indices, sample_negatives
# all tensors are ordered NCHW, the "feature" dimension is C, so the output o... | 5,457 | 41.640625 | 157 | py |
kraken | kraken-main/kraken/lib/pretrain/util.py | # 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 typing import Sequence, Union, Tuple
import torch
import random
import numpy as np
def positive_integers_with_sum(n, total):
ls = ... | 5,805 | 33.975904 | 128 | py |
kraken | kraken-main/tests/test_layers.py | # -*- coding: utf-8 -*-
import unittest
import torch
from kraken.lib import layers
class TestLayers(unittest.TestCase):
"""
Testing custom layer implementations.
"""
def setUp(self):
torch.set_grad_enabled(False)
def test_maxpool(self):
"""
Test maximum pooling layer.
... | 9,708 | 33.675 | 88 | py |
kraken | kraken-main/tests/test_vgsl.py | # -*- coding: utf-8 -*-
import unittest
from pytest import raises
import os
import torch
import tempfile
from kraken.lib import vgsl, layers
class TestVGSL(unittest.TestCase):
"""
Testing VGSL module
"""
def test_helper_train(self):
"""
Tests train/eval mode helper methods
"""... | 3,156 | 33.692308 | 146 | py |
kraken | kraken-main/tests/test_codec.py | # -*- coding: utf-8 -*-
import unittest
from pytest import raises
from torch import IntTensor
from kraken.lib import codec
from kraken.lib.exceptions import KrakenEncodeException, KrakenCodecException
class TestCodec(unittest.TestCase):
"""
Testing codec mapping routines
"""
def setUp(self):
... | 18,763 | 53.231214 | 134 | py |
SSL4MIS | SSL4MIS-master/code/test_urpc_util.py | import math
import h5py
import nibabel as nib
import numpy as np
import SimpleITK as sitk
import torch
import torch.nn.functional as F
from medpy import metric
from skimage.measure import label
from tqdm import tqdm
def test_single_case(net, image, stride_xy, stride_z, patch_size, num_classes=1):
w, h, d = image... | 6,418 | 38.623457 | 169 | py |
SSL4MIS | SSL4MIS-master/code/train_interpolation_consistency_training_2D.py | import argparse
import logging
import os
import random
import shutil
import sys
import time
import numpy as np
import torch
import torch.backends.cudnn as cudnn
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from tensorboardX import SummaryWriter
from torch.nn import BCEWithLogitsLos... | 12,984 | 41.996689 | 108 | py |
SSL4MIS | SSL4MIS-master/code/test_3D.py | import argparse
import os
import shutil
from glob import glob
import torch
from networks.unet_3D import unet_3D
from test_3D_util import test_all_case
parser = argparse.ArgumentParser()
parser.add_argument('--root_path', type=str,
default='../data/BraTS2019', help='Name of Experiment')
parser.add... | 1,495 | 34.619048 | 128 | py |
SSL4MIS | SSL4MIS-master/code/train_adversarial_network_2D.py | import argparse
import logging
import os
import random
import shutil
import sys
import time
import numpy as np
import torch
import torch.backends.cudnn as cudnn
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from tensorboardX import SummaryWriter
from torch.nn import BCEWithLogitsLos... | 11,787 | 40.507042 | 108 | py |
SSL4MIS | SSL4MIS-master/code/train_mean_teacher_3D.py | import argparse
import logging
import os
import random
import shutil
import sys
import time
import numpy as np
import torch
import torch.backends.cudnn as cudnn
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from tensorboardX import SummaryWriter
from torch.nn import BCEWithLogitsLos... | 11,142 | 40.890977 | 126 | py |
SSL4MIS | SSL4MIS-master/code/train_interpolation_consistency_training_3D.py | import argparse
import logging
import os
import random
import shutil
import sys
import time
import numpy as np
import torch
import torch.backends.cudnn as cudnn
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from tensorboardX import SummaryWriter
from torch.nn import BCEWithLogitsLos... | 12,251 | 41.989474 | 126 | py |
SSL4MIS | SSL4MIS-master/code/val_3D.py | import math
from glob import glob
import h5py
import nibabel as nib
import numpy as np
import SimpleITK as sitk
import torch
import torch.nn.functional as F
from medpy import metric
from tqdm import tqdm
def test_single_case(net, image, stride_xy, stride_z, patch_size, num_classes=1):
w, h, d = image.shape
... | 4,073 | 36.722222 | 130 | py |
SSL4MIS | SSL4MIS-master/code/train_fully_supervised_2D.py | import argparse
import logging
import os
import random
import shutil
import sys
import time
import numpy as np
import torch
import torch.backends.cudnn as cudnn
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from tensorboardX import SummaryWriter
from torch.nn import BCEWithLogitsLos... | 8,999 | 40.09589 | 117 | py |
SSL4MIS | SSL4MIS-master/code/train_regularized_dropout_2D.py | import argparse
import logging
import os
import random
import shutil
import sys
import time
import numpy as np
import torch
import torch.backends.cudnn as cudnn
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from tensorboardX import SummaryWriter
from torch.nn import BCEWithLogitsLos... | 14,926 | 42.141618 | 165 | py |
SSL4MIS | SSL4MIS-master/code/train_cross_pseudo_supervision_3D.py | import argparse
import logging
import os
import random
import shutil
import sys
import time
import numpy as np
import torch
import torch.backends.cudnn as cudnn
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from tensorboardX import SummaryWriter
from torch.nn import BCEWithLogitsLos... | 14,030 | 42.574534 | 120 | py |
SSL4MIS | SSL4MIS-master/code/val_urpc_util.py | import math
from glob import glob
import h5py
import nibabel as nib
import numpy as np
import SimpleITK as sitk
import torch
import torch.nn.functional as F
from medpy import metric
from tqdm import tqdm
def test_single_case(net, image, stride_xy, stride_z, patch_size, num_classes=1):
w, h, d = image.shape
... | 4,076 | 36.75 | 124 | py |
SSL4MIS | SSL4MIS-master/code/test_2D_fully.py | import argparse
import os
import shutil
import h5py
import nibabel as nib
import numpy as np
import SimpleITK as sitk
import torch
from medpy import metric
from scipy.ndimage import zoom
from scipy.ndimage.interpolation import zoom
from tqdm import tqdm
# from networks.efficientunet import UNet
from networks.net_fact... | 4,413 | 36.40678 | 76 | py |
SSL4MIS | SSL4MIS-master/code/train_deep_co_training_2D.py | import argparse
import logging
import os
import random
import shutil
import sys
import time
import numpy as np
import torch
import torch.backends.cudnn as cudnn
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from tensorboardX import SummaryWriter
from torch.nn import BCEWithLogitsLos... | 11,350 | 41.354478 | 274 | py |
SSL4MIS | SSL4MIS-master/code/train_entropy_minimization_3D.py | import argparse
import logging
import os
import random
import shutil
import sys
import time
import numpy as np
import torch
import torch.backends.cudnn as cudnn
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from tensorboardX import SummaryWriter
from torch.nn import BCEWithLogitsLos... | 10,388 | 41.060729 | 126 | py |
SSL4MIS | SSL4MIS-master/code/train_cross_consistency_training_2D.py | import argparse
import logging
import os
import random
import shutil
import sys
import time
import numpy as np
import torch
import torch.backends.cudnn as cudnn
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from tensorboardX import SummaryWriter
from torch.nn import BCEWithLogitsLos... | 12,274 | 43.154676 | 108 | py |
SSL4MIS | SSL4MIS-master/code/train_fixmatch_cta.py | import argparse
import logging
import os
import re
import random
import shutil
import sys
import time
from xml.etree.ElementInclude import default_loader
from more_itertools import sample
import numpy as np
import torch
import torch.backends.cudnn as cudnn
import torch.nn as nn
import torch.nn.functional as F
import t... | 16,647 | 38.079812 | 119 | py |
SSL4MIS | SSL4MIS-master/code/train_fully_supervised_3D.py | import argparse
import logging
import os
import random
import shutil
import sys
import time
import numpy as np
import torch
import torch.backends.cudnn as cudnn
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from tensorboardX import SummaryWriter
from torch.nn import BCEWithLogitsLos... | 8,444 | 40.397059 | 126 | py |
SSL4MIS | SSL4MIS-master/code/train_entropy_minimization_2D.py | import argparse
import logging
import os
import random
import shutil
import sys
import time
import numpy as np
import torch
import torch.backends.cudnn as cudnn
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from tensorboardX import SummaryWriter
from torch.nn import BCEWithLogitsLos... | 10,840 | 40.857143 | 108 | py |
SSL4MIS | SSL4MIS-master/code/train_fixmatch_standard_augs.py | import argparse
import logging
import os
import re
import random
import shutil
import sys
import time
from xml.etree.ElementInclude import default_loader
import numpy as np
import torch
import torch.backends.cudnn as cudnn
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import torch.d... | 16,133 | 37.141844 | 119 | py |
SSL4MIS | SSL4MIS-master/code/train_cross_teaching_between_cnn_transformer_2D.py | # -*- coding: utf-8 -*-
# Author: Xiangde Luo
# Date: 16 Dec. 2021
# Implementation for Semi-Supervised Medical Image Segmentation via Cross Teaching between CNN and Transformer.
# # Reference:
# @article{luo2021ctbct,
# title={Semi-Supervised Medical Image Segmentation via Cross Teaching between CNN and Transfor... | 18,123 | 43.530713 | 142 | py |
SSL4MIS | SSL4MIS-master/code/train_adversarial_network_3D.py | import argparse
import logging
import os
import random
import shutil
import sys
import time
import numpy as np
import torch
import torch.backends.cudnn as cudnn
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from tensorboardX import SummaryWriter
from torch.nn import BCEWithLogitsLos... | 11,326 | 40.643382 | 126 | py |
SSL4MIS | SSL4MIS-master/code/val_2D.py | import numpy as np
import torch
from medpy import metric
from scipy.ndimage import zoom
def calculate_metric_percase(pred, gt):
pred[pred > 0] = 1
gt[gt > 0] = 1
if pred.sum() > 0:
dice = metric.binary.dc(pred, gt)
hd95 = metric.binary.hd95(pred, gt)
return dice, hd95
else:
... | 2,359 | 35.307692 | 77 | py |
SSL4MIS | SSL4MIS-master/code/test_urpc.py | import argparse
import os
import shutil
from glob import glob
import numpy
import torch
from networks.unet_3D_dv_semi import unet_3D_dv_semi
from networks.unet_3D import unet_3D
from test_urpc_util import test_all_case
def net_factory(net_type="unet_3D", num_classes=3, in_channels=1):
if net_type == "unet_3D":
... | 1,990 | 34.553571 | 128 | py |
SSL4MIS | SSL4MIS-master/code/train_regularized_dropout_3D.py | import argparse
import logging
import os
import random
import shutil
import sys
import time
import numpy as np
import torch
import torch.backends.cudnn as cudnn
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from tensorboardX import SummaryWriter
from torch.nn import BCEWithLogitsLos... | 13,874 | 42.359375 | 107 | py |
SSL4MIS | SSL4MIS-master/code/train_uncertainty_rectified_pyramid_consistency_2D.py | import argparse
import logging
import os
import random
import shutil
import sys
import time
import numpy as np
import torch
import torch.backends.cudnn as cudnn
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from tensorboardX import SummaryWriter
from torch.nn import BCEWithLogitsLos... | 14,087 | 44.153846 | 127 | py |
SSL4MIS | SSL4MIS-master/code/train_uncertainty_rectified_pyramid_consistency_3D.py | import argparse
import logging
import os
import random
import shutil
import sys
import time
import numpy as np
import torch
import torch.backends.cudnn as cudnn
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from tensorboardX import SummaryWriter
from torch.nn import BCEWithLogitsLos... | 14,470 | 45.085987 | 127 | py |
SSL4MIS | SSL4MIS-master/code/train_cross_pseudo_supervision_2D.py | import argparse
import logging
import os
import random
import shutil
import sys
import time
import numpy as np
import torch
import torch.backends.cudnn as cudnn
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from tensorboardX import SummaryWriter
from torch.nn import BCEWithLogitsLos... | 15,182 | 42.38 | 129 | py |
SSL4MIS | SSL4MIS-master/code/train_uncertainty_aware_mean_teacher_3D.py | import argparse
import logging
import os
import random
import shutil
import sys
import time
import numpy as np
import torch
import torch.backends.cudnn as cudnn
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from tensorboardX import SummaryWriter
from torch.nn import BCEWithLogitsLos... | 12,302 | 41.570934 | 126 | py |
SSL4MIS | SSL4MIS-master/code/train_uncertainty_aware_mean_teacher_2D.py | import argparse
import logging
import os
import random
import shutil
import sys
import time
import numpy as np
import torch
import torch.backends.cudnn as cudnn
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from tensorboardX import SummaryWriter
from torch.nn import BCEWithLogitsLos... | 12,976 | 41.970199 | 108 | py |
SSL4MIS | SSL4MIS-master/code/train_mean_teacher_2D.py | import argparse
import logging
import os
import random
import shutil
import sys
import time
import numpy as np
import torch
import torch.backends.cudnn as cudnn
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from tensorboardX import SummaryWriter
from torch.nn import BCEWithLogitsLos... | 11,916 | 40.961268 | 108 | py |
SSL4MIS | SSL4MIS-master/code/test_3D_util.py | import math
import h5py
import nibabel as nib
import numpy as np
import SimpleITK as sitk
import torch
import torch.nn.functional as F
from medpy import metric
from skimage.measure import label
from tqdm import tqdm
def test_single_case(net, image, stride_xy, stride_z, patch_size, num_classes=1):
w, h, d = image... | 6,008 | 38.27451 | 169 | py |
SSL4MIS | SSL4MIS-master/code/networks/efficient_encoder.py | import re
from typing import List
import torch
import torch.nn as nn
import torch.utils.model_zoo as model_zoo
from efficientnet_pytorch import EfficientNet
from efficientnet_pytorch.utils import get_model_params, url_map
from torchvision.models.densenet import DenseNet
from torchvision.models.resnet import BasicBlock... | 17,641 | 31.975701 | 110 | py |
SSL4MIS | SSL4MIS-master/code/networks/pnet.py |
# -*- coding: utf-8 -*-
"""
An PyTorch implementation of the DeepIGeoS paper:
Wang, Guotai and Zuluaga, Maria A and Li, Wenqi and Pratt, Rosalind and Patel, Premal A and Aertsen, Michael and Doel, Tom and David, Anna L and Deprest, Jan and Ourselin, S{\'e}bastien and others:
DeepIGeoS: a deep interactive geo... | 4,200 | 33.154472 | 202 | py |
SSL4MIS | SSL4MIS-master/code/networks/grid_attention_layer.py | import torch
from torch import nn
from torch.nn import functional as F
from networks.networks_other import init_weights
class _GridAttentionBlockND(nn.Module):
def __init__(self, in_channels, gating_channels, inter_channels=None, dimension=3, mode='concatenation',
sub_sample_factor=(2,2,2)):
... | 16,619 | 40.446384 | 137 | py |
SSL4MIS | SSL4MIS-master/code/networks/attention_unet.py | import torch.nn as nn
import torch
from networks.utils import UnetConv3, UnetUp3_CT, UnetGridGatingSignal3, UnetDsv3
import torch.nn.functional as F
from networks.networks_other import init_weights
from networks.grid_attention_layer import GridAttentionBlock3D
class Attention_UNet(nn.Module):
def __init__(self, ... | 6,336 | 45.595588 | 122 | py |
SSL4MIS | SSL4MIS-master/code/networks/discriminator.py | import torch
import torch.nn as nn
import torch.nn.functional as F
class FC3DDiscriminator(nn.Module):
def __init__(self, num_classes, ndf=64, n_channel=1):
super(FC3DDiscriminator, self).__init__()
# downsample 16
self.conv0 = nn.Conv3d(
num_classes, ndf, kernel_size=4, strid... | 3,133 | 30.029703 | 78 | py |
SSL4MIS | SSL4MIS-master/code/networks/encoder_tool.py | from typing import List
import torch
import torch.nn as nn
import torch.utils.model_zoo as model_zoo
from efficientnet_pytorch import EfficientNet
from efficientnet_pytorch.utils import get_model_params, url_map
class EncoderMixin:
"""Add encoder functionality such as:
- output channels specification of ... | 6,765 | 30.765258 | 87 | py |
SSL4MIS | SSL4MIS-master/code/networks/utils.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from networks.networks_other import init_weights
class conv2DBatchNorm(nn.Module):
def __init__(self, in_channels, n_filters, k_size, stride, padding, bias=True):
super(conv2DBatchNorm, self).__init__()
self.cb_unit = nn.Sequent... | 18,130 | 38.159827 | 120 | py |
SSL4MIS | SSL4MIS-master/code/networks/neural_network.py | # Copyright 2020 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 of the License at
#
# http://w... | 45,370 | 49.189159 | 137 | py |
SSL4MIS | SSL4MIS-master/code/networks/VoxResNet.py | # -*- coding: utf-8 -*-
from __future__ import print_function, division
import torch
import torch.nn as nn
class SEBlock(nn.Module):
def __init__(self, in_channels, r):
super(SEBlock, self).__init__()
redu_chns = int(in_channels / r)
self.se_layers = nn.Sequential(
nn.Adapti... | 3,637 | 30.094017 | 79 | py |
SSL4MIS | SSL4MIS-master/code/networks/vision_transformer.py | # coding=utf-8
# This file borrowed from Swin-UNet: https://github.com/HuCaoFighting/Swin-Unet
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import copy
import logging
import math
from os.path import join as pjoin
import torch
import torch.nn as nn
impor... | 3,981 | 43.244444 | 113 | py |
SSL4MIS | SSL4MIS-master/code/networks/swin_transformer_unet_skip_expand_decoder_sys.py | # This file borrowed from Swin-UNet: https://github.com/HuCaoFighting/Swin-Unet
import torch
import torch.nn as nn
import torch.utils.checkpoint as checkpoint
from einops import rearrange
from timm.models.layers import DropPath, to_2tuple, trunc_normal_
class Mlp(nn.Module):
def __init__(self, in_features, hidden... | 33,208 | 40.253416 | 209 | py |
SSL4MIS | SSL4MIS-master/code/networks/unet.py | # -*- coding: utf-8 -*-
"""
The implementation is borrowed from: https://github.com/HiLab-git/PyMIC
"""
from __future__ import division, print_function
import numpy as np
import torch
import torch.nn as nn
from torch.distributions.uniform import Uniform
def kaiming_normal_init_weight(model):
for m in model.module... | 13,801 | 34.030457 | 79 | py |
SSL4MIS | SSL4MIS-master/code/networks/efficientunet.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from networks.attention import *
from networks.efficient_encoder import get_encoder
def initialize_decoder(module):
for m in module.modules():
if isinstance(m, nn.Conv2d):
nn.init.kaiming_uniform_(m.weight, mode="fan_in", non... | 7,930 | 34.725225 | 117 | py |
SSL4MIS | SSL4MIS-master/code/networks/nnunet.py | # Copyright 2020 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 of the License at
#
# http://w... | 23,919 | 43.71028 | 177 | py |
SSL4MIS | SSL4MIS-master/code/networks/networks_other.py | import functools
import time
import numpy as np
import torch
import torch.nn as nn
from torch.autograd import Variable
from torch.nn import init
from torch.optim import lr_scheduler
###############################################################################
# Functions
############################################... | 20,202 | 37.118868 | 151 | py |
SSL4MIS | SSL4MIS-master/code/networks/vnet.py | import torch
from torch import nn
import torch.nn.functional as F
class ConvBlock(nn.Module):
def __init__(self, n_stages, n_filters_in, n_filters_out, normalization='none'):
super(ConvBlock, self).__init__()
ops = []
for i in range(n_stages):
if i==0:
input_cha... | 9,541 | 35.984496 | 110 | py |
SSL4MIS | SSL4MIS-master/code/networks/attention.py | import torch.nn as nn
try:
from inplace_abn import InPlaceABN
except ImportError:
InPlaceABN = None
class Conv2dReLU(nn.Sequential):
def __init__(
self,
in_channels,
out_channels,
kernel_size,
padding=0,
stride=1,
use_bat... | 3,104 | 26.972973 | 114 | py |
SSL4MIS | SSL4MIS-master/code/networks/enet.py | import torch.nn as nn
import torch
class InitialBlock(nn.Module):
"""The initial block is composed of two branches:
1. a main branch which performs a regular convolution with stride 2;
2. an extension branch which performs max-pooling.
Doing both operations in parallel and concatenating their results
... | 22,927 | 36.281301 | 88 | py |
SSL4MIS | SSL4MIS-master/code/networks/unet_3D_dv_semi.py | """
This file is adapted from https://github.com/ozan-oktay/Attention-Gated-Networks
"""
import math
import torch
import torch.nn as nn
from networks.utils import UnetConv3, UnetUp3, UnetUp3_CT, UnetDsv3
import torch.nn.functional as F
from networks.networks_other import init_weights
class unet_3D_dv_semi(nn.Module)... | 3,865 | 33.212389 | 104 | py |
SSL4MIS | SSL4MIS-master/code/networks/unet_3D.py | # -*- coding: utf-8 -*-
"""
An implementation of the 3D U-Net paper:
Özgün Çiçek, Ahmed Abdulkadir, Soeren S. Lienkamp, Thomas Brox, Olaf Ronneberger:
3D U-Net: Learning Dense Volumetric Segmentation from Sparse Annotation.
MICCAI (2) 2016: 424-432
Note that there are some modifications from the origina... | 3,617 | 34.821782 | 104 | py |
SSL4MIS | SSL4MIS-master/code/augmentations/ctaugment.py | # https://raw.githubusercontent.com/google-research/fixmatch/master/libml/ctaugment.py
#
# Copyright 2019 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... | 6,431 | 25.146341 | 103 | py |
SSL4MIS | SSL4MIS-master/code/dataloaders/brats2019.py | import os
import torch
import numpy as np
from glob import glob
from torch.utils.data import Dataset
import h5py
import itertools
from torch.utils.data.sampler import Sampler
class BraTS2019(Dataset):
""" BraTS2019 Dataset """
def __init__(self, base_dir=None, split='train', num=None, transform=None):
... | 8,814 | 36.194093 | 112 | py |
SSL4MIS | SSL4MIS-master/code/dataloaders/utils.py | import os
import torch
import numpy as np
import torch.nn as nn
# import matplotlib.pyplot as plt
from skimage import measure
import scipy.ndimage as nd
def recursive_glob(rootdir='.', suffix=''):
"""Performs recursive glob with given suffix and rootdir
:param rootdir is the root directory
:param ... | 6,731 | 30.311628 | 144 | py |
SSL4MIS | SSL4MIS-master/code/dataloaders/dataset.py | import os
import cv2
import torch
import random
import numpy as np
from glob import glob
from torch.utils.data import Dataset
import h5py
from scipy.ndimage.interpolation import zoom
from torchvision import transforms
import itertools
from scipy import ndimage
from torch.utils.data.sampler import Sampler
import augment... | 8,440 | 32.232283 | 105 | py |
SSL4MIS | SSL4MIS-master/code/utils/losses.py | import torch
from torch.nn import functional as F
import numpy as np
import torch.nn as nn
from torch.autograd import Variable
def dice_loss(score, target):
target = target.float()
smooth = 1e-5
intersect = torch.sum(score * target)
y_sum = torch.sum(target * target)
z_sum = torch.sum(score * scor... | 6,990 | 30.777273 | 85 | py |
SSL4MIS | SSL4MIS-master/code/utils/util.py | # Copyright (c) 2017-present, Facebook, Inc.
# 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 os
import pickle
import numpy as np
import re
from scipy.ndimage import distance_transform_edt as distance
from skimage i... | 8,190 | 31.121569 | 111 | py |
MERL-LB | MERL-LB-main/mp_test_nn_load.py | import os
import torch
import numpy as np
import torch.nn as nn
import torch.nn.functional as F
import pandas as pd
from itertools import count
from multiprocessing import Pool, cpu_count
from config.test import *
from envs.datacenter_env.env import DatacenterEnv
from utils import *
class Actor(nn.Module):
def _... | 11,123 | 32.506024 | 131 | py |
MERL-LB | MERL-LB-main/mp.py | import torch
from torchvision import datasets, transforms
from tqdm import tqdm
device_ids = [0, 1, 2, 3] # 可用GPU
BATCH_SIZE = 64
transform = transforms.Compose([transforms.ToTensor()])
data_train = datasets.MNIST(root="./data/", transform=transform, train=True, download=True)
data_test = datasets.MNIST(root="./data... | 2,903 | 30.225806 | 91 | py |
MERL-LB | MERL-LB-main/mp_train_nn_nsga2_one.py | import os
import torch
import random
import numpy as np
import torch.nn as nn
import torch.nn.functional as F
import matplotlib.pyplot as plt
from multiprocessing import Pool, cpu_count
from config.ga import *
from typing import List
from envs.datacenter_env.env import DatacenterEnv
from torch.utils.tensorboard impor... | 21,461 | 34.299342 | 96 | py |
MERL-LB | MERL-LB-main/mp_train_nn_nsga2.py | import os
import torch
import random
import numpy as np
import torch.nn as nn
import torch.nn.functional as F
import matplotlib.pyplot as plt
from multiprocessing import Pool, cpu_count
from config.ga import *
from typing import List
from envs.datacenter_env.env import DatacenterEnv
from torch.utils.tensorboard impor... | 21,419 | 34.346535 | 96 | py |
MERL-LB | MERL-LB-main/mp_test_nn_nsga.py | import os
import torch
import numpy as np
import torch.nn as nn
import torch.nn.functional as F
import pandas as pd
from itertools import count
from multiprocessing import Pool, cpu_count
from config.test import *
from envs.datacenter_env.env import DatacenterEnv
from utils import *
class Actor(nn.Module):
def _... | 11,135 | 32.643505 | 131 | py |
MERL-LB | MERL-LB-main/mp_test_sigma.py | import os
import random
import torch
import numpy as np
import pandas as pd
import torch.nn as nn
import torch.nn.functional as F
from torch.distributions import Categorical
from itertools import count
from multiprocessing import Pool, cpu_count
from config.test import *
from envs.datacenter_env.env import DatacenterEn... | 13,433 | 31.686131 | 97 | py |
MERL-LB | MERL-LB-main/mp_test_load.py | import os
import random
import torch
import numpy as np
import pandas as pd
import torch.nn as nn
import torch.nn.functional as F
from torch.distributions import Categorical
from itertools import count
from multiprocessing import Pool, cpu_count
from config.test import *
from envs.datacenter_env.env import DatacenterEn... | 13,101 | 31.59204 | 97 | py |
MERL-LB | MERL-LB-main/sp_train_nn_dqn.py | import os
import random
import numpy as np
import torch
from collections import namedtuple, deque
from itertools import count
from config.dqn import *
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from envs.datacenter_env.env import DatacenterEnv
from utils import *
os.environ["CU... | 12,168 | 31.97832 | 96 | py |
MERL-LB | MERL-LB-main/mp_train_nn_ga.py | import os
import torch
import random
import numpy as np
import torch.nn as nn
import torch.nn.functional as F
import matplotlib.pyplot as plt
from multiprocessing import Pool, cpu_count
from config.ga import *
from typing import List
from envs.datacenter_env.env import DatacenterEnv
from torch.utils.tensorboard impor... | 18,403 | 34.460501 | 96 | py |
MERL-LB | MERL-LB-main/mp_train_nn_deepjs_no_mask.py | import os
import random
import numpy as np
import torch
import torch.nn as nn
import torch.optim as optim
import torch.nn.functional as F
import matplotlib.pyplot as plt
from torch.distributions import Categorical
from torch.utils.data import Dataset, DataLoader
from config.deepjs import *
from envs.datacenter_env.en... | 18,402 | 35.586481 | 98 | py |
MERL-LB | MERL-LB-main/mp_test.py | import os
import random
import torch
import numpy as np
import pandas as pd
import torch.nn as nn
import torch.nn.functional as F
from torch.distributions import Categorical
from itertools import count
from multiprocessing import Pool, cpu_count
from config.test import *
from envs.datacenter_env.env import DatacenterEn... | 12,458 | 32.312834 | 131 | py |
MERL-LB | MERL-LB-main/sp_train_nn_ppo.py | import os
import random
import numpy as np
import torch
from collections import namedtuple, deque
from itertools import count
from config.ppo import *
import torch.nn as nn
import torch.nn.functional as F
from torch.distributions import Categorical
from torch.utils.tensorboard import SummaryWriter
from envs.datacente... | 14,034 | 32.023529 | 96 | py |
MERL-LB | MERL-LB-main/mp_test_nn_sigma.py | import os
import torch
import numpy as np
import torch.nn as nn
import torch.nn.functional as F
import pandas as pd
from itertools import count
from multiprocessing import Pool, cpu_count
from config.test import *
from envs.datacenter_env.env import DatacenterEnv
from utils import *
class Actor(nn.Module):
def _... | 10,899 | 33.169279 | 131 | py |
MERL-LB | MERL-LB-main/mp_train_nn_deepjs_no_mask_ppo.py | import os
import random
import numpy as np
import torch
import torch.nn as nn
import torch.optim as optim
import torch.nn.functional as F
import matplotlib.pyplot as plt
from torch.distributions import Categorical
from torch.utils.data import Dataset, DataLoader
from config.deepjs import *
from envs.datacenter_env.en... | 19,410 | 36.185824 | 100 | py |
MERL-LB | MERL-LB-main/mp_train_nn_moead.py | import os
import torch
import random
import numpy as np
import torch.nn as nn
import torch.nn.functional as F
import matplotlib.pyplot as plt
from multiprocessing import Pool, cpu_count
from config.moead import *
from typing import List
from envs.datacenter_env.env import DatacenterEnv
from torch.utils.tensorboard im... | 16,252 | 33.877682 | 96 | py |
MERL-LB | MERL-LB-main/mp_train_nn_deepjs.py | import os
import random
import numpy as np
import torch
import torch.nn as nn
import torch.optim as optim
import torch.nn.functional as F
import matplotlib.pyplot as plt
from torch.distributions import Categorical
from torch.utils.data import Dataset, DataLoader
from config.deepjs import *
from envs.datacenter_env.en... | 17,996 | 34.994 | 98 | py |
MERL-LB | MERL-LB-main/mp_test_nn.py | import os
import torch
import numpy as np
import torch.nn as nn
import torch.nn.functional as F
from itertools import count
from multiprocessing import Pool, cpu_count
from config.test import *
from envs.datacenter_env.env import DatacenterEnv
from utils import *
class Actor(nn.Module):
def __init__(self, dim_li... | 9,255 | 34.328244 | 134 | py |
MERL-LB | MERL-LB-main/mp_train_nn_nsga2_neighbor.py | import os
import torch
import random
import numpy as np
import torch.nn as nn
import torch.nn.functional as F
import matplotlib.pyplot as plt
from multiprocessing import Pool, cpu_count
from config.ga import *
from typing import List
from envs.datacenter_env.env import DatacenterEnv
from torch.utils.tensorboard impor... | 23,003 | 34.665116 | 96 | py |
MERL-LB | MERL-LB-main/mp_test_server_num.py | import os
import random
import torch
import numpy as np
import pandas as pd
import torch.nn as nn
import torch.nn.functional as F
from torch.distributions import Categorical
from itertools import count
from multiprocessing import Pool, cpu_count
from config.test import *
from envs.datacenter_env.env import DatacenterEn... | 13,588 | 31.823671 | 97 | py |
MERL-LB | MERL-LB-main/mp_train_nn_nsga2_no_mask.py | import os
import torch
import random
import numpy as np
import torch.nn as nn
import torch.nn.functional as F
import matplotlib.pyplot as plt
from multiprocessing import Pool, cpu_count
from config.ga import *
from typing import List
from envs.datacenter_env.env import DatacenterEnv
from torch.utils.tensorboard impor... | 21,474 | 34.378913 | 96 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.