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 |
|---|---|---|---|---|---|---|
adanet | adanet-master/adanet/experimental/keras/ensemble_model_test.py | # Lint as: python3
# Copyright 2019 The AdaNet Authors. All Rights Reserved.
#
# 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.org/licenses/LICENSE-2.0
#
# Unless req... | 3,693 | 34.519231 | 79 | py |
adanet | adanet-master/adanet/experimental/keras/model_search_test.py | # Lint as: python3
# Copyright 2019 The AdaNet Authors. All Rights Reserved.
#
# 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.org/licenses/LICENSE-2.0
#
# Unless req... | 8,219 | 35.533333 | 86 | py |
adanet | adanet-master/adanet/experimental/keras/model_search.py | # Lint as: python3
# Copyright 2019 The AdaNet Authors. All Rights Reserved.
#
# 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.org/licenses/LICENSE-2.0
#
# Unless req... | 1,757 | 32.807692 | 82 | py |
adanet | adanet-master/adanet/experimental/keras/__init__.py | # Lint as: python3
# Copyright 2020 The AdaNet Authors. All Rights Reserved.
# 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.org/licenses/LICENSE-2.0
# Unless requir... | 1,015 | 34.034483 | 74 | py |
adanet | adanet-master/adanet/experimental/controllers/sequential_controller.py | # Lint as: python3
# Copyright 2019 The AdaNet Authors. All Rights Reserved.
#
# 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.org/licenses/LICENSE-2.0
#
# Unless req... | 1,826 | 35.54 | 80 | py |
adanet | adanet-master/adanet/experimental/controllers/controller.py | # Lint as: python3
# Copyright 2019 The AdaNet Authors. All Rights Reserved.
# 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.org/licenses/LICENSE-2.0
# Unless requir... | 1,316 | 31.925 | 77 | py |
adanet | adanet-master/adanet/tf_compat/__init__.py | # Copyright 2018 The AdaNet Authors. All Rights Reserved.
# 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.org/licenses/LICENSE-2.0
# Unless required by applicable la... | 6,952 | 29.362445 | 80 | py |
DsGammaAnalysis | DsGammaAnalysis-main/ml_tool/ml_tool/__main__.py | import sys
import traceback
import argparse
from datetime import datetime
from pathlib import Path
from .dataset import DataSet, BackgroundMode
def parse_arguments(args) -> argparse.Namespace:
parser = argparse.ArgumentParser(prog='ml_tool')
subparsers = parser.add_subparsers(help='This tool has several mode... | 9,864 | 43.638009 | 149 | py |
DsGammaAnalysis | DsGammaAnalysis-main/ml_tool/ml_tool/designer.py | from tensorflow.keras import layers
from tensorflow.keras import models
import tensorflow as tf
from tensorflow import keras
from .model import Model
from .config import *
## Here define models:
# dense models
def create_dense_layers(config):
return_layers = []
return_layers.append(layers.Dense(config['layer1_... | 4,161 | 46.83908 | 141 | py |
DsGammaAnalysis | DsGammaAnalysis-main/ml_tool/ml_tool/model.py | from dataclasses import dataclass
from typing import Dict, List, Union
from pathlib import Path
import json
from tensorflow import keras
@dataclass
class Model:
model: keras.Model
name: str
metadata: Dict[str, Union[str, int, bool, list]]
def save(self, directory) -> None:
self.model.save(st... | 1,289 | 30.463415 | 143 | py |
airflow | airflow-main/airflow/configuration.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... | 76,033 | 40.525942 | 109 | py |
CLIP2Scene | CLIP2Scene-main/downstream.py | import os
import gc
import argparse
import MinkowskiEngine as ME
import pytorch_lightning as pl
from downstream.evaluate import evaluate
from utils.read_config import generate_config
from downstream.model_builder import make_model
from pytorch_lightning.plugins import DDPPlugin
from downstream.lightning_trainer import ... | 3,175 | 36.809524 | 109 | py |
CLIP2Scene | CLIP2Scene-main/pretrain.py | import os
import argparse
import torch.nn as nn
# import MinkowskiEngine as ME
import pytorch_lightning as pl
from utils.read_config import generate_config
from pretrain.model_builder import make_model
from pytorch_lightning.plugins import DDPPlugin
from pretrain.lightning_trainer import LightningPretrain
from pretrain... | 2,421 | 36.261538 | 108 | py |
CLIP2Scene | CLIP2Scene-main/evaluate.py | import torch
import argparse
from downstream.evaluate import evaluate
from utils.read_config import generate_config
from downstream.model_builder import make_model
from downstream.dataloader_kitti import make_data_loader as make_data_loader_kitti
from downstream.dataloader_nuscenes import make_data_loader as make_data_... | 2,938 | 37.671053 | 103 | py |
CLIP2Scene | CLIP2Scene-main/pretrain/dataloader_scannet.py | import os
import copy
import torch
import numpy as np
from PIL import Image
import MinkowskiEngine as ME
from torch.utils.data import Dataset
# import pc_utils
from plyfile import PlyData, PlyElement
import math
# from pc_utils import write_ply_rgb
import sys
sys.path.append("..")
# from MinkowskiEngine.utils import sp... | 8,764 | 35.67364 | 171 | py |
CLIP2Scene | CLIP2Scene-main/pretrain/lightning_datamodule.py | import torch
import numpy as np
import pytorch_lightning as pl
from torch.utils.data import DataLoader
from pretrain.dataloader_nuscenes import (
NuScenesMatchDataset,
minkunet_collate_pair_fn,
)
from pretrain.dataloader_kitti import (
KittiMatchDataset,
kitti_collate_pair_fn,
)
from pretrain.... | 5,540 | 33.203704 | 104 | py |
CLIP2Scene | CLIP2Scene-main/pretrain/lightning_trainer.py | import os
import re
import torch
import numpy as np
import torch.optim as optim
import MinkowskiEngine as ME
import pytorch_lightning as pl
from utils.chamfer_distance import ComputeCDLoss
from pretrain.criterion import NCELoss, DistillKL, semantic_NCELoss
from pytorch_lightning.utilities import rank_zero_only
from tor... | 14,055 | 39.507205 | 132 | py |
CLIP2Scene | CLIP2Scene-main/pretrain/dataloader_nuscenes.py | import os
import copy
import torch
import numpy as np
from PIL import Image
# import MinkowskiEngine as ME
from pyquaternion import Quaternion
from torch.utils.data import Dataset
from nuscenes.nuscenes import NuScenes
from nuscenes.utils.geometry_utils import view_points
from nuscenes.utils.splits import create_splits... | 18,090 | 39.113082 | 147 | py |
CLIP2Scene | CLIP2Scene-main/pretrain/dataloader_nuscenes_spconv.py | import os
import copy
import torch
import numpy as np
from PIL import Image
from pyquaternion import Quaternion
from torch.utils.data import Dataset
from nuscenes.nuscenes import NuScenes
from nuscenes.utils.geometry_utils import view_points
from nuscenes.utils.splits import create_splits_scenes
from nuscenes.utils.dat... | 14,192 | 38.756303 | 114 | py |
CLIP2Scene | CLIP2Scene-main/pretrain/lightning_trainer_spconv.py | import os
import re
import torch
import numpy as np
import torch.optim as optim
import pytorch_lightning as pl
from pretrain.criterion import NCELoss
from pytorch_lightning.utilities import rank_zero_only
def bilinear_interpolate_torch(im, x, y):
"""
Args:
im: (H, W, C) [y, x]
x: (N)
y... | 8,642 | 35.778723 | 128 | py |
CLIP2Scene | CLIP2Scene-main/pretrain/pc_utils.py | """ Utility functions for processing point clouds.
Author: Charles R. Qi, Hao Su
Date: November 2016
"""
import os
import sys
import warnings
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
sys.path.append(BASE_DIR)
# Draw point cloud
from eulerangles import euler2mat
import math
# Point cloud IO
import numpy ... | 21,734 | 35.529412 | 104 | py |
CLIP2Scene | CLIP2Scene-main/pretrain/criterion.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import math
class NCELoss(nn.Module):
"""
Compute the PointInfoNCE loss
"""
def __init__(self, temperature):
super(NCELoss, self).__init__()
self.temperature = temperature
self.criterion = nn.CrossEntropyLoss()
... | 10,649 | 33.690554 | 120 | py |
CLIP2Scene | CLIP2Scene-main/pretrain/dataloader_kitti.py |
import os
import re
import torch
import numpy as np
from torch.utils.data import Dataset
# from MinkowskiEngine.utils import sparse_quantize
from utils.transforms import make_transforms_clouds
from torchsparse import SparseTensor
from torchsparse.utils.collate import sparse_collate_fn
from torchsparse.utils.quantize i... | 10,972 | 34.282958 | 154 | py |
CLIP2Scene | CLIP2Scene-main/downstream/dataloader_scannet.py | import os
import copy
import torch
import numpy as np
from PIL import Image
import MinkowskiEngine as ME
from torch.utils.data import Dataset
# import pc_utils
from plyfile import PlyData, PlyElement
import math
# from pc_utils import write_ply_rgb
import sys
sys.path.append("..")
# from MinkowskiEngine.utils import sp... | 10,704 | 35.660959 | 171 | py |
CLIP2Scene | CLIP2Scene-main/downstream/lightning_datamodule.py | import torch
import numpy as np
import pytorch_lightning as pl
from torch.utils.data import DataLoader
from utils.transforms import make_transforms_clouds
from downstream.dataloader_kitti import SemanticKITTIDataset
from downstream.dataloader_nuscenes import NuScenesDataset, custom_collate_fn
from downstream.dataloader... | 5,158 | 35.85 | 86 | py |
CLIP2Scene | CLIP2Scene-main/downstream/evaluate.py | import numpy as np
import torch
from tqdm import tqdm
from copy import deepcopy
from MinkowskiEngine import SparseTensor
# from torchsparse import SparseTensor
from utils.metrics import compute_IoU
CLASSES_NUSCENES = [
"barrier",
"bicycle",
"bus",
"car",
"construction_vehicle",
"motorcycle",
... | 5,359 | 26.628866 | 101 | py |
CLIP2Scene | CLIP2Scene-main/downstream/lightning_trainer.py | import os
import torch
import torch.optim as optim
import pytorch_lightning as pl
from MinkowskiEngine import SparseTensor
# from torchsparse import SparseTensor
from downstream.criterion import DownstreamLoss, unknown_aware_infoNCE
from pytorch_lightning.utilities import rank_zero_only
from utils.metrics import confus... | 8,081 | 40.446154 | 148 | py |
CLIP2Scene | CLIP2Scene-main/downstream/dataloader_nuscenes.py | import os
import torch
import numpy as np
from torch.utils.data import Dataset
from nuscenes.nuscenes import NuScenes
# from MinkowskiEngine.utils import sparse_quantize
from utils.transforms import make_transforms_clouds
from nuscenes.utils.splits import create_splits_scenes
from nuscenes.utils.data_classes import Lid... | 12,825 | 37.866667 | 149 | py |
CLIP2Scene | CLIP2Scene-main/downstream/model_builder.py | import torch
from model import MinkUNet, SPVCNN
def load_state_with_same_shape(model, weights):
"""
Load common weights in two similar models
(for instance between a pretraining and a downstream training)
"""
model_state = model.state_dict()
if list(weights.keys())[0].startswith("model."):
... | 3,677 | 41.275862 | 98 | py |
CLIP2Scene | CLIP2Scene-main/downstream/criterion.py | """
Lovasz-Softmax and Jaccard hinge loss in PyTorch
Maxim Berman 2018 ESAT-PSI KU Leuven (MIT License)
https://github.com/edwardzhou130/PolarSeg/blob/master/network/lovasz_losses.py
"""
from __future__ import print_function, division
import torch
import torch.nn as nn
from torch.autograd import Variable
import torch... | 14,503 | 32.496536 | 88 | py |
CLIP2Scene | CLIP2Scene-main/downstream/dataloader_kitti.py | import os
import re
import torch
import numpy as np
from torch.utils.data import Dataset
# from MinkowskiEngine.utils import sparse_quantize
from utils.transforms import make_transforms_clouds
# from torchsparse import SparseTensor
# from torchsparse.utils.collate import sparse_collate_fn
# from torchsparse.utils.quant... | 7,816 | 33.436123 | 147 | py |
CLIP2Scene | CLIP2Scene-main/utils/savemodel.py | import torch
import os
def save_checkpoint(self):
trained_epoch = self.cur_epoch + 1
ckpt_name = self.ckpt_dir / ('checkpoint_epoch_%d' % trained_epoch)
checkpoint_state = {}
checkpoint_state['epoch'] = trained_epoch
checkpoint_state['it'] = self.it
if isinstance(self.model, torch.nn.parallel.D... | 1,481 | 41.342857 | 76 | py |
CLIP2Scene | CLIP2Scene-main/utils/chamfer_distance.py | import torch
import torch.nn as nn
def compute_chamfer_distance(p1, p2):
'''
Calculate Chamfer Distance between two point sets
:param p1: size[bn, N, D]
:param p2: size[bn, M, D]
:param debug: whether need to output debug info
:return: sum of Chamfer Distance of two point sets
'''
dif... | 934 | 25.714286 | 85 | py |
CLIP2Scene | CLIP2Scene-main/utils/prompt_engineering.py | import numpy as np
import torch
import clip
import argparse
scannet_classes = ['wall', 'floor', 'cabinet', 'bed', 'chair', 'sofa', 'table', 'door', 'window', 'bookshelf', 'picture', 'counter', 'desk', 'curtain', 'refrigerator', 'shower curtain', 'toilet', 'sink', 'bathtub', 'other furniture']
nuscenes_classes = ["bar... | 17,422 | 171.50495 | 5,180 | py |
CLIP2Scene | CLIP2Scene-main/utils/metrics.py | import torch
def confusion_matrix(preds, labels, num_classes):
hist = (
torch.bincount(
num_classes * labels + preds,
minlength=num_classes ** 2,
)
.reshape(num_classes, num_classes)
.float()
)
return hist
def compute_IoU_from_cmatrix(hist, ignore_... | 1,229 | 28.285714 | 81 | py |
CLIP2Scene | CLIP2Scene-main/utils/pc_utils.py | """ Utility functions for processing point clouds.
Author: Charles R. Qi, Hao Su
Date: November 2016
"""
import os
import sys
import warnings
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
sys.path.append(BASE_DIR)
# Draw point cloud
from eulerangles import euler2mat
import math
# Point cloud IO
import numpy ... | 21,735 | 35.469799 | 104 | py |
CLIP2Scene | CLIP2Scene-main/utils/testfiles.py | import os
import copy
import torch
import numpy as np
from PIL import Image
# import MinkowskiEngine as ME
from pyquaternion import Quaternion
from torch.utils.data import Dataset
from nuscenes.nuscenes import NuScenes
from nuscenes.utils.geometry_utils import view_points
from nuscenes.utils.splits import create_splits... | 17,559 | 37.008658 | 166 | py |
CLIP2Scene | CLIP2Scene-main/utils/convert_clip_weights.py | import torch
import clip
import argparse
def parse_args():
parser = argparse.ArgumentParser(description='Extract and save the CLIP visual weights')
parser.add_argument('--model', default='RN50', choices=['RN50', 'RN101', 'RN50x4', 'RN50x16', 'RN50x64', 'ViT32', 'ViT16', 'ViT14'], help='clip model name')
p... | 4,232 | 46.033333 | 160 | py |
CLIP2Scene | CLIP2Scene-main/utils/transforms.py | import torch
import random
import numpy as np
# from torchvision.transforms import InterpolationMode
from torchvision.transforms import RandomResizedCrop
from torchvision.transforms.functional import resize, resized_crop, hflip
import math
class ComposeClouds:
"""
Compose multiple transformations on a point cl... | 11,427 | 33.841463 | 95 | py |
CLIP2Scene | CLIP2Scene-main/model/clip_model.py | import torch.nn as nn
import torch.nn.functional as F
import clip
class ClipFeatureExtractor(nn.Module):
"""
DINO Vision Transformer Feature Extractor.
"""
def __init__(self, config, preprocessing=None):
super(ClipFeatureExtractor, self).__init__()
self.encoder, preprocess = clip.load... | 1,158 | 28.717949 | 92 | py |
CLIP2Scene | CLIP2Scene-main/model/image_model.py | import os
import torch
import requests
import torch.nn as nn
import torch.nn.functional as F
import torchvision.transforms as T
import torch.utils.model_zoo as model_zoo
from torchvision.models.resnet import model_urls
from model.modules.resnet_encoder import resnet_encoders
import model.modules.dino.vision_transformer... | 8,571 | 34.27572 | 119 | py |
CLIP2Scene | CLIP2Scene-main/model/fusionNet.py | import os
import torch
import requests
import torch.nn as nn
import torch.nn.functional as F
import torchvision.transforms as T
import torch.utils.model_zoo as model_zoo
from torchvision.models.resnet import model_urls
from model.modules.resnet_encoder import resnet_encoders
import model.modules.dino.vision_transformer... | 2,487 | 42.649123 | 188 | py |
CLIP2Scene | CLIP2Scene-main/model/resnet.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.
# https://arxiv.org/abs/2007.10985
import torch.nn as nn
import MinkowskiEngine as ME
from MinkowskiEngine import MinkowskiNetwork
from mode... | 5,183 | 28.123596 | 88 | py |
CLIP2Scene | CLIP2Scene-main/model/spconv_backbone.py | from functools import partial
import numpy as np
import spconv
import torch.nn as nn
def post_act_block(
in_channels,
out_channels,
kernel_size,
indice_key=None,
stride=1,
padding=0,
conv_type="subm",
norm_fn=None,
):
if conv_type == "subm":
conv = spconv.SubMConv3d(
... | 12,158 | 28.512136 | 117 | py |
CLIP2Scene | CLIP2Scene-main/model/spvcnn.py | import torchsparse
import torchsparse.nn as spnn
import torch
import torch.nn.functional as F
import numpy as np
import pickle
from torch import nn
from torchsparse import PointTensor
from torchsparse import SparseTensor
from torchsparse.nn.utils import fapply
import torch
import torch.nn as nn
import torch.nn.function... | 18,958 | 36.691849 | 155 | py |
CLIP2Scene | CLIP2Scene-main/model/vit.py | # Copyright (c) OpenMMLab. All rights reserved.
import math
import warnings
from xmlrpc.client import Boolean
import torch
import torch.nn as nn
from mmcv.cnn import build_norm_layer
from mmcv.cnn.bricks.transformer import FFN, MultiheadAttention
from mmcv.cnn.utils.weight_init import (constant_init, kaiming_init,
... | 26,623 | 39.03609 | 128 | py |
CLIP2Scene | CLIP2Scene-main/model/minkunet.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.
# https://arxiv.org/abs/2007.10985
from model.resnet import ResNetBase, get_norm
from model.modules.common import ConvType, NormType, conv, co... | 11,742 | 28.804569 | 114 | py |
CLIP2Scene | CLIP2Scene-main/model/maskclip_model.py | # Copyright (c) OpenMMLab. All rights reserved.
from mmcv.utils import print_log
from mmcv.cnn.bricks.transformer import FFN, MultiheadAttention
from mmcv.runner import BaseModule, ModuleList, _load_checkpoint
from torch.nn.modules.utils import _pair as to_2tuple
from mmseg.ops import resize
from mmseg.utils import get... | 37,830 | 37.603061 | 119 | py |
CLIP2Scene | CLIP2Scene-main/model/modules/resnet_encoder.py | import torch.nn as nn
from torchvision.models.resnet import ResNet
from torchvision.models.resnet import BasicBlock
from torchvision.models.resnet import Bottleneck
class ResNetEncoder(ResNet):
def __init__(self, **kwargs):
super().__init__(**kwargs)
del self.fc
del self.avgpool
def... | 1,314 | 22.070175 | 59 | py |
CLIP2Scene | CLIP2Scene-main/model/modules/resnet_block.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.nn as nn
from model.modules.common import ConvType, NormType, get_norm, conv
from MinkowskiEngine import MinkowskiReLU
class ... | 3,375 | 23.114286 | 81 | py |
CLIP2Scene | CLIP2Scene-main/model/modules/dino/vision_transformer.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# 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 ... | 15,379 | 40.013333 | 124 | py |
NSVF | NSVF-main/setup.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.
from setuptools import setup
from torch.utils.cpp_extension import BuildExtension, CUDAExtension
import glob
# build clib
# _ext_src_root = ... | 1,224 | 28.878049 | 87 | py |
NSVF | NSVF-main/fairnr/renderer.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 file is to simulate "generator" in fairseq
"""
import os, tempfile, shutil, glob
import time
import torch
import numpy as np
import ... | 10,725 | 41.904 | 145 | py |
NSVF | NSVF-main/fairnr/options.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 argparse
import sys
import torch
from fairseq import options
def parse_args_and_arch(*args, **kwargs):
return options.parse_arg... | 2,595 | 50.92 | 131 | py |
NSVF | NSVF-main/fairnr/modules/renderer.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 math
from collections import defaultdict
import torch
import torch.nn as nn
import torch.nn.functional as F
from fairnr.modules.modul... | 12,718 | 44.102837 | 141 | py |
NSVF | NSVF-main/fairnr/modules/reader.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
import torch.nn as nn
import random, os, glob
from fairnr.data.geometry import get_ray_direction, r6d2mat
torch.autograd.set_de... | 7,959 | 42.736264 | 125 | py |
NSVF | NSVF-main/fairnr/modules/field.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 math
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import grad
from collections import Order... | 21,863 | 45.322034 | 131 | py |
NSVF | NSVF-main/fairnr/modules/encoder.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
import torch.nn as nn
import torch.nn.functional as F
import torch.distributed as dist
import numpy as np
import math
import sys... | 49,252 | 45.377589 | 157 | py |
NSVF | NSVF-main/fairnr/modules/hyper.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.
'''
Pytorch implementations of hyper-network modules.
This code is largely adapted from
https://github.com/vsitzmann/scene-representation-net... | 8,327 | 32.991837 | 125 | py |
NSVF | NSVF-main/fairnr/modules/module_utils.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 math
import torch
import torch.nn as nn
import torch.nn.functional as F
from fairseq.modules import LayerNorm
from fairseq.utils impor... | 5,337 | 31.54878 | 125 | py |
NSVF | NSVF-main/fairnr/modules/implicit.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
import torch.nn as nn
import torch.nn.functional as F
from fairseq.utils import get_activation_fn
from fairnr.modules.hyper impo... | 6,163 | 34.837209 | 111 | py |
NSVF | NSVF-main/fairnr/criterions/rendering_loss.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 math
import torch.nn.functional as F
import torch
from torch import Tensor
from fairseq import metrics
from fairseq.utils import ite... | 9,677 | 43.805556 | 122 | py |
NSVF | NSVF-main/fairnr/criterions/utils.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
import torch.nn.functional as F
TINY = 1e-7
def rgb_loss(predicts, rgbs, masks=None, L1=False, sum=False):
if masks is no... | 971 | 26 | 65 | py |
NSVF | NSVF-main/fairnr/criterions/perceptual_loss.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
import torchvision
class VGGPerceptualLoss(torch.nn.Module):
def __init__(self, resize=False):
super(VGGPerceptualLo... | 2,023 | 39.48 | 103 | py |
NSVF | NSVF-main/fairnr/models/nsvf_bg.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 logging
logger = logging.getLogger(__name__)
import cv2, math, time, copy, json
import numpy as np
from collections import defaultdict... | 7,079 | 43.810127 | 144 | py |
NSVF | NSVF-main/fairnr/models/multi_nsvf.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 logging
logger = logging.getLogger(__name__)
import torch
from fairseq.models import (
register_model,
register_model_archite... | 1,938 | 30.786885 | 89 | py |
NSVF | NSVF-main/fairnr/models/nerf.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 logging
logger = logging.getLogger(__name__)
import cv2, math, time
import numpy as np
from collections import defaultdict
import to... | 9,380 | 43.25 | 117 | py |
NSVF | NSVF-main/fairnr/models/fairnr_model.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.
"""
Base classes for various models.
The basic principle of differentiable rendering is two components:
-- an field or so-called geometri... | 14,302 | 41.19174 | 121 | py |
NSVF | NSVF-main/fairnr/models/nsvf.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 logging
logger = logging.getLogger(__name__)
import cv2, math, time
import numpy as np
from collections import defaultdict
import tor... | 14,499 | 43.072948 | 135 | py |
NSVF | NSVF-main/fairnr/models/nmf.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 logging
logger = logging.getLogger(__name__)
import torch
from fairseq.models import (
register_model,
register_model_architec... | 3,148 | 36.939759 | 92 | py |
NSVF | NSVF-main/fairnr/clib/__init__.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.
''' Modified based on: https://github.com/erikwijmans/Pointnet2_PyTorch '''
from __future__ import (
division,
absolute_import,
w... | 14,842 | 37.553247 | 110 | py |
NSVF | NSVF-main/fairnr/data/data_utils.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
import functools
import cv2
import math
import numpy as np
import imageio
from glob import glob
import os
import copy
import shut... | 11,063 | 28.902703 | 125 | py |
NSVF | NSVF-main/fairnr/data/shape_dataset.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 os, glob
import copy
import numpy as np
import torch
import logging
from collections import defaultdict
from fairseq.data import Fairs... | 20,801 | 36.821818 | 141 | py |
NSVF | NSVF-main/fairnr/data/geometry.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 numpy as np
import torch
import torch.nn.functional as F
from fairnr.data import data_utils as D
try:
from fairnr.clib._ext import... | 11,984 | 33.941691 | 112 | py |
NSVF | NSVF-main/fairnr/data/trajectory.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
import numpy as np
TRAJECTORY_REGISTRY = {}
def register_traj(name):
def register_traj_fn(fn):
if name in TRAJECTO... | 2,045 | 34.894737 | 130 | py |
NSVF | NSVF-main/fairnr/tasks/neural_rendering.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 os, copy
import json
import torch
import imageio
import numpy as np
from collections import defaultdict
from torchvision.utils import s... | 17,291 | 50.159763 | 114 | py |
NSVF | NSVF-main/fairnr_cli/render.py | #!/usr/bin/env python3 -u
# 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 is a copy of fairseq-generate while simpler for other usage.
"""
import logging
import math
import os
impo... | 3,570 | 28.03252 | 96 | py |
NSVF | NSVF-main/fairnr_cli/render_multigpu.py | #!/usr/bin/env python3 -u
# 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 is a copy of fairseq-generate while simpler for other usage.
"""
import logging
import math
import os
impo... | 4,399 | 29.985915 | 98 | py |
NSVF | NSVF-main/fairnr_cli/validate.py | #!/usr/bin/env python3 -u
# 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 logging
import sys
import numpy as np
import torch
from itertools import chain
from fairseq import checkpoin... | 5,384 | 33.082278 | 102 | py |
NSVF | NSVF-main/fairnr_cli/extract.py | #!/usr/bin/env python3 -u
# 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 code is used for extact voxels/meshes from the learne model
"""
import logging
import numpy as np
import tor... | 3,180 | 38.7625 | 127 | py |
NSVF | NSVF-main/fairnr_cli/train.py | #!/usr/bin/env python3 -u
# 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.
"""
Train a new model on one or across multiple GPUs.
This file is mostly copied from the original fairseq code
"""
... | 13,414 | 34.489418 | 117 | py |
RegularizedBN | RegularizedBN-main/setup.py | #!/usr/bin/env python3
# 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 os
from setuptools import setup, find_packages, Extension
import sys
if sys.version_info < (3, 6):
sys.exi... | 4,389 | 25.768293 | 101 | py |
RegularizedBN | RegularizedBN-main/hubconf.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 functools
from fairseq.hub_utils import BPEHubInterface as bpe # noqa
from fairseq.hub_utils import TokenizerHubInterface as tokenize... | 1,432 | 28.244898 | 78 | py |
RegularizedBN | RegularizedBN-main/examples/wav2vec/vq-wav2vec_featurize.py | #!/usr/bin/env python3
# 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.
"""
Helper script to pre-compute embeddings for a wav2letter++ dataset
"""
import pprint
import glob, os, argparse
im... | 7,714 | 29.737052 | 111 | py |
RegularizedBN | RegularizedBN-main/examples/wav2vec/wav2vec_featurize.py | #!/usr/bin/env python3
# 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.
"""
Helper script to pre-compute embeddings for a wav2letter++ dataset
"""
import argparse
import glob
import os
from ... | 7,110 | 29.004219 | 135 | py |
RegularizedBN | RegularizedBN-main/examples/translation_moe/src/mean_pool_gating_network.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
import torch.nn.functional as F
class MeanPoolGatingNetwork(torch.nn.Module):
"""A simple mean-pooling gating network for s... | 2,007 | 38.372549 | 84 | py |
RegularizedBN | RegularizedBN-main/examples/translation_moe/src/logsumexp_moe.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
class LogSumExpMoE(torch.autograd.Function):
"""Standard LogSumExp forward pass, but use *posterior* for the backward.
... | 835 | 29.962963 | 78 | py |
RegularizedBN | RegularizedBN-main/examples/translation_moe/src/translation_moe.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 fairseq import metrics, utils
from fairseq.tasks import register_task
from fairseq.tasks.translation import TranslationTask... | 9,137 | 40.348416 | 107 | py |
RegularizedBN | RegularizedBN-main/examples/roberta/commonsense_qa/commonsense_qa_task.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 json
import os
import numpy as np
import torch
from fairseq.data import (
data_utils,
Dictionary,
encoders,
IdDataset... | 5,921 | 32.84 | 103 | py |
RegularizedBN | RegularizedBN-main/examples/roberta/wsc/wsc_task.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 json
import os
import tempfile
import numpy as np
import torch
import torch.nn.functional as F
from fairseq import utils
from fairseq... | 13,148 | 33.970745 | 103 | py |
RegularizedBN | RegularizedBN-main/examples/roberta/wsc/wsc_criterion.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 math
import torch
import torch.nn.functional as F
from fairseq import utils
from fairseq.data import encoders
from fairseq.criterions... | 6,034 | 35.137725 | 88 | py |
RegularizedBN | RegularizedBN-main/examples/speech_recognition/infer.py | #!/usr/bin/env python3 -u
# 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.
"""
Run inference for pre-processed data with a trained model.
"""
import editdistance
import logging
import math
i... | 14,668 | 33.193473 | 147 | py |
RegularizedBN | RegularizedBN-main/examples/speech_recognition/w2l_decoder.py | #!/usr/bin/env python3
# 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.
"""
Wav2letter decoders.
"""
from collections import namedtuple, deque
import gc
import itertools as it
import numpy ... | 14,872 | 33.269585 | 164 | py |
RegularizedBN | RegularizedBN-main/examples/speech_recognition/criterions/cross_entropy_acc.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.
from __future__ import absolute_import, division, print_function, unicode_literals
import logging
import math
import torch
import torch.nn.f... | 5,372 | 40.015267 | 85 | py |
RegularizedBN | RegularizedBN-main/examples/speech_recognition/criterions/ASG_loss.py | #!/usr/bin/env python3
# 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 fairseq import utils
from fairseq.criterions import FairseqCriterion, register_criterion
from exampl... | 5,857 | 33.25731 | 85 | py |
RegularizedBN | RegularizedBN-main/examples/speech_recognition/models/vggtransformer.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 argparse
import math
from collections.abc import Iterable
import torch
import torch.nn as nn
from fairseq import utils
from fairseq.mo... | 37,043 | 35.786495 | 88 | py |
RegularizedBN | RegularizedBN-main/examples/speech_recognition/models/w2l_conv_glu_enc.py | #!/usr/bin/env python3
# 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 math
import torch
import torch.nn as nn
import torch.nn.functional as F
from fairseq.models import (
Fair... | 6,079 | 32.96648 | 87 | py |
RegularizedBN | RegularizedBN-main/examples/speech_recognition/datasets/asr_prep_json.py | #!/usr/bin/env python3
# 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.
from __future__ import absolute_import, division, print_function, unicode_literals
from collections import namedtuple
... | 3,670 | 36.845361 | 134 | py |
RegularizedBN | RegularizedBN-main/examples/speech_recognition/data/collaters.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 module contains collection of classes which implement
collate functionalities for various tasks.
Collaters should know wh... | 4,812 | 35.462121 | 84 | py |
RegularizedBN | RegularizedBN-main/examples/speech_recognition/data/data_utils.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
def calc_mean_invstddev(feature):
if len(feature.size()) != 2:
raise ValueError("We expect the input feature to be ... | 3,429 | 32.960396 | 84 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.