repo stringlengths 2 99 | file stringlengths 13 225 | code stringlengths 0 18.3M | file_length int64 0 18.3M | avg_line_length float64 0 1.36M | max_line_length int64 0 4.26M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
kraken | kraken-main/tests/test_merging.py | from kraken.lib.train import RecognitionModel
from kraken.lib.exceptions import KrakenInputException
from kraken.lib.default_specs import RECOGNITION_HYPER_PARAMS
#from kraken.ketos.util import _expand_gt
from pathlib import Path
from unittest import TestCase
from unicodedata import normalize
_here = Path(__file__).p... | 9,410 | 42.976636 | 119 | py |
kraken | kraken-main/tests/test_dataset.py | # -*- coding: utf-8 -*-
import unittest
from pathlib import Path
from pytest import raises
from PIL import Image
from kraken.lib.dataset import ImageInputTransforms, BaselineSet
from kraken.lib.util import is_bitonal
from kraken.lib.exceptions import KrakenInputException
thisfile = Path(__file__).resolve().parent
r... | 11,240 | 40.479705 | 98 | py |
kraken | kraken-main/tests/test_train.py | # -*- coding: utf-8 -*-
import unittest
import json
import kraken
from pytest import raises
from pathlib import Path
from kraken.lib import xml
from kraken.lib.train import KrakenTrainer, RecognitionModel, SegmentationModel
from kraken.lib.exceptions import KrakenInputException
thisfile = Path(__file__).resolve().... | 10,918 | 44.119835 | 163 | py |
kraken | kraken-main/tests/test_lineest.py | # -*- coding: utf-8 -*-
import unittest
from PIL import Image
from pathlib import Path
from pytest import raises
from kraken.lib import lineest
thisfile = Path(__file__).resolve().parent
resources = thisfile / 'resources'
class TestLineest(unittest.TestCase):
"""
Testing centerline estimator
"""
d... | 1,551 | 27.740741 | 96 | py |
kraken | kraken-main/tests/test_cli.py | # -*- coding: utf-8 -*-
import os
import click
import unittest
import tempfile
import numpy as np
from PIL import Image
from pathlib import Path
from click.testing import CliRunner
from kraken.kraken import cli
from pytest import raises
thisfile = Path(__file__).resolve().parent
resources = thisfile / 'resources'
c... | 2,179 | 31.058824 | 94 | py |
kraken | kraken-main/tests/test_binarization.py | # -*- coding: utf-8 -*-
import unittest
from pytest import raises
from PIL import Image
from pathlib import Path
from kraken.binarization import nlbin
from kraken.lib.exceptions import KrakenInputException
thisfile = Path(__file__).resolve().parent
resources = thisfile / 'resources'
class TestBinarization(unittest... | 2,076 | 31.453125 | 79 | py |
kraken | kraken-main/tests/test_rpred.py | # -*- coding: utf-8 -*-
import os
import json
import pytest
import unittest
from PIL import Image
from pytest import raises
from pathlib import Path
from collections import defaultdict
from kraken.lib.models import load_any
from kraken.rpred import rpred, mm_rpred, BaselineOCRRecord, BBoxOCRRecord
from kraken.lib.exc... | 14,934 | 42.16474 | 125 | py |
kraken | kraken-main/tests/test_models.py | # -*- coding: utf-8 -*-
import os
import pickle
import unittest
import tempfile
from pytest import raises
from pathlib import Path
import kraken.lib.lstm
from kraken.lib import models
from kraken.lib.exceptions import KrakenInvalidModelException
thisfile = Path(__file__).resolve().parent
resources = thisfile / 'res... | 787 | 20.888889 | 61 | py |
kraken | kraken-main/tests/test_readingorder.py | # -*- coding: utf-8 -*-
import pytest
import unittest
from typing import Sequence, Tuple
import shapely.geometry as geom
import numpy as np
from kraken.lib.segmentation import is_in_region, reading_order, topsort
def polygon_slices(polygon: Sequence[Tuple[int, int]]) -> Tuple[slice, slice]:
"""Convert polygons ... | 9,952 | 45.293023 | 116 | py |
kraken | kraken-main/tests/test_pageseg.py | # -*- coding: utf-8 -*-
import unittest
from PIL import Image
from pytest import raises
from pathlib import Path
from kraken.pageseg import segment
from kraken.lib.exceptions import KrakenInputException
thisfile = Path(__file__).resolve().parent
resources = thisfile / 'resources'
class TestPageSeg(unittest.TestCase... | 1,433 | 33.142857 | 93 | py |
kraken | kraken-main/tests/test_serialization.py | # -*- coding: utf-8 -*-
import json
import unittest
import tempfile
import numpy as np
from lxml import etree
from io import StringIO
from pathlib import Path
from hocr_spec import HocrValidator
from collections import Counter
from kraken import rpred, serialization
from kraken.lib import xml
thisfile = Path(__file_... | 11,646 | 37.186885 | 164 | 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 |
kraken | kraken-main/docs/conf.py | # -*- coding: utf-8 -*-
#
# kraken documentation build configuration file, created by
# sphinx-quickstart on Fri May 22 16:51:45 2015.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# Al... | 10,222 | 30.847352 | 92 | 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/config.py | # --------------------------------------------------------
# Swin Transformer
# Copyright (c) 2021 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Written by Ze Liu
# --------------------------------------------------------'
import os
import yaml
from yacs.config import CfgNode as CN
_C = CN()
... | 7,353 | 30.973913 | 79 | 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/net_factory_3d.py | from networks.unet_3D import unet_3D
from networks.vnet import VNet
from networks.VoxResNet import VoxResNet
from networks.attention_unet import Attention_UNet
from networks.nnunet import initialize_network
def net_factory_3d(net_type="unet_3D", in_chns=1, class_num=2):
if net_type == "unet_3D":
net = une... | 933 | 37.916667 | 77 | py |
SSL4MIS | SSL4MIS-master/code/networks/net_factory.py | from networks.efficientunet import Effi_UNet
from networks.enet import ENet
from networks.pnet import PNet2D
from networks.unet import UNet, UNet_DS, UNet_URPC, UNet_CCT
import argparse
from networks.vision_transformer import SwinUnet as ViT_seg
from networks.config import get_config
from networks.nnunet import initial... | 4,746 | 46.949495 | 118 | 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/config.py | # --------------------------------------------------------
# Swin Transformer
# Copyright (c) 2021 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Written by Ze Liu
# --------------------------------------------------------'
import os
import yaml
from yacs.config import CfgNode as CN
_C = CN()
... | 7,355 | 30.982609 | 79 | 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/__init__.py | import json
from collections import OrderedDict
from augmentations.ctaugment import *
class StorableCTAugment(CTAugment):
def load_state_dict(self, state):
for k in ["decay", "depth", "th", "rates"]:
assert k in state, "{} not in {}".format(k, state.keys())
setattr(self, k, state[... | 1,560 | 23.777778 | 124 | 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/acdc_data_processing.py | import glob
import os
import h5py
import numpy as np
import SimpleITK as sitk
slice_num = 0
mask_path = sorted(glob.glob("/home/xdluo/data/ACDC/image/*.nii.gz"))
for case in mask_path:
img_itk = sitk.ReadImage(case)
origin = img_itk.GetOrigin()
spacing = img_itk.GetSpacing()
direction = img_itk.GetDir... | 1,353 | 34.631579 | 89 | 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/dataloaders/brats_proprecessing.py | import numpy as np
from PIL import Image
import matplotlib.pyplot as plt
from skimage import measure
import nibabel as nib
import SimpleITK as sitk
import glob
def brain_bbox(data, gt):
mask = (data != 0)
brain_voxels = np.where(mask != 0)
minZidx = int(np.min(brain_voxels[0]))
maxZidx = int(np.max(br... | 3,862 | 33.801802 | 88 | 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 |
SSL4MIS | SSL4MIS-master/code/utils/ramps.py | # Copyright (c) 2018, Curious AI Ltd. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain View... | 1,319 | 30.428571 | 76 | py |
SSL4MIS | SSL4MIS-master/code/utils/metrics.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2019/12/14 下午4:41
# @Author : chuyu zhang
# @File : metrics.py
# @Software: PyCharm
import numpy as np
from medpy import metric
def cal_dice(prediction, label, num=2):
total_dice = np.zeros(num-1)
for i in range(1, num):
prediction_tmp ... | 1,289 | 26.446809 | 100 | py |
ipfixcol2 | ipfixcol2-master/src/tools/pcap2flow/pcap2flow.py | #!/usr/bin/env python3
"""
Simple tool for replaying NetFlow v5/v9 and IPFIX packets to a collector.
Author(s):
Lukas Hutak <lukas.hutak@cesnet.cz>
Date: July 2019
Copyright(c) 2019 CESNET z.s.p.o.
SPDX-License-Identifier: BSD-3-Clause
"""
import argparse
import struct
from scapy.all import *
# Dictionary with... | 6,107 | 29.237624 | 111 | py |
iharm3d | iharm3d-master/prob/old_problems/mhdmodes2d/test/test.py | ################################################################################
# #
# SOD SHOCKTUBE #
# ... | 4,815 | 29.871795 | 112 | py |
iharm3d | iharm3d-master/prob/old_problems/mhdmodes2d/test/mhdmodes2d.py | ################################################################################
# #
# SOD SHOCKTUBE #
# ... | 4,670 | 28.942308 | 83 | py |
iharm3d | iharm3d-master/prob/old_problems/mhdmodes3d/test/test_3D.py | ################################################################################
# #
# SOD SHOCKTUBE #
# ... | 5,945 | 29.182741 | 143 | py |
iharm3d | iharm3d-master/prob/old_problems/mhdmodes3d/test/mhdmodes3d.py | ################################################################################
# #
# SOD SHOCKTUBE #
# ... | 5,017 | 29.785276 | 112 | py |
iharm3d | iharm3d-master/prob/old_problems/mhdmodes3d/test/test_faux2D.py | ################################################################################
# #
# SOD SHOCKTUBE #
# ... | 6,783 | 29.285714 | 145 | py |
iharm3d | iharm3d-master/prob/old_problems/mhdmodes1d/test/test.py | ################################################################################
# #
# SOD SHOCKTUBE #
# ... | 4,145 | 28.404255 | 101 | py |
iharm3d | iharm3d-master/prob/old_problems/mhdmodes1d/test/mhdmodes1d.py | ################################################################################
# #
# SOD SHOCKTUBE #
# ... | 4,422 | 28.885135 | 80 | py |
iharm3d | iharm3d-master/script/test/convergence/plot_convergence_bondi.py | ################################################################################
# #
# BONDI INFLOW CONVERGENCE PLOTS #
# ... | 1,796 | 25.820896 | 80 | py |
iharm3d | iharm3d-master/script/test/convergence/plot_convergence_modes.py | ################################################################################
# #
# MHD MODES CONVERGENCE PLOTS #
# ... | 3,453 | 26.412698 | 80 | py |
iharm3d | iharm3d-master/script/analysis/eht_plot.py | ################################################################################
# #
# PLOTS OF VARIABLES COMPUTED IN eht_analysis.py #
# ... | 22,053 | 31.101892 | 147 | py |
iharm3d | iharm3d-master/script/analysis/plot_diff.py | ################################################################################
# #
# PLOT DIFFERENCES IN TWO FILES #
# ... | 3,051 | 32.911111 | 150 | py |
iharm3d | iharm3d-master/script/analysis/eht_analysis.py | ################################################################################
# #
# CALCULATE TIME-DEPENDENT AND TIME-AVERAGED QUANTITIES #
# ... | 14,716 | 37.225974 | 143 | py |
iharm3d | iharm3d-master/script/analysis/analysis_fns.py |
# Convenient analysis functions for physical calculations and averages
# Meant to be imported "from analysis_fns import *" for convenience
import numpy as np
import scipy.fftpack as fft
# Define a dict of names, coupled with the functions required to obtain their variables.
# That way, we only need to specify lists ... | 15,889 | 33.393939 | 155 | py |
iharm3d | iharm3d-master/script/analysis/units.py | ## Handle adding units to quantities. Work in progress
import numpy as np
cgs = {
'CL' : 2.99792458e10,
'QE' : 4.80320680e-10,
'ME' : 9.1093826e-28,
'MP' : 1.67262171e-24,
'MN' : 1.67492728e-24,
'HPL' : 6.6260693e-27,
'HBAR' : 1.0545717e-27,
'KBOL' : 1.3806505e-16,
'GNEWT' : 6.6742e-8,
'SIG' : 5.670400e-5,
'AR' : 7.... | 1,325 | 23.555556 | 71 | py |
iharm3d | iharm3d-master/script/analysis/defs.py | # Definitions of enums and slices used throughout the code
from enum import Enum
class Met(Enum):
"""Enum of the metrics/coordinate systems supported by HARM"""
MINKOWSKI = 0
MKS = 1
#MMKS = 2 # TODO put back support?
FMKS = 3
# Exotic metrics from KORAL et al
EKS = 4
MKS3 = 5
# F... | 3,601 | 29.525424 | 114 | py |
iharm3d | iharm3d-master/script/analysis/movie.py | ################################################################################
# #
# GENERATE MOVIES FROM SIMULATION OUTPUT #
# ... | 16,449 | 46.40634 | 163 | py |
iharm3d | iharm3d-master/script/analysis/movie_compare.py | ################################################################################
# #
# GENERATE MOVIES COMPARING 2 SIMULATIONS' OUTPUT #
# ... | 5,780 | 34.466258 | 96 | py |
iharm3d | iharm3d-master/script/analysis/quick_plot.py | ################################################################################
# #
# PLOT ONE PRIMITIVE #
# ... | 6,425 | 37.023669 | 184 | py |
iharm3d | iharm3d-master/script/analysis/luminosity_th_study.py | #!/usr/bin/env python3
import os, sys
import pickle
import numpy as np
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
from matplotlib.ticker import FuncFormatter
import util
import hdf5_to_dict as io
import plot as bplt
from analysis_fns import *
from defs import Met, Loci
from coordinates ... | 9,874 | 42.888889 | 148 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.