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 |
|---|---|---|---|---|---|---|
GC-SAN | GC-SAN-master/pytorch_code/model.py | #!/usr/bin/env python36
# -*- coding: utf-8 -*-
"""
Created on July, 2018
@author: Tangrizzly
"""
import datetime
import math
import numpy as np
import torch
from torch import nn
from torch.nn import Module, Parameter
import torch.nn.functional as F
from torchsummary import summary
class PositionEmbedding(nn.Module... | 12,650 | 40.478689 | 123 | py |
chrono | chrono-main/docs/conf.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Chrono documentation build configuration file, created by
# sphinx-quickstart on Mon Jul 28 16:30:48 2014.
#
# 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
# aut... | 8,295 | 30.30566 | 79 | py |
Multi-Scale-Feature-Fusion | Multi-Scale-Feature-Fusion-main/bin/main.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Nov 20 21:51:54 2020
@author: endiqq
"""
import sys
import torch
import argparse
from torch.utils.tensorboard import SummaryWriter
import pickle
import numpy as np
import os
import datetime
from pathlib import Path
import getpass
from torch.nn import D... | 57,569 | 66.809187 | 187 | py |
Multi-Scale-Feature-Fusion | Multi-Scale-Feature-Fusion-main/data/utils.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Nov 20 21:52:08 2020
@author: endiqq
"""
import torch
import torch.nn as nn
import os
from PIL import Image, ImageFile
import time
import torchvision
from torchvision import transforms
import copy
import torch.optim as optim
from torch.optim import l... | 52,059 | 46.71769 | 157 | py |
Multi-Scale-Feature-Fusion | Multi-Scale-Feature-Fusion-main/model/global_pool.py | import torch
from torch import nn
class PcamPool(nn.Module):
def __init__(self):
super(PcamPool, self).__init__()
def forward(self, feat_map, logit_map):
assert logit_map is not None
prob_map = torch.sigmoid(logit_map)
weight_map = prob_map / prob_map.sum(dim=2, keepdim=True... | 4,858 | 30.348387 | 72 | py |
Multi-Scale-Feature-Fusion | Multi-Scale-Feature-Fusion-main/model/conv_vit_models.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 9 17:22:45 2022
@author: endiqq
"""
from efficientnet_pytorch import EfficientNet
import pretrainedmodels
import torch.nn as nn
import torchvision
import torch.nn.functional as F
import timm
from functools import partial
from timm.models.vision_t... | 8,091 | 34.182609 | 96 | py |
Multi-Scale-Feature-Fusion | Multi-Scale-Feature-Fusion-main/model/crossattention_models.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Apr 15 15:17:20 2022
@author: endiqq
"""
from efficientnet_pytorch import EfficientNet
import pretrainedmodels
import torch.nn as nn
import torchvision
import torch.nn.functional as F
import timm
from functools import partial
from timm.models.vision_tr... | 19,687 | 38.773737 | 129 | py |
Multi-Scale-Feature-Fusion | Multi-Scale-Feature-Fusion-main/model/attention_map.py | import torch
from torch import nn
from torch.nn import functional as F
from model.utils import get_norm
class Conv2dNormRelu(nn.Module):
def __init__(self, in_ch, out_ch, kernel_size=3, stride=1, padding=0,
bias=True, norm_type='Unknown'):
super(Conv2dNormRelu, self).__init__()
... | 7,017 | 36.529412 | 79 | py |
Multi-Scale-Feature-Fusion | Multi-Scale-Feature-Fusion-main/model/ms_transfuser_models_psa_res50.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Apr 13 22:57:49 2022
@author: endiqq
"""
import math
from collections import deque
import json
from easydict import EasyDict as edict
import os
from functools import partial
import numpy as np
import torch
from torch import nn
import torch.nn.functi... | 20,119 | 42.268817 | 130 | py |
Multi-Scale-Feature-Fusion | Multi-Scale-Feature-Fusion-main/model/utils.py | import torch.nn as nn
from torch.optim import SGD, Adadelta, Adagrad, Adam, RMSprop
def get_norm(norm_type, num_features, num_groups=32, eps=1e-5):
if norm_type == 'BatchNorm':
return nn.BatchNorm2d(num_features, eps=eps)
elif norm_type == "GroupNorm":
return nn.GroupNorm(num_groups, num_featu... | 1,442 | 38 | 73 | py |
Multi-Scale-Feature-Fusion | Multi-Scale-Feature-Fusion-main/model/classifier.py | from torch import nn
import torch.nn.functional as F
from model.backbone.vgg import (vgg19, vgg19_bn)
from model.backbone.densenet import (densenet121, densenet169, densenet201)
from model.backbone.inception import (inception_v3)
from model.global_pool import GlobalPool
from model.attention_map import AttentionMap
B... | 5,906 | 35.018293 | 78 | py |
Multi-Scale-Feature-Fusion | Multi-Scale-Feature-Fusion-main/model/module.py | import torch
from torch import nn, einsum
import torch.nn.functional as F
from einops import rearrange, repeat
from einops.layers.torch import Rearrange
class Residual(nn.Module):
def __init__(self, fn):
super().__init__()
self.fn = fn
def forward(self, x, **kwargs):
return self.fn(x, ... | 4,740 | 33.107914 | 137 | py |
Multi-Scale-Feature-Fusion | Multi-Scale-Feature-Fusion-main/model/conv_vit_models_customized.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 9 17:22:45 2022
@author: endiqq
"""
from efficientnet_pytorch import EfficientNet
import pretrainedmodels
import torch.nn as nn
import torchvision
import torch.nn.functional as F
import timm
from functools import partial
from timm.models.vision_t... | 6,460 | 34.5 | 89 | py |
Multi-Scale-Feature-Fusion | Multi-Scale-Feature-Fusion-main/model/ms_transfuser_models_psa.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Apr 13 22:57:49 2022
@author: endiqq
"""
import math
from collections import deque
import json
from easydict import EasyDict as edict
import os
from functools import partial
import numpy as np
import torch
from torch import nn
import torch.nn.functi... | 20,768 | 43.002119 | 129 | py |
Multi-Scale-Feature-Fusion | Multi-Scale-Feature-Fusion-main/model/Fusion_models.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Dec 19 00:10:52 2020
@author: endiqq
"""
import torch
import torch.nn as nn
import torchvision
import torch.nn.functional as F
class Late_Fusion_Net(nn.Module):
def __init__(self, NN, my_model1, my_model2, num_classes):
super(Late_Fusion... | 11,541 | 38.527397 | 119 | py |
Multi-Scale-Feature-Fusion | Multi-Scale-Feature-Fusion-main/model/transfer_models.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Nov 20 23:56:24 2020
@author: endiqq
"""
from efficientnet_pytorch import EfficientNet
import pretrainedmodels
import torch.nn as nn
import torchvision
import torch.nn.functional as F
import timm
from functools import partial
from timm.models.vision_t... | 5,643 | 33.839506 | 110 | py |
Agriculture-Vision-Segmentation | Agriculture-Vision-Segmentation-master/main.py | import os, sys, random, glob
import numpy as np
import argparse
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
import datetime
import tensorflow as tf
os.environ['TF_DETERMINISTIC_OPS'] = '1'
os.environ['TF_CUDNN_DETERMINISTIC'] = '1'
from tensorflow.keras.models import Model
from tensorflow.keras.layers import Input
from... | 41,307 | 42.118998 | 317 | py |
robustlearn | robustlearn-main/marc/main.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
"""Copyright (c) Facebook, Inc. and its affiliates.
All rights reserved.
This source code is licensed under the license found in the
LICENSE file in the root directory of this source tree.
Portions of the source code are from the OLTR project w... | 9,051 | 38.356522 | 114 | py |
robustlearn | robustlearn-main/marc/utils.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
"""Copyright (c) Facebook, Inc. and its affiliates.
All rights reserved.
This source code is licensed under the license found in the
LICENSE file in the root directory of this source tree.
Portions of the source code are from the OLTR project w... | 10,710 | 32.367601 | 120 | py |
robustlearn | robustlearn-main/marc/run_networks.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
"""Copyright (c) Facebook, Inc. and its affiliates.
All rights reserved.
This source code is licensed under the license found in the
LICENSE file in the root directory of this source tree.
Portions of the source code are from the OLTR project w... | 38,580 | 43.193585 | 118 | py |
robustlearn | robustlearn-main/marc/models/ResNet56Feature.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
"""
Properly implemented ResNet-s for CIFAR10 as described in paper [1].
The implementation and structure of this file is hugely influenced by [2]
which is implemented for ImageNet and doesn't have option A for identity.
Moreover, most of the imp... | 5,897 | 32.322034 | 110 | py |
robustlearn | robustlearn-main/marc/models/MARCClassifier.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import torch.nn as nn
from utils import *
from os import path
import json
class MARCLinear(nn.Module):
"""
A wrapper for nn.Linear with support of MARC method.
"""
def __init__(self, in_features, out_features, cls_freq):
... | 1,632 | 32.326531 | 98 | py |
robustlearn | robustlearn-main/marc/models/ResNet32Feature.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
"""
Properly implemented ResNet-s for CIFAR10 as described in paper [1].
The implementation and structure of this file is hugely influenced by [2]
which is implemented for ImageNet and doesn't have option A for identity.
Moreover, most of the imp... | 5,897 | 32.322034 | 110 | py |
robustlearn | robustlearn-main/marc/models/ResNetFeature.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
"""Copyright (c) Facebook, Inc. and its affiliates.
All rights reserved.
This source code is licensed under the license found in the
LICENSE file in the root directory of this source tree.
Portions of the source code are from the OLTR project w... | 5,649 | 30.21547 | 90 | py |
robustlearn | robustlearn-main/marc/models/ResNet152FeatureCaffe.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
"""Copyright (c) Facebook, Inc. and its affiliates.
All rights reserved.
This source code is licensed under the license found in the
LICENSE file in the root directory of this source tree.
Portions of the source code are from the OLTR project w... | 1,968 | 36.150943 | 139 | py |
robustlearn | robustlearn-main/marc/models/ResNextFeature.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
"""Copyright (c) Facebook, Inc. and its affiliates.
All rights reserved.
This source code is licensed under the license found in the
LICENSE file in the root directory of this source tree.
"""
import math
import torch.nn as nn
import torch.nn.... | 6,028 | 31.413978 | 82 | py |
robustlearn | robustlearn-main/marc/models/DotProductClassifier.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
"""Copyright (c) Facebook, Inc. and its affiliates.
All rights reserved.
This source code is licensed under the license found in the
LICENSE file in the root directory of this source tree.
Portions of the source code are from the OLTR project w... | 1,787 | 30.368421 | 98 | py |
robustlearn | robustlearn-main/marc/layers/ModulatedAttLayer.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
"""Copyright (c) Facebook, Inc. and its affiliates.
All rights reserved.
This source code is licensed under the license found in the
LICENSE file in the root directory of this source tree.
Portions of the source code are from the OLTR project w... | 3,071 | 33.909091 | 102 | py |
robustlearn | robustlearn-main/marc/loss/GRWLoss.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import torch
from torch.nn import functional as F
from torch.nn.modules.loss import _WeightedLoss
import numpy as np
import json
class GRWCrossEntropyLoss(_WeightedLoss):
"""
Generalized Reweight Loss, introduced in
Distribution Ali... | 2,062 | 31.234375 | 96 | py |
robustlearn | robustlearn-main/marc/loss/SoftmaxLoss.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
"""Copyright (c) Facebook, Inc. and its affiliates.
All rights reserved.
This source code is licensed under the license found in the
LICENSE file in the root directory of this source tree.
Portions of the source code are from the OLTR project w... | 932 | 23.552632 | 59 | py |
robustlearn | robustlearn-main/marc/data/ClassAwareSampler.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
"""Copyright (c) Facebook, Inc. and its affiliates.
All rights reserved.
This source code is licensed under the license found in the
LICENSE file in the root directory of this source tree.
Portions of the source code are from the OLTR project w... | 2,725 | 28.630435 | 101 | py |
robustlearn | robustlearn-main/marc/data/ImbalanceCIFAR.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
"""
Adopted from https://github.com/KaihuaTang/Long-Tailed-Recognition.pytorch
"""
import os
import torchvision
import torchvision.transforms as transforms
import numpy as np
import json
from PIL import Image
from .autoaugment import CIFAR10Polic... | 5,915 | 34.638554 | 113 | py |
robustlearn | robustlearn-main/marc/data/dataloader.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
"""Copyright (c) Facebook, Inc. and its affiliates.
All rights reserved.
This source code is licensed under the license found in the
LICENSE file in the root directory of this source tree.
Portions of the source code are from the OLTR project w... | 5,885 | 34.035714 | 151 | py |
robustlearn | robustlearn-main/marc/data/ClassPrioritySampler.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
"""Copyright (c) Facebook, Inc. and its affiliates.
All rights reserved.
This source code is licensed under the license found in the
LICENSE file in the root directory of this source tree.
"""
import random
import numpy as np
from torch.utils.... | 21,007 | 38.121043 | 94 | py |
robustlearn | robustlearn-main/marc/data/MixedPrioritizedSampler.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
"""Copyright (c) Facebook, Inc. and its affiliates.
All rights reserved.
This source code is licensed under the license found in the
LICENSE file in the root directory of this source tree.
"""
import random
import numpy as np
from torch.utils.... | 13,377 | 35.853994 | 91 | py |
robustlearn | robustlearn-main/marc/data/autoaugment.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
from PIL import Image, ImageEnhance, ImageOps
import numpy as np
import random
import torch
class Cutout(object):
def __init__(self, n_holes, length):
self.n_holes = n_holes
self.length = length
def __call__(self, img):... | 12,024 | 44.037453 | 138 | py |
robustlearn | robustlearn-main/marc/data/MetaSampler.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
from torch.utils.data.sampler import Sampler
import torch
import torch.nn as nn
from torch.nn.functional import gumbel_softmax
from queue import Queue
import numpy as np
def invert_sigmoid(x):
return x.log() - (1-x).log()
class SampleLear... | 3,551 | 31.888889 | 95 | py |
robustlearn | robustlearn-main/diversify/alg/opt.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import torch
def get_params(alg, args, nettype):
init_lr = args.lr
if nettype == 'Diversify-adv':
params = [
{'params': alg.dbottleneck.parameters(), 'lr': args.lr_decay2 * init_lr},
{'params': alg.dclass... | 1,415 | 37.27027 | 87 | py |
robustlearn | robustlearn-main/diversify/alg/modelopera.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import torch
from network import act_network
def get_fea(args):
net = act_network.ActNetwork(args.dataset)
return net
def accuracy(network, loader, weights, usedpredict='p'):
correct = 0
total = 0
weights_offset = 0
n... | 1,286 | 28.25 | 67 | py |
robustlearn | robustlearn-main/diversify/alg/algs/base.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import torch
class Algorithm(torch.nn.Module):
def __init__(self, args):
super(Algorithm, self).__init__()
def update(self, minibatches):
raise NotImplementedError
def predict(self, x):
raise NotImplemented... | 326 | 19.4375 | 41 | py |
robustlearn | robustlearn-main/diversify/alg/algs/diversify.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
from collections import Counter
import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
from scipy.spatial.distance import cdist
from alg.modelopera import get_fea
from network import Adver_network, common_network
f... | 5,842 | 37.695364 | 95 | py |
robustlearn | robustlearn-main/diversify/datautil/getdataloader_single.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# coding=utf-8
import numpy as np
from torch.utils.data import DataLoader
import datautil.actdata.util as actutil
from datautil.util import combindataset, subdataset
import datautil.actdata.cross_people as cross_people
task_act = {'cross_peopl... | 2,392 | 39.559322 | 107 | py |
robustlearn | robustlearn-main/diversify/datautil/util.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import numpy as np
import torch
def Nmax(args, d):
for i in range(len(args.test_envs)):
if d < args.test_envs[i]:
return i
return len(args.test_envs)
class basedataset(object):
def __init__(self, x, y):
... | 4,023 | 31.715447 | 91 | py |
robustlearn | robustlearn-main/diversify/datautil/actdata/cross_people.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
from datautil.actdata.util import *
from datautil.util import mydataset, Nmax
import numpy as np
import torch
class ActList(mydataset):
def __init__(self, args, dataset, root_dir, people_group, group_num, transform=None, target_transform=No... | 2,078 | 36.8 | 161 | py |
robustlearn | robustlearn-main/diversify/datautil/actdata/util.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
from torchvision import transforms
import numpy as np
def act_train():
return transforms.Compose([
transforms.ToTensor()
])
def loaddata_from_numpy(dataset='dsads', task='cross_people', root_dir='./data/act/'):
if dataset... | 681 | 27.416667 | 86 | py |
robustlearn | robustlearn-main/diversify/network/Adver_network.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import torch
import torch.nn as nn
from torch.autograd import Function
class ReverseLayerF(Function):
@staticmethod
def forward(ctx, x, alpha):
ctx.alpha = alpha
return x.view_as(x)
@staticmethod
def backward(ct... | 1,038 | 25.641026 | 69 | py |
robustlearn | robustlearn-main/diversify/network/act_network.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import torch.nn as nn
var_size = {
'emg': {
'in_size': 8,
'ker_size': 9,
'fc_size': 32*44
}
}
class ActNetwork(nn.Module):
def __init__(self, taskname):
super(ActNetwork, self).__init__()
se... | 1,106 | 26.675 | 95 | py |
robustlearn | robustlearn-main/diversify/network/common_network.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import torch.nn as nn
import torch.nn.utils.weight_norm as weightNorm
class feat_bottleneck(nn.Module):
def __init__(self, feature_dim, bottleneck_dim=256, type="ori"):
super(feat_bottleneck, self).__init__()
self.bn = nn.B... | 1,112 | 28.289474 | 69 | py |
robustlearn | robustlearn-main/diversify/loss/common_loss.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import torch
import torch.nn.functional as F
def Entropy(input_):
bs = input_.size(0)
epsilon = 1e-5
entropy = -input_ * torch.log(input_ + epsilon)
entropy = torch.mean(torch.sum(entropy, dim=1))
return entropy
def Entrop... | 648 | 23.961538 | 55 | py |
robustlearn | robustlearn-main/diversify/utils/util.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import random
import numpy as np
import torch
import sys
import os
import argparse
import torchvision
import PIL
def set_random_seed(seed=0):
random.seed(seed)
np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed... | 5,625 | 35.771242 | 79 | py |
robustlearn | robustlearn-main/fedclip/methods/fed_at_clip.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import numpy as np
import torch
import torch.nn as nn
import torch.optim as optim
from nets.models import ClipModelat
import argparse
import copy
from utils.prepare_data_dg_clip import *
import utils.clip_util as clu
from utils.config import img_... | 10,389 | 40.394422 | 125 | py |
robustlearn | robustlearn-main/fedclip/nets/models.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import torch.nn as nn
import clip
from utils.clip_util import freeze_param, get_image_features
class ClipModelat(object):
CLIP_MODELS = [
'RN50',
'RN101',
'RN50x4',
'RN50x16',
'RN50x64',
'ViT... | 1,841 | 28.238095 | 111 | py |
robustlearn | robustlearn-main/fedclip/utils/clip_util.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import clip
import torch
def get_similarity(image_features, text_features):
image_features /= image_features.norm(dim=-1, keepdim=True)
text_features /= text_features.norm(dim=-1, keepdim=True)
similarity = (100.0 * image_features @... | 1,260 | 30.525 | 88 | py |
robustlearn | robustlearn-main/fedclip/utils/prepare_data_dg_clip.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import clip
import torchvision.datasets as datasets
from PIL import ImageFile
import numpy as np
from PIL import Image
import torchvision.transforms as transforms
import torch
import sys
import os
base_path = os.path.dirname(os.path.dirname(os.pa... | 3,347 | 31.823529 | 76 | py |
robustlearn | robustlearn-main/fedclip/utils/config.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import random
import numpy as np
import torch
def img_param_init(args):
dataset = args.dataset
if dataset == 'pacs':
domains = ['art_painting', 'cartoon', 'photo', 'sketch']
else:
print('No such dataset exists!')
... | 648 | 22.178571 | 64 | py |
Compression | Compression-master/tensorflow_compression/python/layers/entropy_models.py | # -*- coding: utf-8 -*-
# Copyright 2018 Google LLC. 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 require... | 26,075 | 42.029703 | 80 | py |
HCP-MLR-PL | HCP-MLR-PL-main/SARB.py | import os
import sys
import time
import logging
import numpy as np
from tensorboardX import SummaryWriter
import torch
import torch.nn as nn
import torch.backends.cudnn as cudnn
import torch.optim
import torch.optim.lr_scheduler as lr_scheduler
from model.SARB import SARB
from loss.SARB import BCELoss, ContrastiveL... | 9,454 | 38.232365 | 201 | py |
HCP-MLR-PL | HCP-MLR-PL-main/SARB-journal.py | import os
import sys
import time
import logging
import numpy as np
from tensorboardX import SummaryWriter
import torch
import torch.nn as nn
import torch.backends.cudnn as cudnn
import torch.optim
import torch.optim.lr_scheduler as lr_scheduler
from model.SARB import SARB_journal
from utils.loss import BCELoss, Con... | 10,824 | 41.786561 | 234 | py |
HCP-MLR-PL | HCP-MLR-PL-main/HST.py | import sys
import time
import logging
import numpy as np
from tensorboardX import SummaryWriter
import torch
import torch.nn as nn
import torch.optim
import torch.optim.lr_scheduler as lr_scheduler
from model.HST import HST
from loss.HST import BCELoss, intraAsymmetricLoss, InstanceContrastiveLoss, PrototypeContras... | 12,229 | 43.635036 | 219 | py |
HCP-MLR-PL | HCP-MLR-PL-main/SST.py | import sys
import time
import logging
import numpy as np
from tensorboardX import SummaryWriter
import torch
import torch.nn as nn
import torch.optim
import torch.optim.lr_scheduler as lr_scheduler
from model.SST import SST
from loss.SST import BCELoss, intraAsymmetricLoss, ContrastiveLoss, getIntraPseudoLabel, get... | 11,178 | 41.344697 | 162 | py |
HCP-MLR-PL | HCP-MLR-PL-main/datasets/voc2007.py | import os
import sys
sys.path.append(os.path.join( os.path.dirname(os.path.abspath(__file__)), '..'))
import numpy as np
from PIL import Image
import xml.dom.minidom
from xml.dom.minidom import parse
import torch
import torch.utils.data as data
category_info = {'aeroplane':0, 'bicycle':1, 'bird':2, 'boat':3, 'bottl... | 3,203 | 35 | 115 | py |
HCP-MLR-PL | HCP-MLR-PL-main/datasets/vg.py | import os
import sys
import json
import random
import numpy as np
from PIL import Image
import torch
import torch.utils.data as data
import torchvision.datasets as datasets
class VG(data.Dataset):
def __init__(self, mode,
image_dir, anno_path, labels_path,
input_transform=None,... | 2,622 | 29.5 | 115 | py |
HCP-MLR-PL | HCP-MLR-PL-main/datasets/coco2014.py | import os
import sys
sys.path.append(os.path.join( os.path.dirname(os.path.abspath(__file__)), '..', 'cocoapi/PythonAPI'))
sys.path.append(os.path.join( os.path.dirname(os.path.abspath(__file__)), '..'))
import json
import numpy as np
from PIL import Image
import torch
import torch.utils.data as data
import torchvisi... | 4,996 | 30.037267 | 115 | py |
HCP-MLR-PL | HCP-MLR-PL-main/loss/SARB.py | import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
class BCELoss(nn.Module):
def __init__(self, margin=0.0, reduce=None, size_average=None):
super(BCELoss, self).__init__()
self.margin = margin
self.reduce = reduce
self.size_average = size_ave... | 4,079 | 39.39604 | 158 | py |
HCP-MLR-PL | HCP-MLR-PL-main/loss/HST.py | import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
def getIntraPseudoLabel(intraCoOccurrence, target, margin=0.50):
"""
Shape of intraCoOccurrence : (batchSize, classNum ** 2)
Shape of target : (batchSize, classNum)
"""
batchSize, classNum = target.size(0), ... | 12,679 | 36.294118 | 158 | py |
HCP-MLR-PL | HCP-MLR-PL-main/loss/SST.py | import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
def getIntraPseudoLabel(intraCoOccurrence, target, margin=0.50):
"""
Shape of intraCoOccurrence : (batchSize, classNum ** 2)
Shape of target : (batchSize, classNum)
"""
batchSize, classNum = target.size(0), targe... | 12,733 | 37.823171 | 158 | py |
HCP-MLR-PL | HCP-MLR-PL-main/utils/checkpoint.py | import os
import gc
import shutil
import torch
def load_pretrained_model(model, args):
modelDict = model.backbone.state_dict()
pretrainedModel = torch.load(args.pretrainedModel)
pretrainedDict = {}
for k,v in pretrainedModel.items():
if k.startswith('fc'):
continue
... | 1,257 | 23.666667 | 92 | py |
HCP-MLR-PL | HCP-MLR-PL-main/utils/dataloader.py | import os
import PIL
import numpy as np
import torch
from torch.utils.data import DataLoader
import torchvision.transforms as transforms
from datasets.vg import VG
from datasets.voc2007 import VOC2007
from datasets.coco2014 import COCO2014
from config import prefixPathCOCO, prefixPathVG, prefixPathVOC2007
def get_g... | 5,719 | 43.341085 | 187 | py |
HCP-MLR-PL | HCP-MLR-PL-main/utils/metrics.py | import math
import numpy as np
import torch
class AverageMeter(object):
"""Compute current value, sum and average"""
def __init__(self):
self.reset()
def reset(self):
self.val, self.avg, self.sum, self.count = 0, 0, 0, 0
def update(self, val, num=1):
self.val = val
s... | 13,133 | 38.323353 | 170 | py |
HCP-MLR-PL | HCP-MLR-PL-main/model/Element_Wise_Layer.py | import math
import torch
import torch.nn as nn
from torch.nn.parameter import Parameter
class Element_Wise_Layer(nn.Module):
def __init__(self, in_features, out_features, bias=True):
super(Element_Wise_Layer, self).__init__()
self.in_features = in_features
self.out_features = out_featur... | 1,325 | 26.625 | 124 | py |
HCP-MLR-PL | HCP-MLR-PL-main/model/SARB.py | import numpy as np
import torch
import torch.nn as nn
from .backbone.resnet import resnet101
from .GraphNeuralNetwork import GatedGNN
from .SemanticDecoupling import SemanticDecoupling
from .Element_Wise_Layer import Element_Wise_Layer
class SARB(nn.Module):
def __init__(self, adjacencyMatrix, wordFeatures, pr... | 17,676 | 47.966759 | 192 | py |
HCP-MLR-PL | HCP-MLR-PL-main/model/HST.py | import numpy as np
import torch
import torch.nn as nn
from .backbone.resnet import resnet101
from .GraphNeuralNetwork import GatedGNN
from .SemanticDecoupling import SemanticDecoupling
from .Element_Wise_Layer import Element_Wise_Layer
class HST(nn.Module):
def __init__(self, adjacencyMatrix, wordFeatures,
... | 5,801 | 47.756303 | 163 | py |
HCP-MLR-PL | HCP-MLR-PL-main/model/SST.py | import numpy as np
import torch
import torch.nn as nn
from .backbone.resnet import resnet101
from .GraphNeuralNetwork import GatedGNN
from .SemanticDecoupling import SemanticDecoupling
from .Element_Wise_Layer import Element_Wise_Layer
class SST(nn.Module):
def __init__(self, adjacencyMatrix, wordFeatures,
... | 5,169 | 46.431193 | 163 | py |
HCP-MLR-PL | HCP-MLR-PL-main/model/SemanticDecoupling.py | import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
class SemanticDecoupling(nn.Module):
def __init__(self, classNum, imgFeatureDim, wordFeatureDim, intermediaDim=1024):
super(SemanticDecoupling, self).__init__()
self.classNum = classNum
self.im... | 3,615 | 68.538462 | 213 | py |
HCP-MLR-PL | HCP-MLR-PL-main/model/GraphNeuralNetwork.py | import os
import sys
import numpy as np
import torch
import torch.nn as nn
class GatedGNN(nn.Module):
def __init__(self, inputDim, timeStep, inMatrix, outMatrix):
super(GatedGNN, self).__init__()
self.inputDim, self.timeStep, self.inMatrix, self.outMatrix = inputDim, timeStep, inMatrix, outMatr... | 2,587 | 46.054545 | 125 | py |
HCP-MLR-PL | HCP-MLR-PL-main/model/backbone/resnet.py | import math
import torch.nn as nn
import torch.utils.model_zoo as model_zoo
import torch.nn.functional as F
__all__ = ['ResNet', 'resnet18', 'resnet34', 'resnet50', 'resnet101', 'resnet152']
model_urls = {
'resnet18': 'https://download.pytorch.org/models/resnet18-5c106cde.pth',
'resnet34': 'https://download... | 6,778 | 32.068293 | 90 | py |
lsl-fly | lsl-fly-master/main.py | '''Train CIFAR10 with PyTorch.'''
from __future__ import print_function
import torch
import torch.nn as nn
import torch.optim as optim
import torch.nn.functional as F
import torch.backends.cudnn as cudnn
import torchvision
import torchvision.transforms as transforms
import torchvision.datasets as datasets
import os
... | 7,098 | 30.551111 | 107 | py |
lsl-fly | lsl-fly-master/utils.py | '''Some helper functions for PyTorch, including:
- get_mean_and_std: calculate the mean and std value of dataset.
- msr_init: net parameter initialization.
- progress_bar: progress bar mimic xlua.progress.
'''
import os
import sys
import time
import math
import torch.nn as nn
import torch.nn.init as init
... | 3,446 | 26.576 | 96 | py |
lsl-fly | lsl-fly-master/finetune.py | '''Train CIFAR10 with PyTorch.'''
from __future__ import print_function
import torch
import torch.nn as nn
import torch.optim as optim
import torch.nn.functional as F
import torch.backends.cudnn as cudnn
import torchvision
import torchvision.transforms as transforms
import torchvision.datasets as datasets
import os
... | 9,201 | 31.515901 | 173 | py |
lsl-fly | lsl-fly-master/models/ranknet.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
class BasicBlock(nn.Module):
expansion = 1
def __init__(self, in_planes, planes, stride=1):
super(BasicBlock, self).__init__()
self.conv1 = nn.Conv2d(in_planes, planes, kernel_size=3, stride=stride, padding=... | 3,837 | 35.552381 | 102 | py |
lsl-fly | lsl-fly-master/models/resnet.py | import torch
import torch.nn as nn
import torch.nn.functional as F
class BasicBlock(nn.Module):
expansion = 1
def __init__(self, in_planes, planes, stride=1):
super(BasicBlock, self).__init__()
self.conv1 = nn.Conv2d(in_planes, planes, kernel_size=3, stride=stride, padding=1, bias=False)
... | 3,680 | 33.401869 | 102 | py |
reducingbias | reducingbias-master/PosteriorBias/imsitu.py | import torch as torch
import torch.utils.data as data
import json
from PIL import Image
import os
import os.path
import sys
from constant import *
class imSituTensorEvaluation():
def __init__(self, topk, nref, image_group={}):
self.score_cards = {}
self.topk = topk
self.nref = nref
... | 14,229 | 32.880952 | 113 | py |
reducingbias | reducingbias-master/PosteriorBias/constant.py | import torch
import os
# TODO: find gender.json on server
is_filter = 0 # Filter the instances that are not related to gender when set to be 1.
margin = 0.01
batch_size = 35 # Must be same when training and doing calibrating.
cnn_type = 'resnet_101'
splits = [50, 100, 283]
splits_offset = [0, 1125, 1643]
num_verb =... | 3,060 | 30.556701 | 97 | py |
reducingbias | reducingbias-master/PosteriorBias/run.py | import os
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import sys
import pickle
from matplotlib.legend_handler import HandlerLine2D
import myplot as myplt
import mystat as mystat
import fairCRF_utils as myutils
import preprocess as mypreprocess
from constant import *
import time
import copy
im... | 24,442 | 50.676533 | 180 | py |
reducingbias | reducingbias-master/PosteriorBias/baseline_crf_prob.py | import os
import time
import argparse
from torch import optim
import random as rand
import torch
import torch.nn as nn
from torch.autograd import Variable
import torch.nn.functional as F
import torch.utils.data as data
import torchvision as tv
import torchvision.transforms as tvt
import numpy as np
import math
from ims... | 31,296 | 37.830025 | 182 | py |
reducingbias | reducingbias-master/PosteriorBias/fairCRF_utils.py | import numpy as np
import pandas as pd
import re
import json
from operator import add
import copy
from collections import Counter
import operator
import os
import sys
import configparser
import io
import ast
import myplot as myplt
import pickle
from baseline_crf_prob import *
from constant import *
import time
os.chdi... | 35,855 | 43.988708 | 164 | py |
reducingbias | reducingbias-master/src/fairCRF_utils.py | import numpy as np
import pandas as pd
import re
import json
from operator import add
import copy
from collections import Counter
import operator
import os
import sys
import ConfigParser
import io
import ast
import inference_debias as cocoutils
import myplot as myplt
import pickle
def parse_config(config_file = "conf... | 24,335 | 45.442748 | 213 | py |
taco | taco-master/python_bindings/source/conf.py | # Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# http://www.sphinx-doc.org/en/master/config
# -- Path setup --------------------------------------------------------------
# If extensions (or module... | 2,526 | 31.397436 | 79 | py |
tvm | tvm-main/conftest.py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | 4,701 | 42.137615 | 137 | py |
tvm | tvm-main/apps/bundle_deploy/build_model.py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | 6,491 | 37.642857 | 101 | py |
tvm | tvm-main/apps/ios_rpc/tests/ios_rpc_mobilenet.py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | 6,368 | 33.241935 | 97 | py |
tvm | tvm-main/apps/cpp_rtvm/scripts/download_models.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache Licen... | 1,339 | 35.216216 | 99 | py |
tvm | tvm-main/apps/android_camera/models/prepare_model.py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | 5,118 | 35.564286 | 100 | py |
tvm | tvm-main/apps/pt_tvmdsoop/tests/test_torch_graph_module.py | #!/usr/bin/env python
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "L... | 4,793 | 35.876923 | 100 | py |
tvm | tvm-main/apps/pt_tvmdsoop/tests/test_optimize_torch.py | # pylint: disable=missing-class-docstring
#!/usr/bin/env python
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under... | 5,138 | 30.722222 | 98 | py |
tvm | tvm-main/apps/pt_tvmdsoop/tests/test_as_torch.py | #!/usr/bin/env python
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "L... | 8,027 | 29.758621 | 95 | py |
tvm | tvm-main/apps/pt_tvmdsoop/tests/test_torch_compile_cpu.py | #!/usr/bin/env python
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "L... | 1,877 | 26.217391 | 62 | py |
tvm | tvm-main/apps/pt_tvmdsoop/tests/test_torch_vm_module.py | #!/usr/bin/env python
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "L... | 4,647 | 36.788618 | 90 | py |
tvm | tvm-main/apps/pt_tvmdsoop/tests/test_boolean_tensor.py | #!/usr/bin/env python
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "L... | 3,590 | 26.623077 | 84 | py |
tvm | tvm-main/apps/pt_tvmdsoop/tests/test_torch_script.py | #!/usr/bin/env python
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "L... | 3,270 | 26.957265 | 95 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.