python_code stringlengths 0 4.04M | repo_name stringlengths 8 58 | file_path stringlengths 5 147 |
|---|---|---|
from setuptools import setup
from torch.utils.cpp_extension import BuildExtension, CUDAExtension
setup(
name='PG_OP',
ext_modules=[
CUDAExtension('PG_OP', [
'src/bfs_cluster.cpp',
'src/bfs_cluster_kernel.cu',
])
],
cmdclass={'build_ext': BuildExtension}
)
| ContrastiveSceneContexts-main | downstream/insseg/lib/bfs/ops/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.
import os
import random
import torch
import hydra
import numpy as np
from lib.ddp_trainer import DetectionTrainer
from lib.distributed import... | ContrastiveSceneContexts-main | downstream/votenet/ddp_main.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 sys
import os
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
sys.path.append(BASE_DIR)
ROOT_DIR = os.path.di... | ContrastiveSceneContexts-main | downstream/votenet/datasets/sunrgbd/model_util_sunrgbd.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.
''' Provides Python helper function to read My SUNRGBD dataset.
Author: Charles R. Qi
Date: October, 2017
Updated by Charles R. Qi
Date: De... | ContrastiveSceneContexts-main | downstream/votenet/datasets/sunrgbd/sunrgbd_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.
''' Helper class and functions for loading SUN RGB-D objects
Author: Charles R. Qi
Date: December, 2018
Note: removed unused code for frust... | ContrastiveSceneContexts-main | downstream/votenet/datasets/sunrgbd/sunrgbd_data.py |
# coding: utf-8
# 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.
""" Dataset for 3D object detection on SUN RGB-D (with support of vote supervision).
A sunrgbd oriented bounding box is para... | ContrastiveSceneContexts-main | downstream/votenet/datasets/sunrgbd/sunrgbd_detection_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.
""" Utility functions for metric evaluation.
Author: Or Litany and Charles R. Qi
"""
import os
import sys
BASE_DIR = os.path.dirname(os.pat... | ContrastiveSceneContexts-main | downstream/votenet/datasets/evaluation/metric_util.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 os, sys, argparse
import inspect
from copy import deepcopy
from evaluate_object_detection_helper import eval_det
import nu... | ContrastiveSceneContexts-main | downstream/votenet/datasets/evaluation/evaluate_object_detection.py |
import os, sys
import csv
import numpy as np
import imageio
# print an error message and quit
def print_error(message, user_fault=False):
sys.stderr.write('ERROR: ' + str(message) + '\n')
if user_fault:
sys.exit(2)
sys.exit(-1)
# if string s represents an int
def represents_int(s):
try:
... | ContrastiveSceneContexts-main | downstream/votenet/datasets/evaluation/util.py |
import os, sys
import json
import numpy as np
from plyfile import PlyData, PlyElement
import util
# matrix: 4x4 np array
# points Nx3 np array
def transform_points(matrix, points):
assert len(points.shape) == 2 and points.shape[1] == 3
num_points = points.shape[0]
p = np.concatenate([points, np.ones((num_... | ContrastiveSceneContexts-main | downstream/votenet/datasets/evaluation/util_3d.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.
""" Generic Code for Object Detection Evaluation
Input:
For each class:
For each image:
Predictions: box, score
... | ContrastiveSceneContexts-main | downstream/votenet/datasets/evaluation/evaluate_object_detection_helper.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.
""" Load Scannet scenes with vertices and ground truth labels
for semantic and instance segmentations
"""
# python imports
import math
impor... | ContrastiveSceneContexts-main | downstream/votenet/datasets/scannet/load_scannet_data.py |
# coding: utf-8
# 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.
""" Dataset for object bounding box regression.
An axis aligned bounding box is parameterized by (cx,cy,cz) and (dx,dy,dz)
wh... | ContrastiveSceneContexts-main | downstream/votenet/datasets/scannet/scannet_detection_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.
""" Batch mode in loading Scannet scenes with vertices and ground truth labels
for semantic and instance segmentations
Usage example: python... | ContrastiveSceneContexts-main | downstream/votenet/datasets/scannet/batch_load_scannet_data.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 sys
import os
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
sys.path.append(BASE_DIR)
ROOT_DIR = os.path.di... | ContrastiveSceneContexts-main | downstream/votenet/datasets/scannet/model_util_scannet.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 sys
import os
BASE_DIR = os.path.dirname(__file__)
sys.path.append(BASE_DIR)
import numpy as np
import pc_util
scene_name = 'scanne... | ContrastiveSceneContexts-main | downstream/votenet/datasets/scannet/data_viz.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.
''' Ref: https://github.com/ScanNet/ScanNet/blob/master/BenchmarkScripts '''
import os
import sys
import json
import csv
try:
import num... | ContrastiveSceneContexts-main | downstream/votenet/datasets/scannet/scannet_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 as nn
import numpy as np
import sys
import os
from lib.utils.nn_distance import nn_distance, huber_loss
FAR_THR... | ContrastiveSceneContexts-main | downstream/votenet/models/loss_helper.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 os
import sys
from lib.utils import pc_util
DUMP_CONF_THRESH = 0.5 # Dump boxes with obj prob larger ... | ContrastiveSceneContexts-main | downstream/votenet/models/dump_helper.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 numpy as np
import sys
import os
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
ROOT_DIR = o... | ContrastiveSceneContexts-main | downstream/votenet/models/loss_helper_boxnet.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.
""" Helper functions and class to calculate Average Precisions for 3D object detection.
"""
import os
import sys
import numpy as np
import to... | ContrastiveSceneContexts-main | downstream/votenet/models/ap_helper.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.
''' Voting module: generate votes from XYZ and features of seed points.
Date: July, 2019
Author: Charles R. Qi and Or Litany
'''
import tor... | ContrastiveSceneContexts-main | downstream/votenet/models/voting_module.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 numpy as np
import os
import sys
BASE_DIR = os.path.dirname(os.path... | ContrastiveSceneContexts-main | downstream/votenet/models/proposal_module.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 numpy as np
import sys
import os
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
ROOT_DIR = o... | ContrastiveSceneContexts-main | downstream/votenet/models/boxnet.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 numpy as np
import sys
import os
from models.backbone.pointnet2.po... | ContrastiveSceneContexts-main | downstream/votenet/models/backbone_module.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.
""" Deep hough voting network for 3D object detection in point clouds.
Author: Charles R. Qi and Or Litany
"""
import torch
import torch.nn... | ContrastiveSceneContexts-main | downstream/votenet/models/votenet.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 torch
def str2opt(arg):
assert arg in ['SGD', 'Adam']
return arg
def str2scheduler(arg):
assert arg in... | ContrastiveSceneContexts-main | downstream/votenet/models/backbone/sparseconv/config.py |
# coding: utf-8
# 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
import sys
import numpy as np
import torch
from torch.utils.data import Dataset
from torch.utils.data._utils.colla... | ContrastiveSceneContexts-main | downstream/votenet/models/backbone/sparseconv/voxelized_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. | ContrastiveSceneContexts-main | downstream/votenet/models/backbone/sparseconv/__init__.py |
import collections
import numpy as np
import MinkowskiEngine as ME
from scipy.linalg import expm, norm
# Rotation matrix along axis with angle theta
def M(axis, theta):
return expm(np.cross(np.eye(3), axis / norm(axis) * theta))
class Voxelizer:
def __init__(self,
voxel_size=1,
... | ContrastiveSceneContexts-main | downstream/votenet/models/backbone/sparseconv/voxelizer.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 random
from torch.nn import Module
from MinkowskiEngine import SparseTensor
class Wrapper(Module):
"""
Wrapper for the segmenta... | ContrastiveSceneContexts-main | downstream/votenet/models/backbone/sparseconv/models_sparseconv/wrapper.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 models.backbone.sparseconv.models_sparseconv.resnet import ResNetBase, get_norm
from models.backbone.sparseconv.models_sparseconv.modul... | ContrastiveSceneContexts-main | downstream/votenet/models/backbone/sparseconv/models_sparseconv/resunet.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 models.backbone.sparseconv.models_sparseconv import resunet as resunet
from models.backbone.sparseconv.models_sparseconv import res16u... | ContrastiveSceneContexts-main | downstream/votenet/models/backbone/sparseconv/models_sparseconv/__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.
from models.backbone.sparseconv.models_sparseconv.resnet import ResNetBase, get_norm
from models.backbone.sparseconv.models_sparseconv.module... | ContrastiveSceneContexts-main | downstream/votenet/models/backbone/sparseconv/models_sparseconv/res16unet.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 MinkowskiEngine import MinkowskiNetwork
class Model(MinkowskiNetwork):
"""
Base network for all sparse convnet
By default, all... | ContrastiveSceneContexts-main | downstream/votenet/models/backbone/sparseconv/models_sparseconv/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.
import torch.nn as nn
import MinkowskiEngine as ME
from models.backbone.sparseconv.models_sparseconv.model import Model
from models.backbon... | ContrastiveSceneContexts-main | downstream/votenet/models/backbone/sparseconv/models_sparseconv/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.
import torch
import torch.nn as nn
from torch.autograd import Variable
from MinkowskiEngine import SparseTensor, MinkowskiConvolution, Mink... | ContrastiveSceneContexts-main | downstream/votenet/models/backbone/sparseconv/models_sparseconv/conditional_random_fields.py |
import torch.nn as nn
from models.backbone.sparseconv.models_sparseconv.modules.common import ConvType, NormType, get_norm, conv
from MinkowskiEngine import MinkowskiReLU
class BasicBlockBase(nn.Module):
expansion = 1
NORM_TYPE = NormType.BATCH_NORM
def __init__(self,
inplanes,
... | ContrastiveSceneContexts-main | downstream/votenet/models/backbone/sparseconv/models_sparseconv/modules/resnet_block.py |
import torch.nn as nn
import MinkowskiEngine as ME
from models.modules.common import ConvType, NormType
from models.modules.resnet_block import BasicBlock, Bottleneck
class SELayer(nn.Module):
def __init__(self, channel, reduction=16, D=-1):
# Global coords does not require coords_key
super(SELayer, self... | ContrastiveSceneContexts-main | downstream/votenet/models/backbone/sparseconv/models_sparseconv/modules/senet_block.py |
ContrastiveSceneContexts-main | downstream/votenet/models/backbone/sparseconv/models_sparseconv/modules/__init__.py | |
import collections
from enum import Enum
import torch.nn as nn
import MinkowskiEngine as ME
class NormType(Enum):
BATCH_NORM = 0
INSTANCE_NORM = 1
INSTANCE_BATCH_NORM = 2
def get_norm(norm_type, n_channels, D, bn_momentum=0.1):
if norm_type == NormType.BATCH_NORM:
return ME.MinkowskiBatchNorm(n_channel... | ContrastiveSceneContexts-main | downstream/votenet/models/backbone/sparseconv/models_sparseconv/modules/common.py |
ContrastiveSceneContexts-main | downstream/votenet/models/backbone/sparseconv/lib/__init__.py | |
from scipy.sparse import csr_matrix
import torch
class SparseMM(torch.autograd.Function):
"""
Sparse x dense matrix multiplication with autograd support.
Implementation by Soumith Chintala:
https://discuss.pytorch.org/t/
does-pytorch-support-autograd-on-sparse-matrix/6156/7
"""
def forward(self, matrix... | ContrastiveSceneContexts-main | downstream/votenet/models/backbone/sparseconv/lib/math_functions.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 Ref: https://github.com/erikwijmans/Pointnet2_PyTorch '''
import torch
import torch.nn as nn
from typing import List, T... | ContrastiveSceneContexts-main | downstream/votenet/models/backbone/pointnet2/pytorch_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 glob
import os
from setuptools import setup
from torch.utils.cpp_extension import BuildExtension, CUDAExtension
this_dir = os.path.d... | ContrastiveSceneContexts-main | downstream/votenet/models/backbone/pointnet2/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.
''' Modified based on: https://github.com/erikwijmans/Pointnet2_PyTorch '''
from __future__ import (
division,
absolute_import,
w... | ContrastiveSceneContexts-main | downstream/votenet/models/backbone/pointnet2/pointnet2_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.
''' Testing customized ops. '''
import torch
from torch.autograd import gradcheck
import numpy as np
import os
import sys
BASE_DIR = os.pat... | ContrastiveSceneContexts-main | downstream/votenet/models/backbone/pointnet2/pointnet2_test.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.
''' Pointnet2 layers.
Modified based on: https://github.com/erikwijmans/Pointnet2_PyTorch
Extended with the following:
1. Uniform sampling in... | ContrastiveSceneContexts-main | downstream/votenet/models/backbone/pointnet2/pointnet2_modules.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 os
import sys
import logging
import numpy as np
import importlib
import warnings
import argparse
import torch.optim as ... | ContrastiveSceneContexts-main | downstream/votenet/lib/ddp_trainer.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.
#!/usr/bin/env python3
import os
import time
import torch
import signal
import pickle
import threading
import random
import functools
impor... | ContrastiveSceneContexts-main | downstream/votenet/lib/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.
""" Utility functions for metric evaluation.
Author: Or Litany and Charles R. Qi
"""
import os
import sys
import torch
BASE_DIR = os.path.d... | ContrastiveSceneContexts-main | downstream/votenet/lib/utils/metric_util.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.
""" Generic Code for Object Detection Evaluation
Input:
For each class:
For each image:
Predictions: box, score
... | ContrastiveSceneContexts-main | downstream/votenet/lib/utils/eval_det.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.
""" Chamfer distance in Pytorch.
Author: Charles R. Qi
"""
import torch
import torch.nn as nn
import numpy as np
def huber_loss(error, del... | ContrastiveSceneContexts-main | downstream/votenet/lib/utils/nn_distance.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.
""" Utility functions for processing point clouds.
Author: Charles R. Qi and Or Litany
"""
import os
import sys
BASE_DIR = os.path.dirname(... | ContrastiveSceneContexts-main | downstream/votenet/lib/utils/pc_util.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
from pc_util import bbox_corner_dist_measure
# boxes are axis aigned 2D boxes of shape (n,5) in FLOAT numbers with (x1,y1... | ContrastiveSceneContexts-main | downstream/votenet/lib/utils/nms.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.
'''Code adapted from https://github.com/junyanz/pytorch-CycleGAN-and-pix2pix'''
import os
import time
BASE_DIR = os.path.dirname(os.path.absp... | ContrastiveSceneContexts-main | downstream/votenet/lib/utils/tf_visualizer.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 numpy as np
import trimesh
# color palette for nyu40 labels
def create_color_palette():
return [
(0, 0, 0),
... | ContrastiveSceneContexts-main | downstream/votenet/lib/utils/io3d.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 tensorflow as tf
import numpy as np
import scipy.misc
try:
from StringIO import StringIO # Python 2.7
except ImportError:
fr... | ContrastiveSceneContexts-main | downstream/votenet/lib/utils/tf_logger.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.
""" Helper functions for calculating 2D and 3D bounding box IoU.
Collected and written by Charles R. Qi
Last modified: Jul 2019
"""
from __f... | ContrastiveSceneContexts-main | downstream/votenet/lib/utils/box_util.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 glob, os
import numpy as np
import cv2
import argparse
from plyfile import PlyData, PlyElement
# params
parser = argparse.ArgumentP... | ContrastiveSceneContexts-main | pretrain/scannet_pair/point_cloud_extractor.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 glob, os, sys
from SensorData import SensorData
# params
parser = argparse.ArgumentParser()
# data paths
parser.add... | ContrastiveSceneContexts-main | pretrain/scannet_pair/generage_list.py |
import os, struct
import numpy as np
import zlib
import imageio
import cv2
COMPRESSION_TYPE_COLOR = {-1:'unknown', 0:'raw', 1:'png', 2:'jpeg'}
COMPRESSION_TYPE_DEPTH = {-1:'unknown', 0:'raw_ushort', 1:'zlib_ushort', 2:'occi_ushort'}
class RGBDFrame():
def load(self, file_handle):
self.camera_to_world = np.asar... | ContrastiveSceneContexts-main | pretrain/scannet_pair/SensorData.py |
# Copyright 2014 Darsh Ranjan
#
# This file is part of python-plyfile.
#
# python-plyfile is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any ... | ContrastiveSceneContexts-main | pretrain/scannet_pair/plyfile.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 copy
import numpy as np
import math
import glob, os
import argparse
import open3d as o3d
def make_open3d_point_cloud(xyz, color=None... | ContrastiveSceneContexts-main | pretrain/scannet_pair/compute_full_overlapping.py |
import argparse
import os, sys
from SensorData import SensorData
# params
parser = argparse.ArgumentParser()
# data paths
parser.add_argument('--filename', required=True, help='path to sens file to read')
parser.add_argument('--output_path', required=True, help='path to output folder')
parser.add_argument('--export_d... | ContrastiveSceneContexts-main | pretrain/scannet_pair/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 sys
import os
import json
import logging
import torch
from omegaconf import OmegaConf
from easydict import EasyDict as edict
import ... | ContrastiveSceneContexts-main | pretrain/contrastive_scene_contexts/ddp_train.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 numpy as np
import sys
import os
from model.pointnet2.pointnet2_mo... | ContrastiveSceneContexts-main | pretrain/contrastive_scene_contexts/model/pointnet2backbone.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 model.res16unet as res16unet
import model.pointnet2backbone as pointnet2
MODELS = []
def add_models(module):
MODELS.extend([geta... | ContrastiveSceneContexts-main | pretrain/contrastive_scene_contexts/model/__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.
from model.resnet import ResNetBase, get_norm
from model.modules.common import ConvType, NormType, conv, conv_tr
from model.modules.resnet_bl... | ContrastiveSceneContexts-main | pretrain/contrastive_scene_contexts/model/res16unet.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
import MinkowskiEngine as ME
from MinkowskiEngine import MinkowskiNetwork
from model.modules.common import ConvType,... | ContrastiveSceneContexts-main | pretrain/contrastive_scene_contexts/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.
''' Modified based on Ref: https://github.com/erikwijmans/Pointnet2_PyTorch '''
import torch
import torch.nn as nn
from typing import List, T... | ContrastiveSceneContexts-main | pretrain/contrastive_scene_contexts/model/pointnet2/pytorch_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 glob
import os
from setuptools import setup
from torch.utils.cpp_extension import BuildExtension, CUDAExtension
this_dir = os.path.d... | ContrastiveSceneContexts-main | pretrain/contrastive_scene_contexts/model/pointnet2/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.
''' Modified based on: https://github.com/erikwijmans/Pointnet2_PyTorch '''
from __future__ import (
division,
absolute_import,
w... | ContrastiveSceneContexts-main | pretrain/contrastive_scene_contexts/model/pointnet2/pointnet2_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.
''' Testing customized ops. '''
import torch
from torch.autograd import gradcheck
import numpy as np
import os
import sys
BASE_DIR = os.pat... | ContrastiveSceneContexts-main | pretrain/contrastive_scene_contexts/model/pointnet2/pointnet2_test.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.
''' Pointnet2 layers.
Modified based on: https://github.com/erikwijmans/Pointnet2_PyTorch
Extended with the following:
1. Uniform sampling in... | ContrastiveSceneContexts-main | pretrain/contrastive_scene_contexts/model/pointnet2/pointnet2_modules.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 B... | ContrastiveSceneContexts-main | pretrain/contrastive_scene_contexts/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. | ContrastiveSceneContexts-main | pretrain/contrastive_scene_contexts/model/modules/__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.
import collections
from enum import Enum
import MinkowskiEngine as ME
class NormType(Enum):
BATCH_NORM = 0
SPARSE_LAYER_NORM = 1
SPA... | ContrastiveSceneContexts-main | pretrain/contrastive_scene_contexts/model/modules/common.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 random
class Compose:
def __init__(self, transforms):
self.transforms = transforms
def __call__(self, ... | ContrastiveSceneContexts-main | pretrain/contrastive_scene_contexts/lib/transforms.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 time
class AverageMeter(object):
"""Computes and stores the average and current value"""
def __init__(self):
self.reset()
... | ContrastiveSceneContexts-main | pretrain/contrastive_scene_contexts/lib/timer.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. | ContrastiveSceneContexts-main | pretrain/contrastive_scene_contexts/lib/__init__.py |
# Written by Chris Choy <chrischoy@ai.stanford.edu>
# Distributed under MIT License
import logging
import random
import torch
import torch.utils.data
import numpy as np
import glob
import os
import copy
from tqdm import tqdm
from scipy.linalg import expm, norm
from lib.io3d import write_triangle_mesh
import lib.transf... | ContrastiveSceneContexts-main | pretrain/contrastive_scene_contexts/lib/ddp_data_loaders.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
import os.path as osp
import gc
import logging
import numpy as np
import json
from omegaconf import OmegaConf
import torch.nn as nn... | ContrastiveSceneContexts-main | pretrain/contrastive_scene_contexts/lib/ddp_trainer.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 trimesh
# color palette for nyu40 labels
def create_color_palette():
return [
(0, 0, 0),
(174, ... | ContrastiveSceneContexts-main | pretrain/contrastive_scene_contexts/lib/io3d.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.
#!/usr/bin/env python3
"""Distributed helpers."""
import pickle
import time
import functools
import logging
import torch
import torch.dis... | ContrastiveSceneContexts-main | pretrain/contrastive_scene_contexts/lib/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.
#!/usr/bin/env python3
"""Multiprocessing helpers."""
import multiprocessing as mp
import traceback
from lib.error_handler import ErrorHa... | ContrastiveSceneContexts-main | pretrain/contrastive_scene_contexts/lib/multiprocessing_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 numpy as np
class ShapeContext(object):
def __init__(self, r1=0.125, r2=2, nbins_xy=2, nbins_zy=2):
... | ContrastiveSceneContexts-main | pretrain/contrastive_scene_contexts/lib/shape_context.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.
#!/usr/bin/env python3
"""Multiprocessing error handler."""
import os
import signal
import threading
class ChildException(Exception):
... | ContrastiveSceneContexts-main | pretrain/contrastive_scene_contexts/lib/error_handler.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 import nn
class NCESoftmaxLoss(nn.Module):
def __init__(self):
super(NCESoftmaxLoss, self).__init__()
... | ContrastiveSceneContexts-main | pretrain/contrastive_scene_contexts/lib/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 torch
from torch.utils.data.sampler import Sampler
import torch.distributed as dist
import math
class InfSampler(Sampler):
def __i... | ContrastiveSceneContexts-main | pretrain/contrastive_scene_contexts/lib/data_sampler.py |
# Evaluates semantic label task
# Input:
# - path to .txt prediction files
# - path to .txt ground truth files
# - output file to write results to
# Note that only the valid classes are used for evaluation,
# i.e., any ground truth label not in the valid label set
# is ignored in the evaluation.
#
# example usage... | ContrastiveSceneContexts-main | pretrain/contrastive_scene_contexts/lib/evaluation/evaluate_semantic_label.py |
# Evaluates semantic instance task
# Adapted from the CityScapes evaluation: https://github.com/mcordts/cityscapesScripts/tree/master/cityscapesscripts/evaluation
# Input:
# - path to .txt prediction files
# - path to .txt ground truth files
# - output file to write results to
# Each .txt prediction file look lik... | ContrastiveSceneContexts-main | pretrain/contrastive_scene_contexts/lib/evaluation/evaluate_semantic_instance.py |
import os, sys
import csv
try:
import numpy as np
except:
print("Failed to import numpy package.")
sys.exit(-1)
try:
import imageio
except:
print("Please install the module 'imageio' for image processing, e.g.")
print("pip install imageio")
sys.exit(-1)
# print an error message and quit
def... | ContrastiveSceneContexts-main | pretrain/contrastive_scene_contexts/lib/evaluation/scannet_benchmark_utils/util.py |
import os, sys
import json
try:
import numpy as np
except:
print("Failed to import numpy package.")
sys.exit(-1)
try:
from plyfile import PlyData, PlyElement
except:
print("Please install the module 'plyfile' for PLY i/o, e.g.")
print("pip install plyfile")
sys.exit(-1)
from . import util... | ContrastiveSceneContexts-main | pretrain/contrastive_scene_contexts/lib/evaluation/scannet_benchmark_utils/util_3d.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
import argparse
import time
import torch
from mmcv import Config
from mmcv.parallel import MMDataParallel
from model.builder import build_estimator
def parse_args():
parser = argparse.ArgumentParser(description='MMSeg benchmark a model')
parser.add_argume... | CODD-main | benchmark_speed.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
import argparse
import copy
import os
import os.path as osp
import time
import warnings
import mmcv
import torch
from mmcv.cnn.utils import revert_sync_batchnorm
from mmcv.runner import get_dist_info, init_dist
from mmcv.utils import Config, DictAction, get_git_has... | CODD-main | train.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
import argparse
import os
import mmcv
import torch
from mmcv.parallel import MMDataParallel, MMDistributedDataParallel
from mmcv.runner import (get_dist_info, init_dist, load_checkpoint, wrap_fp16_model)
from mmcv.utils import DictAction
from mmseg.datasets import ... | CODD-main | inference.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
from .inference import single_gpu_inference, multi_gpu_inference
from .train import train_estimator
| CODD-main | apis/__init__.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
import warnings
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_dataloader, build_dataset
from mmse... | CODD-main | apis/train.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
import functools
import os.path as osp
import mmcv
import torch
import torch.distributed as dist
from mmcv.runner import get_dist_info
from mmcv.utils import print_log, mkdir_or_exist
from mmseg.utils import get_root_logger
from utils import RunningStatsWithBuffer... | CODD-main | apis/inference.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.