repo stringlengths 2 99 | file stringlengths 13 225 | code stringlengths 0 18.3M | file_length int64 0 18.3M | avg_line_length float64 0 1.36M | max_line_length int64 0 4.26M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
UNITER | UNITER-master/inf_nlvr2.py | """run inference of NLVR2 (single GPU only)"""
import argparse
import json
import os
from os.path import exists
from time import time
import torch
from torch.utils.data import DataLoader
from apex import amp
from horovod import torch as hvd
from data import (DetectFeatLmdb, TxtTokLmdb,
PrefetchLoade... | 5,465 | 37.765957 | 77 | py |
UNITER | UNITER-master/pretrain_vcr.py | """
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
UNITER pre-training
"""
import argparse
from collections import defaultdict
import json
import os
from os.path import exists, join
from time import time
import torch
from torch.utils.data import DataLoader
from torch.nn import functional as F
fr... | 22,741 | 39.538324 | 79 | py |
UNITER | UNITER-master/inf_re.py | """
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
run inference of VQA for submission
"""
import argparse
import json
import os
from os.path import exists
from time import time
import torch
from torch.utils.data import DataLoader
from apex import amp
from horovod import torch as hvd
from cytoo... | 7,395 | 35.98 | 99 | py |
UNITER | UNITER-master/inf_itm.py | """
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
run inference for Image Text Retrieval
"""
import argparse
import json
import os
from os.path import exists
import pickle
from time import time
import torch
from torch.utils.data import DataLoader
from apex import amp
from horovod import torch ... | 6,413 | 38.109756 | 79 | py |
UNITER | UNITER-master/train_vqa.py | """
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
UNITER finetuning for VQA
"""
import argparse
import json
import os
from os.path import abspath, dirname, exists, join
from time import time
import torch
from torch.nn import functional as F
from torch.nn.utils import clip_grad_norm_
from torch.... | 16,988 | 41.261194 | 79 | py |
UNITER | UNITER-master/train_ve.py | """
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
UNITER finetuning for SNLI-VE
"""
import argparse
import json
import os
from os.path import exists, join
import pickle
from time import time
import torch
from torch.nn import functional as F
from torch.nn.utils import clip_grad_norm_
from torch.... | 16,875 | 41.724051 | 79 | py |
UNITER | UNITER-master/train_re.py | """
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
UNITER finetuning for RE
"""
import argparse
import json
import os
from os.path import exists, join
from time import time
import torch
from torch.nn.utils import clip_grad_norm_
from torch.utils.data import DataLoader
from torch.optim import Ada... | 18,420 | 39.220524 | 79 | py |
UNITER | UNITER-master/train_itm_hard_negatives.py | """
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
UNITER finetuning for Image-Text Retrieval with hard negatives
"""
import argparse
import os
from os.path import exists, join
from time import time
import torch
from torch.nn.utils import clip_grad_norm_
from torch.utils.data import DataLoader, ... | 19,146 | 42.417234 | 79 | py |
UNITER | UNITER-master/optim/misc.py | """
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
Misc lr helper
"""
from torch.optim import Adam, Adamax
from .adamw import AdamW
def build_optimizer(model, opts):
param_optimizer = list(model.named_parameters())
no_decay = ['bias', 'LayerNorm.bias', 'LayerNorm.weight']
optimizer... | 1,037 | 27.833333 | 65 | py |
UNITER | UNITER-master/optim/adamw.py | """
AdamW optimizer (weight decay fix)
copied from hugginface (https://github.com/huggingface/transformers).
"""
import math
import torch
from torch.optim import Optimizer
class AdamW(Optimizer):
""" Implements Adam algorithm with weight decay fix.
Parameters:
lr (float): learning rate. Default 1e-3.... | 4,450 | 41.798077 | 79 | py |
UNITER | UNITER-master/optim/__init__.py | """
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
"""
from .sched import noam_schedule, warmup_linear, vqa_schedule, get_lr_sched
from .adamw import AdamW
| 179 | 21.5 | 75 | py |
UNITER | UNITER-master/optim/sched.py | """
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
optimizer learning rate scheduling helpers
"""
from math import ceil
def noam_schedule(step, warmup_step=4000):
""" original Transformer schedule"""
if step <= warmup_step:
return step / warmup_step
return (warmup_step ** 0.... | 1,258 | 25.787234 | 63 | py |
UNITER | UNITER-master/scripts/eval_nlvr2.py | """
copied from official NLVR2 github
(https://github.com/lil-lab/nlvr/tree/master/nlvr2)
python scripts/eval_nlvr2.py <output.csv> <annotation.json>
"""
import json
import sys
# Load the predictions file. Assume it is a CSV.
predictions = { }
for line in open(sys.argv[1]).readlines():
if line:
splits = line.st... | 2,038 | 30.369231 | 87 | py |
UNITER | UNITER-master/scripts/convert_imgdir.py | """
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
convert image npz to LMDB
"""
import argparse
import glob
import io
import json
import multiprocessing as mp
import os
from os.path import basename, exists
from cytoolz import curry
import numpy as np
from tqdm import tqdm
import lmdb
import ms... | 4,777 | 32.412587 | 79 | py |
UNITER | UNITER-master/scripts/convert_ckpt.py | import sys
from collections import OrderedDict
import torch
bert_ckpt, output_ckpt = sys.argv[1:]
bert = torch.load(bert_ckpt)
uniter = OrderedDict()
for k, v in bert.items():
uniter[k.replace('bert', 'uniter')] = v
torch.save(uniter, output_ckpt)
| 256 | 17.357143 | 43 | py |
UNITER | UNITER-master/utils/const.py | """
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
constants
"""
IMG_DIM = 2048
IMG_LABEL_DIM = 1601
BUCKET_SIZE = 8192
| 143 | 13.4 | 36 | py |
UNITER | UNITER-master/utils/misc.py | """
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
Misc utilities
"""
import json
import random
import sys
import torch
import numpy as np
from utils.logger import LOGGER
class NoOp(object):
""" useful for distributed training No-Ops """
def __getattr__(self, name):
return sel... | 1,507 | 20.239437 | 70 | py |
UNITER | UNITER-master/utils/save.py | """
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
saving utilities
"""
import json
import os
from os.path import abspath, dirname, exists, join
import subprocess
import torch
from utils.logger import LOGGER
def save_training_meta(args):
if args.rank > 0:
return
if not exists... | 2,734 | 35.959459 | 73 | py |
UNITER | UNITER-master/utils/logger.py | """
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
helper for logging
NOTE: loggers are global objects use with caution
"""
import logging
import math
import tensorboardX
_LOG_FMT = '%(asctime)s - %(levelname)s - %(name)s - %(message)s'
_DATE_FMT = '%m/%d/%Y %H:%M:%S'
logging.basicConfig(for... | 2,449 | 24.789474 | 75 | py |
UNITER | UNITER-master/utils/itm_eval.py | """
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
Image Text Retrieval evaluation helper
"""
from time import time
import torch
from horovod import torch as hvd
from tqdm import tqdm
from .logger import LOGGER
from .misc import NoOp
from .distributed import all_gather_list
@torch.no_grad()
d... | 3,661 | 30.843478 | 72 | py |
UNITER | UNITER-master/utils/distributed.py | """
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
distributed API using Horovod
Modified from OpenNMT's native pytorch distributed utils
(https://github.com/OpenNMT/OpenNMT-py)
"""
import math
import pickle
import torch
from horovod import torch as hvd
def all_reduce_and_rescale_tensors(tenso... | 6,296 | 28.985714 | 77 | py |
UNITER | UNITER-master/utils/__init__.py | 0 | 0 | 0 | py | |
UNITER | UNITER-master/data/vcr.py | """
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
VCR dataset
"""
import copy
import json
import torch
from torch.nn.utils.rnn import pad_sequence
from toolz.sandbox import unzip
from cytoolz import concat
from .data import (DetectFeatTxtTokDataset, TxtTokLmdb, DetectFeatLmdb,
... | 11,643 | 37.556291 | 82 | py |
UNITER | UNITER-master/data/mlm.py | """
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
MLM datasets
"""
import random
import torch
from torch.nn.utils.rnn import pad_sequence
from toolz.sandbox import unzip
from .data import (DetectFeatTxtTokDataset, TxtTokLmdb,
pad_tensors, get_gather_index)
def random_word(... | 4,551 | 32.226277 | 79 | py |
UNITER | UNITER-master/data/sampler.py | """
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
sampler for length bucketing (batch by tokens)
"""
import math
import random
import horovod.torch as hvd
import torch
from torch.utils.data import Sampler
from cytoolz import partition_all
class TokenBucketSampler(Sampler):
def __init__(se... | 4,199 | 33.42623 | 79 | py |
UNITER | UNITER-master/data/ve.py | """
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
Visual entailment dataset
# NOTE: basically reuse VQA dataset
"""
from .vqa import VqaDataset, VqaEvalDataset, vqa_collate, vqa_eval_collate
class VeDataset(VqaDataset):
def __init__(self, *args, **kwargs):
super().__init__(3, *args... | 519 | 21.608696 | 74 | py |
UNITER | UNITER-master/data/mrm.py | """
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
MRM Datasets
"""
import random
import torch
from torch.nn.utils.rnn import pad_sequence
from toolz.sandbox import unzip
from .data import DetectFeatTxtTokDataset, pad_tensors, get_gather_index
def _get_img_mask(mask_prob, num_bb):
img_mask... | 7,228 | 34.965174 | 79 | py |
UNITER | UNITER-master/data/vqa.py | """
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
VQA dataset
"""
import torch
from torch.nn.utils.rnn import pad_sequence
from toolz.sandbox import unzip
from .data import DetectFeatTxtTokDataset, pad_tensors, get_gather_index
def _get_vqa_target(example, num_answers):
target = torch.zer... | 4,105 | 31.330709 | 76 | py |
UNITER | UNITER-master/data/data.py | """
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
Dataset interfaces
"""
from collections import defaultdict
from contextlib import contextmanager
import io
import json
from os.path import exists
import numpy as np
import torch
from torch.utils.data import Dataset, ConcatDataset
import horovod.... | 10,028 | 31.041534 | 78 | py |
UNITER | UNITER-master/data/pretrain_vcr.py | from .vcr import VcrDetectFeatTxtTokDataset
from .mlm import random_word
import torch
from toolz.sandbox import unzip
from torch.nn.utils.rnn import pad_sequence
from .data import pad_tensors, get_gather_index
from .mrm import (
_get_img_tgt_mask, _get_img_mask, _mask_img_feat,
_get_feat_target, _get_targets)
... | 9,933 | 35.255474 | 77 | py |
UNITER | UNITER-master/data/nlvr2.py | """
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
NLVR2 dataset
"""
import copy
import torch
from torch.nn.utils.rnn import pad_sequence
from toolz.sandbox import unzip
from cytoolz import concat
from .data import (DetectFeatTxtTokDataset, TxtTokLmdb, DetectFeatLmdb,
get_ids... | 7,186 | 31.817352 | 76 | py |
UNITER | UNITER-master/data/__init__.py | """
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
"""
from .data import (TxtTokLmdb, DetectFeatLmdb,
ImageLmdbGroup, ConcatDatasetWithLens)
from .sampler import TokenBucketSampler
from .loader import PrefetchLoader, MetaLoader
from .vqa import VqaDataset, VqaEvalDataset, vqa_c... | 1,384 | 46.758621 | 74 | py |
UNITER | UNITER-master/data/loader.py | """
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
A prefetch loader to speedup data loading
Modified from Nvidia Deep Learning Examples
(https://github.com/NVIDIA/DeepLearningExamples/tree/master/PyTorch).
"""
import random
import torch
from torch.utils.data import DataLoader
from utils.distri... | 4,747 | 32.202797 | 79 | py |
UNITER | UNITER-master/data/re.py | """
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
Referring Expression dataset
"""
import random
import numpy as np
import json
import torch
from torch.nn.utils.rnn import pad_sequence
from toolz.sandbox import unzip
from .data import (DetectFeatTxtTokDataset, TxtTokLmdb, DetectFeatLmdb,
... | 10,442 | 35.260417 | 79 | py |
UNITER | UNITER-master/data/itm.py | """
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
Itm dataset
"""
from collections import defaultdict
import copy
import random
import torch
from torch.nn.utils.rnn import pad_sequence
from toolz.sandbox import unzip
from cytoolz import concat
import numpy as np
from .data import (DetectFeatTx... | 16,959 | 35.162047 | 79 | py |
UNITER | UNITER-master/model/vcr.py | """
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
Uniter for VCR model
"""
from collections import defaultdict
from torch import nn
from torch.nn import functional as F
from apex.normalization.fused_layer_norm import FusedLayerNorm as LayerNorm
# from .layer import GELU
from .model import (
... | 3,024 | 37.782051 | 80 | py |
UNITER | UNITER-master/model/pretrain.py | """
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
UNITER for pretraining
"""
from collections import defaultdict
import torch
from torch import nn
from torch.nn import functional as F
from apex.normalization.fused_layer_norm import FusedLayerNorm as LayerNorm
from .layer import GELU, BertOnlyM... | 10,155 | 43.156522 | 78 | py |
UNITER | UNITER-master/model/layer.py | """
BERT layers from the huggingface implementation
(https://github.com/huggingface/transformers)
"""
# coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the... | 9,378 | 39.081197 | 104 | py |
UNITER | UNITER-master/model/ve.py | """
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
UNITER for VE model
"""
from .vqa import UniterForVisualQuestionAnswering
class UniterForVisualEntailment(UniterForVisualQuestionAnswering):
""" Finetune UNITER for VE
"""
def __init__(self, config, img_dim):
super().__init_... | 342 | 21.866667 | 66 | py |
UNITER | UNITER-master/model/model.py | """
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
Pytorch modules
some classes are modified from HuggingFace
(https://github.com/huggingface/transformers)
"""
import copy
import json
import logging
from io import open
import torch
from torch import nn
from apex.normalization.fused_layer_norm im... | 15,887 | 42.173913 | 79 | py |
UNITER | UNITER-master/model/vqa.py | """
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
Uniter for VQA model
"""
from collections import defaultdict
from torch import nn
from torch.nn import functional as F
from apex.normalization.fused_layer_norm import FusedLayerNorm as LayerNorm
from .layer import GELU
from .model import Uniter... | 1,860 | 34.113208 | 75 | py |
UNITER | UNITER-master/model/pretrain_vcr.py | from .pretrain import UniterForPretraining
from torch import nn
from .layer import BertOnlyMLMHead
from collections import defaultdict
from torch.nn import functional as F
import torch
class UniterForPretrainingForVCR(UniterForPretraining):
""" 2nd Stage Pretrain UNITER for VCR
"""
def init_type_embedding... | 7,123 | 46.493333 | 80 | py |
UNITER | UNITER-master/model/nlvr2.py | """
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
Uniter for NLVR2 model
"""
from collections import defaultdict
import torch
from torch import nn
from torch.nn import functional as F
from .model import UniterPreTrainedModel, UniterModel
from .attention import MultiheadAttention
class Uniter... | 8,505 | 40.492683 | 76 | py |
UNITER | UNITER-master/model/ot.py | """
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
Wasserstein Distance (Optimal Transport)
"""
import torch
from torch.nn import functional as F
def cost_matrix_cosine(x, y, eps=1e-5):
""" Compute cosine distnace across every pairs of x, y (batched)
[B, L_x, D] [B, L_y, D] -> [B, Lx, L... | 2,866 | 32.337209 | 74 | py |
UNITER | UNITER-master/model/attention.py | """
copy multi-head attention code from pytorch
(https://github.com/pytorch/pytorch),
"""
import warnings
import torch
from torch.nn import Module, Parameter, Linear
from torch.nn.init import xavier_normal_, xavier_uniform_, constant_
from torch.nn.functional import linear, softmax, dropout
def multi_head_attention_... | 19,463 | 47.297767 | 130 | py |
UNITER | UNITER-master/model/re.py | """
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
Uniter for RE model
"""
from collections import defaultdict
import torch
from torch import nn
import random
import numpy as np
from apex.normalization.fused_layer_norm import FusedLayerNorm as LayerNorm
from .layer import GELU
from .model impor... | 5,705 | 36.051948 | 89 | py |
UNITER | UNITER-master/model/itm.py | """
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
UNITER for ITM model
"""
from collections import defaultdict
import torch
from torch import nn
from .model import UniterPreTrainedModel, UniterModel
class UniterForImageTextRetrieval(UniterPreTrainedModel):
""" Finetune UNITER for image te... | 5,619 | 39.142857 | 79 | py |
DenoiseCompression | DenoiseCompression-main/CompressAI/setup.py | # Copyright (c) 2021-2022, InterDigital Communications, Inc
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted (subject to the limitations in the disclaimer
# below) provided that the following conditions are met:
# * Redistributions of source cod... | 5,093 | 31.653846 | 96 | py |
DenoiseCompression | DenoiseCompression-main/CompressAI/codes/test.py | import os, glob
import math
import logging
import time
import argparse
from collections import OrderedDict
import json
import torch
import torch.nn.functional as F
import numpy as np
from criterions.criterion import Criterion
import options.options as option
import utils.util as util
import compressai
torch.backends... | 6,949 | 38.714286 | 139 | py |
DenoiseCompression | DenoiseCompression-main/CompressAI/codes/train.py | import os
import math
import argparse
import random
import logging
import torch
import torch.distributed as dist
from torch.utils.data.sampler import Sampler
import options.options as option
from utils import util
from utils.util import (
configure_optimizers, load_optimizer,
configure_schedulers, load_schedu... | 17,639 | 41 | 137 | py |
DenoiseCompression | DenoiseCompression-main/CompressAI/codes/options/options.py | import os
import logging
import yaml
from utils.util import OrderedYaml
Loader, Dumper = OrderedYaml()
# type = normal, forward, backward
def parse(opt_path, is_train=True):
with open(opt_path, mode='r') as f:
opt = yaml.load(f, Loader=Loader)
opt['is_train'] = is_train
# export CUDA_VISIBLE_DEVI... | 2,606 | 33.302632 | 129 | py |
DenoiseCompression | DenoiseCompression-main/CompressAI/codes/options/__init__.py | 0 | 0 | 0 | py | |
DenoiseCompression | DenoiseCompression-main/CompressAI/codes/criterions/__init__.py | 0 | 0 | 0 | py | |
DenoiseCompression | DenoiseCompression-main/CompressAI/codes/criterions/criterion.py | import math
import torch
import torch.nn as nn
from torch.autograd import Variable
from torchvision import models
import torch.nn.functional as F
class Criterion(nn.Module):
def __init__(self, opt):
super(Criterion, self).__init__()
self.opt = opt
# criterions
self.criterion_metri... | 3,832 | 33.223214 | 113 | py |
DenoiseCompression | DenoiseCompression-main/CompressAI/codes/scripts/sidd_block.py | import os
import scipy.io
from PIL import Image
val_noisy_blocks_path = '../../../data/SIDD/SIDD_Benchmark_zips/ValidationNoisyBlocksSrgb.mat'
val_noisy_blocks = scipy.io.loadmat(val_noisy_blocks_path)
val_noisy_blocks_numpy = val_noisy_blocks['ValidationNoisyBlocksSrgb']
val_gt_blocks_path = '../../../data/SIDD/SIDD... | 2,043 | 44.422222 | 105 | py |
DenoiseCompression | DenoiseCompression-main/CompressAI/codes/scripts/flicker_process.py | import os
import json
import imagesize
from shutil import copyfile
# directory
data_root_dir = '../../../data/flicker/flicker_2W_images'
train_root_dir = '../../../data/flicker/train'
val_root_dir = '../../../data/flicker/val'
if not os.path.exists(train_root_dir):
os.makedirs(train_root_dir)
if not os.path.exists... | 1,184 | 27.214286 | 91 | py |
DenoiseCompression | DenoiseCompression-main/CompressAI/codes/scripts/sidd_tile_annotations.py | from PIL import Image
import glob, os
import json
import numpy as np
import image_slicer
row_col_h_w = {
'S6': (6, 9, 500, 592),
'GP': (4, 8, 761, 506),
'N6': (6, 8, 520, 526),
'G4': (6, 8, 498, 664),
'IP': (6, 8, 504, 504),
}
checked = {
'S6': False,
'GP': False,
'N6': False,
'G4'... | 4,415 | 35.495868 | 124 | py |
DenoiseCompression | DenoiseCompression-main/CompressAI/codes/utils/util.py | import os
import sys
import time
import math
from datetime import datetime
import random
import logging
from collections import OrderedDict
import numpy as np
import cv2
import torch
import torch.nn as nn
import torch.utils.data
from torchvision import transforms
from torchvision.utils import make_grid
from shutil impo... | 13,098 | 34.498645 | 143 | py |
DenoiseCompression | DenoiseCompression-main/CompressAI/codes/utils/__init__.py | 0 | 0 | 0 | py | |
DenoiseCompression | DenoiseCompression-main/CompressAI/compressai/__init__.py | # Copyright (c) 2021-2022, InterDigital Communications, Inc
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted (subject to the limitations in the disclaimer
# below) provided that the following conditions are met:
# * Redistributions of source cod... | 2,868 | 35.782051 | 80 | py |
DenoiseCompression | DenoiseCompression-main/CompressAI/compressai/models/MultiscaleDecomp.py | import torch
import torch.nn as nn
from torch.nn import functional as F
from .waseda import Cheng2020Anchor
from compressai.layers import (
AttentionBlock,
ResidualBlock,
ResidualBlockUpsample,
ResidualBlockWithStride,
conv3x3,
subpel_conv3x3,
conv1x1
)
import warnings
class MultiscaleDecom... | 3,860 | 28.930233 | 84 | py |
DenoiseCompression | DenoiseCompression-main/CompressAI/compressai/models/priors.py | # Copyright (c) 2021-2022, InterDigital Communications, Inc
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted (subject to the limitations in the disclaimer
# below) provided that the following conditions are met:
# * Redistributions of source cod... | 23,319 | 34.226586 | 88 | py |
DenoiseCompression | DenoiseCompression-main/CompressAI/compressai/models/utils.py | # Copyright (c) 2021-2022, InterDigital Communications, Inc
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted (subject to the limitations in the disclaimer
# below) provided that the following conditions are met:
# * Redistributions of source cod... | 4,989 | 33.178082 | 88 | py |
DenoiseCompression | DenoiseCompression-main/CompressAI/compressai/models/waseda.py | # Copyright (c) 2021-2022, InterDigital Communications, Inc
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted (subject to the limitations in the disclaimer
# below) provided that the following conditions are met:
# * Redistributions of source cod... | 5,591 | 35.077419 | 79 | py |
DenoiseCompression | DenoiseCompression-main/CompressAI/compressai/models/__init__.py | # Copyright (c) 2021-2022, InterDigital Communications, Inc
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted (subject to the limitations in the disclaimer
# below) provided that the following conditions are met:
# * Redistributions of source cod... | 1,808 | 55.53125 | 78 | py |
DenoiseCompression | DenoiseCompression-main/CompressAI/compressai/zoo/image.py | # Copyright (c) 2021-2022, InterDigital Communications, Inc
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted (subject to the limitations in the disclaimer
# below) provided that the following conditions are met:
# * Redistributions of source cod... | 19,465 | 39.469854 | 115 | py |
DenoiseCompression | DenoiseCompression-main/CompressAI/compressai/zoo/pretrained.py | # Copyright (c) 2021-2022, InterDigital Communications, Inc
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted (subject to the limitations in the disclaimer
# below) provided that the following conditions are met:
# * Redistributions of source cod... | 2,750 | 41.323077 | 78 | py |
DenoiseCompression | DenoiseCompression-main/CompressAI/compressai/zoo/__init__.py | # Copyright (c) 2021-2022, InterDigital Communications, Inc
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted (subject to the limitations in the disclaimer
# below) provided that the following conditions are met:
# * Redistributions of source cod... | 2,244 | 43.9 | 78 | py |
DenoiseCompression | DenoiseCompression-main/CompressAI/compressai/datasets/SiddDataset.py | import random
import os, glob
import json
import torch
from torch.utils.data import Dataset
from PIL import Image
from torchvision import transforms
class SiddDataset(Dataset):
def __init__(self, dataset_opt):
self.root = dataset_opt['root']
self.transform = transforms.ToTensor()
self.patch... | 3,608 | 38.659341 | 159 | py |
DenoiseCompression | DenoiseCompression-main/CompressAI/compressai/datasets/SyntheticDataset.py | import random
import numpy as np
import torch
from torch.utils.data import Dataset
from PIL import Image
from pathlib import Path
from .utils import sRGBGamma, UndosRGBGamma
from torchvision import transforms
class SyntheticDataset(Dataset):
def __init__(self, dataset_opt):
splitdir = Path(dataset_opt['roo... | 2,867 | 34.85 | 91 | py |
DenoiseCompression | DenoiseCompression-main/CompressAI/compressai/datasets/SyntheticTestDataset.py | import random
import numpy as np
import torch
from torch.utils.data import Dataset
from PIL import Image
from pathlib import Path
from .utils import sRGBGamma, UndosRGBGamma
from torchvision import transforms
class SyntheticTestDataset(Dataset):
def __init__(self, dataset_opt):
root = Path(dataset_opt['roo... | 1,969 | 31.295082 | 82 | py |
DenoiseCompression | DenoiseCompression-main/CompressAI/compressai/datasets/utils.py | import random
import numpy as np
import torch
def sRGBGamma(tensor):
threshold = 0.0031308
a = 0.055
mult = 12.92
gamma = 2.4
res = torch.zeros_like(tensor)
mask = tensor > threshold
res[mask] = (1 + a) * torch.pow(tensor[mask] + 0.001, 1.0 / gamma) - a
res[~mask] = tensor[~mask] * mult... | 717 | 22.933333 | 74 | py |
DenoiseCompression | DenoiseCompression-main/CompressAI/compressai/datasets/__init__.py | # Copyright (c) 2021-2022, InterDigital Communications, Inc
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted (subject to the limitations in the disclaimer
# below) provided that the following conditions are met:
# * Redistributions of source cod... | 1,928 | 54.114286 | 78 | py |
DenoiseCompression | DenoiseCompression-main/CompressAI/compressai/layers/gdn.py | # Copyright (c) 2021-2022, InterDigital Communications, Inc
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted (subject to the limitations in the disclaimer
# below) provided that the following conditions are met:
# * Redistributions of source cod... | 4,085 | 32.491803 | 80 | py |
DenoiseCompression | DenoiseCompression-main/CompressAI/compressai/layers/layers.py | # Copyright (c) 2021-2022, InterDigital Communications, Inc
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted (subject to the limitations in the disclaimer
# below) provided that the following conditions are met:
# * Redistributions of source cod... | 8,243 | 32.376518 | 87 | py |
DenoiseCompression | DenoiseCompression-main/CompressAI/compressai/layers/__init__.py | # Copyright (c) 2021-2022, InterDigital Communications, Inc
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted (subject to the limitations in the disclaimer
# below) provided that the following conditions are met:
# * Redistributions of source cod... | 1,759 | 54 | 78 | py |
DenoiseCompression | DenoiseCompression-main/CompressAI/compressai/utils/__init__.py | # Copyright (c) 2021-2022, InterDigital Communications, Inc
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted (subject to the limitations in the disclaimer
# below) provided that the following conditions are met:
# * Redistributions of source cod... | 1,717 | 58.241379 | 78 | py |
DenoiseCompression | DenoiseCompression-main/CompressAI/compressai/utils/find_close/__main__.py | # Copyright (c) 2021-2022, InterDigital Communications, Inc
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted (subject to the limitations in the disclaimer
# below) provided that the following conditions are met:
# * Redistributions of source cod... | 5,072 | 34.475524 | 94 | py |
DenoiseCompression | DenoiseCompression-main/CompressAI/compressai/utils/find_close/__init__.py | 0 | 0 | 0 | py | |
DenoiseCompression | DenoiseCompression-main/CompressAI/compressai/utils/plot/__main__.py | # Copyright (c) 2021-2022, InterDigital Communications, Inc
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted (subject to the limitations in the disclaimer
# below) provided that the following conditions are met:
# * Redistributions of source cod... | 7,320 | 29.504167 | 111 | py |
DenoiseCompression | DenoiseCompression-main/CompressAI/compressai/utils/plot/__init__.py | # Copyright (c) 2021-2022, InterDigital Communications, Inc
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted (subject to the limitations in the disclaimer
# below) provided that the following conditions are met:
# * Redistributions of source cod... | 1,717 | 58.241379 | 78 | py |
DenoiseCompression | DenoiseCompression-main/CompressAI/compressai/utils/bench/__main__.py | # Copyright (c) 2021-2022, InterDigital Communications, Inc
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted (subject to the limitations in the disclaimer
# below) provided that the following conditions are met:
# * Redistributions of source cod... | 5,369 | 28.184783 | 85 | py |
DenoiseCompression | DenoiseCompression-main/CompressAI/compressai/utils/bench/codecs.py | # Copyright (c) 2021-2022, InterDigital Communications, Inc
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted (subject to the limitations in the disclaimer
# below) provided that the following conditions are met:
# * Redistributions of source cod... | 24,347 | 26.053333 | 88 | py |
DenoiseCompression | DenoiseCompression-main/CompressAI/compressai/utils/bench/__init__.py | # Copyright (c) 2021-2022, InterDigital Communications, Inc
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted (subject to the limitations in the disclaimer
# below) provided that the following conditions are met:
# * Redistributions of source cod... | 1,717 | 58.241379 | 78 | py |
DenoiseCompression | DenoiseCompression-main/CompressAI/compressai/transforms/functional.py | from typing import Tuple, Union
import torch
import torch.nn.functional as F
from torch import Tensor
YCBCR_WEIGHTS = {
# Spec: (K_r, K_g, K_b) with K_g = 1 - K_r - K_b
"ITU-R_BT.709": (0.2126, 0.7152, 0.0722)
}
def _check_input_tensor(tensor: Tensor) -> None:
if (
not isinstance(tensor, Tensor... | 3,953 | 28.073529 | 88 | py |
DenoiseCompression | DenoiseCompression-main/CompressAI/compressai/transforms/__init__.py | # Copyright (c) 2021-2022, InterDigital Communications, Inc
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted (subject to the limitations in the disclaimer
# below) provided that the following conditions are met:
# * Redistributions of source cod... | 1,744 | 55.290323 | 78 | py |
DenoiseCompression | DenoiseCompression-main/CompressAI/compressai/transforms/transforms.py | from . import functional as F_transforms
__all__ = [
"RGB2YCbCr",
"YCbCr2RGB",
"YUV444To420",
"YUV420To444",
]
class RGB2YCbCr:
"""Convert a RGB tensor to YCbCr.
The tensor is expected to be in the [0, 1] floating point range, with a
shape of (3xHxW) or (Nx3xHxW).
"""
def __call_... | 3,308 | 26.806723 | 83 | py |
DenoiseCompression | DenoiseCompression-main/CompressAI/compressai/entropy_models/entropy_models.py | # Copyright (c) 2021-2022, InterDigital Communications, Inc
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted (subject to the limitations in the disclaimer
# below) provided that the following conditions are met:
# * Redistributions of source cod... | 24,657 | 34.840116 | 99 | py |
DenoiseCompression | DenoiseCompression-main/CompressAI/compressai/entropy_models/__init__.py | # Copyright (c) 2021-2022, InterDigital Communications, Inc
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted (subject to the limitations in the disclaimer
# below) provided that the following conditions are met:
# * Redistributions of source cod... | 1,886 | 50 | 80 | py |
DenoiseCompression | DenoiseCompression-main/CompressAI/compressai/ops/parametrizers.py | # Copyright (c) 2021-2022, InterDigital Communications, Inc
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted (subject to the limitations in the disclaimer
# below) provided that the following conditions are met:
# * Redistributions of source cod... | 2,642 | 39.661538 | 78 | py |
DenoiseCompression | DenoiseCompression-main/CompressAI/compressai/ops/__init__.py | # Copyright (c) 2021-2022, InterDigital Communications, Inc
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted (subject to the limitations in the disclaimer
# below) provided that the following conditions are met:
# * Redistributions of source cod... | 1,896 | 53.2 | 78 | py |
DenoiseCompression | DenoiseCompression-main/CompressAI/compressai/ops/bound_ops.py | # Copyright (c) 2021-2022, InterDigital Communications, Inc
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted (subject to the limitations in the disclaimer
# below) provided that the following conditions are met:
# * Redistributions of source cod... | 3,102 | 37.308642 | 78 | py |
DenoiseCompression | DenoiseCompression-main/CompressAI/compressai/ops/ops.py | # Copyright (c) 2021-2022, InterDigital Communications, Inc
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted (subject to the limitations in the disclaimer
# below) provided that the following conditions are met:
# * Redistributions of source cod... | 2,223 | 43.48 | 78 | py |
3d_sir | 3d_sir-master/setup.py | #! /usr/bin/env python
# -*- coding: utf-8 -*-
"""
3D SIR v0.1
For more information see: https://github.com/aasensio/3d_sir
::
Main Changes in 0.1
---------------------
* Working version
:copyright:
A. Asensio Ramos
:license:
The MIT License (MIT)
"""
from distutils.ccompiler import CCompiler
... | 5,067 | 30.478261 | 111 | py |
3d_sir | 3d_sir-master/examples/rempel.py | import sir3d
#iterator = sir3d.synth.Iterator(use_mpi=False)
iterator = sir3d.synth.Iterator(use_mpi=True, batch=256, workers_slant=None)
mod = sir3d.synth.Model('rempel.ini', rank=iterator.get_rank())
iterator.use_model(model=mod)
# iterator.run_all_pixels(rangex=[0,20], rangey=[0,20])
iterator.run_all_pixels()
| 319 | 23.615385 | 76 | py |
3d_sir | 3d_sir-master/sir3d/configuration.py | import numpy as np
from configobj import ConfigObj
__all__ = ['Configuration']
def _lower_to_sep(string, separator='='):
line=string.partition(separator)
string=str(line[0]).lower()+str(line[1])+str(line[2])
return string
class Configuration(object):
def __init__(self, filename):
f = open(f... | 593 | 22.76 | 76 | py |
3d_sir | 3d_sir-master/sir3d/__init__.py | __version__ = "2018.09.13"
__author__ = "Andres Asensio Ramos"
from . import sir_code
from .configuration import *
from . import psf
from . import synth
| 154 | 18.375 | 35 | py |
3d_sir | 3d_sir-master/sir3d/synth/slant.py | import numpy as np
import sys
"""
Model slant+projection tools
"""
# *****************************************************************************
def fftshift_image(im_in, dy=0.0, dx=0.0, useLog=False):
"""
FFTSHIFT_IMAGE, shifts an image by dy, dx pixels using
Fourier transforms.
Input:
... | 2,325 | 25.735632 | 108 | py |
3d_sir | 3d_sir-master/sir3d/synth/model.py | from collections import OrderedDict
from sir3d import sir_code
from sir3d.configuration import Configuration
import numpy as np
import os
import scipy.stats
import logging
import h5py
import scipy.integrate as integ
from scipy import interpolate
# from ipdb import set_trace as stop
__all__ = ['Model']
class Model(ob... | 28,540 | 44.375199 | 177 | py |
3d_sir | 3d_sir-master/sir3d/synth/__init__.py | from .model import *
from .multiprocessing import *
from .slant import *
| 73 | 17.5 | 30 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.