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 |
|---|---|---|---|---|---|---|
CV-SSL-MIS | CV-SSL-MIS-main/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 |
CV-SSL-MIS | CV-SSL-MIS-main/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 |
CV-SSL-MIS | CV-SSL-MIS-main/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 |
CV-SSL-MIS | CV-SSL-MIS-main/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 |
CV-SSL-MIS | CV-SSL-MIS-main/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 |
CV-SSL-MIS | CV-SSL-MIS-main/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 |
CV-SSL-MIS | CV-SSL-MIS-main/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,430 | 25.24898 | 103 | py |
CV-SSL-MIS | CV-SSL-MIS-main/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 |
CV-SSL-MIS | CV-SSL-MIS-main/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 |
CV-SSL-MIS | CV-SSL-MIS-main/code/dataloaders/dataset.py | import os
import cv2
import torch
import random
import math
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
im... | 14,173 | 32.2723 | 107 | py |
CV-SSL-MIS | CV-SSL-MIS-main/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
import numpy as np
# from metrics import dice_coef
# from metrics import dice
import warnings
warnings.filterwarnings("ignore")
def dice_loss(score, target):
target = target.float()
... | 13,604 | 32.264059 | 99 | py |
CV-SSL-MIS | CV-SSL-MIS-main/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,185 | 31.744 | 111 | py |
noncontrastive-ssl | noncontrastive-ssl-master/test_collapse.py | import os
import torch
import argparse
import os.path as osp
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('pretrained', type=str, help='path to simsiam pretrained checkpoint')
parser.add_argument('--type', type=str, default='svd')
parser.add_argument('--normalize', ... | 1,290 | 33.891892 | 94 | py |
noncontrastive-ssl | noncontrastive-ssl-master/main_lincls.py | #!/usr/bin/env python
# Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import argparse
import builtins
import math
import os
import random
import shutil
import time
import w... | 21,693 | 39.39851 | 120 | py |
noncontrastive-ssl | noncontrastive-ssl-master/distill.py | #!/usr/bin/env python
# Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import argparse
import builtins
from copy import deepcopy
import gc
import os
import random
import war... | 19,038 | 43.797647 | 119 | py |
noncontrastive-ssl | noncontrastive-ssl-master/compute_nn.py | # for now, just do it between the imagenet train set
# for now, just do distance
# later, can do cosine similarity
import os
import json
import torch
import argparse
import torch.nn.functional as F
from tqdm import trange
device = 'cuda:0'
def main():
parser = argparse.ArgumentParser(description='Find the neares... | 4,405 | 38.693694 | 109 | py |
noncontrastive-ssl | noncontrastive-ssl-master/resnet_variants.py | from torchvision.models.resnet import _resnet, Bottleneck, ResNet, BasicBlock
from typing import Any
def resnet18_bottleneck_w64(pretrained: bool = False, progress: bool = True, **kwargs: Any) -> ResNet:
return _resnet('none', Bottleneck, [2, 2, 2, 2], pretrained, progress, **kwargs)
def resnet18_bottleneck_w96... | 967 | 43 | 103 | py |
noncontrastive-ssl | noncontrastive-ssl-master/save_reprs_clean.py | """Given some pretrained model, get representations for every image in a desired dataset"""
import argparse
import os
import random
import torch
import torch.nn as nn
import torch.nn.parallel
import torch.backends.cudnn as cudnn
import torch.optim
import torch.utils.data
import torch.utils.data.distributed
import numpy... | 6,831 | 39.426036 | 107 | py |
noncontrastive-ssl | noncontrastive-ssl-master/main_simsiam.py | #!/usr/bin/env python
# Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import argparse
import builtins
import gc
import os
import random
import warnings
import wandb
import ... | 25,509 | 41.445923 | 119 | py |
noncontrastive-ssl | noncontrastive-ssl-master/main_moco.py | #!/usr/bin/env python
# Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import argparse
import builtins
import os
import random
import warnings
import wandb
import math
impo... | 17,589 | 42.647643 | 118 | py |
noncontrastive-ssl | noncontrastive-ssl-master/download_places.py | import argparse
from torchvision import datasets
def main():
parser = argparse.ArgumentParser(description='Download Places365 dataset')
parser.add_argument('root', metavar='DIR', help='path to where dataset should be downloaded')
parser.add_argument('--small', action='store_true', help='Use small version ... | 550 | 33.4375 | 97 | py |
noncontrastive-ssl | noncontrastive-ssl-master/autolearn/data_loading.py | import os
import torch
import autolearn.simsiam as simsiam
from torchvision import transforms
from autolearn.dataset_with_path import ImageDatasetWithPath
def simsiam_train_augs():
normalize = transforms.Normalize(mean=[0.485, 0.456, 0.406],
std=[0.229, 0.224, 0.225])
# M... | 2,574 | 32.441558 | 96 | py |
noncontrastive-ssl | noncontrastive-ssl-master/autolearn/vits.py | # Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import math
import torch
import torch.nn as nn
from functools import partial, reduce
from operator import mul
from timm.mod... | 6,434 | 37.76506 | 120 | py |
noncontrastive-ssl | noncontrastive-ssl-master/autolearn/dataset_with_path.py | import torch.utils.data as data
import torchvision.datasets as datasets
import bisect
class ImageDatasetWithPath(datasets.ImageFolder):
def __getitem__(self, index):
"""
Args:
index (int): Index
Returns:
tuple: (sample, target) where target is class_index of the ta... | 1,734 | 29.982143 | 92 | py |
noncontrastive-ssl | noncontrastive-ssl-master/autolearn/moco/data.py | import os
import autolearn.moco.loader as loader
from torchvision import transforms
from torchvision import datasets
def moco_imagenet_train(args):
traindir = os.path.join(args.data, 'train')
normalize = transforms.Normalize(mean=[0.485, 0.456, 0.406],
std=[0.229, 0.224, 0... | 1,550 | 35.069767 | 74 | py |
noncontrastive-ssl | noncontrastive-ssl-master/autolearn/moco/builder.py | # Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import torch
import torch.nn as nn
class MoCo(nn.Module):
"""
Build a MoCo model with a base encoder, a momentum e... | 5,129 | 34.625 | 114 | py |
noncontrastive-ssl | noncontrastive-ssl-master/autolearn/moco/optimizer.py | # Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import torch
class LARS(torch.optim.Optimizer):
"""
LARS optimizer, no rate scaling or weight decay for parameters... | 1,653 | 35.755556 | 113 | py |
noncontrastive-ssl | noncontrastive-ssl-master/autolearn/simsiam/data.py | """
Contains all the data loaders that we need
"""
import os
import autolearn.simsiam.loader as loader
import numpy as np
from torchvision import transforms
from torchvision import datasets
from torch.utils.data import Subset
from typing import Any, Tuple
from autolearn.dataset_with_path import ImageDatasetWithIndex, I... | 7,566 | 29.14741 | 120 | py |
noncontrastive-ssl | noncontrastive-ssl-master/autolearn/simsiam/builder.py | # Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import torch
import torch.nn as nn
class SimSiam(nn.Module):
"""
Build a SimSiam model.
"""
def __init__(... | 5,837 | 38.445946 | 101 | py |
noncontrastive-ssl | noncontrastive-ssl-master/autolearn/byol/builder.py | # Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import torch
import torch.nn as nn
import torch.nn.functional as F
class BYOL(nn.Module):
"""
Build a BYOL model w... | 3,653 | 34.475728 | 114 | py |
3i4k | 3i4k-master/3i4k_demo.py | import numpy as np
import sys
print('\n\n\n\n\n\n\n\n\n\n\n')
print('#########################################################\n# #\n# Demonstration video: 3i for Korean (3i4K) #\n# #\n#############... | 6,729 | 28.008621 | 302 | py |
3i4k | 3i4k-master/classify.py | import numpy as np
import sys
import fasttext
def read_data(filename):
with open(filename, 'r') as f:
data = [line.split('\t') for line in f.read().splitlines()]
return data
model_ft = fasttext.load_model('vectors/model_drama.bin')
import tensorflow as tf
from keras.backend.tensorflow_backend import... | 4,470 | 28.609272 | 103 | py |
fofe-ner | fofe-ner-master/fofe_mention_net.py | #!/eecs/research/asr/mingbin/python-workspace/hopeless/bin/python
"""
Author : Mingbin Xu (mingbin.xu@gmail.com)
Filename : fofe_mention_net.py
Last Update : Jul 11, 2017
Description : N/A
Website : https://wiki.eecs.yorku.ca/lab/MLL/
Copyright (c) 2016 iNCML (author: Mingbin Xu)
License: MIT License (see... | 75,004 | 33.837436 | 103 | py |
fofe-ner | fofe-ner-master/kbp-ed-trainer.py | #!/eecs/research/asr/mingbin/python-workspace/hopeless/bin/python
"""
Author : Mingbin Xu (mingbin.xu@gmail.com)
Filename : kbp-ed-trainer.py
Last Update : Jul 26, 2016
Description : N/A
Website : https://wiki.eecs.yorku.ca/lab/MLL/
Copyright (c) 2016 iNCML (author: Mingbin Xu)
License: MIT License (see .... | 22,659 | 42.493282 | 124 | py |
MOSNet | MOSNet-master/test.py | import os
import time
import numpy as np
from tqdm import tqdm
import scipy.stats
import pandas as pd
import matplotlib
# Force matplotlib to not use any Xwindows backend.
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import tensorflow as tf
from tensorflow import keras
import model
import utils
import ran... | 5,259 | 29.760234 | 167 | py |
MOSNet | MOSNet-master/model.py | import tensorflow
from tensorflow import keras
from tensorflow.keras import Model, layers
from tensorflow.keras.layers import Dense, Dropout, Conv2D
from tensorflow.keras.layers import LSTM, TimeDistributed, Bidirectional
from tensorflow.keras.constraints import max_norm
class CNN_BLSTM(object):
def __init__(... | 5,201 | 38.112782 | 96 | py |
MOSNet | MOSNet-master/train.py | import os
import time
import numpy as np
from tqdm import tqdm
import scipy.stats
import pandas as pd
import matplotlib
# Force matplotlib to not use any Xwindows backend.
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import argparse
import tensorflow as tf
from tensorflow import keras
import model
import uti... | 7,260 | 30.16309 | 167 | py |
MOSNet | MOSNet-master/custom_test.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import time
import numpy as np
from tqdm import tqdm
import argparse
import fnmatch
from statistics import mean
import tensorflow as tf
from tensorflow import keras
from model import CNN_BLSTM
import utils
import random
random.seed(1984)
def find_file... | 3,657 | 30.534483 | 93 | py |
fiftyone-develop | fiftyone-develop/fiftyone/core/stages.py | """
View stages.
| Copyright 2017-2023, Voxel51, Inc.
| `voxel51.com <https://voxel51.com/>`_
|
"""
from collections import defaultdict, OrderedDict
import contextlib
from copy import deepcopy
import itertools
import random
import reprlib
import uuid
import warnings
from bson import ObjectId
import numpy as np
impor... | 257,895 | 29.775179 | 141 | py |
fiftyone-develop | fiftyone-develop/fiftyone/core/utils.py | """
Core utilities.
| Copyright 2017-2023, Voxel51, Inc.
| `voxel51.com <https://voxel51.com/>`_
|
"""
import typing as t
import atexit
from base64 import b64encode, b64decode
from collections import defaultdict
from contextlib import contextmanager
from copy import deepcopy
from datetime import date, datetime
import ... | 57,947 | 28.370502 | 79 | py |
fiftyone-develop | fiftyone-develop/fiftyone/core/config.py | """
FiftyOne config.
| Copyright 2017-2023, Voxel51, Inc.
| `voxel51.com <https://voxel51.com/>`_
|
"""
import logging
import os
try:
from importlib import metadata as importlib_metadata # Python 3.8
except ImportError:
import importlib_metadata # Python < 3.8
import pytz
import eta
import eta.core.config... | 21,640 | 28.604651 | 81 | py |
fiftyone-develop | fiftyone-develop/fiftyone/core/models.py | """
FiftyOne models.
| Copyright 2017-2023, Voxel51, Inc.
| `voxel51.com <https://voxel51.com/>`_
|
"""
import contextlib
import inspect
import logging
import numpy as np
import eta.core.image as etai
import eta.core.frameutils as etaf
import eta.core.learning as etal
import eta.core.models as etam
import eta.core.u... | 66,893 | 31.378509 | 79 | py |
fiftyone-develop | fiftyone-develop/fiftyone/core/collections.py | """
Interface for sample collections.
| Copyright 2017-2023, Voxel51, Inc.
| `voxel51.com <https://voxel51.com/>`_
|
"""
from collections import defaultdict
from copy import copy
import fnmatch
import itertools
import logging
import numbers
import os
import random
import string
import timeit
import warnings
from bson... | 390,894 | 35.133759 | 145 | py |
fiftyone-develop | fiftyone-develop/fiftyone/zoo/models/torch.py | """
FiftyOne Zoo models provided by :mod:`torchvision:torchvision.models`.
| Copyright 2017-2023, Voxel51, Inc.
| `voxel51.com <https://voxel51.com/>`_
|
"""
import inspect
from packaging import version
import eta.core.utils as etau
import fiftyone as fo
import fiftyone.core.utils as fou
import fiftyone.utils.torch ... | 5,209 | 39.076923 | 79 | py |
fiftyone-develop | fiftyone-develop/fiftyone/zoo/datasets/base.py | """
FiftyOne Zoo Datasets provided natively by the library.
| Copyright 2017-2023, Voxel51, Inc.
| `voxel51.com <https://voxel51.com/>`_
|
"""
import logging
import os
import shutil
import eta.core.serial as etas
import eta.core.utils as etau
import eta.core.web as etaw
import fiftyone.types as fot
import fiftyone.u... | 107,805 | 31.817656 | 136 | py |
fiftyone-develop | fiftyone-develop/fiftyone/zoo/datasets/torch.py | """
FiftyOne Zoo Datasets provided by :mod:`torchvision:torchvision.datasets`.
| Copyright 2017-2023, Voxel51, Inc.
| `voxel51.com <https://voxel51.com/>`_
|
"""
import eta.core.utils as etau
import fiftyone.core.labels as fol
import fiftyone.core.utils as fou
import fiftyone.types as fot
import fiftyone.utils.coco a... | 15,829 | 26.435009 | 79 | py |
fiftyone-develop | fiftyone-develop/fiftyone/zoo/datasets/__init__.py | """
The FiftyOne Dataset Zoo.
This package defines a collection of open source datasets made available for
download via FiftyOne.
| Copyright 2017-2023, Voxel51, Inc.
| `voxel51.com <https://voxel51.com/>`_
|
"""
from collections import OrderedDict
import logging
import os
import eta.core.serial as etas
import eta.c... | 41,712 | 30.600758 | 79 | py |
fiftyone-develop | fiftyone-develop/fiftyone/utils/torch.py | """
PyTorch utilities.
| Copyright 2017-2023, Voxel51, Inc.
| `voxel51.com <https://voxel51.com/>`_
|
"""
import logging
import itertools
import multiprocessing
import sys
import cv2
import numpy as np
from PIL import Image
import eta.core.geometry as etag
import eta.core.image as etai
import eta.core.learning as et... | 54,756 | 32.800617 | 85 | py |
fiftyone-develop | fiftyone-develop/fiftyone/utils/clip/model.py | """
CLIP model from https://github.com/openai/CLIP.
| Copyright 2017-2023, Voxel51, Inc.
| `voxel51.com <https://voxel51.com/>`_
|
"""
from collections import OrderedDict
from typing import Tuple, Union
import numpy as np
import fiftyone.core.utils as fou
fou.ensure_torch()
import torch
import torch.nn.functional a... | 18,878 | 30.570234 | 79 | py |
fiftyone-develop | fiftyone-develop/fiftyone/utils/clip/zoo.py | """
CLIP model wrapper for the FiftyOne Model Zoo.
| Copyright 2017-2023, Voxel51, Inc.
| `voxel51.com <https://voxel51.com/>`_
|
"""
import logging
import os
from packaging.version import Version
import warnings
import eta.core.web as etaw
import fiftyone as fo
import fiftyone.core.models as fom
import fiftyone.cor... | 6,577 | 30.32381 | 79 | py |
fiftyone-develop | fiftyone-develop/tests/intensive/model_tests.py | """
Model inference/embeddings tests.
All of these tests are designed to be run manually via::
pytest tests/intensive/model_tests.py -s -k test_<name>
| Copyright 2017-2023, Voxel51, Inc.
| `voxel51.com <https://voxel51.com/>`_
|
"""
import unittest
import numpy as np
import fiftyone as fo
import fiftyone.zoo ... | 12,171 | 32.166213 | 79 | py |
fiftyone-develop | fiftyone-develop/tests/intensive/evaluation_tests.py | """
Evaluation tests.
You must run these tests interactively as follows::
pytest tests/intensive/evaluation_tests.py -s -k <test_case>
| Copyright 2017-2023, Voxel51, Inc.
| `voxel51.com <https://voxel51.com/>`_
|
"""
import random
import unittest
import numpy as np
import eta.core.utils as etau
import pytest
... | 23,958 | 25.156114 | 78 | py |
fiftyone-develop | fiftyone-develop/tests/isolated/import_deps_test.py | """
Test that the fiftyone core package does not depend on any extra packages that
are intended to be manually installed by users.
| Copyright 2017-2023, Voxel51, Inc.
| `voxel51.com <https://voxel51.com/>`_
|
"""
import sys
import pytest
#
# This is a list of modules that are used (typically by utilities) but whic... | 895 | 26.151515 | 78 | py |
fiftyone-develop | fiftyone-develop/tests/misc/torch_tests.py | """
Tests for the :mod:`fiftyone.utils.torch` module.
| Copyright 2017-2023, Voxel51, Inc.
| `voxel51.com <https://voxel51.com/>`_
|
"""
import unittest
import numpy as np
from PIL import Image
import torch
import torchvision
import fiftyone as fo
import fiftyone.utils.torch as fout
def _get_fake_img(h, w):
ar... | 3,538 | 24.644928 | 78 | py |
fiftyone-develop | fiftyone-develop/docs/theme/setup.py | from setuptools import setup
from io import open
from pytorch_sphinx_theme import __version__
setup(
name="pytorch_sphinx_theme",
version=__version__,
author="Shift Lab",
author_email="info@shiftlabny.com",
url="https://github.com/pytorch/pytorch_sphinx_theme",
docs_url="https://github.com/pyto... | 1,433 | 29.510638 | 63 | py |
fiftyone-develop | fiftyone-develop/docs/theme/pytorch_sphinx_theme/__init__.py | """Pytorch Sphinx theme.
From https://github.com/shiftlab/pytorch_sphinx_theme.
"""
from os import path
__version__ = "0.0.24+voxel51"
__version_full__ = __version__
def get_html_theme_path():
"""Return list of HTML theme paths."""
cur_dir = path.abspath(path.dirname(path.dirname(__file__)))
return cur... | 539 | 22.478261 | 96 | py |
fiftyone-develop | fiftyone-develop/docs/scripts/make_model_zoo_docs.py | """
Script for generating the model zoo docs page contents
``docs/source/user_guide/model_zoo/models.rst``.
| Copyright 2017-2023, Voxel51, Inc.
| `voxel51.com <https://voxel51.com/>`_
|
"""
import logging
import os
import re
from jinja2 import Environment, BaseLoader
import eta.core.utils as etau
import fiftyone.z... | 8,361 | 22.227778 | 101 | py |
fiftyone-develop | fiftyone-develop/docs/source/conf.py | """
Sphinx configuration file.
For a full list of available options, see:
https://www.sphinx-doc.org/en/master/usage/configuration.html
| Copyright 2017-2023, Voxel51, Inc.
| `voxel51.com <https://voxel51.com/>`_
|
"""
import os
import re
import sys
sys.path.insert(0, os.path.abspath("."))
from custom_directives im... | 8,323 | 35.669604 | 159 | py |
fiftyone-develop | fiftyone-develop/docs/source/recipes/image_deduplication_helpers.py | """
Downloads a subset of CIFAR-100 and stores it to disk as follows::
/tmp/fiftyone/
└── cifar100_with_duplicates/
├── <classA>/
│ ├── <image1>.jpg
│ ├── <image2>.jpg
│ └── ...
├── <classB>/
│ ├── <image1>.jpg
│ ├── <image2>.jpg
│ └──... | 3,327 | 17.086957 | 77 | py |
SpectNet | SpectNet-master/codes/SmallNet.py | from custom_layers import Conv1D_zerophase_linear, Conv1D_linearphase, Conv1D_zerophase,\
DCT1D, Conv1D_gammatone, Conv1D_linearphaseType, Attention
from keras.layers import Input, Conv1D, MaxPooling1D, Dense, Dropout, Flatten, Activation, AveragePooling1D, Add
from keras import initializers
from keras.layers.norma... | 9,122 | 45.784615 | 147 | py |
SpectNet | SpectNet-master/codes/train_mfcc.py | from __future__ import print_function, division, absolute_import
# import tensorflow as tf
# from keras.backend.tensorflow_backend import set_session
# config = tf.ConfigProto()
# config.gpu_options.per_process_gpu_memory_fraction = 0.4
# set_session(tf.Session(config=config))
# from clr_callback import CyclicLR
# impo... | 14,479 | 33.47619 | 186 | py |
SpectNet | SpectNet-master/codes/HeartCepTorch.py | import torch
from torch.nn.modules import Module
import torch.nn as nn
import torch.nn.functional as F
from torchsummary import summary,summary
from math import floor,ceil
import numpy as np, matplotlib.pyplot as plt, pandas as pd, os
def plotf(x):
plt.plot(x.cpu().detach().numpy())
class MFCC_Gen(nn.Module):
... | 22,585 | 39.188612 | 171 | py |
SpectNet | SpectNet-master/codes/dann_heartnet_v1.py | from __future__ import print_function, division, absolute_import
# import tensorflow as tf
# from keras.backend.tensorflow_backend import set_session
# config = tf.ConfigProto()
# config.gpu_options.per_process_gpu_memory_fraction = 0.4
# set_session(tf.Session(config=config))
# from clr_callback import CyclicLR
# impo... | 36,591 | 45.673469 | 188 | py |
SpectNet | SpectNet-master/codes/HeartCepNet.py | from __future__ import print_function, absolute_import, division
from keras.initializers import Initializer
from custom_layers import Conv1D_zerophase_linear, Conv1D_linearphase, Conv1D_zerophase,\
DCT1D, Conv1D_gammatone, Conv1D_linearphaseType, Attention
from keras.layers import Input, Conv1D, MaxPooling1D,MaxPoo... | 21,560 | 42.645749 | 151 | py |
SpectNet | SpectNet-master/codes/HeartSegNet.py | from custom_layers import Conv1D_zerophase_linear, Conv1D_linearphase, Conv1D_zerophase,\
DCT1D, Conv1D_gammatone, Conv1D_linearphaseType, Attention
from keras.layers import Input, Conv1D, MaxPooling1D, Dense, Dropout, Flatten, Activation, AveragePooling1D, Lambda, Add
from keras import initializers
from keras.laye... | 16,841 | 46.711048 | 133 | py |
SpectNet | SpectNet-master/codes/Heartnet.py | from custom_layers import Conv1D_zerophase_linear, Conv1D_linearphase, Conv1D_zerophase,\
DCT1D, Conv1D_gammatone, Conv1D_linearphaseType, Attention
from keras.layers import Input, Conv1D, MaxPooling1D, Dense, Dropout, Flatten, Activation, AveragePooling1D
from keras import initializers
from keras.layers.normalizat... | 9,709 | 46.832512 | 133 | py |
SpectNet | SpectNet-master/codes/train_layer_mfcc.py | from __future__ import print_function, division, absolute_import
# import tensorflow as tf
# from keras.backend.tensorflow_backend import set_session
# config = tf.ConfigProto()
# config.gpu_options.per_process_gpu_memory_fraction = 0.4
# set_session(tf.Session(config=config))
# from clr_callback import CyclicLR
# impo... | 7,586 | 30.35124 | 108 | py |
SpectNet | SpectNet-master/codes/utils.py | from __future__ import print_function, division, absolute_import
import os
import numpy as np
np.random.seed(1)
from tensorflow import set_random_seed
set_random_seed(1)
import pandas as pd
from keras.callbacks import Callback, ReduceLROnPlateau,LearningRateScheduler
from keras.optimizers import Adam
from sklearn.metr... | 11,923 | 43.827068 | 157 | py |
SpectNet | SpectNet-master/codes/whole_new_model.py | import torch
from torch.nn.modules import Module
import torch.nn as nn
import torch.nn.functional as F
from torchsummary import summary,summary
from math import floor,ceil
import numpy as np, matplotlib.pyplot as plt, pandas as pd, os
from torch.nn.parameter import Parameter
from HeartCepTorch import Conv_Gammatone_coe... | 1,735 | 38.454545 | 113 | py |
SpectNet | SpectNet-master/codes/mfcc_models.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
import torch.nn.init as init
from torchsummary import summary
class GradReverse(torch.autograd.Function):
"""
Extension of grad reverse layer
"""
@staticmethod
def forward(ctx, x, constant):
... | 8,627 | 36.189655 | 171 | py |
SpectNet | SpectNet-master/codes/LSTMSmallNet.py | from custom_layers import Conv1D_zerophase_linear, Conv1D_linearphase, Conv1D_zerophase,\
DCT1D, Conv1D_gammatone, Conv1D_linearphaseType, Attention
from keras.layers import Input, Conv1D, MaxPooling1D, Dense, Dropout, Flatten, Activation, AveragePooling1D, Add, LSTM, Reshape
from keras import initializers
from ker... | 9,502 | 45.812808 | 147 | py |
SpectNet | SpectNet-master/codes/DenseNet.py | from custom_layers import Conv1D_zerophase_linear, Conv1D_linearphase, Conv1D_zerophase,\
DCT1D, Conv1D_gammatone, Conv1D_linearphaseType, Attention
from keras.layers import Input, Conv1D, MaxPooling1D, Dense, Dropout, Flatten, Activation, AveragePooling1D, Add
from keras import initializers
from keras.layers.norma... | 8,857 | 43.964467 | 147 | py |
SpectNet | SpectNet-master/codes/HeartResNet.py | from custom_layers import Conv1D_zerophase_linear, Conv1D_linearphase, Conv1D_zerophase,\
DCT1D, Conv1D_gammatone, Conv1D_linearphaseType, Attention
from keras.layers import Input, Conv1D, MaxPooling1D, Dense, Dropout, Flatten, Activation, AveragePooling1D, Add
from keras import initializers
from keras.layers.norma... | 11,634 | 46.296748 | 133 | py |
SpectNet | SpectNet-master/codes/custom_layers.py | from __future__ import print_function, absolute_import, division
from keras import backend as K
from keras.engine.topology import Layer
from keras.engine.topology import InputSpec
import tensorflow as tf
from keras.utils import conv_utils
from keras.layers import activations, initializers, regularizers, constraints
imp... | 47,017 | 43.693916 | 127 | py |
SpectNet | SpectNet-master/codes/CustomTensorBoard.py | """Callbacks: utilities called at certain points during model training.
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import os
import csv
import six
import numpy as np
import time
import json
import warnings
import io
import sys
from collections imp... | 17,601 | 45.078534 | 90 | py |
SpectNet | SpectNet-master/codes/Gradient_Reverse_Layer.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Gradient Reversal Layer implementation for Keras
Credits:
https://github.com/michetonu/gradient_reversal_keras_tf/blob/master/flipGradientTF.py
"""
import tensorflow as tf
from keras.engine import Layer
import keras.backend as K
def reverse_gradient(X, hp_lambda):
... | 1,493 | 27.730769 | 85 | py |
SpectNet | SpectNet-master/codes/BalancedDannAudioDataGenerator.py | from __future__ import print_function, division, absolute_import
import numpy as np
from keras.preprocessing.image import Iterator
from scipy import linalg
from scipy.signal import resample
import keras.backend as K
import warnings
from scipy.ndimage.interpolation import shift
import threading
from keras.utils import t... | 41,382 | 46.731257 | 157 | py |
SpectNet | SpectNet-master/codes/Evaluator.py | from __future__ import print_function, division, absolute_import
import os
import numpy as np
np.random.seed(1)
from tensorflow import set_random_seed
set_random_seed(1)
import pandas as pd
from keras.callbacks import Callback, ReduceLROnPlateau
from keras.optimizers import Adam
from sklearn.metrics import confusion_m... | 2,332 | 31.402778 | 98 | py |
SpectNet | SpectNet-master/codes/debug.py | from mfcc_models import Network
model = Network(2,0)
from torchsummary import summary
summary(model.cuda(),(1,2500,64)) | 119 | 29 | 33 | py |
SpectNet | SpectNet-master/codes/trainer.py | from __future__ import print_function, division, absolute_import
# import tensorflow as tf
# from keras.backend.tensorflow_backend import set_session
# config = tf.ConfigProto()
# config.gpu_options.per_process_gpu_memory_fraction = 0.4
# set_session(tf.Session(config=config))
# from clr_callback import CyclicLR
# impo... | 30,361 | 43.65 | 199 | py |
3d-photo-inpainting | 3d-photo-inpainting-master/main.py | import numpy as np
import argparse
import glob
import os
from functools import partial
import vispy
import scipy.misc as misc
from tqdm import tqdm
import yaml
import time
import sys
from mesh import write_ply, read_ply, output_3d_photo
from utils import get_MiDaS_samples, read_MiDaS_depth
import torch
import cv2
from ... | 6,735 | 46.43662 | 185 | py |
3d-photo-inpainting | 3d-photo-inpainting-master/utils.py | import os
import glob
import cv2
import scipy.misc as misc
from skimage.transform import resize
import numpy as np
from functools import reduce
from operator import mul
import torch
from torch import nn
import matplotlib.pyplot as plt
import re
try:
import cynetworkx as netx
except ImportError:
import networkx ... | 76,291 | 52.840508 | 200 | py |
3d-photo-inpainting | 3d-photo-inpainting-master/networks.py | import torch
import torch.nn as nn
import numpy as np
import matplotlib.pyplot as plt
import torch.nn.functional as F
class BaseNetwork(nn.Module):
def __init__(self):
super(BaseNetwork, self).__init__()
def init_weights(self, init_type='normal', gain=0.02):
'''
initialize network's w... | 22,050 | 42.926295 | 162 | py |
3d-photo-inpainting | 3d-photo-inpainting-master/mesh_tools.py | import os
import numpy as np
try:
import cynetworkx as netx
except ImportError:
import networkx as netx
import json
import scipy.misc as misc
#import OpenEXR
import scipy.signal as signal
import matplotlib.pyplot as plt
import cv2
import scipy.misc as misc
from skimage import io
from functools import partial
f... | 56,629 | 51.241697 | 172 | py |
3d-photo-inpainting | 3d-photo-inpainting-master/mesh.py | import os
import numpy as np
try:
import cynetworkx as netx
except ImportError:
import networkx as netx
import matplotlib.pyplot as plt
from functools import partial
from vispy import scene, io
from vispy.scene import visuals
from vispy.visuals.filters import Alpha
import cv2
from moviepy.editor import ImageSeq... | 137,611 | 58.909447 | 236 | py |
3d-photo-inpainting | 3d-photo-inpainting-master/MiDaS/monodepth_net.py | """MonoDepthNet: Network for monocular depth estimation trained by mixing several datasets.
This file contains code that is adapted from
https://github.com/thomasjpfan/pytorch_refinenet/blob/master/pytorch_refinenet/refinenet/refinenet_4cascade.py
"""
import torch
import torch.nn as nn
from torchvision import models
... | 5,508 | 28.459893 | 110 | py |
3d-photo-inpainting | 3d-photo-inpainting-master/MiDaS/run.py | """Compute depth maps for images in the input folder.
"""
import os
import glob
import torch
# from monodepth_net import MonoDepthNet
# import utils
import matplotlib.pyplot as plt
import numpy as np
import cv2
import imageio
def run_depth(img_names, input_path, output_path, model_path, Net, utils, target_w=None):
... | 2,286 | 26.890244 | 115 | py |
3d-photo-inpainting | 3d-photo-inpainting-master/MiDaS/MiDaS_utils.py | """Utils for monoDepth.
"""
import sys
import re
import numpy as np
import cv2
import torch
import imageio
def read_pfm(path):
"""Read pfm file.
Args:
path (str): path to file
Returns:
tuple: (data, scale)
"""
with open(path, "rb") as file:
color = None
width = N... | 4,639 | 23.166667 | 88 | py |
Convolutional-Neural-Network-Based-Image-Watermarking-using-Discrete-Wavelet-Transform | Convolutional-Neural-Network-Based-Image-Watermarking-using-Discrete-Wavelet-Transform-master/trainer.py | import tensorflow as tf
from configs import *
from models.wavetf_model import WaveTFModel
from data_loaders.merged_data_loader import MergedDataLoader
from keras.callbacks import ModelCheckpoint
optimizer = tf.keras.optimizers.Adam(learning_rate=LEARNING_RATE)
losses = {
'embedded_image': 'mse',
'output_waterm... | 1,526 | 41.416667 | 118 | py |
Convolutional-Neural-Network-Based-Image-Watermarking-using-Discrete-Wavelet-Transform | Convolutional-Neural-Network-Based-Image-Watermarking-using-Discrete-Wavelet-Transform-master/attacks/base_attack.py | from tensorflow.python import keras
class BaseAttack(keras.layers.Layer):
def __init__(self, **kwargs):
super(BaseAttack, self).__init__()
def call(self, inputs):
pass
| 196 | 16.909091 | 42 | py |
Convolutional-Neural-Network-Based-Image-Watermarking-using-Discrete-Wavelet-Transform | Convolutional-Neural-Network-Based-Image-Watermarking-using-Discrete-Wavelet-Transform-master/attacks/gaussian_noise_attack.py | import tensorflow as tf
from tensorflow.python import keras
from attacks.base_attack import BaseAttack
class GaussianNoiseAttack(BaseAttack):
def __init__(self, **kwargs):
super(GaussianNoiseAttack, self).__init__()
def gaussian_noise(self, inputs):
shp = keras.backend.shape(inputs)[1:]
... | 626 | 25.125 | 93 | py |
Convolutional-Neural-Network-Based-Image-Watermarking-using-Discrete-Wavelet-Transform | Convolutional-Neural-Network-Based-Image-Watermarking-using-Discrete-Wavelet-Transform-master/attacks/drop_out_attack.py | import tensorflow as tf
from tensorflow.python import keras
from attacks.base_attack import BaseAttack
class DropOutAttack(BaseAttack):
def __init__(self, **kwargs):
super(DropOutAttack, self).__init__()
def drop_out(self, inputs):
shp = keras.backend.shape(inputs)[1:]
mask_select = ... | 685 | 25.384615 | 89 | py |
Convolutional-Neural-Network-Based-Image-Watermarking-using-Discrete-Wavelet-Transform | Convolutional-Neural-Network-Based-Image-Watermarking-using-Discrete-Wavelet-Transform-master/attacks/jpeg_attack.py | import tensorflow as tf
from tensorflow.keras.layers import Lambda
from attacks.base_attack import BaseAttack
class JPEGAttack(BaseAttack):
def __init__(self, **kwargs):
super(JPEGAttack, self).__init__()
def jpeg(self, inputs):
images = tf.convert_to_tensor(inputs)
batch = images.sh... | 684 | 25.346154 | 88 | py |
Convolutional-Neural-Network-Based-Image-Watermarking-using-Discrete-Wavelet-Transform | Convolutional-Neural-Network-Based-Image-Watermarking-using-Discrete-Wavelet-Transform-master/attacks/salt_pepper_attack.py | from tensorflow.python import keras
from attacks.base_attack import BaseAttack
class SaltPepperAttack(BaseAttack):
def __init__(self, **kwargs):
super(SaltPepperAttack, self).__init__()
def salt_pepper(self, inputs):
shp = keras.backend.shape(inputs)[1:]
mask_select = keras.backend.r... | 707 | 28.5 | 108 | py |
Convolutional-Neural-Network-Based-Image-Watermarking-using-Discrete-Wavelet-Transform | Convolutional-Neural-Network-Based-Image-Watermarking-using-Discrete-Wavelet-Transform-master/models/wavetf_model.py | from typing import Tuple
import numpy as np
import tensorflow as tf
from tensorflow.keras.layers import Input, Conv2D, Reshape, Conv2DTranspose, BatchNormalization, Activation, \
AveragePooling2D, Concatenate, Lambda
from tensorflow.keras.models import Model
from wavetf import WaveTFFactory
from attacks.gaussian_... | 6,446 | 52.725 | 117 | py |
martini | martini-master/docs/conf.py | import os
with open(
os.path.join(os.path.dirname(__file__), '../martini/VERSION')
) as version_file:
__version__ = version_file.read().strip()
# -*- coding: utf-8 -*-
#
# Configuration file for the Sphinx documentation builder.
#
# This file does only contain a selection of the most common options. For a... | 5,674 | 28.102564 | 79 | py |
crazyswarm | crazyswarm-master/docs/conf.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Crazyswarm documentation build configuration file, created by
# sphinx-quickstart on Tue Apr 18 20:00:33 2017.
#
# 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
#... | 10,590 | 27.779891 | 80 | py |
lxmert | lxmert-master/src/param.py | # coding=utf-8
# Copyleft 2019 project LXRT.
import argparse
import random
import numpy as np
import torch
def get_optimizer(optim):
# Bind the optimizer
if optim == 'rms':
print("Optimizer: Using RMSProp")
optimizer = torch.optim.RMSprop
elif optim == 'adam':
print("Optimizer: U... | 4,476 | 41.235849 | 117 | py |
lxmert | lxmert-master/src/pretrain/qa_answer_table.py | # coding=utf-8
# Copyleft 2019 project LXRT.
import json
import torch
class AnswerTable:
ANS_CONVERT = {
"a man": "man",
"the man": "man",
"a woman": "woman",
"the woman": "woman",
'one': '1',
'two': '2',
'three': '3',
'four': '4',
'five': '... | 5,015 | 30.54717 | 85 | py |
lxmert | lxmert-master/src/pretrain/lxmert_data.py | # coding=utf-8
# Copyleft 2019 project LXRT.
from collections import defaultdict
import json
import random
import numpy as np
from torch.utils.data import Dataset
from param import args
from pretrain.qa_answer_table import AnswerTable
from utils import load_obj_tsv
TINY_IMG_NUM = 500
FAST_IMG_NUM = 5000
Split2ImgF... | 8,847 | 33.5625 | 89 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.