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
X-VLM
X-VLM-master/Captioning_scst.py
import argparse import os import math import ruamel.yaml as yaml import numpy as np import random import time import datetime import json from pathlib import Path import torch import torch.backends.cudnn as cudnn import torch.distributed as dist from models import load_pretrained from models.model_captioning import X...
11,209
38.471831
154
py
X-VLM
X-VLM-master/Grounding.py
import argparse import os import math import ruamel.yaml as yaml import numpy as np import random import time import datetime import json from pathlib import Path import torch import torch.backends.cudnn as cudnn import torch.distributed as dist from models.model_retrieval import XVLM from models.tokenization_bert ...
13,266
40.984177
156
py
X-VLM
X-VLM-master/Retrieval.py
import argparse import os import sys import math import ruamel.yaml as yaml import numpy as np import random import time import datetime import json from pathlib import Path import torch import torch.nn.functional as F import torch.backends.cudnn as cudnn import torch.distributed as dist from models.model_retrieval ...
15,875
40.560209
128
py
X-VLM
X-VLM-master/Captioning_pretrain.py
import argparse import copy import os import sys import ruamel.yaml as yaml import numpy as np import random import time import datetime import json import math import torch from torch.utils.data import DataLoader import torch.backends.cudnn as cudnn import torch.distributed as dist from torch.optim import Optimizer ...
8,365
37.376147
123
py
X-VLM
X-VLM-master/run.py
# Multi-Grained Vision Language Pre-Training: Aligning Texts with Visual Concepts (https://arxiv.org/abs/2111.08276) # Github: https://github.com/zengyan-97/X-VLM # Copyright (c) 2022, ByteDance Inc. # All rights reserved. import os import sys import time import random import argparse from utils.hdfs_io import HADOOP...
14,363
37.304
149
py
X-VLM
X-VLM-master/scheduler.py
from torch.optim.lr_scheduler import LambdaLR def create_scheduler(args, optimizer): if 'num_training_steps' not in args: args['num_training_steps'] = args['epochs'] * args['step_per_epoch'] print("### num_training_steps, ", args['num_training_steps'], flush=True) if isinstance(args['num_warmup_s...
1,124
37.793103
93
py
X-VLM
X-VLM-master/Grounding_bbox_pretrain.py
import argparse import copy import os import sys import ruamel.yaml as yaml import numpy as np import random import time import datetime import json import math from pathlib import Path import torch from torch.utils.data import DataLoader import torch.backends.cudnn as cudnn import torch.distributed as dist from torc...
8,881
37.450216
122
py
X-VLM
X-VLM-master/NLVR_pretrain.py
import argparse import copy import os import sys import ruamel.yaml as yaml import numpy as np import random import time import datetime import json import math import torch from torch.utils.data import DataLoader import torch.backends.cudnn as cudnn import torch.distributed as dist from torch.optim import Optimizer ...
8,328
37.206422
123
py
X-VLM
X-VLM-master/Captioning.py
import argparse import os import math import ruamel.yaml as yaml import numpy as np import random import time import datetime import json from pathlib import Path import torch import torch.backends.cudnn as cudnn import torch.distributed as dist from models.model_captioning import XVLM import utils from utils.checkp...
10,797
38.992593
142
py
X-VLM
X-VLM-master/Pretrain.py
# Multi-Grained Vision Language Pre-Training: Aligning Texts with Visual Concepts (https://arxiv.org/abs/2111.08276) # Github: https://github.com/zengyan-97/X-VLM # Copyright (c) 2022, ByteDance Inc. # All rights reserved. import argparse import os import sys import ruamel.yaml as yaml import numpy as np import rando...
12,587
41.527027
148
py
X-VLM
X-VLM-master/VQA.py
import argparse import os import math import ruamel.yaml as yaml import numpy as np import random import time import datetime import json from pathlib import Path import torch import torch.backends.cudnn as cudnn import torch.distributed as dist from models.model_vqa import XVLM from models.tokenization_bert import ...
11,104
38.240283
145
py
X-VLM
X-VLM-master/dataset/nlvr_dataset.py
import json import os from torch.utils.data import Dataset from PIL import Image from dataset.utils import pre_caption class nlvr_dataset(Dataset): def __init__(self, ann_file, transform, image_root): self.ann = [] for f in ann_file: self.ann += json.load(open(f, 'r')) self.tra...
1,179
25.818182
69
py
X-VLM
X-VLM-master/dataset/pretrain_dataset.py
# Multi-Grained Vision Language Pre-Training: Aligning Texts with Visual Concepts (https://arxiv.org/abs/2111.08276) # Github: https://github.com/zengyan-97/X-VLM # Copyright (c) 2022, ByteDance Inc. # All rights reserved. import json import copy import math import random import sys import re import io import tracebac...
19,598
39.661826
141
py
X-VLM
X-VLM-master/dataset/grounding_dataset.py
import json import os import math import random from random import random as rand import torch from torch.utils.data import Dataset from torchvision.transforms.functional import hflip, resize from PIL import Image from dataset.utils import pre_caption from refTools.refer_python3 import REFER class grounding_datase...
4,868
31.898649
106
py
X-VLM
X-VLM-master/dataset/coco_karpathy_dataset.py
import os import json import random from collections import Counter import torch from torch.utils.data import Dataset from torchvision.datasets.utils import download_url from PIL import Image from dataset.utils import pre_caption class coco_karpathy_train(Dataset): def __init__(self, transform, image_root, ann...
3,851
28.860465
101
py
X-VLM
X-VLM-master/dataset/utils.py
import re import json import os import numpy as np import torch import torch.distributed as dist import torch.nn.functional as F import utils from tqdm import tqdm from utils.hdfs_io import hexists, hcopy, hopen from vqaTools.vqaEval import VQAEval from refTools.evaluation.refEvaluation import RefEvaluation def pre...
11,446
29.283069
143
py
X-VLM
X-VLM-master/dataset/vqa_dataset.py
import os import json import random from random import random as rand from PIL import Image from torch.utils.data import Dataset from dataset.utils import pre_question from torchvision.transforms.functional import hflip from transformers import BertTokenizer, RobertaTokenizer class vqa_dataset(Dataset): def __...
3,697
29.816667
112
py
X-VLM
X-VLM-master/dataset/dist_dataset.py
#!/usr/bin/env python # -*- coding: utf-8 -*- # Multi-Grained Vision Language Pre-Training: Aligning Texts with Visual Concepts (https://arxiv.org/abs/2111.08276) # Github: https://github.com/zengyan-97/X-VLM # Copyright (c) 2022, ByteDance Inc. # All rights reserved. import sys from typing import List, Any import war...
3,528
36.147368
116
py
X-VLM
X-VLM-master/dataset/re_dataset.py
import json import os from torch.utils.data import Dataset from PIL import Image from PIL import ImageFile ImageFile.LOAD_TRUNCATED_IMAGES = True Image.MAX_IMAGE_PIXELS = None from dataset.utils import pre_caption class re_train_dataset(Dataset): def __init__(self, ann_file, transform, image_root, max_words=3...
2,206
26.5875
76
py
X-VLM
X-VLM-master/dataset/__init__.py
import os import torch from torch.utils.data import DataLoader from torchvision import transforms from PIL import Image from dataset.re_dataset import re_train_dataset, re_eval_dataset from dataset.pretrain_dataset import ImageTextJsonDataset, RegionTextJsonDataset from dataset.nlvr_dataset import nlvr_dataset from da...
10,549
47.842593
161
py
X-VLM
X-VLM-master/models/model_captioning_pretrain.py
import copy import torch from transformers import BertTokenizer from models.xbert import BertLMHeadModel from models.xroberta import RobertaForCausalLM from models import XVLMBase, load_pretrained class XVLM(XVLMBase): # for domain pretrain def __init__(self, config): super().__init__(config, load_vis...
2,298
38.637931
136
py
X-VLM
X-VLM-master/models/model_vqa.py
import copy from models.xbert import BertLMHeadModel from models.xroberta import RobertaForCausalLM from models import XVLMBase, load_pretrained import torch from torch import nn import torch.nn.functional as F import numpy as np class XVLM(XVLMBase): def __init__(self, config): super().__init__(confi...
9,751
45.218009
136
py
X-VLM
X-VLM-master/models/model_nlvr_pretrain.py
import torch from torch import nn import torch.nn.functional as F from models import XVLMBase, load_pretrained from models.xbert import BertConfig from models.xroberta import RobertaConfig class XVLM(XVLMBase): def __init__(self, config): config_text = RobertaConfig.from_json_file(config['text_config']) ...
5,299
44.299145
118
py
X-VLM
X-VLM-master/models/swin_transformer.py
# -------------------------------------------------------- # Swin Transformer # Copyright (c) 2021 Microsoft # Licensed under The MIT License [see LICENSE for details] # Written by Ze Liu # -------------------------------------------------------- import numpy as np from scipy import interpolate import torch import to...
26,827
40.021407
126
py
X-VLM
X-VLM-master/models/xroberta.py
# 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 "License"); # you may not use this file except in compliance with the License. # You may obtain a cop...
74,692
41.730549
213
py
X-VLM
X-VLM-master/models/xbert.py
# 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 "License"); # you may not use this file except in compliance with the License. # You may obtain a cop...
89,162
42.073913
213
py
X-VLM
X-VLM-master/models/model_captioning.py
import copy import torch import torch.nn.functional as F from transformers import BertTokenizer from models.xbert import BertLMHeadModel from models.xroberta import RobertaForCausalLM from models import XVLMBase, load_pretrained class XVLM(XVLMBase): # for domain pretrain def __init__(self, config): s...
6,822
47.390071
146
py
X-VLM
X-VLM-master/models/vit.py
import sys import torch import torch.nn as nn import torch.nn.functional as F from functools import partial from timm.models.vision_transformer import _cfg, PatchEmbed from timm.models.registry import register_model from timm.models.layers import trunc_normal_, DropPath class Mlp(nn.Module): """ MLP as used in ...
10,198
40.125
123
py
X-VLM
X-VLM-master/models/model_nlvr.py
from models import XVLMBase, build_mlp, load_pretrained from models.xbert import BertConfig from models.xroberta import RobertaConfig import torch from torch import nn import torch.nn.functional as F class XVLM(XVLMBase): def __init__(self, config): config_text = RobertaConfig.from_json_file(config['tex...
4,575
48.73913
148
py
X-VLM
X-VLM-master/models/xvlm.py
# Multi-Grained Vision Language Pre-Training: Aligning Texts with Visual Concepts (https://arxiv.org/abs/2111.08276) # Github: https://github.com/zengyan-97/X-VLM # Copyright (c) 2022, ByteDance Inc. # All rights reserved. import os import torch import torch.nn as nn import torch.nn.functional as F import torch.distri...
23,481
45.133595
129
py
X-VLM
X-VLM-master/models/model_bbox_pretrain.py
import torch from models import XVLMBase, load_pretrained class XVLM(XVLMBase): def __init__(self, config): super().__init__(config, load_vision_params=False, load_text_params=False, use_contrastive_loss=False, use_matching_loss=False, use_mlm_loss=False, use_bbox_loss=True) ...
1,231
48.28
117
py
X-VLM
X-VLM-master/models/box_ops.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved """ Utilities for bounding box manipulation and GIoU. """ import torch from torchvision.ops.boxes import box_area def box_cxcywh_to_xyxy(x): # 这个用了 x_c, y_c, w, h = x.unbind(-1) b = [(x_c - 0.5 * w), (y_c - 0.5 * h), (x_c + 0.5 *...
1,523
24.4
70
py
X-VLM
X-VLM-master/models/clip_vit.py
# Copyright 2021 The OpenAI Team Authors and The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # ...
15,843
42.889197
173
py
X-VLM
X-VLM-master/models/model_retrieval.py
import torch from models import XVLMBase, load_pretrained class XVLM(XVLMBase): def __init__(self, config): super().__init__(config, load_vision_params=False, load_text_params=False, use_contrastive_loss=True, use_matching_loss=True, use_mlm_loss=False, use_bbox_loss=False) ...
1,349
47.214286
123
py
X-VLM
X-VLM-master/models/model_pretrain.py
import torch from models import XVLMBase class XVLM(XVLMBase): def __init__(self, config): super().__init__(config, load_vision_params=True, load_text_params=True, use_contrastive_loss=True, use_matching_loss=True, use_mlm_loss=True, use_bbox_loss=True, config_text=None) def ...
1,656
43.783784
132
py
X-VLM
X-VLM-master/accelerators/accelerator.py
# -*- coding: utf-8 -*- # Multi-Grained Vision Language Pre-Training: Aligning Texts with Visual Concepts (https://arxiv.org/abs/2111.08276) # Github: https://github.com/zengyan-97/X-VLM # Copyright (c) 2022, ByteDance Inc. # All rights reserved. from logging import Logger import torch from torch.optim import Optimiz...
1,062
31.212121
116
py
X-VLM
X-VLM-master/accelerators/apex_ddp_accelerator.py
# -*- coding: utf-8 -*- # Multi-Grained Vision Language Pre-Training: Aligning Texts with Visual Concepts (https://arxiv.org/abs/2111.08276) # Github: https://github.com/zengyan-97/X-VLM # Copyright (c) 2022, ByteDance Inc. # All rights reserved. import os import random import sys from typing import Tuple, Union, Opti...
4,068
38.504854
116
py
X-VLM
X-VLM-master/utils/__init__.py
import json import os import time from collections import defaultdict, deque, OrderedDict import datetime import numpy as np import torch import torch.distributed as dist from utils.cider.pyciderevalcap.ciderD.ciderD import CiderD class ScstRewardCriterion(torch.nn.Module): CIDER_REWARD_WEIGHT = 1 def __...
11,272
29.96978
94
py
X-VLM
X-VLM-master/utils/checkpointer.py
# Multi-Grained Vision Language Pre-Training: Aligning Texts with Visual Concepts (https://arxiv.org/abs/2111.08276) # Github: https://github.com/zengyan-97/X-VLM # Copyright (c) 2022, ByteDance Inc. # All rights reserved. from typing import Union, Dict, List, Tuple, Any, Callable import logging import os import re im...
1,629
33.680851
116
py
X-VLM
X-VLM-master/utils/torch_io.py
#!/usr/bin/env python # -*- coding: utf-8 -*- # Multi-Grained Vision Language Pre-Training: Aligning Texts with Visual Concepts (https://arxiv.org/abs/2111.08276) # Github: https://github.com/zengyan-97/X-VLM # Copyright (c) 2022, ByteDance Inc. # All rights reserved. import io import torch from .hdfs_io import hopen...
906
27.34375
116
py
sbvqa
sbvqa-master/utils.py
import json import os import logging import h5py from evalTools.vqaEval import VQAEval from evalTools.vqa import VQA def load_questions_answers(filePath): with h5py.File(filePath, 'r') as hf: questions_train = hf.get(u'ques_train').value questions_test = hf.get(u'ques_test').value ans_tr...
3,845
33.035398
100
py
sbvqa
sbvqa-master/eval_SpeechMod.py
import json import sys import time import h5py import numpy as np from keras.preprocessing.sequence import pad_sequences from keras.utils.np_utils import to_categorical import utils as U from config_speech import * from models import SpeechMod try: loadWeightsFile = sys.argv[1] except IndexError as e: print(...
4,045
38.666667
107
py
sbvqa
sbvqa-master/models.py
import keras.backend as K class TextMod(object): """ model initialization """ def __init__(self, fc_dimension, vocab): self.fc_dimension = fc_dimension self.vocab = vocab """ build model """ def build_model(self, max_len): from keras.models import Model from keras.la...
4,978
38.204724
106
py
sbvqa
sbvqa-master/train_SpeechMod.py
import json import sys import time import h5py import numpy as np from keras.preprocessing.sequence import pad_sequences from keras.utils.generic_utils import Progbar from keras.utils.np_utils import to_categorical import utils as U from config_speech import * from models import SpeechMod try: # to start trainin...
7,599
45.91358
119
py
sbvqa
sbvqa-master/train_TextMod.py
import json import sys import time import h5py import numpy as np from keras.utils.generic_utils import Progbar from keras.utils.np_utils import to_categorical import utils as U from config_text import * from models import TextMod try: # to start training from pre-existing model loadWeightsFile = sys.argv[1]...
6,646
43.019868
119
py
sbvqa
sbvqa-master/eval_TextMod.py
import json import sys import h5py import numpy as np from keras.utils.np_utils import to_categorical import utils as U from config_text import * from models import TextMod try: loadWeightsFile = sys.argv[1] except IndexError as e: print("Must provide as argument path to file containing model weights") r...
3,462
35.840426
107
py
FixRes
FixRes-main/hubconf.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 tqdm import tqdm import torch import hashlib import os import re import shutil import sys import tempfile try: f...
5,269
35.597222
123
py
FixRes
FixRes-main/transforms_v2.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 torchvision.transforms.functional as F from torchvision import transforms import torch import math im...
6,335
30.68
111
py
FixRes
FixRes-main/imnet_finetune/pnasnet.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. # ''' Code from https://github.com/Cadene/pretrained-models.pytorch/blob/master/pretrainedmodels/models/pnasnet.py with some...
18,314
43.13253
108
py
FixRes
FixRes-main/imnet_finetune/resnext_wsl.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. # Optional list of dependencies required by the package ''' Code From : https://github.com/facebookresearch/WSL-Image...
3,386
39.321429
97
py
FixRes
FixRes-main/imnet_finetune/Res.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.nn as nn try: from torch.hub import load_state_dict_from_url except ImportError: from torch.utils.mo...
11,382
36.943333
106
py
FixRes
FixRes-main/imnet_finetune/samplers.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 torch.utils.data.sampler import BatchSampler import torch import numpy as np from torch.utils.data.dataloader import ...
3,579
34.445545
138
py
FixRes
FixRes-main/imnet_finetune/train.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 os.path as osp from typing import Optional import torch import torch.distributed import torch.nn as nn im...
14,952
41.722857
207
py
FixRes
FixRes-main/imnet_finetune/transforms.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 torchvision.transforms.functional as F from torchvision import transforms import numpy as np class R...
2,935
33.139535
111
py
FixRes
FixRes-main/imnet_extract/pnasnet.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. # ''' Code from https://github.com/Cadene/pretrained-models.pytorch/blob/master/pretrainedmodels/models/pnasnet.py with some...
18,325
43.159036
108
py
FixRes
FixRes-main/imnet_extract/resnext_wsl.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. # Optional list of dependencies required by the package ''' Code From : https://github.com/facebookresearch/WSL-Image...
3,386
39.321429
97
py
FixRes
FixRes-main/imnet_extract/Res.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. # ''' Code from : https://github.com/pytorch/vision/blob/master/torchvision/models/resnet.py ''' import torch.nn as nn ...
11,486
36.910891
106
py
FixRes
FixRes-main/imnet_extract/samplers.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 torch.utils.data.sampler import BatchSampler import torch import numpy as np from torch.utils.data.dataloader import ...
3,579
34.445545
138
py
FixRes
FixRes-main/imnet_extract/train.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 os.path as osp from typing import Optional import torch import torch.distributed import torch.nn as nn im...
7,624
38.102564
192
py
FixRes
FixRes-main/imnet_extract/transforms.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 torchvision.transforms.functional as F from torchvision import transforms class Resize(transforms.Res...
2,904
33.176471
111
py
FixRes
FixRes-main/imnet_evaluate/pnasnet.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. # ''' Code from https://github.com/Cadene/pretrained-models.pytorch/blob/master/pretrainedmodels/models/pnasnet.py with some...
18,314
43.13253
108
py
FixRes
FixRes-main/imnet_evaluate/resnext_wsl.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. # Optional list of dependencies required by the package ''' Code From : https://github.com/facebookresearch/WSL-Image...
3,386
39.321429
97
py
FixRes
FixRes-main/imnet_evaluate/Res.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. # ''' Code from : https://github.com/pytorch/vision/blob/master/torchvision/models/resnet.py ''' import torch.nn as nn ...
11,481
36.894389
106
py
FixRes
FixRes-main/imnet_evaluate/samplers.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 torch.utils.data.sampler import BatchSampler import torch import numpy as np from torch.utils.data.dataloader import ...
3,579
34.445545
138
py
FixRes
FixRes-main/imnet_evaluate/train.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 os.path as osp from typing import Optional import torch import torch.distributed import torch.nn as nn im...
7,892
33.021552
192
py
FixRes
FixRes-main/imnet_evaluate/transforms.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 torchvision.transforms.functional as F from torchvision import transforms class Resize(transforms.Re...
2,905
32.790698
111
py
FixRes
FixRes-main/imnet_resnet50_scratch/samplers.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 torch.utils.data.sampler import BatchSampler import torch import numpy as np from torch.utils.data.dataloader import ...
3,579
34.445545
138
py
FixRes
FixRes-main/imnet_resnet50_scratch/train.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 os.path as osp from typing import Optional import torch import torch.distributed import torch.nn as nn im...
9,202
40.642534
180
py
FixRes
FixRes-main/imnet_resnet50_scratch/transforms.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 torchvision.transforms.functional as F from torchvision import transforms import numpy as np class ...
2,883
31.772727
111
py
isbi2017-part3
isbi2017-part3-master/nets/resnet_utils.py
# Copyright 2016 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable ...
10,613
40.623529
80
py
pyshoe
pyshoe-master/ins_tools/geometry_helpers.py
### borrowed from https://github.com/matthew-brett/transforms3d/blob/master/transforms3d/taitbryan.py import numpy as np import math _MAX_FLOAT = np.maximum_sctype(np.float) _FLOAT_EPS = np.finfo(np.float).eps def quat2mat(q): ''' Calculate rotation matrix corresponding to quaternion Parameters ---------...
11,293
27.811224
101
py
pyshoe
pyshoe-master/ins_tools/EKF.py
import numpy as np from numpy import linalg as LA import ins_tools.LSTM as lstm #remove if there is no pytorch installation import ins_tools.SVM as SVM #remove if there is no sci-kit-learn installation from ins_tools.util import * from ins_tools.geometry_helpers import quat2mat, mat2quat, euler2quat, quat2euler from sk...
9,143
36.170732
150
py
pyshoe
pyshoe-master/ins_tools/LSTM.py
import torch import numpy as np device = torch.device("cpu") class LSTM(torch.nn.Module): def __init__(self): super(LSTM, self).__init__() self.lstm = torch.nn.LSTM( input_size=6, hidden_size=90, num_layers=4, batch_first=True, dropout=0.0...
1,482
36.075
93
py
AGI
AGI-master/IG_quantitative.py
# %% # from __future__ import print_function import torch import torch.nn as nn import torch.nn.functional as F import torch.optim as optim from torchvision import datasets, transforms from torchvision import models # from models.resnet import resnet20 import numpy as np import matplotlib.pyplot as plt import argparse ...
4,125
28.683453
110
py
AGI
AGI-master/saliency_quantitative.py
# %% # from __future__ import print_function import torch import torch.nn as nn import torch.nn.functional as F import torch.optim as optim from torchvision import datasets, transforms from torchvision import models # from models.resnet import resnet20 import numpy as np import matplotlib.pyplot as plt import argparse ...
4,072
28.302158
110
py
AGI
AGI-master/AGI_main.py
# %% # from __future__ import print_function import torch import torch.nn as nn import torch.nn.functional as F import torch.optim as optim from torchvision import datasets, transforms from torchvision import models import numpy as np import matplotlib.pyplot as plt import argparse import os import cv2 from utils impo...
7,205
29.533898
118
py
AGI
AGI-master/utils.py
import torch import torch.nn.functional as F import torch.nn as nn import cv2 import numpy as np from matplotlib import pyplot as plt from torch.utils.data.sampler import Sampler from torchvision import transforms, datasets from PIL import Image import json class Normalize(nn.Module) : def __init__(self, mean, ...
4,607
29.315789
88
py
AGI
AGI-master/evaluator.py
#%% # from evaluation import CausalMetric, auc, gkern import pickle import torch import torch.nn as nn import argparse from torchvision import models from evaluation import CausalMetric, auc, gkern from utils import Normalize, pre_processing, pgd_step import pandas as pd #%% parser = argparse.ArgumentParser(descriptio...
2,773
32.02381
110
py
AGI
AGI-master/AGI_quantitive.py
# %% # from __future__ import print_function import torch import torch.nn as nn import torch.nn.functional as F import torch.optim as optim from torchvision import datasets, transforms from torchvision import models import numpy as np import matplotlib.pyplot as plt import argparse import os import cv2 from utils impo...
5,712
30.39011
118
py
AGI
AGI-master/evaluator_gpu1.py
#%% # from evaluation import CausalMetric, auc, gkern import pickle import torch import torch.nn as nn import argparse from torchvision import models from evaluation import CausalMetric, auc, gkern from utils import Normalize, pre_processing, pgd_step import pandas as pd #%% parser = argparse.ArgumentParser(descriptio...
2,767
31.952381
110
py
AGI
AGI-master/evaluator_demo.py
#%% # from evaluation import CausalMetric, auc, gkern import pickle import torch import torch.nn as nn import argparse from torchvision import models from evaluation import CausalMetric, auc, gkern from utils import Normalize, pre_processing, pgd_step import pandas as pd #%% parser = argparse.ArgumentParser(descriptio...
2,444
30.753247
110
py
AGI
AGI-master/evaluation.py
from torch import nn from tqdm import tqdm from scipy.ndimage.filters import gaussian_filter from utils import * HW = 224 * 224 # image area n_classes = 1000 def gkern(klen, nsig): """Returns a Gaussian kernel array. Convolution with it results in image blurring.""" # create nxn zeros inp = np.zeros(...
6,741
40.617284
134
py
AGI
AGI-master/AGI_quantitive_gpu0.py
# %% # from __future__ import print_function import torch import torch.nn as nn import torch.nn.functional as F import torch.optim as optim from torchvision import datasets, transforms from torchvision import models import numpy as np import matplotlib.pyplot as plt import argparse import os import cv2 from utils impo...
5,712
30.39011
118
py
MSSR
MSSR-main/degradation/PerceptualSimilarity/test_network.py
import torch from util import util import models from models import dist_model as dm from IPython import embed use_gpu = False # Whether to use GPU spatial = True # Return a spatial map of perceptual distance. # Linearly calibrated models (LPIPS) model = models.PerceptualLoss(model='net-lin', net='ale...
1,774
33.803922
150
py
MSSR
MSSR-main/degradation/PerceptualSimilarity/train.py
import torch.backends.cudnn as cudnn cudnn.benchmark=False sys.path.insert(0, './') import numpy as np import time import os from models import dist_model as dm from data import data_loader as dl import argparse from util.visualizer import Visualizer from IPython import embed parser = argparse.ArgumentParser() parser....
5,530
52.182692
269
py
MSSR
MSSR-main/degradation/PerceptualSimilarity/perceptual_loss.py
from __future__ import absolute_import import sys import scipy import scipy.misc import numpy as np import torch from torch.autograd import Variable import models use_gpu = True ref_path = './imgs/ex_ref.png' pred_path = './imgs/ex_p1.png' ref_img = scipy.misc.imread(ref_path).transpose(2, 0, 1) / 255. pred_img =...
1,553
27.254545
85
py
MSSR
MSSR-main/degradation/PerceptualSimilarity/models/base_model.py
import os import torch from torch.autograd import Variable from pdb import set_trace as st from IPython import embed class BaseModel(): def __init__(self): pass; def name(self): return 'BaseModel' def initialize(self, use_gpu=True, gpu_ids=[0]): self.use_gpu = use_gpu ...
1,622
26.508475
77
py
MSSR
MSSR-main/degradation/PerceptualSimilarity/models/pretrained_networks.py
from collections import namedtuple import torch from torchvision import models as tv from IPython import embed class squeezenet(torch.nn.Module): def __init__(self, requires_grad=False, pretrained=True): super(squeezenet, self).__init__() pretrained_features = tv.squeezenet1_1(pretrained=pretrained...
6,533
34.901099
109
py
MSSR
MSSR-main/degradation/PerceptualSimilarity/models/util.py
from __future__ import absolute_import from __future__ import division from __future__ import print_function import numpy as np from skimage.metrics import structural_similarity as compare_ssim import torch from torch.autograd import Variable from . import dist_model class PerceptualLoss(torch.nn.Module): def _...
5,767
34.826087
172
py
MSSR
MSSR-main/degradation/PerceptualSimilarity/models/networks_basic.py
from __future__ import absolute_import import sys import torch import torch.nn as nn import torch.nn.init as init from torch.autograd import Variable import numpy as np from pdb import set_trace as st from skimage import color from IPython import embed import PerceptualSimilarity.models.pretrained_networks as pn fro...
7,536
39.090426
134
py
MSSR
MSSR-main/degradation/PerceptualSimilarity/models/dist_model.py
from __future__ import absolute_import import sys import numpy as np import torch from torch import nn import os from collections import OrderedDict from torch.autograd import Variable import itertools from .base_model import BaseModel from scipy.ndimage import zoom import fractions import functools import skimage.tr...
11,819
40.328671
177
py
MSSR
MSSR-main/degradation/PerceptualSimilarity/util/util.py
from __future__ import print_function import numpy as np from PIL import Image import numpy as np import os import matplotlib.pyplot as plt import torch def load_image(path): if(path[-3:] == 'dng'): import rawpy with rawpy.imread(path) as raw: img = raw.postprocess() elif(path[-3:]...
1,433
28.265306
72
py
MSSR
MSSR-main/degradation/PerceptualSimilarity/data/custom_dataset_data_loader.py
import torch.utils.data from data.base_data_loader import BaseDataLoader import os def CreateDataset(dataroots,dataset_mode='2afc',load_size=64,): dataset = None if dataset_mode=='2afc': # human judgements from dataset.twoafc_dataset import TwoAFCDataset dataset = TwoAFCDataset() elif datas...
1,482
36.075
138
py
MSSR
MSSR-main/degradation/PerceptualSimilarity/data/image_folder.py
################################################################################ # Code from # https://github.com/pytorch/vision/blob/master/torchvision/datasets/folder.py # Modified the original code so that it also loads images from the current # directory as well as the subdirectories ###############################...
2,261
30.416667
94
py
MSSR
MSSR-main/degradation/PerceptualSimilarity/data/dataset/twoafc_dataset.py
import os.path import torchvision.transforms as transforms from data.dataset.base_dataset import BaseDataset from data.image_folder import make_dataset from PIL import Image import numpy as np import torch # from IPython import embed class TwoAFCDataset(BaseDataset): def initialize(self, dataroots, load_size=64): ...
2,411
35.545455
99
py
MSSR
MSSR-main/degradation/PerceptualSimilarity/data/dataset/base_dataset.py
import torch.utils.data as data class BaseDataset(data.Dataset): def __init__(self): super(BaseDataset, self).__init__() def name(self): return 'BaseDataset' def initialize(self): pass
237
17.307692
43
py
MSSR
MSSR-main/degradation/PerceptualSimilarity/data/dataset/jnd_dataset.py
import os.path import torchvision.transforms as transforms from data.dataset.base_dataset import BaseDataset from data.image_folder import make_dataset from PIL import Image import numpy as np import torch from IPython import embed class JNDDataset(BaseDataset): def initialize(self, dataroot, load_size=64): ...
1,792
32.203704
75
py
MSSR
MSSR-main/degradation/codes/patch_inference.py
import torch from utils import * import model import torchvision.transforms.functional as TF import argparse parser = argparse.ArgumentParser(description='Apply the trained model to create a dataset') parser.add_argument('--gpu', type=str, help='gpu num') parser.add_argument('--n_GPUs', default=1, type=int, help='ngpu'...
3,104
56.5
170
py
MSSR
MSSR-main/degradation/codes/test.py
import argparse import os import torch.optim as optim import torch.utils.data import torchvision.utils as tvutils import data_loader as loader import yaml import loss import model from receptive_cal import * import utils from torch.utils.data import DataLoader from tensorboardX import SummaryWriter from tqdm import tqd...
14,982
59.906504
129
py
MSSR
MSSR-main/degradation/codes/crop.py
import utils # std_list = [0,0.02,0.04,0.06,0.08,0.1] # paths = [f"/mnt/workspace/DASR/codes/DSN/noise_ablation/{x}.png" for x in std_list] # for std,path in zip(std_list,paths): # img = utils.pil_loader(path) # img_cropped = img.crop((120,10,200,90)) # img_cropped.save(f"/mnt/workspace/DASR/codes/DSN/nois...
5,084
41.375
150
py