repo
stringlengths
1
99
file
stringlengths
13
215
code
stringlengths
12
59.2M
file_length
int64
12
59.2M
avg_line_length
float64
3.82
1.48M
max_line_length
int64
12
2.51M
extension_type
stringclasses
1 value
furniture-bench
furniture-bench-main/vip/vip/examples/plot_reward_curves.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 cv2 import glob from matplotlib import pyplot as plt import numpy as np import os import torch import torchvision...
4,021
34.280702
131
py
furniture-bench
furniture-bench-main/vip/vip/examples/encoder_example.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 omegaconf import hydra import torch import torchvision.transforms as T import numpy as np from PIL import Image fro...
934
25.714286
97
py
furniture-bench
furniture-bench-main/vip/vip/models/model_vip.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 numpy as np from numpy.core.numeric import full import torch import torch.nn as nn from torch.nn.modules.activation ...
3,280
35.054945
138
py
furniture-bench
furniture-bench-main/vip/vip/utils/data_loaders.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 warnings import torchvision warnings.filterwarnings('ignore', category=DeprecationWarning) import os os.environ['M...
4,246
32.976
91
py
furniture-bench
furniture-bench-main/vip/vip/utils/utils.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 random import re import time import numpy as np import torch import torch.nn as nn import torch.nn.functional as F ...
4,974
29.151515
78
py
furniture-bench
furniture-bench-main/vip/vip/utils/logger.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 csv import datetime from collections import defaultdict import numpy as np import torch import torchvision import w...
6,131
32.326087
91
py
furniture-bench
furniture-bench-main/implicit_q_learning/dataset_utils.py
import collections import pickle from typing import Optional, Dict # import d4rl import gym import numpy as np import jax.numpy as jnp from tqdm import tqdm Batch = collections.namedtuple("Batch", ["observations", "actions", "rewards", "masks", "next_observations"]) def split_into_tra...
13,173
39.411043
127
py
furniture-bench
furniture-bench-main/implicit_q_learning/actor.py
from typing import Tuple import jax import jax.numpy as jnp from common import Batch, InfoDict, Model, Params, PRNGKey def update(key: PRNGKey, actor: Model, critic: Model, value: Model, batch: Batch, temperature: float) -> Tuple[Model, InfoDict]: v = value(batch.observations) q1, q2 = critic(ba...
986
30.83871
76
py
furniture-bench
furniture-bench-main/implicit_q_learning/learner.py
"""Implementations of algorithms for continuous control.""" from typing import Optional, Sequence, Tuple import jax import jax.numpy as jnp import numpy as np import optax import policy import value_net from actor import update as awr_update_actor from common import Batch, InfoDict, Model, PRNGKey from critic import...
6,219
29.640394
111
py
furniture-bench
furniture-bench-main/implicit_q_learning/policy.py
import functools from typing import Optional, Sequence, Tuple, Dict import flax.linen as nn import jax import jax.numpy as jnp import numpy as np from tensorflow_probability.substrates import jax as tfp tfd = tfp.distributions tfb = tfp.bijectors from common import MLP, Encoder, ResNet18 from common import Params fr...
3,105
31.694737
103
py
furniture-bench
furniture-bench-main/implicit_q_learning/common.py
import collections from functools import partial import os from typing import Any, Callable, Dict, Optional, Sequence, Tuple import flax import flax.linen as nn import jax import jax.numpy as jnp import optax Batch = collections.namedtuple('Batch', ['observations', 'actions', 'rewards',...
6,800
31.855072
100
py
furniture-bench
furniture-bench-main/implicit_q_learning/value_net.py
from typing import Callable, Sequence, Tuple, Dict import jax.numpy as jnp from flax import linen as nn from common import MLP, Encoder, Encoder class ValueCritic(nn.Module): hidden_dims: Sequence[int] use_encoder: bool = False @nn.compact def __call__(self, observations: Dict[str, jnp.ndarray]) ->...
2,292
33.742424
119
py
furniture-bench
furniture-bench-main/implicit_q_learning/evaluation.py
from typing import Dict import flax.linen as nn import gym import numpy as np def evaluate( agent: nn.Module, env: gym.Env, num_episodes: int, temperature: float = 0.00 ) -> Dict[str, float]: stats = {"return": [], "length": []} for _ in range(num_episodes): observation, done = env.reset(), Fals...
648
23.961538
80
py
furniture-bench
furniture-bench-main/implicit_q_learning/extract_feature.py
import pickle from pathlib import Path import furniture_bench import numpy as np import torch import gym from absl import app, flags FLAGS = flags.FLAGS flags.DEFINE_string("furniture", None, "Furniture name.") flags.DEFINE_string("demo_dir", "square_table_parts_state", "Demonstration dir.") flags.DEFINE_string("o...
4,979
34.571429
155
py
furniture-bench
furniture-bench-main/implicit_q_learning/critic.py
from typing import Tuple import jax.numpy as jnp from common import Batch, InfoDict, Model, Params def loss(diff, expectile=0.8): weight = jnp.where(diff > 0, expectile, (1 - expectile)) return weight * (diff**2) def update_v(critic: Model, value: Model, batch: Batch, expectile: float) -> Tup...
1,574
29.882353
78
py
furniture-bench
furniture-bench-main/r3m/setup.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import os import sys from setuptools import setup, find_packages if sys.version_info.major != 3: print("This Python i...
1,009
30.5625
108
py
furniture-bench
furniture-bench-main/r3m/r3m/example.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import omegaconf import hydra import torch import torchvision.transforms as T import numpy as np from PIL import Image fr...
966
27.441176
97
py
furniture-bench
furniture-bench-main/r3m/r3m/setup.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import os import sys from setuptools import setup, find_packages if sys.version_info.major != 3: print("This Python i...
1,009
30.5625
108
py
furniture-bench
furniture-bench-main/r3m/r3m/train_representation.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import warnings import torchvision warnings.filterwarnings('ignore', category=DeprecationWarning) import os os.environ['...
5,279
33.285714
120
py
furniture-bench
furniture-bench-main/r3m/r3m/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from r3m.models.models_r3m import R3M import os from os.path import expanduser import omegaconf import hydra import gdow...
4,689
40.140351
130
py
furniture-bench
furniture-bench-main/r3m/r3m/trainer.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import hydra import numpy as np from numpy.core.numeric import full import torch import torch.nn as nn import torch.nn.fun...
6,734
40.574074
148
py
furniture-bench
furniture-bench-main/r3m/r3m/models/models_language.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import numpy as np from numpy.core.numeric import full import torch import torch.nn as nn from torch.nn.modules.activation...
2,188
38.8
93
py
furniture-bench
furniture-bench-main/r3m/r3m/models/models_r3m.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import numpy as np from numpy.core.numeric import full import torch import torch.nn as nn from torch.nn.modules.activation...
4,115
37.111111
138
py
furniture-bench
furniture-bench-main/r3m/r3m/r3m/example.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import omegaconf import hydra import torch import torchvision.transforms as T import numpy as np from PIL import Image fr...
966
27.441176
97
py
furniture-bench
furniture-bench-main/r3m/r3m/r3m/train_representation.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import warnings import torchvision warnings.filterwarnings('ignore', category=DeprecationWarning) import os os.environ['...
5,279
33.285714
120
py
furniture-bench
furniture-bench-main/r3m/r3m/r3m/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from r3m.models.models_r3m import R3M import os from os.path import expanduser import omegaconf import hydra import gdow...
4,689
40.140351
130
py
furniture-bench
furniture-bench-main/r3m/r3m/r3m/trainer.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import hydra import numpy as np from numpy.core.numeric import full import torch import torch.nn as nn import torch.nn.fun...
6,734
40.574074
148
py
furniture-bench
furniture-bench-main/r3m/r3m/r3m/models/models_language.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import numpy as np from numpy.core.numeric import full import torch import torch.nn as nn from torch.nn.modules.activation...
2,188
38.8
93
py
furniture-bench
furniture-bench-main/r3m/r3m/r3m/models/models_r3m.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import numpy as np from numpy.core.numeric import full import torch import torch.nn as nn from torch.nn.modules.activation...
4,115
37.111111
138
py
furniture-bench
furniture-bench-main/r3m/r3m/r3m/utils/data_loaders.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import warnings import torchvision warnings.filterwarnings('ignore', category=DeprecationWarning) import os os.environ['...
3,522
31.321101
101
py
furniture-bench
furniture-bench-main/r3m/r3m/r3m/utils/utils.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import random import re import time import numpy as np import torch import torch.nn as nn import torch.nn.functional as F...
4,975
29.341463
78
py
furniture-bench
furniture-bench-main/r3m/r3m/r3m/utils/logger.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import csv import datetime from collections import defaultdict import numpy as np import torch import torchvision import ...
6,165
32.51087
91
py
furniture-bench
furniture-bench-main/r3m/r3m/utils/data_loaders.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import warnings import torchvision warnings.filterwarnings('ignore', category=DeprecationWarning) import os os.environ['...
3,522
31.321101
101
py
furniture-bench
furniture-bench-main/r3m/r3m/utils/utils.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import random import re import time import numpy as np import torch import torch.nn as nn import torch.nn.functional as F...
4,975
29.341463
78
py
furniture-bench
furniture-bench-main/r3m/r3m/utils/logger.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import csv import datetime from collections import defaultdict import numpy as np import torch import torchvision import ...
6,165
32.51087
91
py
LF-DAnet
LF-DAnet-main/test.py
import argparse from utils.utility import * from model.DAnet import Net import numpy as np import imageio import torch import os from einops import rearrange def parse_args(): parser = argparse.ArgumentParser() parser.add_argument('--device', type=str, default='cuda:0') parser.add_argument("--angRes", typ...
5,251
48.54717
163
py
LF-DAnet
LF-DAnet-main/validation.py
import argparse import torch.backends.cudnn as cudnn from utils.utility import * from utils.dataloader import * from model.DAnet import Net parser = argparse.ArgumentParser() parser.add_argument('--device', type=str, default='cuda:0') parser.add_argument('--num_workers', type=int, default=4) parser.add_argument('--mo...
4,944
41.264957
152
py
LF-DAnet
LF-DAnet-main/train.py
import time import argparse import torch.backends.cudnn as cudnn from tqdm import tqdm import random from utils.utility import * from utils.dataloader import * from model.DAnet import Net parser = argparse.ArgumentParser() parser.add_argument('--device', type=str, default='cuda:0') parser.add_argument('--parallel', t...
8,576
43.905759
152
py
LF-DAnet
LF-DAnet-main/utils/utility.py
import torch import numpy as np from skimage import metrics import torch.nn.functional as F from einops import rearrange def save_ckpt(args, net, idx_epoch): if args.parallel: torch.save({'epoch': idx_epoch, 'state_dict': net.module.state_dict()}, './log/' + args.model_name + '_' + str(...
4,266
38.146789
129
py
LF-DAnet
LF-DAnet-main/utils/dataloader.py
import os from torch.utils.data.dataset import Dataset from utils.degrade import * import numpy as np import h5py from torch.utils.data import DataLoader from einops import rearrange class TrainSetLoader(): def __init__(self, args): super(TrainSetLoader, self).__init__() self.args = args s...
2,600
33.68
105
py
LF-DAnet
LF-DAnet-main/utils/degrade.py
import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from einops import rearrange class MultiDegrade(object): def __init__(self, scale=4, kernel_size=21, sig_min=0, sig_max=4.0, noise=None, sig=None): self.kernel_size = kernel_size self.scale = scale if sig...
6,311
40.801325
117
py
LF-DAnet
LF-DAnet-main/model/DAnet.py
import torch import torch.nn as nn from einops import rearrange import torch.nn.functional as F class Net(nn.Module): def __init__(self, factor, angRes): super(Net, self).__init__() channels = 64 n_group = 4 n_block = 4 self.factor = factor self.gen_code = Gen_Code(...
10,452
37.149635
114
py
saic_depth_completion
saic_depth_completion-master/tools/train_matterport.py
import torch import argparse import numpy as np from saic_depth_completion.data.datasets.matterport import Matterport from saic_depth_completion.engine.train import train from saic_depth_completion.utils.tensorboard import Tensorboard from saic_depth_completion.utils.logger import setup_logger from saic_depth_comple...
3,793
30.616667
106
py
saic_depth_completion
saic_depth_completion-master/tools/test_net.py
import torch import argparse from saic_depth_completion.data.datasets.matterport import Matterport from saic_depth_completion.data.datasets.nyuv2_test import NyuV2Test from saic_depth_completion.engine.inference import inference from saic_depth_completion.utils.tensorboard import Tensorboard from saic_depth_completio...
4,177
32.424
93
py
saic_depth_completion
saic_depth_completion-master/saic_depth_completion/metrics/absolute.py
import torch from torch import nn ###### LOSSES ####### class BerHuLoss(nn.Module): def __init__(self, scale=0.5, eps=1e-5): super(BerHuLoss, self).__init__() self.scale = scale self.eps = eps def forward(self, pred, gt): img1 = torch.zeros_like(pred) img2 = torch.zero...
1,943
26.380282
91
py
saic_depth_completion
saic_depth_completion-master/saic_depth_completion/metrics/relative.py
from functools import partial import torch from torch import nn import torch.nn.functional as F from torch.autograd import Variable import numpy as np from math import exp ###### METRICS ####### class DepthRel(nn.Module): def __init__(self, eps=1e-5): super(DepthRel, self).__init__() self.eps = e...
3,570
32.688679
118
py
saic_depth_completion
saic_depth_completion-master/saic_depth_completion/engine/inference.py
import os import time import datetime import torch from tqdm import tqdm import matplotlib.pyplot as plt from saic_depth_completion.utils.meter import AggregatedMeter from saic_depth_completion.utils.meter import Statistics as LossMeter from saic_depth_completion.utils import visualize def inference( model,...
1,649
31.352941
95
py
saic_depth_completion
saic_depth_completion-master/saic_depth_completion/engine/val.py
import time import datetime import torch from tqdm import tqdm from saic_depth_completion.utils.meter import AggregatedMeter from saic_depth_completion.utils.meter import Statistics as LossMeter def validate( model, val_loaders, metrics, epoch=0, logger=None, tensorboard=None, tracker=None ): model.eval...
1,366
32.341463
109
py
saic_depth_completion
saic_depth_completion-master/saic_depth_completion/engine/train.py
import time import datetime import torch from saic_depth_completion.utils.meter import AggregatedMeter from saic_depth_completion.utils.meter import Statistics as LossMeter from saic_depth_completion.engine.val import validate def train( model, trainloader, optimizer, val_loaders={}, scheduler=None, snapshoter=No...
2,859
33.047619
100
py
saic_depth_completion
saic_depth_completion-master/saic_depth_completion/utils/snapshoter.py
import logging import os import torch import numpy as np class Snapshoter: def __init__( self, model, optimizer=None, scheduler=None, save_dir="", period=10, logger=None, ): self.model = model self.optimize...
2,265
31.84058
99
py
saic_depth_completion
saic_depth_completion-master/saic_depth_completion/utils/model_zoo.py
import os import re import torch from torch.hub import load_state_dict_from_url model_resnet_imagenet = { 'resnet18': 'https://download.pytorch.org/models/resnet18-5c106cde.pth', 'resnet34': 'https://download.pytorch.org/models/resnet34-333f7ec4.pth', 'resnet50': 'https://download.pytorch.org/models/resne...
2,795
54.92
126
py
saic_depth_completion
saic_depth_completion-master/saic_depth_completion/utils/tensorboard.py
import torch.utils.tensorboard as tb from saic_depth_completion.utils import visualize class Tensorboard: def __init__(self, tb_dir, max_figures=10): self.tb_dir = tb_dir self.max_figures = max_figures def update(self, metrics_dict, epoch, tag="train"): with tb.SummaryWriter(self.tb_di...
1,087
37.857143
66
py
saic_depth_completion
saic_depth_completion-master/saic_depth_completion/utils/meter.py
from collections import deque import torch class Statistics(object): def __init__(self, maxlen=20): self.enum = deque(maxlen=maxlen) self.denum = deque(maxlen=maxlen) self.total = 0.0 self.count = 0 def reset(self): self.total = 0.0 self.count = 0 self...
2,265
23.630435
71
py
saic_depth_completion
saic_depth_completion-master/saic_depth_completion/data/collate.py
import torch def default_collate(samples): batch = dict() for k in samples[0].keys(): batch[k] = list() for sample in samples: for k, v in sample.items(): batch[k].append(v) for k, v in batch.items(): batch[k] = torch.stack(v) return batch
299
19
35
py
saic_depth_completion
saic_depth_completion-master/saic_depth_completion/data/datasets/nyuv2_test.py
import os import torch from torch.nn import functional as F import numpy as np from PIL import Image import cv2 # ROOT = '/Vol1/dbstore/datasets/depth_completion/Matterport3D/' ROOT = "/Vol0/user/d.senushkin/datasets/nyuv2_test" class NyuV2Test: def __init__( self, root=ROOT, split="1gr10pv1pd", tran...
3,757
38.978723
103
py
saic_depth_completion
saic_depth_completion-master/saic_depth_completion/data/datasets/nyu_raw.py
import os import torch import numpy as np from PIL import Image import random ROOT = '/Vol1/dbstore/datasets/depth_completion/NYUv2_raw' class NYURaw(): def __init__(self, split, dt=0.01, valid_split=0.05, focal=None, image_aug=None, depth_aug=None, geometry_aug=None, ...
4,875
29.666667
108
py
saic_depth_completion
saic_depth_completion-master/saic_depth_completion/data/datasets/matterport.py
import os import torch import numpy as np from PIL import Image # ROOT = '/Vol1/dbstore/datasets/depth_completion/Matterport3D/' ROOT = "/Vol0/user/d.senushkin/datasets/matterport3d" class Matterport: def __init__( self, root=ROOT, split="train", transforms=None ): self.transforms = trans...
4,048
41.177083
104
py
saic_depth_completion
saic_depth_completion-master/saic_depth_completion/data/datasets/completion_dataset.py
import numpy as np from skimage.filters import gaussian import torch def rgb2gray(rgb): return np.dot(rgb[..., :3], [0.2989, 0.5870, 0.1140]) def create_holes_mask(layer, granularity, percentile): gaussian_layer = np.random.uniform(size=layer.shape[1:]) gaussian_layer = gaussian(gaussian_layer, sigma=gr...
2,917
35.024691
91
py
saic_depth_completion
saic_depth_completion-master/saic_depth_completion/modeling/dm_lrn.py
from functools import partial import torch from torch import nn import torch.nn.functional as F from saic_depth_completion.modeling.backbone import build_backbone from saic_depth_completion.modeling.blocks import AdaptiveBlock, MaskEncoder, FusionBlock, CRPBlock, SharedEncoder from saic_depth_completion.utils import...
6,260
37.176829
114
py
saic_depth_completion
saic_depth_completion-master/saic_depth_completion/modeling/lrn.py
from functools import partial import torch from torch import nn import torch.nn.functional as F from saic_depth_completion.modeling.backbone import build_backbone from saic_depth_completion.modeling.blocks import AdaptiveBlock, MaskEncoder, FusionBlock, CRPBlock from saic_depth_completion.utils import registry from ...
4,692
37.154472
103
py
saic_depth_completion
saic_depth_completion-master/saic_depth_completion/modeling/meta.py
import torch import torch.nn.functional as F from saic_depth_completion.utils import registry # refactor this to class MetaModel(torch.nn.Module): def __init__(self, cfg, device): super(MetaModel, self).__init__() self.model = registry.MODELS[cfg.model.arch](cfg.model) self.model.to(device...
1,369
30.860465
86
py
saic_depth_completion
saic_depth_completion-master/saic_depth_completion/modeling/blocks.py
from functools import partial import torch from torch import nn import torch.nn.functional as F from saic_depth_completion import ops from saic_depth_completion.modeling.backbone.res_blocks import Bottleneck class CRPBlock(nn.Module): def conv1x1(self, in_planes, out_planes, stride=1, bias=False): retur...
5,751
35.405063
114
py
saic_depth_completion
saic_depth_completion-master/saic_depth_completion/modeling/backbone/hrnet.py
import sys import torch from torch import nn from torch.nn import Conv2d from collections import namedtuple from saic_depth_completion.modeling.backbone import res_blocks from saic_depth_completion import ops StageSpec = namedtuple( "StageSpec", [ "num_channels", # tuple "num_blocks",...
17,294
39.790094
100
py
saic_depth_completion
saic_depth_completion-master/saic_depth_completion/modeling/backbone/res_blocks.py
import torch import torch.nn as nn from collections import namedtuple import sys def conv3x3(in_planes, out_planes, stride=1, groups=1, dilation=1): """3x3 convolution with padding""" return nn.Conv2d(in_planes, out_planes, kernel_size=3, stride=stride, padding=dilation, groups=groups, b...
3,147
30.168317
90
py
saic_depth_completion
saic_depth_completion-master/saic_depth_completion/modeling/backbone/efficientnet.py
import sys import torch.nn as nn from efficientnet_pytorch import EfficientNet as _EfficientNet from efficientnet_pytorch.utils import url_map, get_model_params from collections import namedtuple StageSpec = namedtuple("StageSpec", ["num_channels", "stage_stamp"],) efficientnet_b0 = tuple(StageSpec(num_channels=nc,...
2,822
34.734177
99
py
saic_depth_completion
saic_depth_completion-master/saic_depth_completion/modeling/backbone/resnet.py
import sys from collections import namedtuple from torch import nn from saic_depth_completion.modeling.backbone import res_blocks from saic_depth_completion import ops StageSpec = namedtuple("StageSpec", ["block_count", "block"],) resnet18 = tuple(StageSpec(block_count=c, block=b) for (c, b) in ((2, "BasicBlock...
5,712
38.951049
106
py
saic_depth_completion
saic_depth_completion-master/saic_depth_completion/ops/batch_norm.py
import torch from torch import nn from torch.nn import functional as F class FrozenBatchNorm2d(nn.Module): """ BatchNorm2d where the batch statistics and the affine parameters are fixed """ def __init__(self, channels, eps=1e-5): super(FrozenBatchNorm2d, self).__init__() self.eps ...
1,460
36.461538
81
py
saic_depth_completion
saic_depth_completion-master/saic_depth_completion/ops/spade.py
import torch from torch import nn from torch.nn import functional as F class SPADE(nn.Module): def __init__(self, x_ch, y_ch, kernel_size=3, upsample='nearest'): super(SPADE, self).__init__() self.eps = 1e-5 assert upsample in ['nearest', 'bilinear'] self.upsample = upsample ...
2,290
28.371795
81
py
saic_depth_completion
saic_depth_completion-master/saic_depth_completion/ops/sean.py
import torch from torch import nn from torch.nn import functional as F class SEAN(nn.Module): def __init__(self, x_ch, y_ch, kernel_size=3, upsample='nearest'): super(SEAN, self).__init__() assert upsample in ['nearest', 'bilinear'] self.upsample = upsample padding = (kernel_size ...
1,678
29.527273
76
py
saic_depth_completion
saic_depth_completion-master/saic_depth_completion/ops/__init__.py
from functools import partial import torch from .batch_norm import FrozenBatchNorm2d from .spade import SPADE, SelfSPADE from .sean import SEAN from saic_depth_completion.utils.registry import Registry MODULATION_LAYERS = Registry() NORM_LAYERS = Registry() ACTIVATION_LAYERS = Registry() ACTIVATION_LAYERS["ReLU"] ...
603
25.26087
57
py
dwave-neal
dwave-neal-master/docs/conf.py
# -*- coding: utf-8 -*- # # dwave_neal documentation build configuration file, created by # sphinx-quickstart on Wed Jul 26 10:55:26 2017. # # This file is execfile()d with the current directory set to its # containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # ...
6,219
29.945274
83
py
IdealGPT
IdealGPT-master/blip_gpt_main.py
import os import yaml import argparse import torch import openai from tqdm import tqdm import pdb from data import VCRSampler from data import VESampler from chat import VCRConversationTwoAgent from chat import VEConversationTwoAgent import random def IdealGPT(vqa_model, dataset, data_ids, model, save_path='', max_...
11,536
45.708502
171
py
IdealGPT
IdealGPT-master/misc/blip_caption.py
import argparse import torch import yaml import json from tqdm import tqdm import jsonlines import os import sys # Get the absolute path to the parent directory parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Add the parent directory to sys.path sys.path.insert(0, parent_dir) from lib.blip2_l...
5,378
38.262774
131
py
IdealGPT
IdealGPT-master/lib/llava_lib.py
import argparse from transformers import AutoTokenizer, AutoModelForCausalLM, AutoConfig import torch import os import json from tqdm import tqdm import shortuuid from llava.conversation import conv_templates from llava.utils import disable_torch_init from transformers import CLIPVisionModel, CLIPImageProcessor, Stopp...
8,493
42.336735
154
py
ccvae
ccvae-master/ss_vae.py
import argparse import torch import torchvision.utils import pyro from pyro.infer import SVI, Trace_ELBO from pyro.optim import Adam from utils.custom_loss import TraceCCVAE_ELBO from utils.dataset_cached import setup_data_loaders, CELEBACached, CELEBA_EASY_LABELS from models.semisup_vae import SSVAE_CCVAE import nump...
5,949
37.387097
98
py
ccvae
ccvae-master/models/networks.py
import torch import torch.nn as nn import torch.nn.functional as F class View(nn.Module): def __init__(self, size): super(View, self).__init__() self.size = size def forward(self, tensor): return tensor.view(self.size) class CELEBAEncoder(nn.Module): def __init__(s...
3,017
30.4375
96
py
ccvae
ccvae-master/models/semisup_vae.py
import numpy as np import torch from torchvision.utils import make_grid, save_image import pyro import pyro.distributions as dist import os from .networks import (CondPrior, Classifier, CELEBADecoder, CELEBAEncoder) class SSVAE_CCVAE(torch.nn.Module): """ Class that deals with the propos...
7,853
40.776596
130
py
ccvae
ccvae-master/utils/custom_loss.py
import torch import pyro from pyro.infer import Trace_ELBO from pyro.util import warn_if_nan from pyro.infer.util import torch_backward, torch_item class TraceCCVAE_ELBO(Trace_ELBO): """ Custom loss """ def __init__(self, vae, *args, **kwargs): super(TraceCCVAE_ELBO, self).__init__(*args, **kw...
1,504
28.509804
85
py
ccvae
ccvae-master/utils/dataset_cached.py
import os import PIL from functools import reduce import numpy as np import torch from torch.utils.data import DataLoader from torchvision.datasets import CelebA import torchvision.transforms as transforms from pyro.contrib.examples.util import get_data_directory def split_celeba(X, y, sup_frac, validation_num): ...
5,783
35.377358
190
py
SIFT
SIFT-master/inference.py
import argparse import csv import json import os import re from types import SimpleNamespace import pytorch_lightning as pl import torch from data_readers import output_modes, processors from data_readers.base_reader import convert_examples_to_features, get_graphs from models import RGCNSemanticEncoder def load_pre...
6,050
36.351852
167
py
SIFT
SIFT-master/train.py
import argparse from importlib import reload import logging import os import json from pathlib import Path import random import numpy as np import pytorch_lightning as pl import torch reload(logging) from models import RGCNSemanticEncoder logger = logging.getLogger(__name__) class LoggingCallback(pl.Callback): ...
6,356
32.81383
138
py
SIFT
SIFT-master/models/pretrained_transformer.py
import logging import pytorch_lightning as pl from torch import nn from transformers import AutoConfig, AutoModel, AutoTokenizer logger = logging.getLogger(__name__) class PretrainedTransformer(pl.LightningModule): def __init__(self, args, num_labels=None, mode="base", **config_kwargs): "Initialize a ...
2,916
38.418919
151
py
SIFT
SIFT-master/models/gnn.py
import torch.nn.functional as F import torch.nn as nn from dgl.nn.pytorch import RelGraphConv class GNN(nn.Module): def __init__(self, h_dim, num_relations, num_hidden_layers=1, dropout=0, activation=F.relu): super().__init__() self.h_dim = h_dim self.num_relations = num_relations ...
1,704
30
98
py
SIFT
SIFT-master/models/rgcn_semantic_encoder.py
import logging from allennlp.modules.matrix_attention import BilinearMatrixAttention from allennlp.nn.util import masked_softmax, masked_max import torch from torch import nn import torch.nn.functional as F from .semantic_encoder import SemanticEncoder from .gnn import RGCN logger = logging.getLogger(__name__) cl...
13,926
47.866667
256
py
SIFT
SIFT-master/models/base_lightning_model.py
import numpy as np import pytorch_lightning as pl import torch from transformers import get_linear_schedule_with_warmup from transformers import AdamW class BaseLightningModel(pl.LightningModule): def __init__(self, args): super().__init__() self.args = args def train_dataloader(self, shuffl...
5,148
39.865079
148
py
SIFT
SIFT-master/models/semantic_encoder.py
import logging import os import pickle from types import GeneratorType from allennlp.nn.util import masked_mean from dgl import DGLGraph from pytorch_lightning.utilities import move_data_to_device import torch from torch import nn import torch.nn.functional as F from torch.utils.data import DataLoader from transformer...
16,081
40.448454
174
py
SIFT
SIFT-master/data_readers/base_reader.py
from collections import Counter import dataclasses from dataclasses import dataclass import json import logging import os import pickle from typing import Any, List, Optional, Tuple, Union from dgl import DGLGraph from rdflib import Graph as RDFGraph import torch from tqdm import tqdm from .rdf2dgl import relations_i...
14,054
40.58284
177
py
SIFT
SIFT-master/data_readers/semantic_dataset.py
import dgl import torch import torch.nn.functional as F from torch.utils.data import Dataset from torch.utils.data._utils.collate import default_collate def _transpose(l): return list(zip(*l)) class SemanticDataset(Dataset): """When labels and/or graphs are not available, pass in a list of Nones""" def...
7,461
42.637427
166
py
SIFT
SIFT-master/data_readers/rdf2dgl.py
# some methods/classes adpated from https://github.com/dmlc/dgl/blob/ca48787ae49e9d73ebf17b1c882cb66fb66fb828/python/dgl/contrib/data/knowledge_graph.py from collections import Counter from dataclasses import dataclass import pickle import sys from typing import Dict, Optional from dgl import DGLGraph from rdflib imp...
3,734
29.867769
152
py
hexaconv
hexaconv-master/groupy/gconv/gconv_tensorflow/keras/layers.py
"""Contains the group equivariant convolutional Keras layers.""" import tensorflow as tf import groupy.gconv.gconv_tensorflow.layers as tf_layers class SplitGConv2D(tf_layers.SplitGConv2D, tf.keras.layers.Layer): """Group convolution base class for split plane groups. A plane group (aka wallpaper group) is a...
31,761
55.116608
119
py
pixel-deflection
pixel-deflection-master/main.py
from __future__ import division import os, sys, argparse, multiprocessing from joblib import Parallel, delayed from glob import glob import numpy as np from utils import * from methods import pixel_deflection, denoiser os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' # silences the TF INFO messages def get_arguments(): p...
4,565
48.630435
138
py
pixel-deflection
pixel-deflection-master/utils.py
import matplotlib import numpy as np from keras.preprocessing import image from scipy.misc import imread import json def batches(array, batch_size): return (array[i:i + batch_size] for i in range(0, len(array), batch_size)) def rgb2ycc(im): xform = np.array([[.299, .587, .114], [-.1687, -.3313, .5], [.5, -.41...
924
25.428571
86
py
pixel-deflection
pixel-deflection-master/methods.py
from __future__ import division from random import randint, uniform import os, sys, argparse, matplotlib, multiprocessing from keras.preprocessing import image from scipy.misc import imread from joblib import Parallel, delayed from glob import glob import numpy as np os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' norm = mat...
1,707
38.72093
120
py
DeepFormableTag
DeepFormableTag-master/setup.py
""" !/usr/bin/env python Copyright (c) Facebook, Inc. and its affiliates. Edited by Mustafa B. Yaldiz (VCLAB, KAIST) """ import glob import os import shutil from os import path from setuptools import find_packages, setup from typing import List import torch # from torch.utils.cpp_extension import CUDA_HOME, CppExtensio...
1,768
31.163636
97
py
DeepFormableTag
DeepFormableTag-master/tools/generate_board_pdf.py
# Copyright (c) Mustafa B. Yaldiz (VCLAB, KAIST) All Rights Reserved. """ This code creates pdfs for given configs. """ import os, json, argparse from pathlib import Path from collections import OrderedDict import cairo import numpy as np from cv2 import aruco import torch from deepformable.utils import ( get_aruc...
9,512
41.28
117
py
DeepFormableTag
DeepFormableTag-master/tools/training_visualizer.py
# Copyright (c) Mustafa B. Yaldiz (VCLAB, KAIST) All Rights Reserved. import cv2 from cv2 import aruco import random import matplotlib.pyplot as plt import json import numpy as np import argparse import math from pathlib import Path from typing import Union from copy import deepcopy import datetime import os import ran...
8,608
35.790598
108
py
DeepFormableTag
DeepFormableTag-master/tools/predictor_demo.py
# Copyright (c) Facebook, Inc. and its affiliates. import argparse import glob from pathlib import Path import multiprocessing as mp import os import tempfile import time import warnings import tqdm import json import cv2 import numpy as np import torch from detectron2.data.detection_utils import read_image from detec...
7,927
36.396226
95
py
DeepFormableTag
DeepFormableTag-master/tools/train.py
# Copyright (c) Mustafa B. Yaldiz (VCLAB, KAIST) All Rights Reserved. from pathlib import Path import json import torch import detectron2 import detectron2.utils.comm as comm from detectron2.engine import default_argument_parser, default_setup, launch import deepformable from deepformable.engine import DeepformableTr...
3,491
36.148936
128
py
DeepFormableTag
DeepFormableTag-master/deepformable/evaluation/evaluation.py
""" This code is modified from detectron2 implementation, changes are logged in comments. Copyright (c) Mustafa B. Yaldiz (VCLAB, KAIST) All Rights Reserved. """ import os import copy import logging import itertools import datetime from collections import OrderedDict import numpy as np import torch import pycocotoo...
16,742
41.820972
108
py
DeepFormableTag
DeepFormableTag-master/deepformable/layers/adaptive_loss.py
# Copyright (c) Mustafa B. Yaldiz (VCLAB, KAIST) All Rights Reserved. import torch import torch.distributed as dist from torch import nn from torch.nn import functional as F from detectron2.utils.comm import get_world_size, is_main_process from .dist_ops import AllReduce class AdaptiveLoss(nn.Module): """ Th...
3,133
40.786667
94
py