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 |
|---|---|---|---|---|---|---|
DeepFormableTag | DeepFormableTag-master/deepformable/layers/dist_ops.py | """
This code references https://github.com/ag14774/diffdist/blob/b5c17c7354bbbe98b6e8a791ea78614861b4997a/diffdist/
It is primarily used to distribute marker generation task across GPUs.
Copyright (c) Mustafa B. Yaldiz (VCLAB, KAIST) All Rights Reserved.
"""
import torch
import torch.distributed as dist
from torch.aut... | 2,224 | 40.203704 | 112 | py |
DeepFormableTag | DeepFormableTag-master/deepformable/engine/trainers.py | """
Copyright (c) Mustafa B. Yaldiz (VCLAB, KAIST) All Rights Reserved.
"""
import logging
import weakref
import time
from contextlib import ExitStack
import os
from collections import OrderedDict
import numpy as np
import torch
from torch import nn
from torch.nn import functional as F
from torch.nn.parallel import D... | 15,324 | 39.328947 | 113 | py |
DeepFormableTag | DeepFormableTag-master/deepformable/utils/image_utils.py | # Copyright (c) Mustafa B. Yaldiz (VCLAB, KAIST) All Rights Reserved.
import math
from typing import List, Optional
import numpy as np
import kornia
import torch
import torch.nn.functional as F
def sample_param(
param_range, shape=1, strength=None,
training=True, device=torch.device("cpu")
):
min_v, max_... | 4,648 | 33.69403 | 111 | py |
DeepFormableTag | DeepFormableTag-master/deepformable/utils/visualize_utils.py | """
This code implements new visualizers and modifies detectron2's demo.py.
Copyright (c) Mustafa B. Yaldiz (VCLAB, KAIST) All Rights Reserved.
"""
from copy import deepcopy
import atexit
import bisect
import multiprocessing as mp
from typing import List
from collections import deque
import numpy as np
import random
im... | 12,827 | 38.349693 | 130 | py |
DeepFormableTag | DeepFormableTag-master/deepformable/utils/env.py | """
Implemented by Facebook, Inc. and its affiliates.
Edited by Mustafa B. Yaldiz
"""
import torch
import detectron2
import numpy as np
import random
_DEEPFORMABLE_ENV_SETUP_DONE = False
def setup_environment():
# Perform environment setup work.
global _DEEPFORMABLE_ENV_SETUP_DONE
if _DEEPFORMABLE_ENV_SE... | 1,228 | 25.148936 | 86 | py |
DeepFormableTag | DeepFormableTag-master/deepformable/data/dataset_mapper.py | # Copyright (c) Mustafa B. Yaldiz (VCLAB, KAIST) All Rights Reserved.
import copy
import logging
from typing import List, Optional, Union
import numpy as np
import cv2
import torch
from detectron2.config import configurable
from detectron2.structures import Boxes, BoxMode, Instances, PolygonMasks
from detectron2.data... | 12,538 | 43.464539 | 121 | py |
DeepFormableTag | DeepFormableTag-master/deepformable/data/build.py | # Copyright (c) Mustafa B. Yaldiz (VCLAB, KAIST) All Rights Reserved.
import logging
import random
import torch
import torch.utils.data as torchdata
from detectron2.config import configurable
from detectron2.data.build import _train_loader_from_config, build_batch_data_loader
from detectron2.data.common import _MapIt... | 2,933 | 33.116279 | 98 | py |
DeepFormableTag | DeepFormableTag-master/deepformable/modeling/renderer.py | # Copyright (c) Mustafa B. Yaldiz (VCLAB, KAIST) All Rights Reserved.
import logging
import numpy as np
import math
from typing import Tuple
import torch
from torch import nn
import torch.nn.functional as F
from detectron2.config import configurable
from deepformable.utils import sample_param, get_disk_blur_kernel
... | 11,040 | 44.813278 | 178 | py |
DeepFormableTag | DeepFormableTag-master/deepformable/modeling/rpn.py | """
This code is modified from detectron2 implementation,
to add adaptive loss to region proposal network.
Copyright (c) Mustafa B. Yaldiz (VCLAB, KAIST) All Rights Reserved.
"""
from typing import Dict, List, Optional, Tuple, Union
import torch
from torch import nn
from fvcore.nn import giou_loss
from detectron2.lay... | 4,840 | 45.548077 | 114 | py |
DeepFormableTag | DeepFormableTag-master/deepformable/modeling/backbone/utils.py |
"""
This code modifies FPN implementation from detectron2 to output stem features.
Copyright (c) Mustafa B. Yaldiz (VCLAB, KAIST) All Rights Reserved.
"""
import torch
import torch.nn.functional as F
from detectron2.modeling.backbone.fpn import FPN as FPN_detectron2
class FPN(FPN_detectron2):
def forward(self, x... | 1,893 | 43.046512 | 99 | py |
DeepFormableTag | DeepFormableTag-master/deepformable/modeling/backbone/vovnet.py | """
This code is copied from VoVNet https://github.com/youngwanLEE/vovnet-detectron2.
Copyright (c) Youngwan Lee (ETRI) All Rights Reserved.
"""
from collections import OrderedDict
import torch
import torch.nn as nn
import torch.nn.functional as F
from detectron2.layers import FrozenBatchNorm2d, ShapeSpec, get_norm
fr... | 12,757 | 29.668269 | 120 | py |
DeepFormableTag | DeepFormableTag-master/deepformable/modeling/marker_roi_heads/naive_transform_head.py | # Copyright (c) Mustafa B. Yaldiz (VCLAB, KAIST) All Rights Reserved.
import numpy as np
from typing import Dict, List, Optional, Tuple, Union
import fvcore.nn.weight_init as weight_init
import torch
from torch import nn
from torch.nn import functional as F
from detectron2.structures import ImageList, Instances
from d... | 4,884 | 33.892857 | 110 | py |
DeepFormableTag | DeepFormableTag-master/deepformable/modeling/marker_roi_heads/corner_head.py | # Copyright (c) Mustafa B. Yaldiz (VCLAB, KAIST) All Rights Reserved.
import numpy as np
from typing import Dict, List, Union
import fvcore.nn.weight_init as weight_init
import torch
from torch import nn
from torch.nn import functional as F
from detectron2.config import configurable
from detectron2.layers import Conv2... | 9,758 | 38.036 | 111 | py |
DeepFormableTag | DeepFormableTag-master/deepformable/modeling/marker_roi_heads/decoder_head.py | # Copyright (c) Mustafa B. Yaldiz (VCLAB, KAIST) All Rights Reserved.
import numpy as np
from typing import List
import fvcore.nn.weight_init as weight_init
import torch
from torch import nn
from torch.nn import functional as F
from detectron2.config import configurable
from detectron2.layers import Conv2d, Linear, ge... | 6,317 | 37.290909 | 101 | py |
DeepFormableTag | DeepFormableTag-master/deepformable/modeling/marker_roi_heads/marker_roi_heads.py | # Copyright (c) Mustafa B. Yaldiz (VCLAB, KAIST) All Rights Reserved.
import numpy as np
from typing import Dict, List, Optional, Tuple, Union
import torch
from torch import nn
from detectron2.config import configurable
from detectron2.structures import ImageList, Instances
from detectron2.modeling import ROI_HEADS_R... | 3,153 | 35.252874 | 138 | py |
DeepFormableTag | DeepFormableTag-master/deepformable/modeling/marker_roi_heads/transformer_head.py | # Copyright (c) Mustafa B. Yaldiz (VCLAB, KAIST) All Rights Reserved.
import numpy as np
from typing import Dict, List, Optional, Tuple, Union
import fvcore.nn.weight_init as weight_init
from fvcore.nn import smooth_l1_loss
import torch
from torch import nn
from torch.nn import functional as F
from detectron2.structur... | 20,922 | 41.526423 | 134 | py |
DeepFormableTag | DeepFormableTag-master/deepformable/modeling/intermediate_augmentor/tps_augmentor.py | """
This code implemented by Andreas Meulueman and Mustafa B. Yaldiz
Copyright (c) (VCLAB, KAIST) All Rights Reserved.
"""
import itertools
import torch
from torch import nn
import torch.nn.functional as F
from detectron2.config import configurable
from .build import INTERMEDIATE_AUGMENTOR_REGISTRY, IntermediateAugm... | 8,502 | 41.303483 | 129 | py |
DeepFormableTag | DeepFormableTag-master/deepformable/modeling/intermediate_augmentor/radial_distortion_augmentor.py | """
This code implemented by Andreas Meulueman and Mustafa B. Yaldiz
Copyright (c) (VCLAB, KAIST) All Rights Reserved.
"""
import itertools
import torch
import torch.nn.functional as F
from detectron2.config import configurable
from .build import INTERMEDIATE_AUGMENTOR_REGISTRY, IntermediateAugmentor
from deepformabl... | 4,062 | 38.067308 | 133 | py |
DeepFormableTag | DeepFormableTag-master/deepformable/modeling/intermediate_augmentor/jpeg_augmentor.py | """
JPEG compression augmentation, see https://github.com/ando-khachatryan/HiDDeN
Modified by Andreas Meulueman and Mustafa B. Yaldiz.
Copyright (c) 2018 ando-khachatryan
"""
import torch
from torch import nn
import torch.nn.functional as F
import kornia
import numpy as np
import detectron2
from detectron2.config impo... | 4,838 | 36.804688 | 121 | py |
DeepFormableTag | DeepFormableTag-master/deepformable/modeling/intermediate_augmentor/perspective_augmentor.py | """
This code implemented by Andreas Meulueman and Mustafa B. Yaldiz
Copyright (c) (VCLAB, KAIST) All Rights Reserved.
"""
import itertools
import torch
from torch import nn
import kornia
from detectron2.config import configurable
from .build import INTERMEDIATE_AUGMENTOR_REGISTRY, IntermediateAugmentor
from deepfo... | 3,147 | 36.47619 | 114 | py |
DeepFormableTag | DeepFormableTag-master/deepformable/modeling/intermediate_augmentor/color_augmentations.py | """
This code implemented by Andreas Meulueman and Mustafa B. Yaldiz
Copyright (c) (VCLAB, KAIST) All Rights Reserved.
"""
import torch
from torch import nn
import torch.nn.functional as F
import kornia
import numpy as np
import detectron2
from detectron2.config import configurable
from .build import INTERMEDIATE_AUG... | 6,641 | 29.328767 | 109 | py |
DeepFormableTag | DeepFormableTag-master/deepformable/modeling/intermediate_augmentor/build.py | """
Copyright (c) Mustafa B. Yaldiz (VCLAB, KAIST) All Rights Reserved.
TODO:
- Support batch operations for the images. Currently the input is (C, H, W).
"""
import torch
from torch import nn
from detectron2.utils.registry import Registry
from abc import ABCMeta, abstractmethod
INTERMEDIATE_AUGMENTOR_REGISTRY = Re... | 4,388 | 38.1875 | 126 | py |
DeepFormableTag | DeepFormableTag-master/deepformable/modeling/meta_arch/classical_detector.py | # Copyright (c) Mustafa B. Yaldiz (VCLAB, KAIST) All Rights Reserved.
import numpy as np
from typing import List, Dict
import torch
from torch import nn
import detectron2
from detectron2.structures import ImageList, Instances, Boxes
from detectron2.modeling import META_ARCH_REGISTRY
from ..marker_generator import bui... | 4,248 | 40.252427 | 97 | py |
DeepFormableTag | DeepFormableTag-master/deepformable/modeling/meta_arch/utils.py | """
This code is modified from detectron2 implementation,
changes are logged in comments.
Copyright (c) Mustafa B. Yaldiz (VCLAB, KAIST) All Rights Reserved.
"""
from __future__ import division
from typing import List, Dict, Optional, Tuple
import numpy as np
import torch
from torch.nn import functional as F
from d... | 2,080 | 37.537037 | 93 | py |
DeepFormableTag | DeepFormableTag-master/deepformable/modeling/meta_arch/render_rcnn.py | """
This code is modified from detectron2 implementation,
changes are logged in comments.
Copyright (c) Mustafa B. Yaldiz (VCLAB, KAIST) All Rights Reserved.
"""
from __future__ import division
from typing import List, Dict, Optional
import numpy as np
import torch
from torch.nn import functional as F
from detectro... | 11,596 | 45.951417 | 123 | py |
DeepFormableTag | DeepFormableTag-master/deepformable/modeling/marker_generator/aruco_generator.py | # Copyright (c) Mustafa B. Yaldiz (VCLAB, KAIST) All Rights Reserved.
import logging
import numpy as np
import cv2
from cv2 import aruco
import torch
from torch import nn
import torch.nn.functional as F
from detectron2.config import configurable
from detectron2.utils.comm import all_gather, is_main_process
from detec... | 6,392 | 37.512048 | 110 | py |
DeepFormableTag | DeepFormableTag-master/deepformable/modeling/marker_generator/generalized_generator.py | """
Some layers here are copied from facebookresearch/pytorch_GAN_zoo: https://github.com/facebookresearch/pytorch_GAN_zoo
Our marker generator builds on top of those layers.
Copyright (c) Mustafa B. Yaldiz (VCLAB, KAIST) All Rights Reserved.
"""
import logging
import numpy as np
from sklearn.neighbors import KDTree
im... | 17,170 | 37.673423 | 127 | py |
DeepFormableTag | DeepFormableTag-master/deepformable/modeling/marker_generator/build.py | # Copyright (c) Mustafa B. Yaldiz (VCLAB, KAIST) All Rights Reserved.
import torch
from torch import nn
import numpy as np
from detectron2.utils.registry import Registry
from detectron2.utils.events import get_event_storage
from abc import ABCMeta, abstractmethod
MARKER_GENERATOR_REGISTRY = Registry("MARKER_GENERATOR... | 3,919 | 37.811881 | 106 | py |
nnvm | nnvm-master/tutorials/from_onnx.py | """
Compile ONNX Models
===================
**Author**: `Joshua Z. Zhang <https://zhreshold.github.io/>`_
This article is an introductory tutorial to deploy ONNX models with NNVM.
For us to begin with, onnx module is required to be installed.
A quick solution is to install protobuf compiler, and
```bash
pip install ... | 3,737 | 35.291262 | 89 | py |
nnvm | nnvm-master/tutorials/from_mxnet.py | """
Compile MXNet Models
====================
**Author**: `Joshua Z. Zhang <https://zhreshold.github.io/>`_
This article is an introductory tutorial to deploy mxnet models with NNVM.
For us to begin with, mxnet module is required to be installed.
A quick solution is
```
pip install mxnet --user
```
or please refer t... | 4,181 | 35.365217 | 88 | py |
nnvm | nnvm-master/tutorials/deploy_model_on_rasp.py | """
Deploy the Pretrained Model on Raspberry Pi
===========================================
**Author**: `Ziheng Jiang <https://ziheng.org/>`_
This is an example of using NNVM to compile a ResNet model and deploy
it on raspberry pi.
To begin with, we import nnvm(for compilation) and TVM(for deployment).
"""
import tvm... | 7,993 | 33.456897 | 89 | py |
nnvm | nnvm-master/tutorials/from_keras.py | """
Compile Keras Models
=====================
**Author**: `Yuwei Hu <https://Huyuwei.github.io/>`_
This article is an introductory tutorial to deploy keras models with NNVM.
For us to begin with, keras should be installed.
Tensorflow is also required since it's used as the default backend of keras.
A quick solution... | 4,009 | 33.869565 | 87 | py |
nnvm | nnvm-master/tutorials/from_coreml.py | """
Compile CoreML Models
=====================
**Author**: `Joshua Z. Zhang <https://zhreshold.github.io/>`_
This article is an introductory tutorial to deploy CoreML models with NNVM.
For us to begin with, coremltools module is required to be installed.
A quick solution is to install via pip
```bash
pip install -U... | 3,377 | 32.445545 | 85 | py |
nnvm | nnvm-master/tutorials/deploy_model_on_mali_gpu.py | """
Deploy the Pretrained Model on ARM Mali GPU
=======================================================
**Author**: `Lianmin Zheng <https://lmzheng.net/>`_, `Ziheng Jiang <https://ziheng.org/>`_
This is an example of using NNVM to compile a ResNet model and
deploy it on Firefly-RK3399 with ARM Mali GPU. We will use t... | 8,488 | 34.970339 | 103 | py |
nnvm | nnvm-master/tutorials/from_mxnet_to_webgl.py | """
Quick Start - End-to-End Tutorial for NNVM/TVM Pipeline for OpenGL and WebGL
============================================================================
**Author**: `Zhixun Tan <https://github.com/phisiart>`_
This example shows how to build a neural network with NNVM python frontend and
generate runtime library f... | 16,410 | 31.561508 | 100 | py |
nnvm | nnvm-master/examples/sgx/build_model.py | """Creates a neural network graph module, the system library, and params.
Heavily inspired by tutorials/from_mxnet.py
"""
from __future__ import print_function
import ast
import os
from os import path as osp
import tempfile
import mxnet as mx
from mxnet.gluon.model_zoo.vision import get_model
from mxnet.gluon.utils im... | 2,125 | 27.346667 | 77 | py |
nnvm | nnvm-master/python/nnvm/testing/resnet.py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | 8,795 | 37.748899 | 96 | py |
nnvm | nnvm-master/python/nnvm/frontend/mxnet.py | # pylint: disable=invalid-name, import-self
"""MXNet symbol frontend."""
from __future__ import absolute_import as _abs
import json
import tvm
from .. import symbol as _sym
__all__ = ['from_mxnet']
def _get_nnvm_op(op_name):
op = getattr(_sym, op_name)
if not op:
raise RuntimeError("Unable to map op_n... | 14,778 | 36.510152 | 96 | py |
nnvm | nnvm-master/python/nnvm/frontend/keras.py | # pylint: disable=invalid-name, import-self
"""Keras frontend."""
from __future__ import absolute_import as _abs
import sys
import numpy as np
import tvm
from .. import symbol as _sym
from .common import SymbolTable
__all__ = ['from_keras']
def _check_data_format(keras_layer):
if hasattr(keras_layer, ('data_form... | 19,776 | 38.554 | 99 | py |
nnvm | nnvm-master/python/nnvm/frontend/onnx.py | # pylint: disable=import-self, invalid-name, unused-argument
"""ONNX: Open Neural Network Exchange frontend."""
from __future__ import absolute_import as _abs
import numpy as np
import tvm
from .. import symbol as _sym
from .. import graph as _graph
from ..compiler import graph_util
from .common import get_nnvm_op, Ren... | 23,120 | 31.564789 | 83 | py |
nnvm | nnvm-master/python/nnvm/frontend/__init__.py | """NNVM frontends."""
from __future__ import absolute_import
from .mxnet import from_mxnet
from .onnx import from_onnx
from .coreml import from_coreml
from .keras import from_keras
from .darknet import from_darknet
| 215 | 26 | 38 | py |
nnvm | nnvm-master/amalgamation/amalgamation.py | import sys
import os.path, re, StringIO
blacklist = [
'Windows.h',
'mach/clock.h', 'mach/mach.h',
'malloc.h',
'glog/logging.h', 'io/azure_filesys.h', 'io/hdfs_filesys.h', 'io/s3_filesys.h',
'sys/stat.h', 'sys/types.h',
'omp.h', 'execinfo.h', 'packet/sse-inl.h'
]
def get_sources(def_file):... | 2,628 | 25.029703 | 101 | py |
nnvm | nnvm-master/tests/python/frontend/mxnet/test_forward.py | import numpy as np
import topi
import tvm
from tvm.contrib import graph_runtime
import nnvm.symbol as sym
import nnvm.compiler
from nnvm.testing.config import ctx_list
from nnvm import frontend
import mxnet as mx
from mxnet import gluon
from mxnet.gluon.model_zoo import vision
import model_zoo
def verify_mxnet_front... | 5,024 | 37.068182 | 96 | py |
nnvm | nnvm-master/tests/python/frontend/mxnet/test_graph.py | import mxnet as mx
import nnvm
from nnvm.compiler import graph_util, graph_attr
import model_zoo
def compare_graph(sym1, sym2, ishape=(2, 3, 224, 224)):
g1 = nnvm.graph.create(sym1)
g2 = nnvm.graph.create(sym2)
graph_attr.set_shape_inputs(g1, {'data':ishape})
graph_attr.set_shape_inputs(g2, {'data':ish... | 1,662 | 31.607843 | 70 | py |
nnvm | nnvm-master/tests/python/frontend/mxnet/model_zoo/resnet.py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | 9,769 | 47.606965 | 147 | py |
nnvm | nnvm-master/tests/python/frontend/mxnet/model_zoo/vgg.py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | 4,240 | 48.313953 | 154 | py |
nnvm | nnvm-master/tests/python/frontend/mxnet/model_zoo/mlp.py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | 1,993 | 47.634146 | 103 | py |
nnvm | nnvm-master/tests/python/frontend/onnx/test_forward.py | import numpy as np
import nnvm
import tvm
from tvm.contrib import graph_runtime
from nnvm.testing.config import ctx_list
import onnx
from model_zoo import super_resolution, squeezenet1_1, lenet, resnet18_1_0
def verify_onnx_forward_impl(graph_file, data_shape, out_shape):
import caffe2.python.onnx.backend
def ... | 1,970 | 34.836364 | 92 | py |
nnvm | nnvm-master/tests/python/frontend/keras/test_forward.py | import numpy as np
import nnvm
import tvm
from tvm.contrib import graph_runtime
from nnvm.testing.config import ctx_list
import keras
# prevent keras from using up all gpu memory
import tensorflow as tf
from keras.backend.tensorflow_backend import set_session
config = tf.ConfigProto()
config.gpu_options.per_process_gp... | 6,617 | 34.772973 | 112 | py |
nnvm | nnvm-master/docs/conf.py | # -*- coding: utf-8 -*-
#
# documentation build configuration file, created by
# sphinx-quickstart on Thu Jul 23 19:40:08 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.
#
# All confi... | 7,025 | 32.457143 | 88 | py |
fraud-detection-handbook | fraud-detection-handbook-main/Chapter_References/shared_functions.py | #!/usr/bin/env python
# coding: utf-8
# (shared_functions)=
# # Shared functions
#
# This notebook contains functions which are commonly reused in the book, for loading and saving data, fitting and assessing prediction models, or plotting results.
#
# The notebook can be downloaded from GitHub with
#
# ```
# !curl... | 63,257 | 36.0363 | 165 | py |
vHive | vHive-main/function-images/cnn_serving/squeezenet.py | """
Reference : https://github.com/rcmalli/keras-squeezenet
SqueezeNet v1.1 Implementation using Keras Functional Framework 2.0
"""
from tensorflow.python.keras._impl.keras.applications.imagenet_utils import _obtain_input_shape
from tensorflow.python.keras._impl.keras import backend as K
from tensorflow.python.keras._... | 5,552 | 38.94964 | 145 | py |
vHive | vHive-main/function-images/cnn_serving/server.py | from concurrent import futures
import logging
import grpc
import helloworld_pb2
import helloworld_pb2_grpc
import tensorflow as tf
from tensorflow.python.keras.preprocessing import image
from tensorflow.python.keras.applications.resnet50 import preprocess_input, decode_predictions
import numpy as np
from squeezenet... | 2,173 | 29.619718 | 94 | py |
vHive | vHive-main/function-images/rnn_serving/server.py | # Copyright 2015 gRPC authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing... | 2,536 | 31.525641 | 209 | py |
vHive | vHive-main/function-images/rnn_serving/rnn.py | import torch
import torch.nn as nn
from torch.autograd import Variable
class RNN(nn.Module):
def __init__(self, input_size, hidden_size, output_size, all_categories, n_categories, all_letters, n_letters):
super(RNN, self).__init__()
self.hidden_size = hidden_size
self.all_categories = all... | 2,902 | 36.217949 | 115 | py |
jwst | jwst-master/makenirissgrismflats.py | #!/usr/bin/env python
#Generate NIRISS WFSS grism flat field reference files by correcting the imaging flat with data from grism flats.
#Uses jwst and jwst_reffiles python packages
#Takes in direct and dispersed NIRISS WFSS flat field images to identify features of low transmission on the NIRISS pick-off mirror, inclu... | 32,434 | 49.054012 | 304 | py |
jwst | jwst-master/makenirissimagingflats.py | #!/usr/bin/env python
#Generate NIRISS imaging flat field reference files.
#Uses jwst and jwst_reffiles python packages
#Normalize, sigma clip and combine multiple flat integrations/exposures.
#The flat field will be normalized to a sigma-clipped average value of one as per the CALWEBB_IMAGE2 definition.
#No surface f... | 16,495 | 43.948229 | 383 | py |
FGSM-PGI | FGSM-PGI-master/FGSM_MEP.py | import argparse
import copy
import logging
import os
import time
from torchvision.utils import make_grid, save_image
import numpy as np
import torch
from models import *
# from preact_resnet import PreActResNet18
from utils import *
logger = logging.getLogger(__name__)
def get_args():
parser = argparse.Argument... | 14,222 | 40.955752 | 132 | py |
FGSM-PGI | FGSM-PGI-master/utils02.py | '''Some helper functions for PyTorch, including:
- get_mean_and_std: calculate the mean and std value of dataset.
- msr_init: net parameter initialization.
- progress_bar: progress bar mimic xlua.progress.
'''
import os
import sys
import time
import math
from TinyImageNet import TinyImageNet
import torch.nn... | 13,112 | 33.782493 | 134 | py |
FGSM-PGI | FGSM-PGI-master/utils.py |
import os
import sys
import time
import math
import torch.nn as nn
import torch.nn.init as init
from torchvision import datasets, transforms
import torch
import torch.nn.functional as F
import torch.utils.data as data
import copy
import torch.optim as optim
# cifar10_mean = (0.4914, 0.4822, 0.4465)
# cifar10_std = ... | 18,203 | 32.586716 | 118 | py |
FGSM-PGI | FGSM-PGI-master/FGSM_MEP_cifar100.py | import argparse
import copy
import logging
import os
import time
from torchvision.utils import make_grid, save_image
import numpy as np
import torch
from Cifar100_models import *
from utils import *# from preact_resnet import PreActResNet18
logger = logging.getLogger(__name__)
def get_args():
parser = argparse... | 14,243 | 41.017699 | 132 | py |
FGSM-PGI | FGSM-PGI-master/utils_ImageNet.py | import logging
import os
import datetime
import torchvision.models as models
import math
import torch
import yaml
from easydict import EasyDict
import shutil
import numpy as np
class AverageMeter(object):
"""Computes and stores the average and current value"""
def __init__(self):
self.reset()
def r... | 16,030 | 34.703786 | 118 | py |
FGSM-PGI | FGSM-PGI-master/FGSM_MEP_TinyImageNet.py | import argparse
import copy
import logging
import os
import time
from torchvision.utils import make_grid, save_image
import numpy as np
import torch
from ImageNet_models import *
from utils02 import *
logger = logging.getLogger(__name__)
def get_args():
parser = argparse.ArgumentParser()
parser.add_argument... | 13,917 | 40.056047 | 132 | py |
FGSM-PGI | FGSM-PGI-master/models/shufflenetv2.py | '''ShuffleNetV2 in PyTorch.
See the paper "ShuffleNet V2: Practical Guidelines for Efficient CNN Architecture Design" for more details.
'''
import torch
import torch.nn as nn
import torch.nn.functional as F
class ShuffleBlock(nn.Module):
def __init__(self, groups=2):
super(ShuffleBlock, self).__init__()
... | 5,530 | 32.932515 | 107 | py |
FGSM-PGI | FGSM-PGI-master/models/regnet.py | '''RegNet in PyTorch.
Paper: "Designing Network Design Spaces".
Reference: https://github.com/keras-team/keras-applications/blob/master/keras_applications/efficientnet.py
'''
import torch
import torch.nn as nn
import torch.nn.functional as F
class SE(nn.Module):
'''Squeeze-and-Excitation block.'''
def __in... | 4,548 | 28.160256 | 106 | py |
FGSM-PGI | FGSM-PGI-master/models/efficientnet.py | '''EfficientNet in PyTorch.
Paper: "EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks".
Reference: https://github.com/keras-team/keras-applications/blob/master/keras_applications/efficientnet.py
'''
import torch
import torch.nn as nn
import torch.nn.functional as F
def swish(x):
return x ... | 5,719 | 31.5 | 106 | py |
FGSM-PGI | FGSM-PGI-master/models/pnasnet.py | '''PNASNet in PyTorch.
Paper: Progressive Neural Architecture Search
'''
import torch
import torch.nn as nn
import torch.nn.functional as F
class SepConv(nn.Module):
'''Separable Convolution.'''
def __init__(self, in_planes, out_planes, kernel_size, stride):
super(SepConv, self).__init__()
se... | 4,258 | 32.801587 | 105 | py |
FGSM-PGI | FGSM-PGI-master/models/resnet.py | '''ResNet in PyTorch.
For Pre-activation ResNet, see 'preact_resnet.py'.
Reference:
[1] Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian Sun
Deep Residual Learning for Image Recognition. arXiv:1512.03385
'''
import torch
import torch.nn as nn
import torch.nn.functional as F
class BasicBlock(nn.Module):
expansi... | 4,241 | 30.656716 | 83 | py |
FGSM-PGI | FGSM-PGI-master/models/mobilenetv2.py | '''MobileNetV2 in PyTorch.
See the paper "Inverted Residuals and Linear Bottlenecks:
Mobile Networks for Classification, Detection and Segmentation" for more details.
'''
import torch
import torch.nn as nn
import torch.nn.functional as F
class Block(nn.Module):
'''expand + depthwise + pointwise'''
def __init... | 3,092 | 34.551724 | 114 | py |
FGSM-PGI | FGSM-PGI-master/models/vgg.py | '''VGG11/13/16/19 in Pytorch.'''
import torch
import torch.nn as nn
cfg = {
'VGG11': [64, 'M', 128, 'M', 256, 256, 'M', 512, 512, 'M', 512, 512, 'M'],
'VGG13': [64, 64, 'M', 128, 128, 'M', 256, 256, 'M', 512, 512, 'M', 512, 512, 'M'],
'VGG16': [64, 64, 'M', 128, 128, 'M', 256, 256, 256, 'M', 512, 512, 512... | 1,442 | 29.0625 | 117 | py |
FGSM-PGI | FGSM-PGI-master/models/densenet.py | '''DenseNet in PyTorch.'''
import math
import torch
import torch.nn as nn
import torch.nn.functional as F
class Bottleneck(nn.Module):
def __init__(self, in_planes, growth_rate):
super(Bottleneck, self).__init__()
self.bn1 = nn.BatchNorm2d(in_planes)
self.conv1 = nn.Conv2d(in_planes, 4*gr... | 3,542 | 31.805556 | 96 | py |
FGSM-PGI | FGSM-PGI-master/models/preact_resnet.py | '''Pre-activation ResNet in PyTorch.
Reference:
[1] Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian Sun
Identity Mappings in Deep Residual Networks. arXiv:1603.05027
'''
import torch
import torch.nn as nn
import torch.nn.functional as F
class PreActBlock(nn.Module):
'''Pre-activation version of the BasicBlock.... | 4,078 | 33.277311 | 102 | py |
FGSM-PGI | FGSM-PGI-master/models/googlenet.py | '''GoogLeNet with PyTorch.'''
import torch
import torch.nn as nn
import torch.nn.functional as F
class Inception(nn.Module):
def __init__(self, in_planes, n1x1, n3x3red, n3x3, n5x5red, n5x5, pool_planes):
super(Inception, self).__init__()
# 1x1 conv branch
self.b1 = nn.Sequential(
... | 3,221 | 28.833333 | 83 | py |
FGSM-PGI | FGSM-PGI-master/models/resnext.py | '''ResNeXt in PyTorch.
See the paper "Aggregated Residual Transformations for Deep Neural Networks" for more details.
'''
import torch
import torch.nn as nn
import torch.nn.functional as F
class Block(nn.Module):
'''Grouped convolution block.'''
expansion = 2
def __init__(self, in_planes, cardinality=32... | 3,478 | 35.239583 | 129 | py |
FGSM-PGI | FGSM-PGI-master/models/senet.py | '''SENet in PyTorch.
SENet is the winner of ImageNet-2017. The paper is not released yet.
'''
import torch
import torch.nn as nn
import torch.nn.functional as F
class BasicBlock(nn.Module):
def __init__(self, in_planes, planes, stride=1):
super(BasicBlock, self).__init__()
self.conv1 = nn.Conv2d(... | 4,027 | 32.016393 | 102 | py |
FGSM-PGI | FGSM-PGI-master/models/shufflenet.py | '''ShuffleNet in PyTorch.
See the paper "ShuffleNet: An Extremely Efficient Convolutional Neural Network for Mobile Devices" for more details.
'''
import torch
import torch.nn as nn
import torch.nn.functional as F
class ShuffleBlock(nn.Module):
def __init__(self, groups):
super(ShuffleBlock, self).__init... | 3,542 | 31.209091 | 126 | py |
FGSM-PGI | FGSM-PGI-master/models/wide_resnet.py | import math
import torch
import torch.nn as nn
import torch.nn.functional as F
class BasicBlock(nn.Module):
def __init__(self, in_planes, out_planes, stride, dropRate=0.0):
super(BasicBlock, self).__init__()
self.bn1 = nn.BatchNorm2d(in_planes)
self.relu1 = nn.ReLU(inplace=True)
se... | 3,897 | 41.369565 | 116 | py |
FGSM-PGI | FGSM-PGI-master/models/lenet.py | '''LeNet in PyTorch.'''
import torch.nn as nn
import torch.nn.functional as F
class LeNet(nn.Module):
def __init__(self):
super(LeNet, self).__init__()
self.conv1 = nn.Conv2d(3, 6, 5)
self.conv2 = nn.Conv2d(6, 16, 5)
self.fc1 = nn.Linear(16*5*5, 120)
self.fc2 = nn.Linear... | 699 | 28.166667 | 43 | py |
FGSM-PGI | FGSM-PGI-master/models/mobilenet.py | '''MobileNet in PyTorch.
See the paper "MobileNets: Efficient Convolutional Neural Networks for Mobile Vision Applications"
for more details.
'''
import torch
import torch.nn as nn
import torch.nn.functional as F
class Block(nn.Module):
'''Depthwise conv + Pointwise conv'''
def __init__(self, in_planes, out_... | 2,025 | 31.677419 | 123 | py |
FGSM-PGI | FGSM-PGI-master/models/dpn.py | '''Dual Path Networks in PyTorch.'''
import torch
import torch.nn as nn
import torch.nn.functional as F
class Bottleneck(nn.Module):
def __init__(self, last_planes, in_planes, out_planes, dense_depth, stride, first_layer):
super(Bottleneck, self).__init__()
self.out_planes = out_planes
sel... | 3,562 | 34.989899 | 116 | py |
FGSM-PGI | FGSM-PGI-master/models/DRN.py | import torch
import torch.nn as nn
from torch.nn import functional as F
class DSN(nn.Module):
"""Deep Summarization Network"""
def __init__(self, in_dim=1024, hid_dim=256, num_layers=1, cell='lstm'):
super(DSN, self).__init__()
assert cell in ['lstm', 'gru'], "cell must be either 'lstm' or 'gr... | 729 | 33.761905 | 108 | py |
FGSM-PGI | FGSM-PGI-master/autoattack/utils_tf.py | import tensorflow as tf
import numpy as np
import torch
class ModelAdapter():
def __init__(self, logits, x, y, sess, num_classes=10):
self.logits = logits
self.sess = sess
self.x_input = x
self.y_input = y
self.num_classes = num_classes
# gradients of logits... | 4,827 | 44.980952 | 171 | py |
FGSM-PGI | FGSM-PGI-master/autoattack/autoattack.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
import numpy as np
import argparse
import time
from .other_utils import Logger
class AutoAttack():
def __init__(self, model, norm='Linf', eps=.3, seed=None, verbose=True,
attacks_to_run=[], versi... | 11,640 | 45.011858 | 119 | py |
FGSM-PGI | FGSM-PGI-master/autoattack/autopgd_tf.py | import numpy as np
import time
import torch
#import scipy.io
#import numpy.linalg as nl
#
import os
import sys
import torch.nn as nn
import torch.nn.functional as F
class APGDAttack():
def __init__(self, model, n_iter=100, norm='Linf', n_restarts=1, eps=None,
seed=0, loss='ce', eot_iter=1,... | 18,674 | 46.884615 | 195 | py |
FGSM-PGI | FGSM-PGI-master/autoattack/square.py | # Copyright (c) 2020-present, Francesco Croce
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ i... | 17,594 | 38.807692 | 85 | py |
FGSM-PGI | FGSM-PGI-master/autoattack/autopgd_pt.py | import numpy as np
import time
import torch
#import scipy.io
#import numpy.linalg as nl
#
import os
import sys
import torch.nn as nn
import torch.nn.functional as F
class APGDAttack():
def __init__(self, model, n_iter=100, norm='Linf', n_restarts=1, eps=None,
seed=0, loss='ce', eot_iter=1,... | 20,742 | 47.016204 | 195 | py |
FGSM-PGI | FGSM-PGI-master/autoattack/utils_tf2.py | import tensorflow as tf
import numpy as np
import torch
class ModelAdapter():
def __init__(self, model, num_classes=10):
"""
Please note that model should be tf.keras model without activation function 'softmax'
"""
self.num_classes = num_classes
self.tf_model = model
... | 8,038 | 37.099526 | 162 | py |
FGSM-PGI | FGSM-PGI-master/autoattack/fab_pt.py | # Copyright (c) 2019-present, Francesco Croce
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ i... | 32,142 | 41.914553 | 140 | py |
FGSM-PGI | FGSM-PGI-master/autoattack/fab_tf.py | # Copyright (c) 2019-present, Francesco Croce
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ i... | 32,060 | 41.977212 | 140 | py |
FGSM-PGI | FGSM-PGI-master/ImageNet_models/resnet.py | '''ResNet in PyTorch.
For Pre-activation ResNet, see 'preact_resnet.py'.
Reference:
[1] Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian Sun
Deep Residual Learning for Image Recognition. arXiv:1512.03385
'''
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
cla... | 4,053 | 31.693548 | 102 | py |
FGSM-PGI | FGSM-PGI-master/ImageNet_models/vgg.py | '''VGG11/13/16/19 in Pytorch.'''
import torch
import torch.nn as nn
from torch.autograd import Variable
cfg = {
'VGG11': [64, 'M', 128, 'M', 256, 256, 'M', 512, 512, 'M', 512, 512, 'M'],
'VGG13': [64, 64, 'M', 128, 128, 'M', 256, 256, 'M', 512, 512, 'M', 512, 512, 'M'],
'VGG16': [64, 64, 'M', 128, 128, 'M... | 1,449 | 31.954545 | 117 | py |
FGSM-PGI | FGSM-PGI-master/ImageNet_models/densenet.py | '''DenseNet in PyTorch.'''
import math
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
class Bottleneck(nn.Module):
def __init__(self, in_planes, growth_rate):
super(Bottleneck, self).__init__()
self.bn1 = nn.BatchNorm2d(in_planes)
s... | 3,607 | 31.8 | 96 | py |
FGSM-PGI | FGSM-PGI-master/ImageNet_models/preact_resnet.py | '''Pre-activation ResNet in PyTorch.
Reference:
[1] Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian Sun
Identity Mappings in Deep Residual Networks. arXiv:1603.05027
'''
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
class PreActBlock(nn.Module):
'''Pre-... | 4,127 | 33.115702 | 102 | py |
FGSM-PGI | FGSM-PGI-master/ImageNet_models/googlenet.py | '''GoogLeNet with PyTorch.'''
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
class Inception(nn.Module):
def __init__(self, in_planes, n1x1, n3x3red, n3x3, n5x5red, n5x5, pool_planes):
super(Inception, self).__init__()
# 1x1 conv branch
... | 3,237 | 29.54717 | 83 | py |
FGSM-PGI | FGSM-PGI-master/ImageNet_models/resnext.py | '''ResNeXt in PyTorch.
See the paper "Aggregated Residual Transformations for Deep Neural Networks" for more details.
'''
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
class Block(nn.Module):
'''Grouped convolution block.'''
expansion = 2
def __i... | 3,525 | 34.979592 | 129 | py |
FGSM-PGI | FGSM-PGI-master/ImageNet_models/senet.py | '''SENet in PyTorch.
SENet is the winner of ImageNet-2017. The paper is not released yet.
'''
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
class BasicBlock(nn.Module):
def __init__(self, in_planes, planes, stride=1):
super(BasicBlock, self).__ini... | 4,075 | 31.870968 | 102 | py |
FGSM-PGI | FGSM-PGI-master/ImageNet_models/shufflenet.py | '''ShuffleNet in PyTorch.
See the paper "ShuffleNet: An Extremely Efficient Convolutional Neural Network for Mobile Devices" for more details.
'''
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
class ShuffleBlock(nn.Module):
def __init__(self, groups):
... | 3,598 | 31.133929 | 126 | py |
FGSM-PGI | FGSM-PGI-master/ImageNet_models/wide_resnet.py | import math
import torch
import torch.nn as nn
import torch.nn.functional as F
class BasicBlock(nn.Module):
def __init__(self, in_planes, out_planes, stride, dropRate=0.0):
super(BasicBlock, self).__init__()
self.bn1 = nn.BatchNorm2d(in_planes)
self.relu1 = nn.ReLU(inplace=True)
se... | 3,902 | 41.423913 | 116 | py |
FGSM-PGI | FGSM-PGI-master/ImageNet_models/lenet.py | '''LeNet in PyTorch.'''
import torch.nn as nn
import torch.nn.functional as F
class LeNet(nn.Module):
def __init__(self):
super(LeNet, self).__init__()
self.conv1 = nn.Conv2d(3, 6, 5)
self.conv2 = nn.Conv2d(6, 16, 5)
self.fc1 = nn.Linear(16*5*5, 120)
self.fc2 = nn.Linear... | 699 | 28.166667 | 43 | py |
FGSM-PGI | FGSM-PGI-master/ImageNet_models/mobilenet.py | '''MobileNet in PyTorch.
See the paper "MobileNets: Efficient Convolutional Neural Networks for Mobile Vision Applications"
for more details.
'''
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
class Block(nn.Module):
'''Depthwise conv + Pointwise conv'''
... | 2,072 | 31.390625 | 123 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.