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 |
|---|---|---|---|---|---|---|
UMR | UMR-master/external/SoftRas/soft_renderer/functional/look.py | import numpy as np
import torch
import torch.nn.functional as F
def look(vertices, eye, direction=[0, 1, 0], up=None):
"""
"Look" transformation of vertices.
"""
if (vertices.ndimension() != 3):
raise ValueError('vertices Tensor should have 3 dimensions')
device = vertices.device
if ... | 1,655 | 30.846154 | 86 | py |
UMR | UMR-master/external/SoftRas/soft_renderer/functional/projection.py | import torch
def projection(vertices, P, dist_coeffs, orig_size):
'''
Calculate projective transformation of vertices given a projection matrix
P: 3x4 projection matrix
dist_coeffs: vector of distortion coefficients
orig_size: original size of image captured by the camera
'''
vertices = to... | 1,198 | 37.677419 | 88 | py |
UMR | UMR-master/external/SoftRas/soft_renderer/functional/orthogonal.py | import torch
def orthogonal(vertices, scale):
'''
Compute orthogonal projection from a given angle
To find equivalent scale to perspective projection
set scale = focal_pixel / object_depth -- to 0~H/W pixel range
= 1 / ( object_depth * tan(half_fov_angle) ) -- to -1~1 pixel range
''... | 584 | 33.411765 | 81 | py |
UMR | UMR-master/external/SoftRas/soft_renderer/functional/look_at.py | import numpy as np
import torch
import torch.nn.functional as F
def look_at(vertices, eye, at=[0, 0, 0], up=[0, 1, 0]):
"""
"Look at" transformation of vertices.
"""
if (vertices.ndimension() != 3):
raise ValueError('vertices Tensor should have 3 dimensions')
device = vertices.device
... | 2,060 | 31.714286 | 86 | py |
UMR | UMR-master/external/PerceptualSimilarity/test_network.py | # import sys; sys.path += ['models']
import torch
from util import util
from models import dist_model as dm
from IPython import embed
use_gpu = True # Whether to use GPU
spatial = False # Return a spatial map of perceptual distance.
# Optional args spatial_shape and spatial_order... | 1,939 | 38.591837 | 154 | py |
UMR | UMR-master/external/PerceptualSimilarity/train.py | import torch.backends.cudnn as cudnn
cudnn.benchmark=False
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.add_argument('--datasets... | 4,955 | 50.092784 | 269 | py |
UMR | UMR-master/external/PerceptualSimilarity/perceptual_loss.py | from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import torch
torch.manual_seed(seed)
torch.cuda.manual_seed(seed)
torch.cuda.manual_seed_all(seed)
torch.backends.cudnn.benchmark = False
torch.backends.cudnn.deterministic = True
from torch.autograd import Va... | 3,142 | 32.084211 | 136 | py |
UMR | UMR-master/external/PerceptualSimilarity/models/base_model.py | import os
import torch
from ..util import util as util
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):
self.use... | 1,755 | 27.322581 | 78 | py |
UMR | UMR-master/external/PerceptualSimilarity/models/pretrained_networks.py | from collections import namedtuple
import torch
from torchvision import models
from IPython import embed
class squeezenet(torch.nn.Module):
def __init__(self, requires_grad=False, pretrained=True):
super(squeezenet, self).__init__()
pretrained_features = models.squeezenet1_1(pretrained=pretrained).... | 6,863 | 35.510638 | 109 | py |
UMR | UMR-master/external/PerceptualSimilarity/models/networks_basic.py | 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 ..util import util as util
from skimage import color
from IPython import embed
from . import pretrained_networks as pn
# Off-the-shelf deep network
class PNet(nn.M... | 9,840 | 38.207171 | 122 | py |
UMR | UMR-master/external/PerceptualSimilarity/models/dist_model.py | import os
seed = 0
os.environ['PYTHONHASHSEED'] = str(seed)
import numpy as np
np.random.seed(seed)
# torch modules
import torch
torch.manual_seed(seed)
torch.cuda.manual_seed(seed)
torch.cuda.manual_seed_all(seed)
torch.backends.cudnn.benchmark = False
torch.backends.cudnn.deterministic = True
from torch import nn
i... | 13,261 | 39.31003 | 240 | py |
UMR | UMR-master/external/PerceptualSimilarity/util/util.py | from __future__ import print_function
import numpy as np
from PIL import Image
import inspect
import re
import numpy as np
import os
import collections
import matplotlib.pyplot as plt
from scipy.ndimage.interpolation import zoom
from skimage.measure import compare_ssim
import torch
from IPython import embed
import cv2
... | 14,035 | 30.053097 | 153 | py |
UMR | UMR-master/external/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 |
UMR | UMR-master/external/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 |
UMR | UMR-master/external/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 |
UMR | UMR-master/external/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 |
UMR | UMR-master/external/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 |
UMR | UMR-master/experiments/train_s1.py | # ------------------------------------------------------------
# Copyright (C) 2020 NVIDIA Corporation. All rights reserved.
# Nvidia Source Code License-NC
# Code written by Xueting Li.
# ------------------------------------------------------------
# Training Script
# For CUB birds reconstruction, without semantic co... | 17,627 | 40.380282 | 130 | py |
UMR | UMR-master/experiments/train_s2.py | # ------------------------------------------------------------
# Copyright (C) 2020 NVIDIA Corporation. All rights reserved.
# Nvidia Source Code License-NC
# Code written by Xueting Li.
# ------------------------------------------------------------
# Training Script
# For CUB birds reconstruction.
# With semantic cor... | 21,831 | 44.107438 | 268 | py |
UMR | UMR-master/experiments/avg_uv.py | # -----------------------------------------------------------
# Copyright (C) 2020 NVIDIA Corporation. All rights reserved.
# Nvidia Source Code License-NC
# Code written by Xueting Li.
# -----------------------------------------------------------
# Script to compute a semantic template given trained reconstruction ne... | 13,316 | 39.975385 | 121 | py |
UMR | UMR-master/experiments/demo.py | # ------------------------------------------------------------
# Copyright (C) 2020 NVIDIA Corporation. All rights reserved.
# Nvidia Source Code License-NC
# Code written by Xueting Li.
# ------------------------------------------------------------
# Demo Script
# Inputs:
# - single view images
# Outputs:
# - Recon... | 8,779 | 38.54955 | 128 | py |
UMR | UMR-master/experiments/test_kp.py | # ------------------------------------------------------------
# Copyright (C) 2020 NVIDIA Corporation. All rights reserved.
# Nvidia Source Code License-NC
# Code written by Xueting Li.
# ------------------------------------------------------------
# Testing Script for quantitative evaluations
# Inputs:
# - single v... | 14,179 | 39.630372 | 117 | py |
UMR | UMR-master/experiments/test_iou.py | # ------------------------------------------------------------
# Copyright (C) 2020 NVIDIA Corporation. All rights reserved.
# Nvidia Source Code License-NC
# Code written by Xueting Li.
# ------------------------------------------------------------
# Testing Script for quantitative evaluations
# Inputs:
# - single v... | 4,584 | 33.473684 | 108 | py |
UMR | UMR-master/nnutils/discriminators.py | # -----------------------------------------------------------------------------------
# Code adapted from:
# https://github.com/jvanvugt/pytorch-domain-adaptation/blob/master/utils.py
#
# MIT License
#
# Copyright (c) 2018 Joris
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of t... | 3,395 | 38.034483 | 85 | py |
UMR | UMR-master/nnutils/chamfer_python.py | # -----------------------------------------------------------------------------
# Code adapted from:
# https://github.com/ThibaultGROUEIX/ChamferDistancePytorch/blob/719b0f1ca5ba370616cb837c03ab88d9a88173ff/chamfer_python.py
#
# MIT License
#
# Copyright (c) 2019 ThibaultGROUEIX
#
# Permission is hereby granted, fr... | 2,701 | 39.939394 | 123 | py |
UMR | UMR-master/nnutils/loss_utils.py | # -----------------------------------------------------------
# Copyright (C) 2020 NVIDIA Corporation. All rights reserved.
# Nvidia Source Code License-NC
# Code written by Xueting Li.
# -----------------------------------------------------------
from __future__ import absolute_import
from __future__ import division
... | 17,938 | 39.678005 | 161 | py |
UMR | UMR-master/nnutils/net_blocks.py | # -----------------------------------------------------------------------------------
# Code adapted from:
# https://github.com/shubhtuls/factored3d/blob/master/nnutils/net_blocks.py
# -----------------------------------------------------------------------------------
from __future__ import division
from __future__ im... | 9,077 | 33.915385 | 145 | py |
UMR | UMR-master/nnutils/scops_utils.py | # -----------------------------------------------------------------------------------
# Code adapted from:
# https://github.com/NVlabs/SCOPS/blob/master/utils/utils.py
#
# Copyright (C) 2019 NVIDIA Corporation. All rights reserved.
# Licensed under the CC BY-NC-SA 4.0 license (https://creativecommons.org/licenses/by-n... | 3,596 | 31.116071 | 107 | py |
UMR | UMR-master/nnutils/train_utils.py | # -----------------------------------------------------------
# Code adapted from:
# https://github.com/akanazawa/cmr/blob/master/nnutils/train_utils.py
#
# MIT License
#
# Copyright (c) 2018 akanazawa
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated... | 10,779 | 40.461538 | 111 | py |
UMR | UMR-master/nnutils/cub_mesh.py | # -----------------------------------------------------------
# Copyright (C) 2020 NVIDIA Corporation. All rights reserved.
# Nvidia Source Code License-NC
# Code written by Xueting Li.
# -----------------------------------------------------------
from __future__ import absolute_import
from __future__ import division
f... | 19,568 | 37.521654 | 161 | py |
UMR | UMR-master/nnutils/cub_mesh_s1.py | # -----------------------------------------------------------
# Copyright (C) 2020 NVIDIA Corporation. All rights reserved.
# Nvidia Source Code License-NC
# Code written by Xueting Li.
# -----------------------------------------------------------
from __future__ import absolute_import
from __future__ import division
f... | 13,094 | 35.783708 | 161 | py |
UMR | UMR-master/nnutils/nmr_pytorch.py | # -----------------------------------------------------------------------------------
# Code adapted from:
# https://github.com/akanazawa/cmr/blob/master/nnutils/nmr.py
#
# MIT License
#
# Copyright (c) 2018 akanazawa
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this softwar... | 4,836 | 36.496124 | 171 | py |
UMR | UMR-master/nnutils/smr.py | # -----------------------------------------------------------
# Copyright (C) 2020 NVIDIA Corporation. All rights reserved.
# Nvidia Source Code License-NC
# Code written by Xueting Li.
# -----------------------------------------------------------
from __future__ import absolute_import
from __future__ import division
f... | 4,821 | 34.455882 | 254 | py |
UMR | UMR-master/nnutils/geom_utils.py | # -----------------------------------------------------------------------------------
# Code adapted from:
# https://github.com/akanazawa/cmr/blob/master/nnutils/geom_utils.py
#
# MIT License
#
# Copyright (c) 2018 akanazawa
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this soft... | 6,606 | 28.761261 | 85 | py |
UMR | UMR-master/nnutils/perceptual_loss.py | # -----------------------------------------------------------------------------------
# Code adapted from:
# https://github.com/akanazawa/cmr/blob/master/nnutils/perceptual_loss.py
#
# MIT License
#
# Copyright (c) 2018 akanazawa
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of ... | 2,298 | 38.637931 | 85 | py |
UMR | UMR-master/nnutils/test_utils.py | # -----------------------------------------------------------
# Code adapted from:
# https://github.com/akanazawa/cmr/blob/master/nnutils/test_utils.py
#
# MIT License
# Copyright (c) 2018 akanazawa
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated docu... | 7,190 | 40.80814 | 138 | py |
UMR | UMR-master/utils/image.py | # -----------------------------------------------------------
# Code adapted from:
# https://github.com/akanazawa/cmr/blob/master/utils/image.py
#
# MIT License
#
# Copyright (c) 2018 akanazawa
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documen... | 12,539 | 28.43662 | 107 | py |
UMR | UMR-master/utils/transformations.py | # -*- coding: utf-8 -*-
# transformations.py
# Copyright (c) 2006-2017, Christoph Gohlke
# Copyright (c) 2006-2017, The Regents of the University of California
# Produced at the Laboratory for Fluorescence Dynamics
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modifica... | 66,389 | 33.38115 | 79 | py |
UMR | UMR-master/utils/kp_utils.py | # -----------------------------------------------------------
# Copyright (C) 2020 NVIDIA Corporation. All rights reserved.
# Nvidia Source Code License-NC
# Code written by Xueting Li.
# -----------------------------------------------------------
import torch
import torch.nn as nn
import cv2
import numpy as np
import... | 3,221 | 34.406593 | 122 | py |
UMR | UMR-master/utils/mesh.py | # -----------------------------------------------------------
# Code adapted from: https://github.com/akanazawa/cmr/blob/master/utils/image.py
#
# MIT License
#
# Copyright (c) 2018 akanazawa
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentat... | 11,455 | 37.442953 | 124 | py |
UMR | UMR-master/data/base.py | # -----------------------------------------------------------------------------
# Code adapted from https://github.com/akanazawa/cmr/blob/master/data/base.py
#
# MIT License
#
# Copyright (c) 2018 akanazawa
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associ... | 12,678 | 37.075075 | 126 | py |
UMR | UMR-master/data/cub_kp_transfer.py | # -----------------------------------------------------------------------------------
# Code adapted from https://github.com/nileshkulkarni/csm/blob/master/csm/data/cub.py
#
# Copyright (C) 2020 NVIDIA Corporation. All rights reserved.
# Nvidia Source Code License-NC
# --------------------------------------------------... | 4,726 | 32.055944 | 106 | py |
UMR | UMR-master/data/cub.py | # -----------------------------------------------------------------------------
# Code adapted from:
# https://github.com/akanazawa/cmr/blob/master/data/cub.py
#
# MIT License
#
# Copyright (c) 2018 akanazawa
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and asso... | 3,993 | 38.156863 | 106 | py |
neurop | neurop-main/codes_pytorch/test.py | from utils import *
from data import build_train_loader, build_val_loader
import argparse
import logging
import os
import random
import numpy as np
import torch
from models import build_model
from tqdm import tqdm
from collections import defaultdict
import imageio
if __name__ == '__main__':
parser = argparse.Arg... | 2,676 | 31.646341 | 159 | py |
neurop | neurop-main/codes_pytorch/train.py | from utils import *
from data import build_train_loader,build_val_loader
import argparse
import logging
import os
import random
import numpy as np
import torch
from models import build_model
from tqdm import tqdm
from collections import defaultdict
import imageio
if __name__ == '__main__':
parser = argparse.Argum... | 2,438 | 32.410959 | 96 | py |
neurop | neurop-main/codes_pytorch/models/loss.py | import torch
import torch.nn as nn
class TVLoss(nn.Module):
def __init__(self,TVLoss_weight=1):
super(TVLoss,self).__init__()
self.TVLoss_weight = TVLoss_weight
def forward(self,x):
batch_size = x.size()[0]
h_x = x.size()[2]
w_x = x.size()[3]
count_h = self._ten... | 1,062 | 34.433333 | 74 | py |
neurop | neurop-main/codes_pytorch/models/model.py | from models.networks import *
from models.loss import *
from torch.nn.parallel import DataParallel
import os
import logging
from collections import OrderedDict, defaultdict
import torch
import torch.nn as nn
class InitModel():
def __init__(self, opt):
self.opt = opt
self.device = torch.device(op... | 10,476 | 38.685606 | 178 | py |
neurop | neurop-main/codes_pytorch/models/networks.py | import functools
import math
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
import argparse
import numpy as np
class Operator(nn.Module):
def __init__(self, in_nc=3, out_nc=3,base_nf=64):
super(Operator,self).__init__()
self.base_nf = base_nf
... | 4,310 | 33.488 | 114 | py |
neurop | neurop-main/codes_pytorch/data/dataset.py | from utils import *
from collections import defaultdict
import imageio
import torch
from torch.utils.data import Dataset
import numpy as np
class InitDataset(Dataset):
def __init__(self,dataset_opt):
super(InitDataset,self).__init__()
opt = dataset_opt
filepath_EX = get_file_paths(os.path.... | 6,541 | 46.064748 | 125 | py |
neurop | neurop-main/codes_pytorch/data/__init__.py | """create dataset and dataloader"""
import logging
import torch
import torch.utils.data
from .dataset import *
def build_train_loader(dataset_opt):
mode = dataset_opt['mode']
num_workers = dataset_opt['n_cpus']
batch_size = dataset_opt['batch_size']
assert(batch_size == 1)
if mode == 'init':
... | 1,877 | 35.115385 | 97 | py |
neurop | neurop-main/codes_jittor/test.py | from utils import *
from data import build_train_loader, build_val_loader
import argparse
import logging
import os
import random
import numpy as np
import torch
from models import build_model
from tqdm import tqdm
from collections import defaultdict
import imageio
import torch
import jittor as jt
if __name__ == '__mai... | 2,725 | 32.243902 | 159 | py |
neurop | neurop-main/codes_jittor/train.py | from utils import *
from data import build_train_loader,build_val_loader
import argparse
import logging
import os
import random
import numpy as np
import torch
from models import build_model
from tqdm import tqdm
from collections import defaultdict
import imageio
import jittor as jt
if __name__ == '__main__':
par... | 2,506 | 31.558442 | 96 | py |
neurop | neurop-main/codes_jittor/models/model.py | from models.networks import *
from models.loss import *
import os
import logging
from collections import OrderedDict, defaultdict
import torch
class InitModel():
def __init__(self, opt):
self.opt = opt
self.name = "neurop_initialization"
net_opt = opt['network_G']
if opt['device'] ... | 7,341 | 37.239583 | 174 | py |
neurop | neurop-main/codes_jittor/models/networks.py | from jittor import Module
import jittor as jt
import jittor.nn as nn
import numpy as np
import torch
class Operator(Module):
def __init__(self, in_nc=3, out_nc=3,base_nf=64):
super(Operator,self).__init__()
self.base_nf = base_nf
self.out_nc = out_nc
self.encoder = nn.Conv2d(in_nc... | 4,196 | 32.047244 | 109 | py |
NerfingMVS | NerfingMVS-main/run.py | import sys
import torch
from torch.multiprocessing import set_start_method
set_start_method('spawn', force=True)
import time
from src import initialize, depth_priors, run_nerf, filter, evaluation
from utils.pose_utils import gen_poses
from options import config_parser
if __name__=='__main__':
time = t... | 723 | 23.133333 | 70 | py |
NerfingMVS | NerfingMVS-main/src/run_nerf.py | import os, sys
sys.path.append('..')
import numpy as np
import imageio
import random
import time
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.tensorboard import SummaryWriter
from tqdm import tqdm, trange
import cv2
import pdb
from models.nerf.run_nerf_helpers import *
from opti... | 24,429 | 37.655063 | 170 | py |
NerfingMVS | NerfingMVS-main/src/evaluation.py | import os, sys
sys.path.append('..')
import torch
from utils.io_utils import *
from utils.evaluation_utils import *
from options import config_parser
def main(args):
image_list = load_img_list(args.datadir, load_test=False)
prior_path = os.path.join(args.basedir, args.expname, 'depth_priors', 'results')
n... | 1,671 | 39.780488 | 84 | py |
NerfingMVS | NerfingMVS-main/src/depth_priors.py | import os, sys
sys.path.append('..')
import numpy as np
import torch
import cv2
from torch.utils.tensorboard import SummaryWriter
from tqdm import tqdm, trange
import pdb
from models.depth_priors.mannequin_challenge_model import MannequinChallengeModel
from options import config_parser
from utils.io_utils import *
fr... | 4,940 | 34.804348 | 123 | py |
NerfingMVS | NerfingMVS-main/models/nerf/run_nerf_helpers.py | import torch
torch.autograd.set_detect_anomaly(True)
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
import lpips
import time
import skimage
import os
import pdb
# Misc
img2mse = lambda x, y : torch.mean((x - y) ** 2)
depth2mse = lambda x, y, mask : torch.mean((x[mask] - y[mask]) ** 2)
mse2psn... | 7,412 | 36.439394 | 139 | py |
NerfingMVS | NerfingMVS-main/models/depth_priors/depth_model.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
from abc import abstractmethod
import torch
class DepthModel(torch.nn.Module):
def __init__(self):
super().__init__()
def forward(self, images, metadata=None):
"""
Images should be feed in the format (N, C, H, ... | 1,037 | 25.615385 | 77 | py |
NerfingMVS | NerfingMVS-main/models/depth_priors/mannequin_challenge_model.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
import sys
import os
import wget
from zipfile import ZipFile
import torch
import torch.autograd as autograd
from .mannequin_challenge.models import pix2pix_model
from .mannequin_challenge.options.train_options import TrainOptions
from .depth_mod... | 3,457 | 31.622642 | 122 | py |
NerfingMVS | NerfingMVS-main/models/depth_priors/mannequin_challenge/models/base_model.py | # Copyright 2019 Google LLC
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, soft... | 2,221 | 29.027027 | 78 | py |
NerfingMVS | NerfingMVS-main/models/depth_priors/mannequin_challenge/models/pix2pix_model.py | # Copyright 2019 Google LLC
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, soft... | 26,932 | 39.68429 | 113 | py |
NerfingMVS | NerfingMVS-main/models/depth_priors/mannequin_challenge/models/networks.py | # Copyright 2019 Google LLC
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, soft... | 24,148 | 37.700321 | 87 | py |
NerfingMVS | NerfingMVS-main/models/depth_priors/mannequin_challenge/models/hourglass.py | # Copyright 2019 Google LLC
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, soft... | 6,211 | 33.131868 | 79 | py |
NerfingMVS | NerfingMVS-main/utils/nerf_utils.py | import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
def align_scales(depth_priors, colmap_depths, colmap_masks, poses, sc, i_train, i_test):
ratio_priors = []
for i in range(depth_priors.shape[0]):
ratio_priors.append(np.median(colmap_depths[i][colmap_masks[i]]) / np.m... | 4,794 | 40.336207 | 119 | py |
NerfingMVS | NerfingMVS-main/utils/evaluation_utils.py | import os
import cv2
import numpy as np
import torch
import lpips
import skimage
def compute_errors(gt, pred):
"""Computation of error metrics between predicted and ground truth depths
"""
thresh = np.maximum((gt / pred), (pred / gt))
a1 = (thresh < 1.25 ).mean()
a2 = (thresh < 1.25 ** 2).mean(... | 3,802 | 33.889908 | 115 | py |
NerfingMVS | NerfingMVS-main/utils/depth_priors_utils.py | import torch
def compute_depth_loss(depth_pred, depth_gt, mask_gt):
loss_list = []
for pred, gt, mask in zip(depth_pred, depth_gt, mask_gt):
log_pred = torch.log(pred[mask])
log_target = torch.log(gt[mask])
alpha = (log_target - log_pred).sum()/mask.sum()
log_diff = torch.abs((l... | 472 | 35.384615 | 61 | py |
NerfingMVS | NerfingMVS-main/utils/io_utils.py | import os
import cv2
import numpy as np
import torch
import imageio
from torchvision import transforms
from .colmap_utils import *
import pdb
def load_img_list(datadir, load_test=False):
with open(os.path.join(datadir, 'train.txt'), 'r') as f:
lines = f.readlines()
image_list = [line.strip() for l... | 5,040 | 32.164474 | 100 | py |
HiPart | HiPart-main/docs/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:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If ex... | 4,029 | 29.300752 | 79 | py |
ANP_backdoor | ANP_backdoor-main/optimize_mask_cifar.py | import os
import time
import argparse
import numpy as np
from collections import OrderedDict
import torch
from torch.utils.data import DataLoader, RandomSampler
from torchvision.datasets import CIFAR10
import torchvision.transforms as transforms
import models
import data.poison_cifar as poison
parser = argparse.Argum... | 11,094 | 42.853755 | 119 | py |
ANP_backdoor | ANP_backdoor-main/prune_neuron_cifar.py | import os
import argparse
import numpy as np
import pandas as pd
import torch
from torch.utils.data import DataLoader
from torchvision.datasets import CIFAR10
import torchvision.transforms as transforms
import models
import data.poison_cifar as poison
parser = argparse.ArgumentParser(description='Train poisoned netwo... | 8,345 | 46.965517 | 119 | py |
ANP_backdoor | ANP_backdoor-main/train_backdoor_cifar.py | import os
import time
import argparse
import logging
import numpy as np
import torch
from torch.utils.data import DataLoader
from torchvision.datasets import CIFAR10
import torchvision.transforms as transforms
import models
import data.poison_cifar as poison
parser = argparse.ArgumentParser(description='Train poisone... | 8,066 | 46.175439 | 120 | py |
ANP_backdoor | ANP_backdoor-main/models/anp_batchnorm.py | # This code is based on:
# https://pytorch.org/docs/stable/_modules/torch/nn/modules/batchnorm.html#BatchNorm2d
# only perturbing weights
import torch
from torch import Tensor
import torch.nn as nn
import torch.nn.functional as F
import torch.nn.init as init
from torch.nn.parameter import Parameter
class NoisyBatchN... | 7,578 | 44.113095 | 115 | py |
ANP_backdoor | ANP_backdoor-main/models/mobilenetv2.py | '''MobileNetV2 in PyTorch.
See the paper "Inverted Residuals and Linear Bottlenecks:
Mobile Networks for Classification, Detection and Segmentation" for more details.
'''
import torch
import torch.nn as nn
import torch.nn.functional as F
class Block(nn.Module):
'''expand + depthwise + pointwise'''
def __init_... | 3,152 | 36.094118 | 114 | py |
ANP_backdoor | ANP_backdoor-main/models/vgg_cifar.py | '''VGG for CIFAR10. FC layers are removed.
(c) YANG, Wei
'''
import torch.nn as nn
import torch.utils.model_zoo as model_zoo
import math
__all__ = [
'VGG', 'vgg11', 'vgg11_bn', 'vgg13', 'vgg13_bn', 'vgg16', 'vgg16_bn',
'vgg19_bn', 'vgg19',
]
model_urls = {
'vgg11': 'https://download.pytorch.org/models/v... | 4,762 | 31.401361 | 113 | py |
ANP_backdoor | ANP_backdoor-main/models/resnet_cifar.py | # This code is modified by
# https://github.com/kuangliu/pytorch-cifar/blob/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, norm_layer=None):
super(BasicBlock, self)._... | 4,648 | 34.48855 | 83 | py |
ANP_backdoor | ANP_backdoor-main/data/poison_cifar.py | import os
import numpy as np
from copy import deepcopy
from torchvision.datasets import CIFAR10
from torch.utils.data import Dataset
from PIL import Image
def split_dataset(dataset, val_frac=0.1, perm=None):
"""
:param dataset: The whole dataset which will be split.
:param val_frac: the fraction of valida... | 6,760 | 41.25625 | 128 | py |
Food-Recipe-CNN | Food-Recipe-CNN-master/python-files/06_02_neural_network_inceptionV3.py | # AUTO-GENERATED FROM JUPYTER NOTEBOOKS
# coding: utf-8
# # **Inception V3 Food Classification 230 categories**
#
# ---
#
#
# In[ ]:
import random
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.pyplot import imshow
get_ipython().run_line_magic('matplotlib', 'inline')
import keras
from keras... | 14,981 | 23.400651 | 303 | py |
Food-Recipe-CNN | Food-Recipe-CNN-master/python-files/05_tSNE.py | # AUTO-GENERATED FROM JUPYTER NOTEBOOKS
# coding: utf-8
# # [Chefkoch.de](http://www.chefkoch.de/) Maturaarbeit 2017/18
# ------
#
# ## Ziel:
# ###
# In[1]:
get_ipython().run_line_magic('matplotlib', 'inline')
import os
import random
import _pickle as pickle
import numpy as np
import matplotlib.pyplot
from matpl... | 7,578 | 23.136943 | 156 | py |
Food-Recipe-CNN | Food-Recipe-CNN-master/python-files/06_05_neural_network_feature_extraction_VGG16_experimental.py | # AUTO-GENERATED FROM JUPYTER NOTEBOOKS
# coding: utf-8
# # **VGG 16 Bottleneck Feature extraction Food Classification 230 categories **
#
# ---
#
#
# https://gist.github.com/Thimira/354b90d59faf8b0d758f74eae3a511e2
#
# http://www.codesofinterest.com/2017/08/bottleneck-features-multi-class-classification-keras.ht... | 11,821 | 23.993658 | 279 | py |
Food-Recipe-CNN | Food-Recipe-CNN-master/python-files/predict_mymodel.py | # AUTO-GENERATED FROM JUPYTER NOTEBOOKS
# coding: utf-8
# In[3]:
get_ipython().run_line_magic('matplotlib', 'inline')
import os
import random
import numpy as np
import keras
import matplotlib.pyplot as plt
from matplotlib.pyplot import imshow
from PIL import Image
from keras.preprocessing import image
from kera... | 11,298 | 25.276744 | 657 | py |
Food-Recipe-CNN | Food-Recipe-CNN-master/python-files/06_03_neural_network_inceptionV3_train_last_layers.py | # AUTO-GENERATED FROM JUPYTER NOTEBOOKS
# coding: utf-8
# # **Inception V3 Food Classification 230 categories**
#
# ---
#
#
# In[1]:
import random
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.pyplot import imshow
get_ipython().run_line_magic('matplotlib', 'inline')
import keras
from keras... | 13,116 | 24.770138 | 317 | py |
Food-Recipe-CNN | Food-Recipe-CNN-master/python-files/07_recurrent_neural_network.py | # AUTO-GENERATED FROM JUPYTER NOTEBOOKS
# coding: utf-8
# In[1]:
import logging
logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.INFO)
# In[2]:
import csv
# In[3]:
def get_preperation():
merged_list = []
skip_first = False # col name
chef_file = '/input/recipe... | 4,642 | 19.364035 | 91 | py |
Food-Recipe-CNN | Food-Recipe-CNN-master/python-files/06_01_neural_network_fit_data_into_mem.py | # AUTO-GENERATED FROM JUPYTER NOTEBOOKS
# coding: utf-8
# # [Chefkoch.de](http://www.chefkoch.de/) Maturaarbeit 2017/18
# ------
#
# # Convolutional Neural Network
#
# ## Ziel:
# ### Training vom ersten Model mit [Cloud Computing Power](https://neptune.ml/)
# In[1]:
import matplotlib.pyplot as plt
import matplot... | 6,593 | 21.053512 | 150 | py |
Food-Recipe-CNN | Food-Recipe-CNN-master/python-files/06_04_neural_network_feature_extraction_VGG16.py | # AUTO-GENERATED FROM JUPYTER NOTEBOOKS
# coding: utf-8
# # **Feature Extraction from FC-2 Layer VGG-16**
#
# ---
#
#
# In[1]:
get_ipython().system("echo 'tqdm\\ntables\\nfalconn\\nPyDrive' > requirements.txt")
get_ipython().system('pip install -r requirements.txt')
# In[2]:
import random
import numpy as np
... | 16,986 | 29.885455 | 1,151 | py |
Food-Recipe-CNN | Food-Recipe-CNN-master/python-files/models_evaluation.py | # AUTO-GENERATED FROM JUPYTER NOTEBOOKS
# coding: utf-8
# ## Find out which model predicts with highest accuracy.
#
# #### 28.10.2018
# # Download and prepare models and dataset for testing
# In[8]:
########################### KNOW RAM AND GPU MEMORY ############################
# Thanks to: Stas Bekman
# https:/... | 10,613 | 21.728051 | 238 | py |
Food-Recipe-CNN | Food-Recipe-CNN-master/python-files/evaluate_one_model.py | # AUTO-GENERATED FROM JUPYTER NOTEBOOKS
# coding: utf-8
# # **Evaluate your best model on the whole dataset**
#
# ---
#
#
# In[2]:
from google.colab import files
get_ipython().run_line_magic('matplotlib', 'inline')
import os
import random
import numpy as np
import keras
import matplotlib.pyplot as plt
from m... | 10,272 | 24.491315 | 294 | py |
Food-Recipe-CNN | Food-Recipe-CNN-master/deploy/predict_food.py | # coding=utf-8
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.decomposition import IncrementalPCA
from keras.preprocessing import image
from keras.applications import VGG16
from keras.applications.imagenet_utils import preprocess_input as preprocess_input_vgg
from keras.application... | 6,312 | 36.35503 | 144 | py |
Food-Recipe-CNN | Food-Recipe-CNN-master/deploy/utils_food.py | import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from keras.preprocessing import image
def plot_preds(image, probabilities, top_n, categories):
"""Plot the probabilities from the Inception network."""
plt.imshow(image)
plt.axis('off')
plt.figure()
order = list(reversed(range(... | 2,843 | 38.5 | 148 | py |
tflite-micro | tflite-micro-main/tensorflow/lite/micro/tools/tflm_model_transforms_test.py | # Copyright 2023 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 applica... | 3,247 | 37.211765 | 86 | py |
tflite-micro | tflite-micro-main/tensorflow/lite/micro/tools/requantize_flatbuffer_test.py | # Copyright 2023 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 applica... | 4,714 | 39.646552 | 106 | py |
tflite-micro | tflite-micro-main/tensorflow/lite/micro/testing/generate_test_models.py | # Copyright 2020 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 applica... | 3,110 | 33.955056 | 80 | py |
tflite-micro | tflite-micro-main/tensorflow/lite/micro/examples/mnist_lstm/train.py | # Copyright 2022 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 applica... | 6,866 | 32.334951 | 158 | py |
tflite-micro | tflite-micro-main/tensorflow/lite/micro/examples/recipes/resource_variables_lib.py | # Copyright 2023 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 applica... | 3,995 | 32.579832 | 89 | py |
tflite-micro | tflite-micro-main/tensorflow/lite/micro/examples/recipes/resource_variables_test.py | # Copyright 2023 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 applica... | 2,454 | 37.359375 | 86 | py |
tflite-micro | tflite-micro-main/tensorflow/lite/micro/examples/hello_world/train.py | # Copyright 2023 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 applica... | 4,685 | 32.234043 | 107 | py |
tflite-micro | tflite-micro-main/tensorflow/lite/micro/examples/hello_world/quantization/ptq.py | # Copyright 2023 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 applica... | 4,227 | 35.448276 | 139 | py |
tflite-micro | tflite-micro-main/tensorflow/lite/micro/examples/memory_footprint/create_adder_model.py | # Copyright 2021 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 applica... | 1,956 | 33.946429 | 80 | py |
tflite-micro | tflite-micro-main/tensorflow/lite/micro/kernels/testdata/lstm_test_data_generator_test.py | # Copyright 2023 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 applica... | 3,836 | 34.527778 | 84 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.