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 |
|---|---|---|---|---|---|---|
easy_pbr | easy_pbr-master/examples/shadows.py | #!/usr/bin/env python3
try:
import torch
except ImportError:
pass
from easypbr import *
config_file="./config/shadows.cfg"
view=Viewer.create(config_file)
#puts the camera in a nicer view than default. You can also comment these two lines and EasyPBR will place the camera by default for you so that the scene i... | 698 | 24.888889 | 171 | py |
easy_pbr | easy_pbr-master/examples/colormap.py | #!/usr/bin/env python3
try:
import torch
except ImportError:
pass
from easypbr import *
import numpy as np
def map_range_np( input_val, input_start, input_end, output_start, output_end):
# input_clamped=torch.clamp(input_val, input_start, input_end)
input_clamped=np.clip(input_val, input_start, input... | 1,174 | 22.039216 | 115 | py |
easy_pbr | easy_pbr-master/examples/offscreen.py | #!/usr/bin/env python3
try:
import torch
except ImportError:
pass
from easypbr import *
config_file="./config/offscreen.cfg" #sets the use_offscreen flag
view=Viewer.create(config_file)
#puts the camera in a nicer view than default. You can also comment these two lines and EasyPBR will place the camera by defa... | 936 | 27.393939 | 171 | py |
easy_pbr | easy_pbr-master/examples/head.py | #!/usr/bin/env python3
try:
import torch
except ImportError:
pass
from easypbr import *
config_file="./config/head.cfg"
view=Viewer.create(config_file)
#hide the gird floor
Scene.set_floor_visible(False)
def make_figure():
head=Mesh("/media/rosu/Data/data/3d_objs/3d_scan_store/OBJ/Head/Head.OBJ")
head.set... | 5,617 | 47.017094 | 170 | py |
easy_pbr | easy_pbr-master/examples/textures.py | #!/usr/bin/env python3
try:
import torch
except ImportError:
pass
from easypbr import *
config_file="./config/textures.cfg"
view=Viewer.create(config_file)
#lantern
mesh=Mesh("./data/textured/lantern/lantern_obj.obj")
mesh.set_diffuse_tex("./data/textured/lantern/textures/lantern_Base_Color.jpg")
mesh.set_norm... | 660 | 23.481481 | 82 | py |
easy_pbr | easy_pbr-master/examples/lines.py | #!/usr/bin/env python3
try:
import torch
except ImportError:
pass
from easypbr import *
config_file="./config/default_params.cfg"
view=Viewer.create(config_file)
# Scene.set_floor_visible(False)
mesh=Mesh()
mesh.V=[ #fill up the vertices of the mesh as a matrix of Nx3
[0,0,0],
[0,1,0],
[0.2... | 902 | 19.522727 | 133 | py |
easy_pbr | easy_pbr-master/examples/pbr.py | #!/usr/bin/env python3
try:
import torch
except ImportError:
pass
from easypbr import *
config_file="./config/pbr.cfg"
view=Viewer.create(config_file)
#puts the camera in a nicer view than default. You can also comment these two lines and EasyPBR will place the camera by default for you so that the scene is fu... | 1,123 | 30.222222 | 171 | py |
easy_pbr | easy_pbr-master/examples/primitives.py | #!/usr/bin/env python3
try:
import torch
except ImportError:
pass
from easypbr import *
config_file="./config/primitives.cfg"
view=Viewer.create(config_file)
# Scene.set_floor_visible(False)
box=Mesh()
box.create_box(1,1,1)
Scene.show(box,"box")
sphere=Mesh()
sphere.create_sphere([0,0,0], 1)
sphere.model_mat... | 625 | 17.969697 | 95 | py |
easy_pbr | easy_pbr-master/examples/cuda_gl_interop.py | #!/usr/bin/env python3
try:
import torch
except ImportError:
pass
from easypbr import *
#Just to have something close to the macros we have in c++
def profiler_start(name):
if(Profiler.is_profiling_gpu()):
torch.cuda.synchronize()
Profiler.start(name)
def profiler_end(name):
if(Profiler.is_p... | 3,015 | 27.186916 | 171 | py |
easy_pbr | easy_pbr-master/examples/show_img.py | #!/usr/bin/env python3
try:
import torch
except ImportError:
pass
from easypbr import *
view=Viewer.create()
#show a mesh
mesh=Mesh("./data/bunny.ply")
Scene.show(mesh,"mesh")
mat=Mat("./data/uv_checker.png")
#show one img
Gui.show(mat, "mat1")
#show another image
view.update()
original_screen_tex=view.re... | 1,103 | 19.444444 | 85 | py |
easy_pbr | easy_pbr-master/examples/subsurface_scattering.py | #!/usr/bin/env python3
try:
import torch
except ImportError:
pass
from easypbr import *
config_file="./config/subsurface_scattering.cfg"
view=Viewer.create(config_file)
#hide the gird floor
Scene.set_floor_visible(False)
def make_figure():
#download model from https://www.3dscanstore.com/blog/Free-3D-Head-M... | 3,020 | 35.841463 | 163 | py |
easy_pbr | easy_pbr-master/examples/high_poly.py | #!/usr/bin/env python3
try:
import torch
except ImportError:
pass
from easypbr import *
config_file="./config/high_poly.cfg"
view=Viewer.create(config_file)
#puts the camera in a nicer view than default. You can also comment these two lines and EasyPBR will place the camera by default for you so that the scene... | 896 | 26.181818 | 171 | py |
easy_pbr | easy_pbr-master/examples/bloom.py | #!/usr/bin/env python3
try:
import torch
except ImportError:
pass
from easypbr import *
config_file="./config/bloom.cfg"
view=Viewer.create(config_file)
mesh=Mesh("./data/head.obj")
Scene.show(mesh,"mesh")
#puts the camera in a nicer view than default. You can also comment these two lines and EasyPBR will pla... | 787 | 25.266667 | 171 | py |
easy_pbr | easy_pbr-master/examples/surfel.py | #!/usr/bin/env python3
try:
import torch
except ImportError:
pass
from easypbr import *
config_file="./config/surfel.cfg"
view=Viewer.create(config_file)
#puts the camera in a nicer view than default. You can also comment these two lines and EasyPBR will place the camera by default for you so that the scene is... | 812 | 23.636364 | 171 | py |
easy_pbr | easy_pbr-master/examples/balls.py | #!/usr/bin/env python3
try:
import torch
except ImportError:
pass
from easypbr import *
config_file="./config/balls.cfg"
view=Viewer.create(config_file)
mesh=Mesh("./data/sphere.obj")
Scene.show(mesh,"mesh")
#hide the gird floor
Scene.set_floor_visible(False)
while True:
view.update()
| 302 | 12.772727 | 32 | py |
easy_pbr | easy_pbr-master/examples/example_cpp/setup.py | import os
import re
import sys
import platform
import subprocess
import glob
from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext
from distutils.version import LooseVersion
from distutils.command.install_headers import install_headers as install_headers_orig
from setuptools import... | 10,790 | 34.496711 | 215 | py |
easy_pbr | easy_pbr-master/examples/example_cpp/python/example.py | #!/usr/bin/env python3
import sys
import os
import time
try:
import torch
except ImportError:
pass
from easypbr import *
| 129 | 10.818182 | 22 | py |
easy_pbr | easy_pbr-master/examples/example_cpp/python/mwe.py | #!/usr/bin/env python3
try:
import torch
except ImportError:
pass
from easypbr import *
from easypbr_wrapper import *
view = Viewer.create()
config_file="config/example.cfg"
wrapper = EasyPBRwrapper.create(config_file,view)
while True:
view.update()
| 264 | 16.666667 | 49 | py |
easy_pbr | easy_pbr-master/python/latticenet.py | #!/usr/bin/env python3.6
import sys
import os
try:
import torch
except ImportError:
pass
from easypbr import *
from easypbr import *
from os import listdir
from os.path import isfile, join
import natsort
config_file="./config/default_params.cfg"
meshes_path="/media/rosu/Data/data/semantic_kitti/predictions/fi... | 1,806 | 29.627119 | 112 | py |
easy_pbr | easy_pbr-master/python/empty.py | #!/usr/bin/env python3
try:
import torch
except ImportError:
pass
from easypbr import *
config_file="./config/default_params.cfg"
view=Viewer.create(config_file)
while True:
view.update()
| 201 | 12.466667 | 41 | py |
dlrm | dlrm-master/data_loader_terabyte.py | # Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from __future__ import absolute_import, division, print_function, unicode_literals
import os
import numpy as np
from torch.util... | 12,477 | 32.815718 | 89 | py |
dlrm | dlrm-master/extend_distributed.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
#
import builtins
import os
import sys
import torch
import torch.distributed as dist
from torch.autograd import Function
from torch.autograd.p... | 19,445 | 31.195364 | 125 | py |
dlrm | dlrm-master/dlrm_s_caffe2.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
#
# Description: an implementation of a deep learning recommendation model (DLRM)
# The model input consists of dense and sparse features. The ... | 73,313 | 42.024648 | 104 | py |
dlrm | dlrm-master/dlrm_data_pytorch.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
#
# Description: generate inputs and targets for the dlrm benchmark
# The inpts and outputs are generated according to the following three opti... | 46,812 | 35.232972 | 88 | py |
dlrm | dlrm-master/dlrm_s_pytorch.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
#
# Description: an implementation of a deep learning recommendation model (DLRM)
# The model input consists of dense and sparse features. The ... | 74,030 | 38.399148 | 123 | py |
dlrm | dlrm-master/dlrm_data_caffe2.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
#
# Description: generate inputs and targets for the dlrm benchmark
# The inpts and outputs are generated according to the following three opti... | 30,067 | 34.625592 | 86 | py |
dlrm | dlrm-master/mlperf_logger.py | # Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
Utilities for MLPerf logging
"""
import os
import torch
try:
from mlperf_logging import mllog
from mlperf_logging.m... | 2,929 | 23.621849 | 103 | py |
dlrm | dlrm-master/tools/visualize.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
#
#
# This script performs the visualization of the embedding tables created in
# DLRM during the training procedure. We use two popular techni... | 40,723 | 38.499515 | 200 | py |
dlrm | dlrm-master/optim/rwsadagrad.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import torch
from torch.optim import Optimizer
class RWSAdagrad(Optimizer):
"""Implements Row Wise Sparse Adagrad algorithm.
Argum... | 5,004 | 39.691057 | 123 | py |
dlrm | dlrm-master/tricks/qr_embedding_bag.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
#
# Quotient-Remainder Trick
#
# Description: Applies quotient remainder-trick to embeddings to reduce
# embedding sizes.
#
# References:
# [1]... | 9,675 | 51.021505 | 115 | py |
dlrm | dlrm-master/tricks/md_embedding_bag.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
#
# Mixed-Dimensions Trick
#
# Description: Applies mixed dimension trick to embeddings to reduce
# embedding sizes.
#
# References:
# [1] Anto... | 3,123 | 37.097561 | 86 | py |
DiffBEV | DiffBEV-main/tools/test.py | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
import os
import os.path as osp
import shutil
import time
import warnings
import mmcv
import torch
from mmcv.parallel import MMDataParallel, MMDistributedDataParallel
from mmcv.runner import (get_dist_info, init_dist, load_checkpoint,
... | 8,889 | 36.669492 | 100 | py |
DiffBEV | DiffBEV-main/tools/benchmark.py | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
import time
import torch
from mmcv import Config
from mmcv.parallel import MMDataParallel
from mmcv.runner import load_checkpoint, wrap_fp16_model
from mmseg.datasets import build_dataloader, build_dataset
from mmseg.models import build_segmentor
def p... | 2,556 | 28.390805 | 75 | py |
DiffBEV | DiffBEV-main/tools/onnx2tensorrt.py | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
import os
import os.path as osp
from typing import Iterable, Optional, Union
import matplotlib.pyplot as plt
import mmcv
import numpy as np
import onnxruntime as ort
import torch
from mmcv.ops import get_onnxruntime_op_path
from mmcv.tensorrt import (TRTW... | 9,334 | 32.700361 | 79 | py |
DiffBEV | DiffBEV-main/tools/publish_model.py | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
import subprocess
import torch
def parse_args():
parser = argparse.ArgumentParser(
description='Process a checkpoint to be published')
parser.add_argument('in_file', help='input checkpoint filename')
parser.add_argument('out_file', h... | 1,076 | 28.108108 | 77 | py |
DiffBEV | DiffBEV-main/tools/pytorch2onnx.py | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
from functools import partial
import mmcv
import numpy as np
import onnxruntime as rt
import torch
import torch._C
import torch.serialization
from mmcv import DictAction
from mmcv.onnx import register_extra_symbolics
from mmcv.runner import load_checkpoin... | 13,614 | 33.732143 | 79 | py |
DiffBEV | DiffBEV-main/tools/deploy_test.py | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
import os
import os.path as osp
import shutil
import warnings
from typing import Any, Iterable
import mmcv
import numpy as np
import torch
from mmcv.parallel import MMDataParallel
from mmcv.runner import get_dist_info
from mmcv.utils import DictAction
fr... | 11,139 | 36.508418 | 77 | py |
DiffBEV | DiffBEV-main/tools/pytorch2torchscript.py | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
import mmcv
import numpy as np
import torch
import torch._C
import torch.serialization
from mmcv.runner import load_checkpoint
from torch import nn
from mmseg.models import build_segmentor
torch.manual_seed(3)
def digit_version(version_str):
digit... | 6,057 | 31.569892 | 77 | py |
DiffBEV | DiffBEV-main/tools/train.py | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
import copy
import os
os.environ["TORCH_DISTRIBUTED_DEBUG"] = "DETAIL"
import os.path as osp
import time
import warnings
import torch.distributed as dist
import mmcv
import torch
from mmcv.cnn.utils import revert_sync_batchnorm
from mmcv.runner import get_... | 6,790 | 36.10929 | 104 | py |
DiffBEV | DiffBEV-main/tools/torchserve/mmseg_handler.py | # Copyright (c) OpenMMLab. All rights reserved.
import base64
import os
import cv2
import mmcv
import torch
from mmcv.cnn.utils.sync_bn import revert_sync_batchnorm
from ts.torch_handler.base_handler import BaseHandler
from mmseg.apis import inference_segmentor, init_segmentor
class MMsegHandler(BaseHandler):
... | 1,867 | 31.77193 | 79 | py |
DiffBEV | DiffBEV-main/tools/torchserve/test_torchserve.py | from argparse import ArgumentParser
from io import BytesIO
import matplotlib.pyplot as plt
import mmcv
import requests
from mmseg.apis import inference_segmentor, init_segmentor
def parse_args():
parser = ArgumentParser(
description='Compare result of torchserve and pytorch,'
'and visualize them... | 1,747 | 29.137931 | 77 | py |
DiffBEV | DiffBEV-main/tools/torchserve/mmseg2torchserve.py | # Copyright (c) OpenMMLab. All rights reserved.
from argparse import ArgumentParser, Namespace
from pathlib import Path
from tempfile import TemporaryDirectory
import mmcv
try:
from model_archiver.model_packaging import package_model
from model_archiver.model_packaging_utils import ModelExportUtils
except Imp... | 3,700 | 32.044643 | 76 | py |
DiffBEV | DiffBEV-main/tools/model_converters/vit2mmseg.py | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
import os.path as osp
from collections import OrderedDict
import mmcv
import torch
from mmcv.runner import CheckpointLoader
def convert_vit(ckpt):
new_ckpt = OrderedDict()
for k, v in ckpt.items():
if k.startswith('head'):
... | 2,117 | 28.830986 | 79 | py |
DiffBEV | DiffBEV-main/tools/model_converters/swin2mmseg.py | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
import os.path as osp
from collections import OrderedDict
import mmcv
import torch
from mmcv.runner import CheckpointLoader
def convert_swin(ckpt):
new_ckpt = OrderedDict()
def correct_unfold_reduction_order(x):
out_channel, in_channel ... | 2,728 | 30.011364 | 79 | py |
DiffBEV | DiffBEV-main/tools/model_converters/mit2mmseg.py | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
import os.path as osp
from collections import OrderedDict
import mmcv
import torch
from mmcv.runner import CheckpointLoader
def convert_mit(ckpt):
new_ckpt = OrderedDict()
# Process the concat between q linear weights and kv linear weights
f... | 3,069 | 35.987952 | 79 | py |
DiffBEV | DiffBEV-main/mmseg/apis/inference.py | # Copyright (c) OpenMMLab. All rights reserved.
import matplotlib.pyplot as plt
import mmcv
import torch
from mmcv.parallel import collate, scatter
from mmcv.runner import load_checkpoint
from mmseg.datasets.pipelines import Compose
from mmseg.models import build_segmentor
def init_segmentor(config, checkpoint=None,... | 4,663 | 33.043796 | 79 | py |
DiffBEV | DiffBEV-main/mmseg/apis/test.py | # Copyright (c) OpenMMLab. All rights reserved.
import os.path as osp
import tempfile
import mmcv
import numpy as np
import torch
from mmcv.engine import collect_results_cpu, collect_results_gpu
from mmcv.image import tensor2imgs
from mmcv.runner import get_dist_info
def np2tmp(array, temp_file_name=None, tmpdir=None... | 3,672 | 31.219298 | 78 | py |
DiffBEV | DiffBEV-main/mmseg/apis/train.py | # Copyright (c) OpenMMLab. All rights reserved.
import random
import warnings
import numpy as np
import torch
from mmcv.parallel import MMDataParallel, MMDistributedDataParallel
from mmcv.runner import build_optimizer, build_runner
from mmseg.core import DistEvalHook, EvalHook
from mmseg.datasets import build_dataloa... | 4,147 | 33.280992 | 78 | py |
DiffBEV | DiffBEV-main/mmseg/core/evaluation/eval_hooks.py | # Copyright (c) OpenMMLab. All rights reserved.
import os.path as osp
import warnings
import torch.distributed as dist
from mmcv.runner import DistEvalHook as _DistEvalHook
from mmcv.runner import EvalHook as _EvalHook
from torch.nn.modules.batchnorm import _BatchNorm
class EvalHook(_EvalHook):
"""Single GPU Eva... | 5,186 | 36.05 | 79 | py |
DiffBEV | DiffBEV-main/mmseg/core/evaluation/metrics.py | # Copyright (c) OpenMMLab. All rights reserved.
from collections import OrderedDict
import mmcv
import numpy as np
import torch
def f_score(precision, recall, beta=1):
"""calculate the f-score value.
Args:
precision (float | torch.Tensor): The precision value.
recall (float | torch.Tensor): ... | 16,077 | 39.60101 | 79 | py |
DiffBEV | DiffBEV-main/mmseg/core/seg/sampler/ohem_pixel_sampler.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn.functional as F
from ..builder import PIXEL_SAMPLERS
from .base_pixel_sampler import BasePixelSampler
@PIXEL_SAMPLERS.register_module()
class OHEMPixelSampler(BasePixelSampler):
"""Online Hard Example Mining Sampler for segmentation.
... | 3,305 | 40.325 | 103 | py |
DiffBEV | DiffBEV-main/mmseg/models/necks/ic_neck.py | import torch.nn.functional as F
from mmcv.cnn import ConvModule
from mmcv.runner import BaseModule
from mmseg.ops import resize
from ..builder import NECKS
class CascadeFeatureFusion(BaseModule):
"""Cascade Feature Fusion Unit in ICNet.
Args:
low_channels (int): The number of input channels for
... | 5,312 | 34.898649 | 76 | py |
DiffBEV | DiffBEV-main/mmseg/models/necks/multilevel_neck.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch.nn as nn
from mmcv.cnn import ConvModule, xavier_init
from mmseg.ops import resize
from ..builder import NECKS
@NECKS.register_module()
class MultiLevelNeck(nn.Module):
"""MultiLevelNeck.
A neck structure connect vit backbone and decoder_heads.
... | 2,716 | 33.392405 | 76 | py |
DiffBEV | DiffBEV-main/mmseg/models/necks/mla_neck.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch.nn as nn
from mmcv.cnn import ConvModule, build_norm_layer
from ..builder import NECKS
class MLAModule(nn.Module):
def __init__(self,
in_channels=[1024, 1024, 1024, 1024],
out_channels=256,
norm_cfg=N... | 3,873 | 31.554622 | 78 | py |
DiffBEV | DiffBEV-main/mmseg/models/necks/lift_splat_shoot_transformer.py | import torch
import torch.nn as nn
from mmcv.runner import BaseModule
from ..builder import NECKS
def gen_dx_bx(xbound, ybound, zbound):
dx = torch.Tensor([row[2] for row in [xbound, ybound, zbound]])
bx = torch.Tensor([row[0] + row[2]/2.0 for row in [xbound, ybound, zbound]])
nx = torch.Tensor([(row[1] - ... | 7,226 | 42.8 | 152 | py |
DiffBEV | DiffBEV-main/mmseg/models/necks/jpu.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn as nn
from mmcv.cnn import ConvModule, DepthwiseSeparableConvModule
from mmcv.runner import BaseModule
from mmseg.ops import resize
from ..builder import NECKS
@NECKS.register_module()
class JPU(BaseModule):
"""FastFCN: Rethinking Dilat... | 5,079 | 37.484848 | 79 | py |
DiffBEV | DiffBEV-main/mmseg/models/necks/v4_pyva_transformer.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from ..builder import NECKS
def feature_selection(input, dim, index):
views = [input.size(0)] + [1 if i != dim else -1 for i in range(1, len(input.size()))]
expanse = list(input.size())
expanse[0] = -1
expanse[dim] = -1
index = inde... | 10,732 | 40.762646 | 160 | py |
DiffBEV | DiffBEV-main/mmseg/models/necks/linear_transformer.py | import torch
import torch.nn as nn
from mmcv.runner import BaseModule
from ..builder import NECKS
import torch.nn.functional as F
@NECKS.register_module()
class TransformerLinear(BaseModule):
def __init__(self, use_light=False, use_high_res=False, input_width=25, input_height=19, input_dim=768, output_width=100, o... | 4,918 | 43.718182 | 159 | py |
DiffBEV | DiffBEV-main/mmseg/models/necks/pyramid_transformer.py | import math
import torch
import torch.nn as nn
import torch.nn.functional as F
from mmcv.runner import BaseModule
from functools import reduce
from operator import mul
from ..builder import NECKS
# generate grids in BEV
def _make_grid(resolution, extents):
# Create a grid of cooridinates in the birds-eye-view
... | 8,122 | 40.871134 | 113 | py |
DiffBEV | DiffBEV-main/mmseg/models/necks/fpn.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import ConvModule
from mmcv.runner import BaseModule, auto_fp16
from mmseg.ops import resize
from ..builder import NECKS
import pdb
@NECKS.register_module()
class FPN(BaseModule):
"""Feature Pyramid... | 9,192 | 42.363208 | 79 | py |
DiffBEV | DiffBEV-main/mmseg/models/necks/pyva_transformer.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from ..builder import NECKS
def feature_selection(input, dim, index):
views = [input.size(0)] + [1 if i != dim else -1 for i in range(1, len(input.size()))]
expanse = list(input.size())
expanse[0] = -1
expanse[dim] = -1
index = inde... | 5,002 | 37.782946 | 113 | py |
DiffBEV | DiffBEV-main/mmseg/models/decode_heads/fcn_head.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn as nn
from mmcv.cnn import ConvModule
from ..builder import HEADS
from .decode_head import BaseDecodeHead
@HEADS.register_module()
class FCNHead(BaseDecodeHead):
"""Fully Convolution Networks for Semantic Segmentation.
This head is... | 2,845 | 33.289157 | 77 | py |
DiffBEV | DiffBEV-main/mmseg/models/decode_heads/sep_aspp_head.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn as nn
from mmcv.cnn import ConvModule, DepthwiseSeparableConvModule
from mmseg.ops import resize
from ..builder import HEADS
from .aspp_head import ASPPHead, ASPPModule
class DepthwiseSeparableASPPModule(ASPPModule):
"""Atrous Spatial P... | 3,535 | 33.330097 | 76 | py |
DiffBEV | DiffBEV-main/mmseg/models/decode_heads/ann_head.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn as nn
from mmcv.cnn import ConvModule
from ..builder import HEADS
from ..utils import SelfAttentionBlock as _SelfAttentionBlock
from .decode_head import BaseDecodeHead
class PPMConcat(nn.ModuleList):
"""Pyramid Pooling Module that only ... | 9,284 | 36.439516 | 77 | py |
DiffBEV | DiffBEV-main/mmseg/models/decode_heads/apc_head.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import ConvModule
from mmseg.ops import resize
from ..builder import HEADS
from .decode_head import BaseDecodeHead
class ACM(nn.Module):
"""Adaptive Context Module used in APCNet.
... | 5,580 | 33.88125 | 76 | py |
DiffBEV | DiffBEV-main/mmseg/models/decode_heads/isa_head.py | import math
import torch
import torch.nn.functional as F
from mmcv.cnn import ConvModule
from ..builder import HEADS
from ..utils import SelfAttentionBlock as _SelfAttentionBlock
from .decode_head import BaseDecodeHead
class SelfAttentionBlock(_SelfAttentionBlock):
"""Self-Attention Module.
Args:
i... | 4,929 | 33.475524 | 79 | py |
DiffBEV | DiffBEV-main/mmseg/models/decode_heads/ocr_head.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import ConvModule
from mmseg.ops import resize
from ..builder import HEADS
from ..utils import SelfAttentionBlock as _SelfAttentionBlock
from .cascade_decode_head import BaseCascadeDecodeHea... | 4,327 | 32.550388 | 76 | py |
DiffBEV | DiffBEV-main/mmseg/models/decode_heads/dm_head.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import ConvModule, build_activation_layer, build_norm_layer
from ..builder import HEADS
from .decode_head import BaseDecodeHead
class DCM(nn.Module):
"""Dynamic Convolutional Module us... | 5,032 | 34.443662 | 79 | py |
DiffBEV | DiffBEV-main/mmseg/models/decode_heads/ema_head.py | # Copyright (c) OpenMMLab. All rights reserved.
import math
import torch
import torch.distributed as dist
import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import ConvModule
from ..builder import HEADS
from .decode_head import BaseDecodeHead
def reduce_mean(tensor):
"""Reduce mean when distrib... | 5,824 | 33.264706 | 77 | py |
DiffBEV | DiffBEV-main/mmseg/models/decode_heads/da_head.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn.functional as F
from mmcv.cnn import ConvModule, Scale
from torch import nn
from mmseg.core import add_prefix
from ..builder import HEADS
from ..utils import SelfAttentionBlock as _SelfAttentionBlock
from .decode_head import BaseDecodeHead
... | 5,622 | 30.238889 | 77 | py |
DiffBEV | DiffBEV-main/mmseg/models/decode_heads/psp_head.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn as nn
from mmcv.cnn import ConvModule
from mmseg.ops import resize
from ..builder import HEADS
from .decode_head import BaseDecodeHead
class PPM(nn.ModuleList):
"""Pooling Pyramid Module used in PSPNet.
Args:
pool_scales (t... | 3,404 | 31.740385 | 78 | py |
DiffBEV | DiffBEV-main/mmseg/models/decode_heads/cc_head.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from ..builder import HEADS
from .fcn_head import FCNHead
try:
from mmcv.ops import CrissCrossAttention
except ModuleNotFoundError:
CrissCrossAttention = None
@HEADS.register_module()
class CCHead(FCNHead):
"""CCNet: Criss-Cross Attention for ... | 1,464 | 30.847826 | 102 | py |
DiffBEV | DiffBEV-main/mmseg/models/decode_heads/enc_head.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import ConvModule, build_norm_layer
from mmseg.ops import Encoding, resize
from ..builder import HEADS, build_loss
from .decode_head import BaseDecodeHead
class EncModule(nn.Module):
"... | 6,792 | 34.941799 | 78 | py |
DiffBEV | DiffBEV-main/mmseg/models/decode_heads/pyramid_head_kitti.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from abc import ABCMeta
from mmcv.runner import BaseModule, force_fp32
from ..builder import HEADS
from ..losses import iou
import cv2
import numpy as np
def prior_uncertainty_loss(x, mask, priors):
# priors shape: [2]-->[1,2,1,1]-->[bs,2,196,200]... | 10,610 | 36.761566 | 136 | py |
DiffBEV | DiffBEV-main/mmseg/models/decode_heads/setr_up_head.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch.nn as nn
from mmcv.cnn import ConvModule, build_norm_layer
from mmseg.ops import Upsample
from ..builder import HEADS
from .decode_head import BaseDecodeHead
@HEADS.register_module()
class SETRUPHead(BaseDecodeHead):
"""Naive upsampling head and Progre... | 2,962 | 35.134146 | 79 | py |
DiffBEV | DiffBEV-main/mmseg/models/decode_heads/setr_mla_head.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn as nn
from mmcv.cnn import ConvModule
from mmseg.ops import Upsample
from ..builder import HEADS
from .decode_head import BaseDecodeHead
@HEADS.register_module()
class SETRMLAHead(BaseDecodeHead):
"""Multi level feature aggretation head... | 2,177 | 33.03125 | 79 | py |
DiffBEV | DiffBEV-main/mmseg/models/decode_heads/dpt_head.py | import math
import torch
import torch.nn as nn
from mmcv.cnn import ConvModule, Linear, build_activation_layer
from mmcv.runner import BaseModule
from mmseg.ops import resize
from ..builder import HEADS
from .decode_head import BaseDecodeHead
class ReassembleBlocks(BaseModule):
"""ViTPostProcessBlock, process c... | 10,351 | 34.210884 | 78 | py |
DiffBEV | DiffBEV-main/mmseg/models/decode_heads/fpn_head.py | # Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import torch.nn as nn
from mmcv.cnn import ConvModule
from mmseg.ops import Upsample, resize
from ..builder import HEADS
from .decode_head import BaseDecodeHead
@HEADS.register_module()
class FPNHead(BaseDecodeHead):
"""Panoptic Feature Pyramid N... | 2,437 | 33.828571 | 79 | py |
DiffBEV | DiffBEV-main/mmseg/models/decode_heads/nl_head.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from mmcv.cnn import NonLocal2d
from ..builder import HEADS
from .fcn_head import FCNHead
@HEADS.register_module()
class NLHead(FCNHead):
"""Non-local Neural Networks.
This head is the implementation of `NLNet
<https://arxiv.org/abs/1711.07971... | 1,605 | 30.490196 | 78 | py |
DiffBEV | DiffBEV-main/mmseg/models/decode_heads/dnl_head.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from mmcv.cnn import NonLocal2d
from torch import nn
from ..builder import HEADS
from .fcn_head import FCNHead
class DisentangledNonLocal2d(NonLocal2d):
"""Disentangled Non-Local Blocks.
Args:
temperature (float): Temperature to adjust att... | 4,619 | 33.736842 | 78 | py |
DiffBEV | DiffBEV-main/mmseg/models/decode_heads/decode_head.py | from abc import ABCMeta, abstractmethod
import torch
import torch.nn as nn
from mmcv.runner import BaseModule, auto_fp16, force_fp32
from mmseg.core import build_pixel_sampler
from mmseg.ops import resize
from ..builder import build_loss
from ..losses import accuracy
class BaseDecodeHead(BaseModule, metaclass=ABCMe... | 10,468 | 39.111111 | 79 | py |
DiffBEV | DiffBEV-main/mmseg/models/decode_heads/lraspp_head.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn as nn
from mmcv import is_tuple_of
from mmcv.cnn import ConvModule
from mmseg.ops import resize
from ..builder import HEADS
from .decode_head import BaseDecodeHead
@HEADS.register_module()
class LRASPPHead(BaseDecodeHead):
"""Lite R-ASP... | 3,086 | 32.554348 | 77 | py |
DiffBEV | DiffBEV-main/mmseg/models/decode_heads/uper_head.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn as nn
from mmcv.cnn import ConvModule
from mmseg.ops import resize
from ..builder import HEADS
from .decode_head import BaseDecodeHead
from .psp_head import PPM
@HEADS.register_module()
class UPerHead(BaseDecodeHead):
"""Unified Percept... | 4,020 | 30.414063 | 72 | py |
DiffBEV | DiffBEV-main/mmseg/models/decode_heads/aspp_head.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn as nn
from mmcv.cnn import ConvModule
from mmseg.ops import resize
from ..builder import HEADS
from .decode_head import BaseDecodeHead
class ASPPModule(nn.ModuleList):
"""Atrous Spatial Pyramid Pooling (ASPP) Module.
Args:
... | 3,467 | 30.816514 | 76 | py |
DiffBEV | DiffBEV-main/mmseg/models/decode_heads/psa_head.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import ConvModule
from mmseg.ops import resize
from ..builder import HEADS
from .decode_head import BaseDecodeHead
try:
from mmcv.ops import PSAMask
except ModuleNotFoundError:
PSAM... | 7,532 | 37.045455 | 79 | py |
DiffBEV | DiffBEV-main/mmseg/models/decode_heads/pyramid_head.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from abc import ABCMeta
from mmcv.runner import BaseModule, force_fp32
from ..builder import HEADS
from ..losses import iou
def prior_uncertainty_loss(x, mask, priors):
# priors shape: [14]-->[1,14,1,1]-->[bs,14,196,200]
priors = x.new(priors)... | 8,647 | 35.644068 | 157 | py |
DiffBEV | DiffBEV-main/mmseg/models/decode_heads/gc_head.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from mmcv.cnn import ContextBlock
from ..builder import HEADS
from .fcn_head import FCNHead
@HEADS.register_module()
class GCHead(FCNHead):
"""GCNet: Non-local Networks Meet Squeeze-Excitation Networks and Beyond.
This head is the implementation o... | 1,639 | 32.469388 | 79 | py |
DiffBEV | DiffBEV-main/mmseg/models/decode_heads/segformer_head.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn as nn
from mmcv.cnn import ConvModule
from mmseg.models.builder import HEADS
from mmseg.models.decode_heads.decode_head import BaseDecodeHead
from mmseg.ops import resize
@HEADS.register_module()
class SegformerHead(BaseDecodeHead):
"""... | 2,044 | 29.522388 | 78 | py |
DiffBEV | DiffBEV-main/mmseg/models/decode_heads/point_head.py | # Copyright (c) OpenMMLab. All rights reserved.
# Modified from https://github.com/facebookresearch/detectron2/tree/master/projects/PointRend/point_head/point_head.py # noqa
import torch
import torch.nn as nn
from mmcv.cnn import ConvModule
from mmcv.ops import point_sample
from mmseg.models.builder import HEADS
fro... | 14,862 | 41.224432 | 126 | py |
DiffBEV | DiffBEV-main/mmseg/models/utils/embed.py | # Copyright (c) OpenMMLab. All rights reserved.
import math
from typing import Sequence
import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import build_conv_layer, build_norm_layer
from mmcv.runner.base_module import BaseModule
from mmcv.utils import to_2tuple
class AdaptivePadding(nn.Module):
"... | 15,781 | 36.221698 | 80 | py |
DiffBEV | DiffBEV-main/mmseg/models/utils/se_layer.py | # Copyright (c) OpenMMLab. All rights reserved.
import mmcv
import torch.nn as nn
from mmcv.cnn import ConvModule
from .make_divisible import make_divisible
class SELayer(nn.Module):
"""Squeeze-and-Excitation Module.
Args:
channels (int): The input (and output) channels of the SE layer.
rati... | 2,151 | 35.474576 | 79 | py |
DiffBEV | DiffBEV-main/mmseg/models/utils/SynchronizedBatchNorm2d.py | import collections
import torch
import torch.nn.functional as F
from torch.nn.modules.batchnorm import _BatchNorm
from torch.nn.parallel._functions import ReduceAddCoalesced, Broadcast
import queue
import threading
class FutureResult(object):
"""A thread-safe future implementation. Used only as one-to-one pipe."""... | 14,819 | 40.166667 | 127 | py |
DiffBEV | DiffBEV-main/mmseg/models/utils/res_layer.py | # Copyright (c) OpenMMLab. All rights reserved.
from mmcv.cnn import build_conv_layer, build_norm_layer
from mmcv.runner import Sequential
from torch import nn as nn
class ResLayer(Sequential):
"""ResLayer to build ResNet style backbone.
Args:
block (nn.Module): block used to build ResLayer.
... | 3,395 | 34.010309 | 79 | py |
DiffBEV | DiffBEV-main/mmseg/models/utils/self_attention_block.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from mmcv.cnn import ConvModule, constant_init
from torch import nn as nn
from torch.nn import functional as F
class SelfAttentionBlock(nn.Module):
"""General self-attention block/non-local block.
Please refer to https://arxiv.org/abs/1706.03762 fo... | 6,173 | 37.347826 | 78 | py |
DiffBEV | DiffBEV-main/mmseg/models/utils/up_conv_block.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn as nn
from mmcv.cnn import ConvModule, build_upsample_layer
class UpConvBlock(nn.Module):
"""Upsample convolution block in decoder for UNet.
This upsample convolution block consists of one upsample module
followed by one convolu... | 4,016 | 38 | 79 | py |
DiffBEV | DiffBEV-main/mmseg/models/utils/inverted_residual.py | # Copyright (c) OpenMMLab. All rights reserved.
from mmcv.cnn import ConvModule
from torch import nn
from torch.utils import checkpoint as cp
from .se_layer import SELayer
class InvertedResidual(nn.Module):
"""InvertedResidual block for MobileNetV2.
Args:
in_channels (int): The input channels of the... | 7,162 | 32.471963 | 79 | py |
DiffBEV | DiffBEV-main/mmseg/models/utils/dist_util.py | """
Helpers for distributed training.
"""
import io
import os
import socket
import blobfile as bf
from mpi4py import MPI
import torch as th
import torch.distributed as dist
# Change this to reflect your cluster layout.
# The GPU for a given rank is (rank % GPUS_PER_NODE).
GPUS_PER_NODE = 8
SETUP_RETRY_COUNT = 3
d... | 2,424 | 24.797872 | 87 | py |
DiffBEV | DiffBEV-main/mmseg/models/segmentors/base.py | # Copyright (c) OpenMMLab. All rights reserved.
import warnings
from abc import ABCMeta, abstractmethod
from collections import OrderedDict
import mmcv
import numpy as np
import torch
import torch.distributed as dist
from mmcv.runner import BaseModule, auto_fp16
class BaseSegmentor(BaseModule, metaclass=ABCMeta):
... | 10,642 | 37.843066 | 86 | py |
DiffBEV | DiffBEV-main/mmseg/models/segmentors/cascade_encoder_decoder.py | # Copyright (c) OpenMMLab. All rights reserved.
from torch import nn
from mmseg.core import add_prefix
from mmseg.ops import resize
from .. import builder
from ..builder import SEGMENTORS
from .encoder_decoder import EncoderDecoder
@SEGMENTORS.register_module()
class CascadeEncoderDecoder(EncoderDecoder):
"""Cas... | 3,134 | 35.882353 | 78 | py |
DiffBEV | DiffBEV-main/mmseg/models/segmentors/encoder_decoder.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn as nn
import torch.nn.functional as F
from mmseg.core import add_prefix
from mmseg.ops import resize
from .. import builder
from ..builder import SEGMENTORS
from .base import BaseSegmentor
@SEGMENTORS.register_module()
class EncoderDecoder(... | 11,231 | 37.465753 | 79 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.