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 |
|---|---|---|---|---|---|---|
fusion-dance | fusion-dance-main/utils/data.py | import torch
import torch.nn as nn
from torchvision import transforms
import numpy as np
import pandas as pd
import joblib
import random
from PIL import Image
import os
class ConditioningLabelsHandler:
"""
A class to handle conditioning information for certain models.
If a single column is given, each ca... | 26,203 | 36.976812 | 123 | py |
fusion-dance | fusion-dance-main/utils/graphics.py | import torch
import torch.nn as nn
from torchvision import transforms
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import animation
from matplotlib import colors
from PIL import Image
from tqdm import tqdm
import os
def make_grid(images, height, width, fig=None, axis=None):
if fig is None... | 4,252 | 32.226563 | 87 | py |
negev | negev-main/main_wsol.py | import datetime as dt
import sys
from copy import deepcopy
# from torch.nn.parallel import DistributedDataParallel as DDP
import torch.distributed as dist
from torch.utils.data.distributed import DistributedSampler
from dlib.parallel import MyDDP as DDP
from dlib.process.parseit import parse_input
from dlib.process.... | 4,421 | 29.496552 | 76 | py |
negev | negev-main/eval.py | import datetime as dt
from os.path import join
import torch.cuda
from dlib.process.parseit import parse_input
from dlib.utils.shared import fmsg
from dlib.utils.tools import log_device
from dlib.utils.tools import log_args
from dlib.utils.tools import save_model
from dlib.utils.tools import get_best_epoch
from dl... | 3,873 | 30.754098 | 79 | py |
negev | negev-main/dlib/__init__.py | import sys
from os.path import dirname, abspath
root_dir = dirname(dirname(abspath(__file__)))
sys.path.append(root_dir)
from dlib.stdcl import STDClassifier
from dlib.stdcl import MaxMinClassifier
from dlib.unet import Unet
from dlib.unet import UnetFCAM
from dlib.unet import UnetNEGEV
from dlib.unetplusplus import... | 2,597 | 27.549451 | 80 | py |
negev | negev-main/dlib/pan/model.py | import sys
from os.path import dirname, abspath
from typing import Optional, Union
root_dir = dirname(dirname(dirname(abspath(__file__))))
sys.path.append(root_dir)
from dlib.pan.decoder import PANDecoder
from dlib.encoders import get_encoder
from dlib.base import SegmentationModel
from dlib.base import SegmentationH... | 4,156 | 34.836207 | 79 | py |
negev | negev-main/dlib/pan/decoder.py | import torch
import torch.nn as nn
import torch.nn.functional as F
class ConvBnRelu(nn.Module):
def __init__(
self,
in_channels: int,
out_channels: int,
kernel_size: int,
stride: int = 1,
padding: int = 0,
dilation: int = 1,
... | 6,132 | 31.449735 | 78 | py |
negev | negev-main/dlib/cams/core.py | import sys
from os.path import dirname, abspath
from typing import Optional, Union, List, Tuple
from functools import partial
import torch
from torch import Tensor
from torch import nn
import torch.nn.functional as F
root_dir = dirname(dirname(dirname(abspath(__file__))))
sys.path.append(root_dir)
import dlib
from ... | 9,289 | 32.781818 | 104 | py |
negev | negev-main/dlib/cams/builtincam.py | import sys
from os.path import dirname, abspath
from typing import Optional, Union, List, Tuple
from functools import partial
import torch
from torch import Tensor
from torch import nn
import torch.nn.functional as F
# from torch.nn.parallel import DistributedDataParallel as DDP
root_dir = dirname(dirname(dirname(ab... | 21,335 | 32.07907 | 104 | py |
negev | negev-main/dlib/cams/seeds_eval.py | from copy import deepcopy
import sys
from os.path import dirname, abspath
import torch
import torch.nn.functional as F
import torch.nn as nn
from kornia.morphology import dilation
root_dir = dirname(dirname(dirname(abspath(__file__))))
sys.path.append(root_dir)
__all__ = ['AccSeeds',
'AccSeedsmeter',
... | 6,135 | 28.358852 | 80 | py |
negev | negev-main/dlib/cams/selflearning.py | import operator
import sys
import os
from os.path import dirname, abspath
import time
from typing import Callable, Tuple
import torch
import torch.nn.functional as F
import torch.nn as nn
import numpy as np
from skimage.util.dtype import dtype_range
from kornia.morphology import dilation
from kornia.morphology import... | 40,467 | 28.113669 | 80 | py |
negev | negev-main/dlib/cams/gradcam.py | # Copyright (C) 2020-2021, François-Guillaume Fernandez.
# This program is licensed under the Apache License version 2.
# See LICENSE or go to <https://www.apache.org/licenses/LICENSE-2.0.txt> for
# full license details.
import sys
from os.path import dirname, abspath, join
import torch
from torch import Tensor
from... | 21,738 | 33.894061 | 85 | py |
negev | negev-main/dlib/cams/normalizers.py | import sys
from os.path import dirname, abspath
import torch
import torch.nn.functional as F
import torch.nn as nn
root_dir = dirname(dirname(dirname(abspath(__file__))))
sys.path.append(root_dir)
__all__ = ['CamStandardizer']
class CamStandardizer(nn.Module):
def __init__(self, w=5., a=-1., b=1.):
su... | 1,854 | 21.621951 | 66 | py |
negev | negev-main/dlib/cams/cam.py | # Copyright (C) 2020-2021, François-Guillaume Fernandez.
# This program is licensed under the Apache License version 2.
# See LICENSE or go to <https://www.apache.org/licenses/LICENSE-2.0.txt> for full license details.
import math
import sys
from os.path import dirname, abspath, join
import torch
from torch import T... | 23,322 | 34.66208 | 113 | py |
negev | negev-main/dlib/unetplusplus/model.py | import sys
from os.path import dirname, abspath
from typing import Optional, Union, List
root_dir = dirname(dirname(dirname(abspath(__file__))))
sys.path.append(root_dir)
from dlib.unetplusplus.decoder import UnetPlusPlusDecoder
from dlib.encoders import get_encoder
from dlib.base import SegmentationModel
from dlib.b... | 5,076 | 39.616 | 79 | py |
negev | negev-main/dlib/unetplusplus/decoder.py | import sys
from os.path import dirname, abspath
import torch
import torch.nn as nn
import torch.nn.functional as F
root_dir = dirname(dirname(dirname(abspath(__file__))))
sys.path.append(root_dir)
from dlib.base import modules as md
class DecoderBlock(nn.Module):
def __init__(
self,
in_... | 5,513 | 35.276316 | 120 | py |
negev | negev-main/dlib/manet/model.py | import sys
from os.path import dirname, abspath
from typing import Optional, Union, List
root_dir = dirname(dirname(dirname(abspath(__file__))))
sys.path.append(root_dir)
from dlib.manet.decoder import MAnetDecoder
from dlib.encoders import get_encoder
from dlib.base import SegmentationModel
from dlib.base import Seg... | 4,954 | 38.959677 | 80 | py |
negev | negev-main/dlib/manet/decoder.py | import sys
from os.path import dirname, abspath
import torch
import torch.nn as nn
import torch.nn.functional as F
root_dir = dirname(dirname(dirname(abspath(__file__))))
sys.path.append(root_dir)
from dlib.base import modules as md
class PAB(nn.Module):
def __init__(self, in_channels, out_channels, pab_channe... | 6,825 | 31.817308 | 91 | py |
negev | negev-main/dlib/routines/debug_cp_best_models.py | import sys
from os.path import dirname, abspath, join
import os
import subprocess
import matplotlib.pyplot as plt
import torch
from matplotlib.ticker import MaxNLocator
import pickle as pkl
root_dir = dirname(dirname(dirname(abspath(__file__))))
sys.path.append(root_dir)
from dlib.utils.shared import find_files_patt... | 960 | 27.264706 | 78 | py |
negev | negev-main/dlib/routines/fast_eval.py | import sys
from os.path import dirname, abspath, join
import matplotlib.pyplot as plt
import torch
from matplotlib.ticker import MaxNLocator
import pickle as pkl
root_dir = dirname(dirname(dirname(abspath(__file__))))
sys.path.append(root_dir)
from dlib.cams import AccSeeds
from dlib.cams import AccSeedsmeter
from d... | 3,687 | 36.252525 | 76 | py |
negev | negev-main/dlib/process/prologues_old.py | import os
import sys
from os.path import join, dirname, expanduser, abspath
import subprocess
from copy import deepcopy
import datetime as dt
import shutil
import random
import pickle as pkl
import warnings
import yaml
import torch
from torch.utils.data import DataLoader
root_dir = dirname(dirname(dirname(abspath(__f... | 36,002 | 33.386819 | 80 | py |
negev | negev-main/dlib/process/instantiators.py | import warnings
import sys
import os
from os.path import dirname, abspath, join, basename
from copy import deepcopy
import torch
import torch.nn as nn
from torch.optim import SGD
from torch.optim import Adam
import torch.optim.lr_scheduler as lr_scheduler
root_dir = dirname(dirname(dirname(abspath(__file__))))
sys.pa... | 35,435 | 35.835759 | 80 | py |
negev | negev-main/dlib/process/parseit.py | # Sel-contained-as-possible module handles parsing the input using argparse.
# handles seed, and initializes some modules for reproducibility.
import os
from os.path import dirname, abspath, join, basename, expanduser, normpath
import sys
import argparse
from copy import deepcopy
import warnings
import subprocess
impo... | 45,364 | 42.620192 | 80 | py |
negev | negev-main/dlib/pspnet/model.py | import sys
from os.path import dirname, abspath
from typing import Optional, Union
root_dir = dirname(dirname(dirname(abspath(__file__))))
sys.path.append(root_dir)
from dlib.pspnet.decoder import PSPDecoder
from dlib.encoders import get_encoder
from dlib.base import SegmentationModel
from dlib.base import Segmentat... | 4,840 | 37.728 | 79 | py |
negev | negev-main/dlib/pspnet/decoder.py | import sys
from os.path import dirname, abspath
import torch
import torch.nn as nn
import torch.nn.functional as F
root_dir = dirname(dirname(dirname(abspath(__file__))))
sys.path.append(root_dir)
from dlib.base import modules
class PSPBlock(nn.Module):
def __init__(self, in_channels, out_channels, pool_size,... | 2,179 | 25.26506 | 79 | py |
negev | negev-main/dlib/poolings/mil.py | import sys
from os.path import dirname, abspath
import torch
import torch.nn as nn
root_dir = dirname(dirname(dirname(abspath(__file__))))
sys.path.append(root_dir)
from dlib.configure import constants
from dlib.poolings.core import _BasicPooler
class _Attention(nn.Module):
def __init__(self,
... | 4,582 | 29.966216 | 80 | py |
negev | negev-main/dlib/poolings/core.py | import sys
from os.path import dirname, abspath
import re
import torch.nn as nn
import torch
import torch.nn.functional as F
root_dir = dirname(dirname(dirname(abspath(__file__))))
sys.path.append(root_dir)
__all__ = ['GAP', 'WGAP', 'MaxPool', 'LogSumExpPool']
class _BasicPooler(nn.Module):
def __init__(self,
... | 5,900 | 27.785366 | 78 | py |
negev | negev-main/dlib/poolings/wildcat.py | import sys
from os.path import dirname, abspath
import torch
import torch.nn as nn
root_dir = dirname(dirname(dirname(abspath(__file__))))
sys.path.append(root_dir)
from dlib.configure import constants
from dlib.poolings.core import _BasicPooler
__all__ = ['WildCatCLHead']
class _WildCatPoolDecision(nn.Module):... | 6,635 | 31.370732 | 79 | py |
negev | negev-main/dlib/stdcl/classifier.py | import sys
from os.path import dirname, abspath
from typing import Optional, Union, List
import torch
from torch.cuda.amp import autocast
root_dir = dirname(dirname(dirname(abspath(__file__))))
sys.path.append(root_dir)
from dlib.encoders import get_encoder
from dlib.base import STDClModel
from dlib import poolings... | 5,239 | 31.345679 | 78 | py |
negev | negev-main/dlib/stdcl/maxmin_classifier.py | import sys
from os.path import dirname, abspath
from typing import Optional, Union, List
import torch
from torch.cuda.amp import autocast
from torch.nn import functional as F
root_dir = dirname(dirname(dirname(abspath(__file__))))
sys.path.append(root_dir)
from dlib.encoders import get_encoder
from dlib.base import ... | 10,169 | 32.787375 | 80 | py |
negev | negev-main/dlib/learning/lr_scheduler.py | import math
import torch.optim.lr_scheduler as lr_scheduler
class MyStepLR(lr_scheduler.StepLR):
"""
Override: https://pytorch.org/docs/1.0.0/_modules/torch/optim/lr_scheduler.html#StepLR
Reason: we want to fix the learning rate to not get lower than some value:
min_lr.
Sets the learning rate of... | 3,353 | 34.305263 | 90 | py |
negev | negev-main/dlib/learning/inference_wsol.py | import copy
import random
import time
from pathlib import Path
import subprocess
from os.path import normpath
import kornia.morphology
import numpy as np
import os
import sys
from os.path import dirname, abspath, join
import datetime as dt
import pickle as pkl
from typing import Tuple
import torch
from torch.utils.da... | 40,683 | 39.003933 | 81 | py |
negev | negev-main/dlib/learning/train_wsol.py | import os
import sys
import time
from os.path import dirname, abspath, join
from typing import Optional, Union, Tuple
from copy import deepcopy
import pickle as pkl
import math
import datetime as dt
import numpy as np
import torch
from tqdm import tqdm as tqdm
import matplotlib.pyplot as plt
from matplotlib.ticker im... | 58,706 | 37.395683 | 80 | py |
negev | negev-main/dlib/learning/train.py | import os
import sys
from os.path import dirname, abspath, join
from copy import deepcopy
import pickle as pkl
import subprocess
import math
from texttable import Texttable
import numpy as np
import torch
from tqdm import tqdm as tqdm
from PIL import Image
import matplotlib.pyplot as plt
from matplotlib.ticker import... | 39,298 | 32.791058 | 81 | py |
negev | negev-main/dlib/div_classifiers/core.py | import os
import torch
import torch.nn as nn
from torch.utils.model_zoo import load_url
import sys
from os.path import dirname, abspath, join
root_dir = dirname(dirname(dirname(abspath(__file__))))
sys.path.append(root_dir)
from dlib.configure import constants
from dlib.utils.shared import count_params
import torch... | 2,042 | 23.914634 | 78 | py |
negev | negev-main/dlib/div_classifiers/inception.py | """
Original code: https://github.com/pytorch/vision/blob/master/torchvision/models/inception.py
"""
import os
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.model_zoo import load_url
import sys
from os.path import dirname, abspath, join
root_dir = dirname(dirname(dirname(abspath... | 26,248 | 34.045394 | 92 | py |
negev | negev-main/dlib/div_classifiers/resnet.py | """
Original code: https://github.com/pytorch/vision/blob/master/torchvision/models/resnet.py
"""
import sys
from os.path import dirname, abspath, join
import os
import torch
import torch.nn as nn
from torch.utils.model_zoo import load_url
import torch.nn.functional as F
root_dir = dirname(dirname(dirname(abspath(__... | 25,656 | 33.671622 | 89 | py |
negev | negev-main/dlib/div_classifiers/vgg.py | """
Original code: https://github.com/pytorch/vision/blob/master/torchvision/models/vgg.py
"""
import os
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.model_zoo import load_url
import sys
from os.path import dirname, abspath, join
root_dir = dirname(dirname(dirname(abspath(__fi... | 20,103 | 33.60241 | 86 | py |
negev | negev-main/dlib/div_classifiers/util.py | """
Copyright (c) 2020-present NAVER Corp.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distri... | 2,416 | 38.622951 | 80 | py |
negev | negev-main/dlib/div_classifiers/parts/acol.py | """
Original repository: https://github.com/xiaomengyc/ACoL
"""
import sys
from os.path import dirname, abspath, join
root_dir = dirname(dirname(dirname(dirname(abspath(__file__)))))
sys.path.append(root_dir)
import torch
import torch.nn as nn
from dlib.div_classifiers.parts.util import get_attention
__all__ = ['Ac... | 1,757 | 34.16 | 80 | py |
negev | negev-main/dlib/div_classifiers/parts/cutmix.py | """
Original repository: https://github.com/clovaai/CutMix-PyTorch
"""
import numpy as np
import torch
__all__ = ['cutmix']
def cutmix(x, target, beta):
lam = np.random.beta(beta, beta)
rand_index = torch.randperm(x.size()[0]).cuda()
target_a = target.clone().detach()
target_b = target[rand_index].... | 999 | 23.390244 | 77 | py |
negev | negev-main/dlib/div_classifiers/parts/adl.py | """
Original repository: https://github.com/junsukchoe/ADL
"""
import torch
import torch.nn as nn
__all__ = ['ADL']
class ADL(nn.Module):
def __init__(self, adl_drop_rate=0.75, adl_drop_threshold=0.8):
super(ADL, self).__init__()
if not (0 <= adl_drop_rate <= 1):
raise ValueError("Dr... | 1,726 | 34.979167 | 80 | py |
negev | negev-main/dlib/div_classifiers/parts/has.py | """
Original repository: https://github.com/kkanshul/Hide-and-Seek
"""
import random
__all__ = ['has']
def has(image, grid_size, drop_rate):
"""
Args:
image: torch.Tensor, N x C x H x W, float32.
grid_size: int
drop_rate: float
Returns:
image: torch.Tensor, N x C x H x W,... | 806 | 25.032258 | 62 | py |
negev | negev-main/dlib/div_classifiers/parts/util.py | """
Copyright (c) 2020-present NAVER Corp.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distri... | 1,796 | 40.790698 | 80 | py |
negev | negev-main/dlib/div_classifiers/parts/__init__.py | import sys
from os.path import dirname, abspath, join
import functools
import torch.utils.model_zoo as model_zoo
root_dir = dirname(dirname(dirname(dirname(abspath(__file__)))))
sys.path.append(root_dir)
from dlib.div_classifiers.parts.has import has
from dlib.div_classifiers.parts.acol import AcolBase
from dlib.di... | 527 | 30.058824 | 64 | py |
negev | negev-main/dlib/div_classifiers/parts/spg.py | """
Original repository: https://github.com/xiaomengyc/SPG
"""
import torch
import torch.nn as nn
from .util import get_attention
__all__ = ['spg']
def compute_attention(feat_map, labels, logits_b1, logits_b2):
upsample_module = nn.Upsample(size=(224, 224), mode='bilinear')
attention = get_attention(upsamp... | 2,894 | 31.897727 | 75 | py |
negev | negev-main/dlib/metrics/base.py | import sys
from os.path import dirname, abspath
import torch
root_dir = dirname(dirname(dirname(abspath(__file__))))
sys.path.append(root_dir)
from dlib.losses import base
from dlib.functional import core as F
from dlib.base.modules import Activation
__all__ = [
'IoU',
'Fscore',
'Accuracy',
'Recall... | 3,725 | 27.015038 | 76 | py |
negev | negev-main/dlib/metrics/average.py | import sys
from os.path import dirname, abspath
import torch
root_dir = dirname(dirname(dirname(abspath(__file__))))
sys.path.append(root_dir)
from dlib.metrics import base
from dlib.losses.base import Metric
from dlib.utils.reproducibility import set_seed
class MeanMetric(Metric):
def __init__(self, ignore_c... | 2,616 | 25.434343 | 79 | py |
negev | negev-main/dlib/metrics/wsol_metrics.py | import os
import time
from copy import deepcopy
import sys
from os.path import dirname, abspath, join
import threading
from copy import deepcopy
from typing import Optional, Union, Tuple
import cv2
import numpy as np
import torch.utils.data as torchdata
import torch
root_dir = dirname(dirname(dirname(abspath(__file_... | 18,829 | 34.461394 | 80 | py |
negev | negev-main/dlib/parallel/my_ddp.py | import sys
from os.path import dirname, abspath
from torch.nn.parallel import DistributedDataParallel as DDP
root_dir = dirname(dirname(dirname(abspath(__file__))))
sys.path.append(root_dir)
__all__ = ['MyDDP']
class MyDDP(DDP):
def __getattr__(self, name):
try:
return super().__getattr__(... | 404 | 19.25 | 60 | py |
negev | negev-main/dlib/parallel/__init__.py | import sys
from os.path import dirname, abspath
from typing import Union
import torch
import torch.distributed as dist
root_dir = dirname(dirname(dirname(abspath(__file__))))
sys.path.append(root_dir)
from dlib.parallel.my_ddp import MyDDP
def sync_tensor_across_gpus(t: Union[torch.Tensor, None]
... | 665 | 26.75 | 59 | py |
negev | negev-main/dlib/datasets/tools.py | import sys
import os
from os.path import dirname, abspath, join
import csv
import yaml
from torchvision import transforms
from torch.utils.data import DataLoader
root_dir = dirname(dirname(dirname(abspath(__file__))))
sys.path.append(root_dir)
from dlib.datasets import transforms as extended_transforms
from dlib.da... | 16,142 | 34.246725 | 82 | py |
negev | negev-main/dlib/datasets/wsol_loader.py | import sys
from os.path import join, dirname, abspath
import random
from typing import Tuple
import numbers
from collections.abc import Sequence
from torch import Tensor
import torch
import munch
import numpy as np
import os
from PIL import Image
from torch.utils.data import DataLoader
from torch.utils.data import Dat... | 16,875 | 33.024194 | 80 | py |
negev | negev-main/dlib/datasets/loader.py | import os
import sys
from os.path import join, dirname, abspath
import collections
import copy
import warnings
import datetime as dt
from PIL import Image
import numpy as np
import tqdm
import pickle as pkl
from PIL import ImageEnhance
import torchvision.transforms.functional as TF
from torchvision import transforms... | 73,856 | 40.492697 | 81 | py |
negev | negev-main/dlib/datasets/transforms.py | """
Customized transforms.
Reference: https://github.com/NVIDIA/semantic-segmentation/blob/
5cdce2c7b349b4ae740d363eb7d934a4473dbc04/transforms/transforms.py
"""
"""
Standard Transform
"""
import random
import numpy as np
from skimage.filters import gaussian
from skimage.restoration import denoise_bilateral
from... | 13,876 | 29.769401 | 80 | py |
negev | negev-main/dlib/crf/dense_crf_loss.py | import sys
import os
import time
from os.path import dirname, abspath, join
import datetime as dt
import numpy as np
import torch
import torch.nn as nn
from torch.autograd import Function
from torch.autograd import Variable
import torch.nn.functional as F
from torch.cuda.amp import custom_fwd
from torch.cuda.amp impo... | 6,519 | 30.960784 | 80 | py |
negev | negev-main/dlib/crf/color_dense_crf_loss.py | import sys
import os
import time
from os.path import dirname, abspath, join
import datetime as dt
import numpy as np
import torch
import torch.nn as nn
from torch.autograd import Function
from torch.autograd import Variable
import torch.nn.functional as F
from torch.cuda.amp import custom_fwd
from torch.cuda.amp impo... | 6,381 | 30.91 | 79 | py |
negev | negev-main/dlib/crf/PAM_cuda/setup.py | from setuptools import setup
from torch.utils.cpp_extension import BuildExtension, CUDAExtension
setup(
name='extensions',
ext_modules=[
CUDAExtension('HT_opp', [
'cuda_opps/HT.cpp',
'cuda_opps/HT_kernel.cu',
]),
],
cmdclass={
'build_ext': BuildExtension
... | 328 | 19.5625 | 67 | py |
negev | negev-main/dlib/crf/PAM_cuda/pl.py | import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import torch
import HT_opp
import numpy as np
def _simple_hash(key, hash_vector, table_size):
res = (key*hash_vector).sum(dim=1)
return (res%table_size).type(torch.cuda.IntTensor)
class PermutohedralLattice(torch.autograd.Functi... | 20,544 | 33.822034 | 110 | py |
negev | negev-main/dlib/crf/PAM_cuda/PAM.py | import torch.nn as nn
import torch.nn.functional as F
import torch
from pl import PermutohedralLattice as pl
class PAM(nn.Module):
def __init__(self, in_f, filt_f, out_f, n_split):
super(PAM, self).__init__()
self.in_f = in_f
self.filt_f = filt_f
self.out_f = out_f
self.n_s... | 1,804 | 45.282051 | 104 | py |
negev | negev-main/dlib/visualization/vision.py | import os
import sys
from os.path import dirname, abspath, join
from PIL import Image, ImageDraw, ImageFont
import PIL
import matplotlib as mlp
import matplotlib.pyplot as plt
import numpy as np
import torch
from matplotlib.colors import ListedColormap
root_dir = dirname(dirname(dirname(abspath(__file__))))
sys.path... | 38,154 | 32.70583 | 80 | py |
negev | negev-main/dlib/encoders/inceptionv4.py | """ Each encoder should have following attributes and methods and be inherited
from `_base.EncoderMixin`
Attributes:
_out_channels (list of int): specify number of channels for each encoder
feature tensor
_depth (int): specify number of stages in decoder (in other words number of
downsampling operatio... | 3,665 | 32.633028 | 79 | py |
negev | negev-main/dlib/encoders/timm_resnest.py | import sys
from os.path import dirname, abspath
from timm.models.resnet import ResNet
from timm.models.resnest import ResNestBottleneck
import torch.nn as nn
root_dir = dirname(dirname(dirname(abspath(__file__))))
sys.path.append(root_dir)
from dlib.encoders._base import EncoderMixin
class ResNestEncoder(ResNet, E... | 7,477 | 33.62037 | 139 | py |
negev | negev-main/dlib/encoders/timm_sknet.py | import sys
from os.path import dirname, abspath
from timm.models.resnet import ResNet
from timm.models.sknet import SelectiveKernelBottleneck, SelectiveKernelBasic
import torch.nn as nn
root_dir = dirname(dirname(dirname(abspath(__file__))))
sys.path.append(root_dir)
from dlib.encoders._base import EncoderMixin
cl... | 3,585 | 31.306306 | 131 | py |
negev | negev-main/dlib/encoders/inceptionresnetv2.py | """ Each encoder should have following attributes and methods and be inherited
from `_base.EncoderMixin`
Attributes:
_out_channels (list of int): specify number of channels for each encoder
feature tensor
_depth (int): specify number of stages in decoder (in other words number of
downsampling operatio... | 3,720 | 33.137615 | 79 | py |
negev | negev-main/dlib/encoders/efficientnet.py | """ Each encoder should have following attributes and methods and be inherited
from `_base.EncoderMixin`
Attributes:
_out_channels (list of int): specify number of channels for each encoder
feature tensor
_depth (int): specify number of stages in decoder (in other words number of
downsampling operatio... | 6,599 | 32.333333 | 87 | py |
negev | negev-main/dlib/encoders/_utils.py | import torch
import torch.nn as nn
def patch_first_conv(model, in_channels):
"""Change first convolution layer input channels.
In case:
in_channels == 1 or in_channels == 2 -> reuse original weights
in_channels > 3 -> make random kaiming normal initialization
"""
# get first conv
... | 1,515 | 28.72549 | 80 | py |
negev | negev-main/dlib/encoders/resnet.py | """ Each encoder should have following attributes and methods and be inherited
from `_base.EncoderMixin`
Attributes:
_out_channels (list of int): specify number of channels for each encoder
feature tensor
_depth (int): specify number of stages in decoder (in other words number of
downsampling operatio... | 16,533 | 35.824053 | 134 | py |
negev | negev-main/dlib/encoders/vgg.py | """ Each encoder should have following attributes and methods and be inherited
from `_base.EncoderMixin`
Attributes:
_out_channels (list of int): specify number of channels for each encoder
feature tensor
_depth (int): specify number of stages in decoder (in other words number
of downsampling operatio... | 9,043 | 32.128205 | 113 | py |
negev | negev-main/dlib/encoders/densenet.py | """ Each encoder should have following attributes and methods and be
inherited from `_base.EncoderMixin`
Attributes:
_out_channels (list of int): specify number of channels for each encoder
feature tensor
_depth (int): specify number of stages in decoder (in other words number of
downsampling operatio... | 5,462 | 31.909639 | 108 | py |
negev | negev-main/dlib/encoders/senet.py | """ Each encoder should have following attributes and methods and be inherited
from `_base.EncoderMixin`
Attributes:
_out_channels (list of int): specify number of channels for each encoder
feature tensor
_depth (int): specify number of stages in decoder (in other words number of
downsampling operati... | 5,889 | 29.837696 | 79 | py |
negev | negev-main/dlib/encoders/_base.py | from os.path import dirname, abspath
import sys
import torch
import torch.nn as nn
from typing import List
from collections import OrderedDict
root_dir = dirname(dirname(dirname(abspath(__file__))))
sys.path.append(root_dir)
from dlib.encoders import _utils as utils
class EncoderMixin:
"""Add encoder function... | 1,639 | 27.77193 | 80 | py |
negev | negev-main/dlib/encoders/timm_efficientnet.py | import sys
from os.path import dirname, abspath
import torch
import torch.nn as nn
from timm.models.efficientnet import EfficientNet
from timm.models.efficientnet import decode_arch_def, round_channels, default_cfgs
from timm.models.layers.activations import Swish
root_dir = dirname(dirname(dirname(abspath(__file__)... | 13,792 | 33.225806 | 110 | py |
negev | negev-main/dlib/encoders/__init__.py | import sys
from os.path import dirname, abspath, join
import functools
import torch.utils.model_zoo as model_zoo
root_dir = dirname(dirname(dirname(abspath(__file__))))
sys.path.append(root_dir)
from dlib.configure import constants
from dlib.utils.shared import is_cc
from dlib.encoders.resnet import resnet_encoders... | 3,982 | 35.541284 | 83 | py |
negev | negev-main/dlib/encoders/xception.py | import sys
from os.path import dirname, abspath
import re
import torch.nn as nn
from pretrainedmodels.models.xception import pretrained_settings
from pretrainedmodels.models.xception import Xception
root_dir = dirname(dirname(dirname(abspath(__file__))))
sys.path.append(root_dir)
from dlib.encoders._base import Enc... | 2,136 | 27.118421 | 80 | py |
negev | negev-main/dlib/encoders/mobilenet.py | """ Each encoder should have following attributes and methods and be inherited
from `_base.EncoderMixin`
Attributes:
_out_channels (list of int): specify number of channels for each encoder
feature tensor
_depth (int): specify number of stages in decoder (in other words number of
downsampling operatio... | 3,065 | 29.969697 | 87 | py |
negev | negev-main/dlib/encoders/dpn.py | """ Each encoder should have following attributes and methods and be inherited
from `_base.EncoderMixin`
Attributes:
_out_channels (list of int): specify number of channels for each encoder
feature tensor
_depth (int): specify number of stages in decoder (in other words number of
downsampling operati... | 6,098 | 31.269841 | 79 | py |
negev | negev-main/dlib/encoders/timm_res2net.py | import sys
from os.path import dirname, abspath
from timm.models.resnet import ResNet
from timm.models.res2net import Bottle2neck
import torch.nn as nn
root_dir = dirname(dirname(dirname(abspath(__file__))))
sys.path.append(root_dir)
from dlib.encoders._base import EncoderMixin
class Res2NetEncoder(ResNet, Encoder... | 5,740 | 32.573099 | 134 | py |
negev | negev-main/dlib/encoders/timm_regnet.py |
import sys
from os.path import dirname, abspath
from timm.models.regnet import RegNet
import torch.nn as nn
root_dir = dirname(dirname(dirname(abspath(__file__))))
sys.path.append(root_dir)
from dlib.encoders._base import EncoderMixin
class RegNetEncoder(RegNet, EncoderMixin):
def __init__(self, out_channels,... | 13,099 | 37.304094 | 130 | py |
negev | negev-main/dlib/encoders/inceptionv3.py | """ Each encoder should have following attributes and methods and be inherited
from `_base.EncoderMixin`
Attributes:
_out_channels (list of int): specify number of channels for each encoder
feature tensor
_depth (int): specify number of stages in decoder (in other words number of
downsampling operatio... | 4,219 | 30.969697 | 79 | py |
negev | negev-main/dlib/encoders/wsol_backbones/inceptionv3.py | import sys
from os.path import dirname, abspath
root_dir = dirname(dirname(dirname(dirname(abspath(__file__)))))
sys.path.append(root_dir)
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.model_zoo as model_zoo
__all__ = ['InceptionV3']
'https://github.com/clovaai/wsolevaluatio... | 12,558 | 35.08908 | 94 | py |
negev | negev-main/dlib/base/modules.py | import torch
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,
... | 3,595 | 26.661538 | 76 | py |
negev | negev-main/dlib/base/model.py | import sys
from os.path import dirname, abspath
import datetime as dt
import torch
import torch.nn.functional as F
root_dir = dirname(dirname(dirname(abspath(__file__))))
sys.path.append(root_dir)
from dlib.base import initialization as init
from dlib.utils.shared import count_params
class STDClModel(torch.nn.Modu... | 8,614 | 28.604811 | 79 | py |
negev | negev-main/dlib/base/heads.py | import sys
from os.path import dirname, abspath
import torch.nn as nn
root_dir = dirname(dirname(dirname(abspath(__file__))))
sys.path.append(root_dir)
from dlib.base.modules import Flatten, Activation
from dlib.configure import constants
class SegmentationHead(nn.Sequential):
def __init__(self,
... | 2,314 | 33.552239 | 87 | py |
negev | negev-main/dlib/base/initialization.py | import torch.nn as nn
def initialize_decoder(module):
for m in module.modules():
if isinstance(m, nn.Conv2d):
nn.init.kaiming_uniform_(m.weight, mode="fan_in",
nonlinearity="relu")
if m.bias is not None:
nn.init.constant_(m.bias... | 858 | 28.62069 | 61 | py |
negev | negev-main/dlib/configure/config.py | import os
import sys
from os.path import join, dirname, abspath
import datetime as dt
import munch
root_dir = dirname(dirname(dirname(abspath(__file__))))
sys.path.append(root_dir)
from dlib.configure import constants
__all__ = ['get_config']
def mch(**kwargs):
return munch.Munch(dict(**kwargs))
def config... | 26,366 | 51.211881 | 84 | py |
negev | negev-main/dlib/linknet/model.py | import sys
from os.path import dirname, abspath
from typing import Optional, Union
root_dir = dirname(dirname(dirname(abspath(__file__))))
sys.path.append(root_dir)
from dlib.linknet.decoder import LinknetDecoder
from dlib.base import SegmentationHead, SegmentationModel, ClassificationHead
from dlib.encoders import g... | 4,428 | 37.850877 | 79 | py |
negev | negev-main/dlib/linknet/decoder.py | import sys
from os.path import dirname, abspath
import torch.nn as nn
root_dir = dirname(dirname(dirname(abspath(__file__))))
sys.path.append(root_dir)
from dlib.base import modules
class TransposeX2(nn.Sequential):
def __init__(self, in_channels, out_channels, use_batchnorm=True):
super().__init__()
... | 2,407 | 27.666667 | 77 | py |
negev | negev-main/dlib/utils/reproducibility.py | # self-contained-as-possible module.
# handles reproducibility procedures.
import random
import os
import warnings
import numpy as np
import torch
DEFAULT_SEED = 0 # the default seed.
__all__ = [
'check_if_allow_multgpu_mode',
'set_seed',
'set_default_seed',
'reset_default_seed',
'set_to_de... | 4,112 | 26.979592 | 76 | py |
negev | negev-main/dlib/utils/tools.py | import sys
from os.path import dirname, abspath, join, basename, normpath
import os
import subprocess
import glob
import shutil
import subprocess
import datetime as dt
import math
from collections.abc import Iterable
import torch
import yaml
from sklearn.metrics import auc
import numpy as np
root_dir = dirname(dirnam... | 13,554 | 30.30485 | 78 | py |
negev | negev-main/dlib/utils/shared.py | # This module shouldn't import any of our modules to avoid recursive importing.
import os
from os.path import dirname, abspath
import sys
import argparse
import textwrap
from os.path import join
import fnmatch
from pathlib import Path
import subprocess
from sklearn.metrics import auc
import torch
import numpy as np
r... | 6,653 | 26.725 | 80 | py |
negev | negev-main/dlib/utils/meter.py | import numpy as np
class Meter(object):
def reset(self):
pass
def add(self, value):
pass
@property
def value(self):
pass
class AverageValueMeter(Meter):
def __init__(self):
super(AverageValueMeter, self).__init__()
self.values = []
self.counter ... | 2,050 | 21.788889 | 83 | py |
negev | negev-main/dlib/unet/model.py | import sys
from os.path import dirname, abspath
from typing import Optional, Union, List
import torch
from torch.cuda.amp import autocast
root_dir = dirname(dirname(dirname(abspath(__file__))))
sys.path.append(root_dir)
from dlib.unet.decoder import UnetDecoder
from dlib.unet.decoder import UnetFCAMDecoder
from dlib... | 29,980 | 36.71195 | 80 | py |
negev | negev-main/dlib/unet/decoder.py | import sys
from os.path import dirname, abspath
import torch
import torch.nn as nn
import torch.nn.functional as F
root_dir = dirname(dirname(dirname(abspath(__file__))))
sys.path.append(root_dir)
from dlib.base import modules as md
class DecoderBlock(nn.Module):
def __init__(
self,
in_... | 11,977 | 28.648515 | 80 | py |
negev | negev-main/dlib/deeplabv3/model.py | import sys
from os.path import dirname, abspath
root_dir = dirname(dirname(dirname(abspath(__file__))))
sys.path.append(root_dir)
from typing import Optional
from dlib.deeplabv3.decoder import DeepLabV3Decoder, DeepLabV3PlusDecoder
from dlib.base import SegmentationModel, SegmentationHead, ClassificationHead
from dli... | 9,950 | 36.269663 | 79 | py |
negev | negev-main/dlib/deeplabv3/decoder.py | """
BSD 3-Clause License
Copyright (c) Soumith Chintala 2016,
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of con... | 7,421 | 31.552632 | 80 | py |
negev | negev-main/dlib/losses/base.py | import sys
from os.path import dirname, abspath
import re
import torch.nn as nn
root_dir = dirname(dirname(dirname(abspath(__file__))))
sys.path.append(root_dir)
from dlib.base.modules import Activation
from dlib.functional import core as F
class BaseObject(nn.Module):
def __init__(self, name=None):
s... | 3,430 | 22.662069 | 80 | py |
negev | negev-main/dlib/losses/focal.py | import sys
from os.path import dirname, abspath
from typing import Optional
from functools import partial
root_dir = dirname(dirname(dirname(abspath(__file__))))
sys.path.append(root_dir)
import torch
from torch.nn.modules.loss import _Loss
from dlib.functional._functional import focal_loss_with_logits
from dlib.co... | 3,335 | 31.705882 | 82 | py |
negev | negev-main/dlib/losses/core.py | import sys
from os.path import dirname, abspath
from typing import Optional, Union, List, Tuple
from itertools import cycle
import re
import torch.nn as nn
import torch
import torch.nn.functional as F
from torchvision.transforms.functional import rgb_to_grayscale
root_dir = dirname(dirname(dirname(abspath(__file__)))... | 30,703 | 28.075758 | 80 | py |
negev | negev-main/dlib/losses/elb.py | import sys
from os.path import dirname, abspath
import torch
import torch.nn as nn
root_dir = dirname(dirname(dirname(abspath(__file__))))
sys.path.append(root_dir)
from dlib.utils.reproducibility import set_seed
__all__ = ['ELB']
class ELB(nn.Module):
"""
Extended log-barrier loss (ELB).
Optimize ine... | 4,612 | 28.76129 | 77 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.