python_code stringlengths 0 4.04M | repo_name stringlengths 8 58 | file_path stringlengths 5 147 |
|---|---|---|
# Copyright (c) 2018-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
"""
Classes Node, Arc, DependencyTree providing functionality for syntactic dependency trees
"""
from __future__ import prin... | colorlessgreenRNNs-main | src/syntactic_testsets/tree_module.py |
# Copyright (c) 2018-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
import sys
from utils import read_paradigms, load_vocab, extract_sent_features, transform_gold, vocab_freqs
import pandas as ... | colorlessgreenRNNs-main | src/syntactic_testsets/_create_datatable.py |
# Copyright (c) 2018-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
| colorlessgreenRNNs-main | src/syntactic_testsets/__init__.py |
# Copyright (c) 2018-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
from __future__ import print_function
#!/usr/bin/env python
import sys
import re
from collections import namedtuple
ConllC... | colorlessgreenRNNs-main | src/syntactic_testsets/conll_utils.py |
# Copyright (c) 2018-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
import pandas as pd
from collections import defaultdict
import string
def read_paradigms(path):
""" reads morphological... | colorlessgreenRNNs-main | src/syntactic_testsets/utils.py |
# Copyright (c) 2018-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
import argparse
import random
import pandas as pd
import tree_module as tm
from extract_dependency_patterns import grep_morp... | colorlessgreenRNNs-main | src/syntactic_testsets/generate_nonsense.py |
# Copyright (c) 2018-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
def is_vowel(c):
return c in ["a","o","u","e","i","A","O","U","E","I","è"]
def alt_numeral_morph(morph):
if "Number... | colorlessgreenRNNs-main | src/syntactic_testsets/generate_utils.py |
# Copyright (c) 2018-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
import argparse
from collections import defaultdict
from data import data_utils
parser = argparse.ArgumentParser(description=... | colorlessgreenRNNs-main | src/data/collect_paradigms.py |
# Copyright (c) 2018-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
import sys
file_name = sys.argv[1]
for l in open(file_name):
fields = l.strip().split("\t")
if len(fields) == 10:
... | colorlessgreenRNNs-main | src/data/preprocess_EnglishUD_morph.py |
# Copyright (c) 2018-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
import argparse
import logging
from collections import defaultdict
from random import shuffle
from data import data_utils
par... | colorlessgreenRNNs-main | src/data/data_vocab_prep.py |
# Copyright (c) 2018-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
import gzip
import logging
def read_gzip_stream(path):
with gzip.open(path, 'rt', encoding="UTF-8") as f:
for line... | colorlessgreenRNNs-main | src/data/data_utils.py |
# Copyright (c) 2018-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
import conll_utils
import tree_module as tm
def remove_segmented_morphemes_hebrew(t):
for start, end, token in t.fused_n... | colorlessgreenRNNs-main | src/data/hebrew/preprocess_HebrewUD_morph.py |
# Copyright (c) 2018-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
import sys
file_name = sys.argv[1]
for l in open(file_name):
fields = l.strip().split("\t")
if len(fields) == 10:
morp... | colorlessgreenRNNs-main | src/data/hebrew/add_poss_wiki_annotation.py |
# Copyright (c) 2018-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
import sys
file_name = sys.argv[1]
for l in open(file_name):
fields = l.strip().split("\t")
if len(fields) == 10:
mor... | colorlessgreenRNNs-main | src/data/hebrew/remove_binyanim.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
import logging
from dataclasses import dataclass, field
from math import sqrt
from typing import List, Optional, Union
import torch
import torch.nn as nn
logger: logging.Logger = logging.getLogger(__name__)
@dataclass
class MtlConfigs:
mtl_model: str = "att... | AdaTT-main | mtl_lib.py |
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
import os
import json
import argparse
import numpy as np
class BisonEval:
def __init__(sel... | binary-image-selection-main | bison_eval.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 sys
import hydra
import torch
from lib.ddp_trainer import SegmentationTrainer
from lib.distributed import multi_proc_run
d... | ContrastiveSceneContexts-main | downstream/semseg/ddp_main.py |
import random
import logging
import numpy as np
import scipy
import scipy.ndimage
import scipy.interpolate
import torch
# A sparse tensor consists of coordinates and associated features.
# You must apply augmentation to both.
# In 2D, flip, shear, scale, and rotation of images are coordinate transformation
# color j... | ContrastiveSceneContexts-main | downstream/semseg/datasets/transforms.py |
#from lib.datasets import synthia
#from lib.datasets import shapenet
from datasets import stanford
from datasets import scannet
DATASETS = []
def add_datasets(module):
DATASETS.extend([getattr(module, a) for a in dir(module) if 'Dataset' in a])
add_datasets(stanford)
#add_datasets(synthia)
add_datasets(scannet)... | ContrastiveSceneContexts-main | downstream/semseg/datasets/__init__.py |
import logging
import unittest
import imageio
import os
import os.path as osp
import pickle
import numpy as np
from collections import defaultdict
from plyfile import PlyData
from lib.pc_utils import Camera, read_plyfile
from lib.dataset import DictDataset, VoxelizationDataset, TemporalVoxelizationDataset, \
str2... | ContrastiveSceneContexts-main | downstream/semseg/datasets/synthia.py |
from abc import ABC
from pathlib import Path
from collections import defaultdict
import random
import numpy as np
from enum import Enum
import torch
from torch.utils.data import Dataset, DataLoader
import MinkowskiEngine as ME
from plyfile import PlyData
import datasets.transforms as t
from datasets.dataloader impo... | ContrastiveSceneContexts-main | downstream/semseg/datasets/dataset.py |
import logging
import os
import sys
import numpy as np
from collections import defaultdict
from scipy import spatial
import torch
from plyfile import PlyData
from lib.utils import read_txt, fast_hist, per_class_iu
from datasets.dataset import VoxelizationDataset, DatasetPhase, str2datasetphase_type, cache
import datas... | ContrastiveSceneContexts-main | downstream/semseg/datasets/stanford.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,
c... | ContrastiveSceneContexts-main | downstream/semseg/datasets/voxelizer.py |
import math
import torch
import torch.distributed as dist
from torch.utils.data.sampler import Sampler
class InfSampler(Sampler):
"""Samples elements randomly, without replacement.
Arguments:
data_source (Dataset): dataset to sample from
"""
def __init__(self, data_source, shuffle=False):
s... | ContrastiveSceneContexts-main | downstream/semseg/datasets/dataloader.py |
import logging
import os
import sys
from pathlib import Path
import torch
import numpy as np
from scipy import spatial
from datasets.dataset import VoxelizationDataset, DatasetPhase, str2datasetphase_type
from lib.pc_utils import read_plyfile, save_point_cloud
from lib.utils import read_txt, fast_hist, per_class_iu
f... | ContrastiveSceneContexts-main | downstream/semseg/datasets/scannet.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 | downstream/semseg/datasets/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 | downstream/semseg/datasets/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 | downstream/semseg/datasets/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 | downstream/semseg/datasets/evaluation/scannet_benchmark_utils/util_3d.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 | downstream/semseg/datasets/evaluation/scannet_benchmark_utils/scripts/evaluate_semantic_label.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 | downstream/semseg/datasets/evaluation/scannet_benchmark_utils/scripts/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)
import util
# ma... | ContrastiveSceneContexts-main | downstream/semseg/datasets/evaluation/scannet_benchmark_utils/scripts/util_3d.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 | downstream/semseg/datasets/evaluation/scannet_benchmark_utils/scripts/evaluate_semantic_instance.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 numpy as np
import os
import torch
from tqdm import tqdm
from lib.utils import mkdir_p
from lib.pc_utils import save_po... | ContrastiveSceneContexts-main | downstream/semseg/datasets/preprocessing/stanford/stanford.py |
import os
import sys
import plyfile
import json
import time
import torch
import argparse
import numpy as np
def get_raw2scannet_label_map():
lines = [line.rstrip() for line in open('scannetv2-labels.combined.tsv')]
lines = lines[1:]
raw2scannet = {}
for i in range(len(lines)):
elements = lines[... | ContrastiveSceneContexts-main | downstream/semseg/datasets/preprocessing/scannet/collect_indoor3d_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 random
from torch.nn import Module
from MinkowskiEngine import SparseTensor
class Wrapper(Module):
"""
Wrapper for the segment... | ContrastiveSceneContexts-main | downstream/semseg/models/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.resnet import ResNetBase, get_norm
from models.modules.common import ConvType, NormType, conv, conv_tr
from models.modules.resne... | ContrastiveSceneContexts-main | downstream/semseg/models/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.
import models.resunet as resunet
import models.res16unet as res16unet
MODELS = []
def add_models(module):
MODELS.extend([getattr(module, ... | ContrastiveSceneContexts-main | downstream/semseg/models/__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.resnet import ResNetBase, get_norm
from models.modules.common import ConvType, NormType, conv, conv_tr
from models.modules.resnet... | ContrastiveSceneContexts-main | downstream/semseg/models/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/semseg/models/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
from models.common import get_norm
import MinkowskiEngine as ME
import MinkowskiEngine.MinkowskiFunctional as MEF
... | ContrastiveSceneContexts-main | downstream/semseg/models/residual_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 MinkowskiEngine as ME
def get_norm(norm_type, num_feats, bn_momentum=0.05, D=-1):
if norm_type == 'BN':
return ME.MinkowskiBa... | ContrastiveSceneContexts-main | downstream/semseg/models/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 torch.nn as nn
import MinkowskiEngine as ME
from models.model import Model
from models.modules.common import ConvType, NormType, get... | ContrastiveSceneContexts-main | downstream/semseg/models/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.nn as nn
from models.modules.common import ConvType, NormType, get_norm, conv
from MinkowskiEngine import MinkowskiReLU
clas... | ContrastiveSceneContexts-main | downstream/semseg/models/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
import MinkowskiEngine as ME
from models.modules.common import ConvType, NormType
from models.modules.resnet_block i... | ContrastiveSceneContexts-main | downstream/semseg/models/modules/senet_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 | downstream/semseg/models/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 torch.nn as nn
import MinkowskiEngine as ME
class NormType(Enum):
BATCH_NORM = 0
INST... | ContrastiveSceneContexts-main | downstream/semseg/models/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 os
import torch
import numpy as np
import glob
import time
import argparse
import pykeops
from pykeops.torch import LazyTensor
pykeop... | ContrastiveSceneContexts-main | downstream/semseg/lib/sampling_points.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/semseg/lib/__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 matplotlib.pyplot as plt
import matplotlib
import numpy as np
from matplotlib.pyplot import *
from PIL import Image
colors = [ 'xkcd... | ContrastiveSceneContexts-main | downstream/semseg/lib/plot_graph.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
from torch.optim import SGD, Adam
from torch.optim.lr_scheduler import LambdaLR, StepLR
class LambdaStepLR(LambdaLR):
de... | ContrastiveSceneContexts-main | downstream/semseg/lib/solvers.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
import os
import shutil
import tempfile
import warnings
import numpy as np
import torch
import torch.nn as nn
from sklearn.... | ContrastiveSceneContexts-main | downstream/semseg/lib/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.
import numpy as np
import logging
import os
import sys
import torch
import logging
import torch.nn.functional as F
from torch import nn
fro... | ContrastiveSceneContexts-main | downstream/semseg/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 | downstream/semseg/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
import os
import time
import torch
import signal
import pickle
import threading
import functools
import traceback
imp... | ContrastiveSceneContexts-main | downstream/semseg/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.
import os
import numpy as np
from numpy.linalg import matrix_rank, inv
from plyfile import PlyData, PlyElement
import pandas as pd
COLOR_MA... | ContrastiveSceneContexts-main | downstream/semseg/lib/pc_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 json
import logging
import os
import errno
import time
import torch
import numpy as np
from omegaconf import OmegaConf
from lib.pc_ut... | ContrastiveSceneContexts-main | downstream/semseg/lib/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.
from scipy.sparse import csr_matrix
import torch
class SparseMM(torch.autograd.Function):
"""
Sparse x dense matrix multiplication wit... | ContrastiveSceneContexts-main | downstream/semseg/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.
import torch
import torch.nn as nn
from MinkowskiEngine import MinkowskiGlobalPooling, MinkowskiBroadcastAddition, MinkowskiBroadcastMulti... | ContrastiveSceneContexts-main | downstream/semseg/lib/layers.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 sys
import hydra
import torch
import numpy as np
from lib.ddp_trainer import SegmentationTrainer
from lib.distributed impor... | ContrastiveSceneContexts-main | downstream/insseg/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 random
import logging
import numpy as np
import scipy
import scipy.ndimage
import scipy.interpolate
import torch
# A sparse tensor... | ContrastiveSceneContexts-main | downstream/insseg/datasets/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.
#from lib.datasets import synthia
from datasets import stanford
from datasets import scannet
#from lib.datasets import shapenet
DATASETS =... | ContrastiveSceneContexts-main | downstream/insseg/datasets/__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 logging
import unittest
import imageio
import os
import os.path as osp
import pickle
import numpy as np
from collections import defa... | ContrastiveSceneContexts-main | downstream/insseg/datasets/synthia.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 abc import ABC
from pathlib import Path
from collections import defaultdict
import random
import numpy as np
from enum import Enum
im... | ContrastiveSceneContexts-main | downstream/insseg/datasets/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 logging
import os
import sys
import numpy as np
from collections import defaultdict
from scipy import spatial
import torch
from plyfi... | ContrastiveSceneContexts-main | downstream/insseg/datasets/stanford.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
import numpy as np
import MinkowskiEngine as ME
from scipy.linalg import expm, norm
# Rotation matrix along axis with ... | ContrastiveSceneContexts-main | downstream/insseg/datasets/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 math
import torch
import torch.distributed as dist
from torch.utils.data.sampler import Sampler
class InfSampler(Sampler):
"""Samp... | ContrastiveSceneContexts-main | downstream/insseg/datasets/dataloader.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
import os
import sys
from pathlib import Path
import torch
import numpy as np
from scipy import spatial
from datasets.datas... | ContrastiveSceneContexts-main | downstream/insseg/datasets/scannet.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 | downstream/insseg/datasets/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 | downstream/insseg/datasets/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 | downstream/insseg/datasets/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 | downstream/insseg/datasets/evaluation/scannet_benchmark_utils/util_3d.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 | downstream/insseg/datasets/evaluation/scannet_benchmark_utils/scripts/evaluate_semantic_label.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 | downstream/insseg/datasets/evaluation/scannet_benchmark_utils/scripts/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)
import util
# ma... | ContrastiveSceneContexts-main | downstream/insseg/datasets/evaluation/scannet_benchmark_utils/scripts/util_3d.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 | downstream/insseg/datasets/evaluation/scannet_benchmark_utils/scripts/evaluate_semantic_instance.py |
import random
from torch.nn import Module
from MinkowskiEngine import SparseTensor
class Wrapper(Module):
"""
Wrapper for the segmentation networks.
"""
OUT_PIXEL_DIST = -1
def __init__(self, NetClass, in_nchannel, out_nchannel, config):
super(Wrapper, self).__init__()
self.initialize_filter(NetCl... | ContrastiveSceneContexts-main | downstream/insseg/models/wrapper.py |
from models.resnet import ResNetBase, get_norm
from models.modules.common import ConvType, NormType, conv, conv_tr
from models.modules.resnet_block import BasicBlock, BasicBlockINBN, Bottleneck
import torch.nn as nn
import MinkowskiEngine as ME
from MinkowskiEngine import MinkowskiReLU
import MinkowskiEngine.Minkowsk... | ContrastiveSceneContexts-main | downstream/insseg/models/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.
import models.resunet as resunet
import models.res16unet as res16unet
MODELS = []
def add_models(module):
MODELS.extend([getattr(module... | ContrastiveSceneContexts-main | downstream/insseg/models/__init__.py |
from models.resnet import ResNetBase, get_norm
from models.modules.common import ConvType, NormType, conv, conv_tr
from models.modules.resnet_block import BasicBlock, Bottleneck
from MinkowskiEngine import MinkowskiReLU, SparseTensor
import MinkowskiEngine.MinkowskiOps as me
class Res16UNetBase(ResNetBase):
BLOCK ... | ContrastiveSceneContexts-main | downstream/insseg/models/res16unet.py |
from MinkowskiEngine import MinkowskiNetwork
class Model(MinkowskiNetwork):
"""
Base network for all sparse convnet
By default, all networks are segmentation networks.
"""
OUT_PIXEL_DIST = -1
def __init__(self, in_channels, out_channels, config, D, **kwargs):
super(Model, self).__init__(D)
self.... | ContrastiveSceneContexts-main | downstream/insseg/models/model.py |
import torch.nn as nn
from models.common import get_norm
import MinkowskiEngine as ME
import MinkowskiEngine.MinkowskiFunctional as MEF
class BasicBlockBase(nn.Module):
expansion = 1
NORM_TYPE = 'BN'
def __init__(self,
inplanes,
planes,
stride=1,
di... | ContrastiveSceneContexts-main | downstream/insseg/models/residual_block.py |
import MinkowskiEngine as ME
def get_norm(norm_type, num_feats, bn_momentum=0.05, D=-1):
if norm_type == 'BN':
return ME.MinkowskiBatchNorm(num_feats, momentum=bn_momentum)
elif norm_type == 'IN':
return ME.MinkowskiInstanceNorm(num_feats, dimension=D)
else:
raise ValueError(f'Type {norm_type}, not ... | ContrastiveSceneContexts-main | downstream/insseg/models/common.py |
import torch.nn as nn
import MinkowskiEngine as ME
from models.model import Model
from models.modules.common import ConvType, NormType, get_norm, conv, sum_pool
from models.modules.resnet_block import BasicBlock, Bottleneck
class ResNetBase(Model):
BLOCK = None
LAYERS = ()
INIT_DIM = 64
PLANES = (64, 128, 2... | ContrastiveSceneContexts-main | downstream/insseg/models/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.nn as nn
from models.modules.common import ConvType, NormType, get_norm, conv
from MinkowskiEngine import MinkowskiReLU
class ... | ContrastiveSceneContexts-main | downstream/insseg/models/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
import MinkowskiEngine as ME
from models.modules.common import ConvType, NormType
from models.modules.resnet_block imp... | ContrastiveSceneContexts-main | downstream/insseg/models/modules/senet_block.py |
ContrastiveSceneContexts-main | downstream/insseg/models/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 torch.nn as nn
import MinkowskiEngine as ME
class NormType(Enum):
BATCH_NORM = 0
INSTA... | ContrastiveSceneContexts-main | downstream/insseg/models/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. | ContrastiveSceneContexts-main | downstream/insseg/lib/__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 logging
from torch.optim import SGD, Adam
from torch.optim.lr_scheduler import LambdaLR, StepLR
class LambdaStepLR(LambdaLR):
d... | ContrastiveSceneContexts-main | downstream/insseg/lib/solvers.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
import os
import shutil
import tempfile
import warnings
import numpy as np
import torch
import torch.nn as nn
from sklearn.m... | ContrastiveSceneContexts-main | downstream/insseg/lib/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.
import numpy as np
import logging
import os
import sys
import torch
import logging
import torch.nn.functional as F
from torch import nn
fro... | ContrastiveSceneContexts-main | downstream/insseg/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 | downstream/insseg/lib/io3d.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
import time
import torch
import signal
import pickle
import threading
import functools
import traceback
imp... | ContrastiveSceneContexts-main | downstream/insseg/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.
import os
import numpy as np
from numpy.linalg import matrix_rank, inv
from plyfile import PlyData, PlyElement
import pandas as pd
COLOR_MA... | ContrastiveSceneContexts-main | downstream/insseg/lib/pc_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 json
import logging
import os
import errno
import time
import torch
import numpy as np
from omegaconf import OmegaConf
from lib.pc_ut... | ContrastiveSceneContexts-main | downstream/insseg/lib/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.
from scipy.sparse import csr_matrix
import torch
class SparseMM(torch.autograd.Function):
"""
Sparse x dense matrix multiplication wit... | ContrastiveSceneContexts-main | downstream/insseg/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.
import torch
import torch.nn as nn
from MinkowskiEngine import MinkowskiGlobalPooling, MinkowskiBroadcastAddition, MinkowskiBroadcastMultip... | ContrastiveSceneContexts-main | downstream/insseg/lib/layers.py |
import os
import torch
import numpy as np
from torch.autograd import Function
import argparse
#from lib.datasets.scannet.datagen.export_ids_per_vertex import read_segmentation, write_triangle_mesh
#from lib.utils.io import read_triangle_mesh, create_color_palette, write_triangle_mesh
#from lib.utils.scannet_benchmark_u... | ContrastiveSceneContexts-main | downstream/insseg/lib/bfs/bfs.py |
'''
PointGroup operations
Written by Li Jiang
'''
| ContrastiveSceneContexts-main | downstream/insseg/lib/bfs/ops/ops.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.