python_code stringlengths 0 4.04M | repo_name stringlengths 8 58 | file_path stringlengths 5 147 |
|---|---|---|
# Copyright (c) Meta Platforms, Inc. and affiliates.
import math
import random
import cv2
import mmcv
import numpy as np
import torch
import torch.nn.functional as F
import torchvision.transforms as transforms
from mmseg.datasets import PIPELINES
@PIPELINES.register_module(force=True)
class RandomCrop(object):
... | CODD-main | datasets/transforms.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
import copy
import os.path as osp
import re
import sys
import mmcv
import numpy as np
from mmcv.utils import print_log
from mmseg.datasets import DATASETS, CustomDataset
from mmseg.datasets.pipelines import Compose
from mmseg.utils import get_root_logger
from termi... | CODD-main | datasets/custom_stereo_mf.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
from mmseg.datasets import DATASETS
from .scene_flow import SceneFlowMultiFrameDataset
@DATASETS.register_module()
class TartanAirMultiFrameDataset(SceneFlowMultiFrameDataset):
def __init__(self, **kwargs):
super(SceneFlowMultiFrameDataset, self).__in... | CODD-main | datasets/tartanair.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
import copy
from mmcv.utils import print_log
from mmseg.datasets import DATASETS
from mmseg.utils import get_root_logger
from .custom_stereo_mf import CustomStereoMultiFrameDataset
@DATASETS.register_module()
class SceneFlowMultiFrameDataset(CustomStereoMultiFra... | CODD-main | datasets/scene_flow.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
import re
import mmcv
# Requirements: Numpy as PIL/Pillow
import numpy as np
from PIL import Image
# sintel
# Check for endianness, based on Daniel Scharstein's optical flow code.
# Using little-endian architecture, these two should be equal.
TAG_FLOAT = 202021.25... | CODD-main | datasets/data_io.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
from .formating import DefaultFormatBundle # NOQA
from .loading_stereo import * # NOQA
from .custom_stereo_mf import CustomStereoMultiFrameDataset # NOQA
from .kitti_depth import Kitti2015MultiFrameDataset, KittiDepthMultiFrameDataset # NOQA
from .scene_flow imp... | CODD-main | datasets/__init__.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
from mmseg.datasets import DATASETS
from .scene_flow import SceneFlowMultiFrameDataset
@DATASETS.register_module()
class SintelMultiFrameDataset(SceneFlowMultiFrameDataset):
"""Person dataset.
In segmentation map annotation for ADE20K, 0 stands for backg... | CODD-main | datasets/sintel.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
import os.path as osp
import mmcv
import numpy as np
from mmseg.datasets import PIPELINES
from mmseg.datasets.pipelines import LoadImageFromFile
from .data_io import disparity_read, flow_read, read_numpy_tartanair, read_numpy_tartanair_uint8, read_kitti_disp, \
... | CODD-main | datasets/loading_stereo.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
from mmseg.datasets import DATASETS
from .scene_flow import SceneFlowMultiFrameDataset
@DATASETS.register_module()
class Kitti2015MultiFrameDataset(SceneFlowMultiFrameDataset):
def __init__(self, **kwargs):
super(SceneFlowMultiFrameDataset, self).__in... | CODD-main | datasets/kitti_depth.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
import torch
import numpy as np
from mmcv.parallel import DataContainer as DC
from mmseg.datasets import PIPELINES
from mmseg.datasets.pipelines import to_tensor
@PIPELINES.register_module(force=True)
class DefaultFormatBundle(object):
"""Default formatting b... | CODD-main | datasets/formating.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
import torch
from .warp import flow_warp
BF_DEFAULT = 1050 * 0.2 # baseline * focal length
__imagenet_stats = {'mean': [0.485, 0.456, 0.406],
'std': [0.229, 0.224, 0.225]}
def compute_valid_mask(gt_disp, meta, gt_semantic_seg=None, gt_flow_p... | CODD-main | utils/misc.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
from .running_stats import *
from .metric import *
from .misc import *
from .warp import *
| CODD-main | utils/__init__.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
import csv
import re
import numpy as np
class AverageMeter(object):
"""Computes and stores the average and current value"""
def __init__(self, name=' ', fmt=':f'):
self.name = name
self.fmt = fmt
self.reset()
def reset(self):... | CODD-main | utils/running_stats.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
import numpy as np
import torch
EPSILON = 1e-8
def epe_metric(d_est, d_gt, mask, use_np=False):
d_est, d_gt = d_est[mask], d_gt[mask]
if use_np:
epe = np.mean(np.abs(d_est - d_gt))
else:
epe = torch.mean(torch.abs(d_est - d_gt))
r... | CODD-main | utils/metric.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
import os
import re
from argparse import ArgumentParser
import numpy as np
from natsort import natsorted
def write_to_file(args, left_image, right_image, disparity, flow, disp_change, flow_occ, disp_frame2_in_frame1,
disp_occ, split):
fname ... | CODD-main | utils/generate_split_files.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
import torch
import torch.nn.functional as F
def normalize_coords(grid):
"""Normalize coordinates of image scale to [-1, 1]
Args:
grid: [B, 2, H, W]
"""
assert grid.size(1) == 2
h, w = grid.size()[2:]
grid[:, 0, :, :] = 2 * (grid[:,... | CODD-main | utils/warp.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
import os
import re
import time
from argparse import ArgumentParser
import cv2
import numpy as np
import open3d as o3d
from natsort import natsorted
from tqdm import tqdm
class InteractivePCDVisualizer(object):
def __call__(self, pcd_list):
o3d.visual... | CODD-main | utils/vis_point_cloud.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
_base_ = [
'models/consistent_online_depth_network.py', 'datasets/custom.py',
'default_runtime.py'
]
| CODD-main | configs/inference_config.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
_base_ = [
'models/codd.py', 'datasets/scene_flow.py',
'default_runtime.py', 'schedules/schedule_stereo.py'
] | CODD-main | configs/training_config.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
log_config = dict(
interval=50,
hooks=[
dict(type='TextLoggerHook'),
dict(type='TensorboardLoggerHook')
])
# yapf:enable
dist_params = dict(backend='nccl')
log_level = 'INFO'
load_from = None
resume_from = None
workflow = [('train', 1)]
c... | CODD-main | configs/default_runtime.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# pseudo camera parameters that doesn't really matter for inference
intrinsics = [640, 360, 1050, 1050]
calib = 210
disp_range = (1, 210)
depth_range = (calib / 210.0, calib / 1.0)
img_norm_cfg = dict(mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_... | CODD-main | configs/datasets/custom.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# dataset settings
dataset_type = "TartanAirMultiFrameDataset"
data_root = "PATH_TO_DATA"
train_split = "PATH_TO_SPLIT"
val_split = "PATH_TO_SPLIT"
test_split = "PATH_TO_SPLIT"
calib = 320 * 0.25 # from https://github.com/castacks/tartanair_tools/blob/master/data_... | CODD-main | configs/datasets/tartanair.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# dataset settings
dataset_type = "SceneFlowMultiFrameDataset"
data_root = "PATH_TO_STEREO_IMG"
disp_root = "PATH_TO_DISPARITY"
flow_root = "PATH_TO_FLOW"
disp_change_root = "PATH_TO_DISPARITY_CHANGE"
train_split = "PATH_TO_SPLIT"
val_split = "PATH_TO_SPLIT"
test_sp... | CODD-main | configs/datasets/scene_flow.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# dataset settings
dataset_type = "SintelMultiFrameDataset"
data_root = "PATH_TO_DATA"
flow_root = "PATH_TO_FLOW"
train_split = "PATH_TO_SPLIT"
val_split = "PATH_TO_SPLIT"
test_split = "PATH_TO_SPLIT"
calib = 688 * 0.01
disp_range = (1.0, 210.0)
depth_range = (cali... | CODD-main | configs/datasets/sintel.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# dataset settings
dataset_type = "KittiDepthMultiFrameDataset"
data_root = "PATH_TO_DATA"
train_split = "PATH_TO_SPLIT"
val_split = "PATH_TO_SPLIT"
test_split = "PATH_TO_SPLIT"
calib = 384.38 # from raw data calibration result
disp_range = (1.0, 210.0)
depth_rang... | CODD-main | configs/datasets/kitti_depth.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# dataset settings
dataset_type = "Kitti2015MultiFrameDataset"
data_root = "PATH_TO_DATA"
train_split = "PATH_TO_SPLIT"
val_split = "PATH_TO_SPLIT"
test_split = "PATH_TO_SPLIT"
calib = 384.38 # from raw data calibration result
disp_range = (1.0, 210.0)
depth_range... | CODD-main | configs/datasets/kitti_2015.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# model settings
max_disp = 320
iters = 1 # 16 for scene flow/KITTI, 1 for Sintel/TartanAir
motion_loss_weight = 1.0 # 0.5 for joint training tartan/KITTI, 1.0 for pretrain
freeze_stereo = True
freeze_motion = False
if freeze_stereo or freeze_motion:
find_un... | CODD-main | configs/models/stereo_motion.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# model settings
max_disp = 320
iters = 16 # 16 for scene flow/KITTI, 1 for Sintel/TartanAir
motion_loss_weight = 0.5 # 0.5 for joint training tartan/KITTI, 1.0 for pretrain
fusion_loss_weight = 1.0
wr_weight = 1.0
wf_weight = 1.0
freeze_stereo = False
freeze_mo... | CODD-main | configs/models/codd.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# model settings
max_disp = 320
freeze_stereo = False
freeze_motion = True
freeze_fusion = True
if freeze_stereo or freeze_motion or freeze_fusion:
find_unused_parameters = True
model = dict(
type='ConsistentOnlineDynamicDepth',
stereo=dict(
ty... | CODD-main | configs/models/stereo.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# optimizer
gpu_factor = 8
max_iter = 100000 // gpu_factor
optimizer = dict(type="Adam", lr=2e-4, weight_decay=0.00001)
optimizer_config = dict(grad_clip=dict(max_norm=1))
# learning policy
lr_config = dict(
policy="OneCycle",
max_lr=2e-4,
total_steps=ma... | CODD-main | configs/schedules/schedule_fusion.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# optimizer
optimizer = dict(type='Adam', lr=4e-4, betas=(0.9, 0.999))
optimizer_config = dict()
# learning policy
lr_config = dict(policy='MultiGamma', step=[225, 293, 315], gamma=[0.25, 0.4, 0.25])
# runtime settings
runner = dict(type='EpochBasedRunner', max_epo... | CODD-main | configs/schedules/schedule_stereo.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# optimizer
gpu_factor = 8
max_iter = 200000 // gpu_factor
optimizer = dict(type="Adam", lr=2e-4, weight_decay=0.00001)
optimizer_config = dict(grad_clip=dict(max_norm=1))
# learning policy
lr_config = dict(
policy="OneCycle",
max_lr=2e-4,
total_steps=ma... | CODD-main | configs/schedules/schedule_motion.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# optimizer
gpu_factor = 8
max_iter = 100000 // gpu_factor
optimizer = dict(type="Adam", lr=2e-5, weight_decay=1e-6)
optimizer_config = dict(grad_clip=dict(max_norm=1))
# learning policy
lr_config = dict(
policy="OneCycle",
max_lr=2e-5,
total_steps=max_i... | CODD-main | configs/schedules/schedule_motion_finetune.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# optimizer
gpu_factor = 8
max_iter = 50000 // gpu_factor
optimizer = dict(type="Adam", lr=2e-5, weight_decay=1e-6)
optimizer_config = dict(grad_clip=dict(max_norm=1))
# learning policy
lr_config = dict(
policy="OneCycle",
max_lr=2e-5,
total_steps=max_it... | CODD-main | configs/schedules/schedule_fusion_finetune.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# optimizer
gpu_factor = 8
max_iter = 100000 // gpu_factor
optimizer = dict(type="Adam", lr=2e-5, weight_decay=1e-6)
optimizer_config = dict(grad_clip=dict(max_norm=1))
# learning policy
lr_config = dict(
policy="OneCycle",
max_lr=2e-5,
total_steps=max_i... | CODD-main | configs/schedules/schedule_stereo_finetune.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
import os.path as osp
from abc import ABCMeta
from collections import OrderedDict
import numpy as np
import torch
import torch.distributed as dist
from mmcv.runner import BaseModule, auto_fp16
from mmcv.utils import mkdir_or_exist
from mmseg.models.builder import M... | CODD-main | model/codd.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
from .builder import *
from .codd import ConsistentOnlineDynamicDepth
from .fusion import *
from .losses import *
from .motion import *
from .stereo import *
from .lr_updater import *
__all__ = ["build_estimator"]
| CODD-main | model/__init__.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
import warnings
from mmseg.models.builder import MODELS
ESTIMATORS = MODELS
def build_estimator(cfg, train_cfg=None, test_cfg=None):
"""Build estimator."""
if train_cfg is not None or test_cfg is not None:
warnings.warn(
'train_cfg an... | CODD-main | model/builder.py |
from mmcv.runner import HOOKS, LrUpdaterHook
import mmcv
@HOOKS.register_module()
class MultiGammaLrUpdaterHook(LrUpdaterHook):
"""Step LR scheduler.
Args:
step (list[int]): Step to decay the LR. If an int value is given,
regard it as the decay interval. If a list is given, decay LR at
... | CODD-main | model/lr_updater.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
from .fusion import Fusion
from .others import NullFusion, GTFusion, KalmanFusion
__all__ = ["NullFusion", "GTFusion", "KalmanFusion", "Fusion"]
| CODD-main | model/fusion/__init__.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
import math
import torch
import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import constant_init, kaiming_init, normal_init, trunc_normal_init
from mmcv.utils.parrots_wrapper import _BatchNorm
from mmseg.models import builder as builder_oss
from mm... | CODD-main | model/fusion/fusion.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
import torch
import torch.nn as nn
from mmseg.models.builder import MODELS
@MODELS.register_module()
class NullFusion(nn.Module):
"""Implements a NULL memory module that does not do anything"""
def __init__(
self,
**kwargs,
):
... | CODD-main | model/fusion/others.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
import torch
import torch.nn as nn
import torch.nn.functional as F
from mmseg.models import LOSSES
@LOSSES.register_module()
class FusionLoss(nn.Module):
def __init__(
self, min_disp=1, max_disp=192, loss_weight=(1.0), wr_weight=1.0, wf_weight=1.0
... | CODD-main | model/losses/temporal.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
import torch
import torch.nn as nn
import torch.nn.functional as F
from mmseg.models import LOSSES
def subpix_cost(cost: torch.Tensor, disp: torch.Tensor, maxdisp: int):
"""
phi, e.g. eqt(9) in HITNet paper
:param cost:
:param disp:
:return:
... | CODD-main | model/losses/hitnet.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
from .hitnet import *
from .temporal import *
| CODD-main | model/losses/__init__.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
from .hitnet import HITNetMF
| CODD-main | model/stereo/__init__.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
import torch
import torch.nn as nn
from mmseg.models.builder import BACKBONES
def conv_down(inp, oup):
return nn.Sequential(
nn.Conv2d(inp, oup, 4, stride=2, padding=1),
nn.LeakyReLU(negative_slope=0.2, inplace=True),
nn.Conv2d(oup, oup... | CODD-main | model/stereo/hitnet/backbone.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
import torch
import torch.nn as nn
import torch.nn.functional as F
from mmseg.models import builder as builder_oss
from mmseg.models.builder import MODELS
from utils import thres_metric
from ...builder import ESTIMATORS
@ESTIMATORS.register_module()
class HITNetM... | CODD-main | model/stereo/hitnet/hitnet.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
from .backbone import HITUNet
from .initialization import TileInitialization
from .propagation import TilePropagation
from .hitnet import HITNetMF
| CODD-main | model/stereo/hitnet/__init__.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
import torch
import torch.nn as nn
import torch.nn.functional as F
from mmseg.models.builder import MODELS
def make_grid(h, w, device):
gridh = torch.arange(h, device=device).float()
gridw = torch.arange(w, device=device).float()
gridh, gridw = torch.... | CODD-main | model/stereo/hitnet/initialization.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
import torch
import torch.nn as nn
import torch.nn.functional as F
from mmseg.models.builder import MODELS
def to_plane(d, dx, dy, size=4):
c = torch.linspace(-(size - 1) / 2, (size - 1) / 2, size, device=d.device)
a = c.view([1, 1, size])
a = torch.... | CODD-main | model/stereo/hitnet/propagation.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
from .motion import Motion
from .others import GTMotion
__all__ = ["Motion", "GTMotion"]
| CODD-main | model/motion/__init__.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
import torch
import torch.nn as nn
import torch.nn.functional as F
from mmseg.models import builder as builder_oss
from mmseg.models.builder import MODELS
from pytorch3d.renderer import (
PerspectiveCameras,
PointsRasterizationSettings,
PointsRenderer,
... | CODD-main | model/motion/motion.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
import torch
import torch.nn as nn
from lietorch import SE3
from mmseg.models.builder import MODELS
from utils import flow_warp
@MODELS.register_module()
class GTMotion(nn.Module):
def __init__(self):
super(GTMotion, self).__init__()
self.loss... | CODD-main | model/motion/others.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# Adapted from RAFT3D repository: https://github.com/princeton-vl/RAFT-3D
import lietorch_extras
import torch
import torch.nn.functional as F
from lietorch import SE3
from . import projective_ops as pops
class SE3BuilderInplace(torch.autograd.Function):
@sta... | CODD-main | model/motion/raft3d/se3_field.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# Adapted from RAFT3D repository: https://github.com/princeton-vl/RAFT-3D
import torch
import torch.nn as nn
import torch.nn.functional as F
# lietorch for tangent space backpropogation
from lietorch import SE3
from mmseg.models import builder as builder_oss
from m... | CODD-main | model/motion/raft3d/raft3d.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
from .raft3d import RAFT3D
| CODD-main | model/motion/raft3d/__init__.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# Adapted from RAFT3D repository: https://github.com/princeton-vl/RAFT-3D
import torch
import torch.nn.functional as F
def bilinear_sampler(img, coords, mode='bilinear', mask=False):
""" Wrapper for grid_sample, uses pixel coordinates """
H, W = img.shape... | CODD-main | model/motion/raft3d/sampler_ops.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# Adapted from RAFT3D repository: https://github.com/princeton-vl/RAFT-3D
from .sampler_ops import *
MIN_DEPTH = 0.05
EPS = 1e-5
def project(Xs, intrinsics):
""" Pinhole camera projection """
X, Y, Z = Xs.unbind(dim=-1)
Z = Z + EPS
fx, fy, cx, cy... | CODD-main | model/motion/raft3d/projective_ops.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# Adapted from RAFT3D repository: https://github.com/princeton-vl/RAFT-3D
import lietorch_extras
import torch
import torch.nn.functional as F
class CorrSampler(torch.autograd.Function):
""" Index from correlation pyramid """
@staticmethod
def forward... | CODD-main | model/motion/raft3d/blocks/corr.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# Adapted from RAFT3D repository: https://github.com/princeton-vl/RAFT-3D
import time
import numpy as np
import scipy.sparse
import torch
import torch.nn.functional as F
from sksparse import cholmod
class GridCholeskySolver(torch.autograd.Function):
@static... | CODD-main | model/motion/raft3d/blocks/grid.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# Adapted from RAFT3D repository: https://github.com/princeton-vl/RAFT-3D
| CODD-main | model/motion/raft3d/blocks/__init__.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# Adapted from RAFT3D repository: https://github.com/princeton-vl/RAFT-3D
import torch
import torch.nn as nn
class ResidualBlock(nn.Module):
def __init__(self, in_planes, planes, norm_fn='group', stride=1):
super(ResidualBlock, self).__init__()
... | CODD-main | model/motion/raft3d/blocks/extractor.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# Adapted from RAFT3D repository: https://github.com/princeton-vl/RAFT-3D
import torch
import torch.nn as nn
class ConvGRU(nn.Module):
def __init__(self, hidden_dim=128, input_dim=192 + 128, dilation=4):
super(ConvGRU, self).__init__()
self.hi... | CODD-main | model/motion/raft3d/blocks/gru.py |
"""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 pylab
import torch
import pickle
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
import... | classifier-balancing-main | tau_norm.py |
"""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 yaml
import csv
import h5py
class Logger(object):
def __init__(self, logdir):
self.logdir = lo... | classifier-balancing-main | logger.py |
"""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.
Portions of the source code are from the OLTR project which
notice below and in LICENSE in the root directory of
this source tree... | classifier-balancing-main | utils.py |
"""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.
Portions of the source code are from the OLTR project which
notice below and in LICENSE in the root directory of
this source tree... | classifier-balancing-main | run_networks.py |
"""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.
Portions of the source code are from the OLTR project which
notice below and in LICENSE in the root directory of
this source tree... | classifier-balancing-main | main.py |
"""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.
Portions of the source code are from the OLTR project which
notice below and in LICENSE in the root directory of
this source tree... | classifier-balancing-main | layers/ModulatedAttLayer.py |
"""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.
Portions of the source code are from the OLTR project which
notice below and in LICENSE in the root directory of
this source tree... | classifier-balancing-main | loss/SoftmaxLoss.py |
"""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.
Portions of the source code are from the OLTR project which
notice below and in LICENSE in the root directory of
this source tree... | classifier-balancing-main | loss/DiscCentroidsLoss.py |
"""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.
Portions of the source code are from the OLTR project which
notice below and in LICENSE in the root directory of
this source tree... | classifier-balancing-main | models/MetaEmbeddingClassifier.py |
"""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.
"""
from models.ResNetFeature import *
from utils import *
from os import path
def create_model(use_selfatt=False, use_... | classifier-balancing-main | models/ResNet101Feature.py |
"""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.
Portions of the source code are from the OLTR project which
notice below and in LICENSE in the root directory of
this source tree... | classifier-balancing-main | models/ResNet152FeatureCaffe.py |
"""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 math
import torch.nn as nn
import torch.nn.functional as F
from layers.ModulatedAttLayer import ModulatedAttLayer
de... | classifier-balancing-main | models/ResNextFeature.py |
"""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.
"""
from models.ResNetFeature import *
from utils import *
from os import path
def create_model(use_selfatt=False, use_... | classifier-balancing-main | models/ResNet50Feature.py |
"""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.
Portions of the source code are from the OLTR project which
notice below and in LICENSE in the root directory of
this source tree... | classifier-balancing-main | models/ResNetFeature.py |
"""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.
Portions of the source code are from the OLTR project which
notice below and in LICENSE in the root directory of
this source tree... | classifier-balancing-main | models/DotProductClassifier.py |
"""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.
"""
from models.ResNextFeature import *
from utils import *
from os import path
def create_model(use_selfatt=False, use... | classifier-balancing-main | models/ResNext101Feature.py |
"""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 torch
import torch.nn as nn
from torch.nn.parameter import Parameter
from utils import *
from os import path
class ... | classifier-balancing-main | models/TauNormClassifier.py |
"""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.
Portions of the source code are from the OLTR project which
notice below and in LICENSE in the root directory of
this source tree... | classifier-balancing-main | models/CosNormClassifier.py |
"""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.
Portions of the source code are from the OLTR project which
notice below and in LICENSE in the root directory of
this source tree... | classifier-balancing-main | models/ResNet10Feature.py |
"""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.
"""
from models.ResNextFeature import *
from utils import *
from os import path
def create_model(use_selfatt=False, use... | classifier-balancing-main | models/ResNext152Feature.py |
"""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 torch
import torch.nn as nn
import numpy as np
import pickle
from os import path
class KNNClassifier(nn.Module):
... | classifier-balancing-main | models/KNNClassifier.py |
"""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.
"""
from models.ResNextFeature import *
from utils import *
from os import path
def create_model(use_selfatt=False, use_... | classifier-balancing-main | models/ResNext50Feature.py |
"""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.
"""
from models.ResNetFeature import *
from utils import *
from os import path
def create_model(use_selfatt=False, use_f... | classifier-balancing-main | models/ResNet152Feature.py |
"""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.
Portions of the source code are from the OLTR project which
notice below and in LICENSE in the root directory of
this source tree... | classifier-balancing-main | data/ClassAwareSampler.py |
"""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 random
import numpy as np
from torch.utils.data.sampler import Sampler
class PriorityTree(object):
def __init__... | classifier-balancing-main | data/MixedPrioritizedSampler.py |
"""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 random
import numpy as np
from torch.utils.data.sampler import Sampler
class RandomCycleIter:
def __init__... | classifier-balancing-main | data/ClassPrioritySampler.py |
"""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.
Portions of the source code are from the OLTR project which
notice below and in LICENSE in the root directory of
this source tree... | classifier-balancing-main | data/dataloader.py |
"""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.
Usage:
1. Change "root" to your data path
2. python gen_lists.py
"""
import os
import json
from tqdm import tqdm
root = '/check... | classifier-balancing-main | data/iNaturalist18/gen_lists.py |
"""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
from tqdm import tqdm
root = '/datasets01_101/imagenet_full_size/061417'
split2txt = {
'train': 'I... | classifier-balancing-main | data/ImageNet/gen_txt.py |
import re
import sys
import os
import os.path
import random
import json
import time
import nltk.data
import spacy
import pandas as pd
import random
from multiprocessing import Pipe, Pool
from functools import partial
from collections import defaultdict, Counter
from tqdm import tqdm
sys.path.append("/checkpoint/sima... | concurrentqa-main | dataset_construction/cleanEnron.py |
import os
import sys
import argparse
import json as json
import pandas as pd
from collections import Counter, defaultdict
from importlib import reload
from email.parser import Parser
# recursively get the document body
def get_body(body):
if type(body) == str:
return [body]
else:
body_results ... | concurrentqa-main | dataset_construction/EnronParser.py |
import os
import csv
import ujson
import json
from tqdm import tqdm
import requests
import pandas as pd
import numpy as np
import time
import ast
import random
from collections import Counter, defaultdict, OrderedDict
INBOX = "skilling-j"
def add_entry(q="", idx="", answer=[], sp1={}, sp2={}, typ="", domain=[]):
e... | concurrentqa-main | dataset_construction/Enron_skilling-j/make_queries.py |
# Copyright (c) Meta Platforms, Inc. and 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 argparse
import os
import uuid
from pathlib import Path
import main as classification
import submitit
def parse... | ConvNeXt-main | run_with_submitit.py |
# Copyright (c) Meta Platforms, Inc. and 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
from torchvision import datasets, transforms
from timm.data.constants import \
IMAGENET_DEFAULT_MEAN, IMA... | ConvNeXt-main | datasets.py |
# Copyright (c) Meta Platforms, Inc. and 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 math
from typing import Iterable, Optional
import torch
from timm.data import Mixup
from timm.utils import accura... | ConvNeXt-main | engine.py |
# Copyright (c) Meta Platforms, Inc. and 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 math
import time
from collections import defaultdict, deque
import datetime
import numpy as np
from tim... | ConvNeXt-main | utils.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.