python_code
stringlengths
0
229k
# Copyright (c) Meta Platforms, Inc. and affiliates. # This software may be used and distributed according to the terms of the GNU General Public License version 3. from ...util.model import BenchmarkModel from .build_sam import sam_model_registry from .predictor import SamPredictor from PIL import Image import numpy ...
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import torch import torch.nn as nn from typing import Type class MLPBlock(nn.Module): def __init__( self, ...
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import torch from torch import Tensor, nn import math from typing import Tuple, Type from .common import MLPBlock clas...
import os import subprocess import sys def pip_install_requirements(): subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-q', '-r', 'requirements.txt']) def download_checkpoint(): subprocess.check_call(['wget', '-P', '.data', 'https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth'...
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import torch import torch.nn as nn import torch.nn.functional as F from typing import Optional, Tuple, Type from .common...
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import numpy as np import torch from torch import nn from typing import Any, Optional, Tuple, Type from .common import L...
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import torch from torch import nn from torch.nn import functional as F from typing import Any, Dict, List, Tuple from .i...
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import torch from torch import nn from torch.nn import functional as F from typing import List, Tuple, Type from .common...
from torchbenchmark.tasks import NLP from torchbenchmark.util.framework.huggingface.model_factory import HuggingFaceModel class Model(HuggingFaceModel): task = NLP.LANGUAGE_MODELING DEFAULT_TRAIN_BSIZE = 4 DEFAULT_EVAL_BSIZE = 1 def __init__(self, test, device, batch_size=None, extra_args=[]): ...
import subprocess import sys import os from torchbenchmark.util.framework.huggingface.patch_hf import patch_transformers, cache_model def pip_install_requirements(): subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-q', '-r', 'requirements.txt']) if __name__ == '__main__': pip_install_requirem...
import torch from . import tke_pytorch from typing import Tuple from torchbenchmark.tasks import OTHER from ...util.model import BenchmarkModel def _generate_inputs(size): import numpy as np import math np.random.seed(17) shape = ( math.ceil(2 * size ** (1 / 3)), math.ceil(2 * size *...
import torch def solve_tridiag(a, b, c, d): """ Solves a tridiagonal matrix system with diagonals a, b, c and RHS vector d. """ assert a.shape == b.shape and a.shape == c.shape and a.shape == d.shape n = a.shape[-1] for i in range(1, n): w = a[..., i] / b[..., i - 1] b[..., i...
if __name__ == "__main__": pass
from torchbenchmark.tasks import NLP from torchbenchmark.util.framework.huggingface.model_factory import HuggingFaceModel class Model(HuggingFaceModel): task = NLP.LANGUAGE_MODELING # Original train batch size per device: 8 # Source: https://github.com/huggingface/transformers/blob/master/examples/flax/lan...
import subprocess import sys import os from torchbenchmark.util.framework.huggingface.patch_hf import patch_transformers, cache_model def pip_install_requirements(): subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-q', '-r', 'requirements.txt']) if __name__ == '__main__': pip_install_requirem...
# Copyright (c) 2017 NVIDIA Corporation import argparse from math import sqrt parser = argparse.ArgumentParser(description='RMSE_calculator') parser.add_argument('--path_to_predictions', type=str, default="", metavar='N', help='Path file with actual ratings and predictions') parser.add_argument('-...
# Benchmark created from NVidia DeepRecommender github project: # https://github.com/NVIDIA/DeepRecommender # a32a8a5c23092c551616acf6fac5b32e1155d18b # Test supports eval and train modes for cpu and cuda targets. # # Both nvtrain.py and nvinfer.py support all original command # line parameters but tensorflow depen...
# Copyright (c) 2017 NVIDIA Corporation # parameters to run benchmark on cpu # --path_to_train_data Netflix/N1W_TRAIN --path_to_eval_data Netflix/N1W_TEST --hidden_layers 512,512,1024 --non_linearity_type selu --save_path model_save/model.epoch_0 --drop_prob 0.8 --predictions_path preds.txt --nooutput --forcecpu # pa...
# Copyright (c) 2017 NVIDIA Corporation # to run against cuda: # --gpu_ids 0 --path_to_train_data Netflix/N1W_TRAIN --path_to_eval_data Netflix/N1W_VALID --hidden_layers 512,512,1024 --non_linearity_type selu --batch_size 128 --logdir model_save --drop_prob 0.8 --optimizer momentum --lr 0.005 --weight_decay 0 --aug_st...
import subprocess import sys def pip_install_requirements(): subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-q', '-r', 'requirements.txt']) if __name__ == '__main__': pip_install_requirements()
# Copyright (c) 2017 NVIDIA Corporation from os import listdir, path, makedirs import random import sys import time import datetime def print_stats(data): total_ratings = 0 print("STATS") for user in data: total_ratings += len(data[user]) print("Total Ratings: {}".format(total_ratings)) print("Total User...
# Copyright (c) 2017 NVIDIA Corporation import sys import datetime import random from math import floor def print_stats(data): total_ratings = 0 print("STATS") for user in data: total_ratings += len(data[user]) print("Total Ratings: {}".format(total_ratings)) print("Total User count: {}".format(len(data....
# Copyright (c) 2017 NVIDIA Corporation
# Copyright (c) 2017 NVIDIA Corporation
# Copyright (c) 2017 NVIDIA Corporation import torch import torch.nn as nn import torch.nn.functional as F import torch.nn.init as weight_init from torch.autograd import Variable def activation(input, kind): #print("Activation: {}".format(kind)) if kind == 'selu': return F.selu(input) elif kind == 'relu': ...
# Copyright (c) 2017 NVIDIA Corporation
# Copyright (c) 2017 NVIDIA Corporation """Data Layer Classes""" from os import listdir, path from random import shuffle import torch class UserItemRecDataProvider: def __init__(self, params, user_id_map=None, item_id_map=None): self._params = params self._data_dir = self.params['data_dir'] self._extensi...
import os from torchbenchmark.tasks import COMPUTER_VISION from torchbenchmark.util.framework.detectron2.model_factory import Detectron2Model MODEL_NAME = os.path.basename(os.path.dirname(os.path.abspath(__file__))) MODEL_DIR = os.path.abspath(os.path.dirname(__file__)) class Model(Detectron2Model): task = COMPUT...
import os from torchbenchmark.util.framework.detectron2 import install_detectron2 MODEL_NAME = os.path.basename(os.path.dirname(os.path.abspath(__file__))) MODEL_DIR = os.path.abspath(os.path.dirname(__file__)) if __name__ == '__main__': install_detectron2(MODEL_NAME, MODEL_DIR)
import torch import torch.optim as optim import torch.nn as nn import torch.utils.data as data import torchvision.models as models from opacus import PrivacyEngine from opacus.validators.module_validator import ModuleValidator from typing import Tuple from ...util.model import BenchmarkModel from torchbenchmark.tasks ...
import subprocess import sys def pip_install_requirements(): subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-q', '-r', 'requirements.txt']) if __name__ == '__main__': pip_install_requirements()
from ...util.model import BenchmarkModel from torchbenchmark.tasks import NLP import torch from .model import GPT, SequenceGeneratorNanoGPT, GPTConfig, GPTGenerationConfig class Model(BenchmarkModel): task = NLP.GENERATION DEFAULT_EVAL_BSIZE = 1 def __init__(self, test, device, batch_size=None, extra_arg...
""" Full definition of a GPT Language Model, all of it in this single file. References: 1) the official GPT-2 TensorFlow implementation released by OpenAI: https://github.com/openai/gpt-2/blob/master/src/model.py 2) huggingface/transformers PyTorch implementation: https://github.com/huggingface/transformers/blob/main/s...
from torchbenchmark.util.framework.vision.model_factory import TorchVisionModel from torchbenchmark.tasks import COMPUTER_VISION import torch.optim as optim import torch import torchvision.models as models class Model(TorchVisionModel): task = COMPUTER_VISION.CLASSIFICATION # Original train batch size: 512, o...
import argparse import random from collections import deque import math import gym import numpy as np class ActionRepeatWrapper(gym.Wrapper): def __init__(self, env, repeat_multiplier=8): super().__init__(env) self.action_space = gym.spaces.Box( -1.0, 1.0, shape=(1 + self.env.action_s...
import dataclasses @dataclasses.dataclass class SACConfig: env_id = "Pendulum-v1" seed = 123 num_steps = 1 transitions_per_step = 1 max_episode_steps = 10 batch_size = 512 tau = 0.005 actor_lr = 1e-4 critic_lr = 1e-4 gamma = 0.99 init_alpha = 0.1 alpha_lr = 1e-4 buff...
import torch import os import copy import pickle import math from itertools import chain from ...util.model import BenchmarkModel from torchbenchmark.tasks import REINFORCEMENT_LEARNING from typing import Tuple from .config import SACConfig from .envs import load_gym from .sac import SACAgent from .replay import Prio...
import argparse import copy import math import os from itertools import chain import numpy as np import tensorboardX import torch import torch.nn.functional as F import tqdm from . import envs, nets, replay, utils class SACAgent: def __init__( self, obs_space_size, act_space_size, ...
import numpy as np import torch def unique(sorted_array): """ More efficient implementation of np.unique for sorted arrays :param sorted_array: (np.ndarray) :return:(np.ndarray) sorted_array without duplicate elements """ if len(sorted_array) == 1: return sorted_array left = sorted...
import math import os import random from collections import namedtuple import gym import numpy as np import torch def clean_hparams_dict(hparams_dict): return {key: val for key, val in hparams_dict.items() if val} def get_grad_norm(model): total_norm = 0.0 for p in model.parameters(): try: ...
import os import subprocess import sys def pip_install_requirements(): subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-q', '-r', 'requirements.txt']) if __name__ == '__main__': pip_install_requirements()
import math import numpy as np import torch import torch.nn.functional as F from torch import distributions as pyd from torch import nn from . import utils def weight_init(m): if isinstance(m, nn.Linear): nn.init.orthogonal_(m.weight.data) m.bias.data.fill_(0.0) elif isinstance(m, nn.Conv2d)...
from torchbenchmark.util.framework.vision.model_factory import TorchVisionModel from torchbenchmark.tasks import COMPUTER_VISION import torchvision.models as models class Model(TorchVisionModel): task = COMPUTER_VISION.CLASSIFICATION # Train batch size: use the training batch in paper. # Source: https://ar...
# Ported from pytorch example: # https://github.com/pytorch/examples/blob/master/dcgan/main.py from __future__ import print_function import argparse import os import random from typing import Any, Tuple import torch import torch.nn as nn import torch.nn.parallel import torch.backends.cudnn as cudnn import torch.opt...
import subprocess import sys def pip_install_requirements(): subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-q', '-r', 'requirements.txt']) if __name__ == '__main__': pip_install_requirements()
from torchbenchmark.util.framework.huggingface.model_factory import HuggingFaceModel from torchbenchmark.tasks import SPEECH import torch class Model(HuggingFaceModel): task = SPEECH.RECOGNITION DEFAULT_EVAL_BSIZE = 8 DEFAULT_EVAL_CUDA_PRECISION = "fp16" def __init__(self, test, device, batch_size...
import subprocess import sys import os from torchbenchmark.util.framework.huggingface.patch_hf import patch_transformers, cache_model def pip_install_requirements(): subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-q', '-r', 'requirements.txt']) if __name__ == '__main__': pip_install_requireme...
import os from torchbenchmark.tasks import COMPUTER_VISION from torchbenchmark.util.framework.detectron2.model_factory import Detectron2Model MODEL_NAME = os.path.basename(os.path.dirname(__file__)) MODEL_DIR = os.path.abspath(os.path.dirname(__file__)) class Model(Detectron2Model): task = COMPUTER_VISION.DETECTI...
import os from torchbenchmark.util.framework.detectron2 import install_detectron2 MODEL_NAME = os.path.basename(os.path.dirname(os.path.abspath(__file__))) MODEL_DIR = os.path.abspath(os.path.dirname(__file__)) if __name__ == '__main__': install_detectron2(MODEL_NAME, MODEL_DIR)
import os from torchbenchmark.tasks import COMPUTER_VISION from torchbenchmark.util.framework.detectron2.model_factory import Detectron2Model MODEL_NAME = os.path.basename(os.path.dirname(os.path.abspath(__file__))) MODEL_DIR = os.path.abspath(os.path.dirname(__file__)) class Model(Detectron2Model): task = COMPUT...
import os from torchbenchmark.util.framework.detectron2 import install_detectron2 MODEL_NAME = os.path.basename(os.path.dirname(os.path.abspath(__file__))) MODEL_DIR = os.path.abspath(os.path.dirname(__file__)) if __name__ == '__main__': install_detectron2(MODEL_NAME, MODEL_DIR)
from torchbenchmark.util.framework.vision.model_factory import TorchVisionModel from torchbenchmark.tasks import COMPUTER_VISION import torchvision.models as models class Model(TorchVisionModel): task = COMPUTER_VISION.CLASSIFICATION DEFAULT_TRAIN_BSIZE = 128 DEFAULT_EVAL_BSIZE = 64 def __init__(self,...
from torchbenchmark.util.framework.gnn.model_factory import BasicGNNModel from torchbenchmark.tasks import GNN class Model(BasicGNNModel): def __init__(self, test, device, batch_size=None, extra_args=[]): super().__init__(model_name="gcn", test=test, device=device, batch_size=batch...
from torchbenchmark.util.framework.gnn import install_pytorch_geometric if __name__ == '__main__': install_pytorch_geometric()
from torchbenchmark.util.framework.gnn.model_factory import BasicGNNModel from torchbenchmark.tasks import GNN class Model(BasicGNNModel): def __init__(self, test, device, batch_size=None, extra_args=[]): super().__init__(model_name="gin", test=test, device=device, batch_size=batch...
from torchbenchmark.util.framework.gnn import install_pytorch_geometric if __name__ == '__main__': install_pytorch_geometric()
import torch def get_drhodT(salt, temp, p): rho0 = 1024.0 z0 = 0.0 theta0 = 283.0 - 273.15 grav = 9.81 betaT = 1.67e-4 betaTs = 1e-5 gammas = 1.1e-8 zz = -p - z0 thetas = temp - theta0 return -(betaTs * thetas + betaT * (1 - gammas * grav * zz * rho0)) * rho0 def get_drhodS(...
import torch from . import isoneutral_pytorch from torchbenchmark.tasks import OTHER from ...util.model import BenchmarkModel from typing import Tuple def _generate_inputs(size): import math import numpy as np np.random.seed(17) shape = ( math.ceil(2 * size ** (1 / 3)), math.ceil(2 * ...
if __name__ == "__main__": pass
# This example was adapated from https://github.com/muhrin/milad # It is licensed under the GLPv3 license. You can find a copy of it # here: https://www.gnu.org/licenses/gpl-3.0.en.html . import torch import torch.optim as optim import torch.nn as nn import torch.nn.functional as F from functorch import vmap, jacrev f...
import subprocess import sys def pip_install_requirements(): subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-q', '-r', 'requirements.txt']) if __name__ == '__main__': pip_install_requirements()
from torchbenchmark.tasks import NLP from torchbenchmark.util.framework.huggingface.model_factory import HuggingFaceModel class Model(HuggingFaceModel): task = NLP.LANGUAGE_MODELING DEFAULT_TRAIN_BSIZE = 4 DEFAULT_EVAL_BSIZE = 1 def __init__(self, test, device, batch_size=None, extra_args=[]): ...
import subprocess import sys import os from torchbenchmark.util.framework.huggingface.patch_hf import patch_transformers, cache_model def pip_install_requirements(): subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-q', '-r', 'requirements.txt']) if __name__ == '__main__': pip_install_requirem...
""" fastNLP model (TorchBenchmark Version) This model resembles the "BertEmedding Q&A" task in [fastNLP Tutorial](https://fastnlp.readthedocs.io/zh/latest/tutorials/extend_1_bert_embedding.html). Input data simulates [CMRC2018 dataset](https://ymcui.com/cmrc2018/). The program runs only for benchmark purposes and does...
import subprocess import os import sys import patch def patch_fastnlp(): import fastNLP current_dir = os.path.dirname(os.path.abspath(__file__)) patch_file = os.path.join(current_dir, "fastnlp.patch") fastNLP_dir = os.path.dirname(fastNLP.__file__) fastNLP_target_file = os.path.join(fastNLP_dir, "e...
""" Generator of a simulated CMRC2018 dataset. Use random Chinese characters with the same length as the original dataset. """ import os import pathlib import json import random TRAIN_NUM_BATCH = 1 EVAL_NUM_BATCH = 1 CMRC2018_TRAIN_SPEC = { # Original # "data_size": 2403, # Benchmark "data_size": 6, #...
import torch from . import eos_pytorch from torchbenchmark.tasks import OTHER from ...util.model import BenchmarkModel from typing import Tuple def _generate_inputs(size): import math import numpy as np np.random.seed(17) shape = ( math.ceil(2 * size ** (1/3)), math.ceil(2 * size ** (1...
""" ========================================================================== in-situ density, dynamic enthalpy and derivatives from Absolute Salinity and Conservative Temperature, using the computationally-efficient 48-term expression for density in terms of SA, CT and p (IOC et al., 2010). ==================...
if __name__ == "__main__": pass
# Generated by gen_torchvision_benchmark.py import torch import torch.optim as optim import torchvision.models as models from torch.quantization import quantize_fx from torchbenchmark.tasks import COMPUTER_VISION from ...util.model import BenchmarkModel from typing import Tuple class Model(BenchmarkModel): task =...
import argparse import numpy as np import random import torch import torch.nn as nn import torch.nn.functional as F from torch import optim from typing import Tuple torch.backends.cudnn.deterministic = True torch.backends.cudnn.benchmark = False from .pytorch_unet.unet import UNet from .pytorch_unet.utils.dice_score...
import subprocess import sys def pip_install_requirements(): subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-q', '-r', 'pytorch_unet/requirements.txt']) if __name__ == '__main__': pip_install_requirements()
import argparse import logging import os import numpy as np import torch import torch.nn.functional as F from PIL import Image from torchvision import transforms from utils.data_loading import BasicDataset from unet import UNet from utils.utils import plot_img_and_mask def predict_img(net, full_img, ...
import argparse import logging import sys from pathlib import Path import torch import torch.nn as nn import torch.nn.functional as F import wandb from torch import optim from torch.utils.data import DataLoader, random_split from tqdm import tqdm from utils.data_loading import BasicDataset, CarvanaDataset from utils....
import torch import torch.nn.functional as F from tqdm import tqdm from utils.dice_score import multiclass_dice_coeff, dice_coeff def evaluate(net, dataloader, device): net.eval() num_val_batches = len(dataloader) dice_score = 0 # iterate over the validation set for batch in tqdm(dataloader, tot...
import torch from unet import UNet as _UNet def unet_carvana(pretrained=False): """ UNet model trained on the Carvana dataset ( https://www.kaggle.com/c/carvana-image-masking-challenge/data ). Set the scale to 0.5 (50%) when predicting. """ net = _UNet(n_channels=3, n_classes=2, bilinear=True) ...
import logging from os import listdir from os.path import splitext from pathlib import Path import numpy as np import torch from PIL import Image from torch.utils.data import Dataset class BasicDataset(Dataset): def __init__(self, images_dir: str, masks_dir: str, scale: float = 1.0, mask_suffix: str = ''): ...
import torch from torch import Tensor def dice_coeff(input: Tensor, target: Tensor, reduce_batch_first: bool = False, epsilon=1e-6): # Average of Dice coefficient for all batches, or for a single mask assert input.size() == target.size() if input.dim() == 2 and reduce_batch_first: raise ValueError...
import matplotlib.pyplot as plt def plot_img_and_mask(img, mask): classes = mask.shape[0] if len(mask.shape) > 2 else 1 fig, ax = plt.subplots(1, classes + 1) ax[0].set_title('Input image') ax[0].imshow(img) if classes > 1: for i in range(classes): ax[i + 1].set_title(f'Output ...
from .unet_model import UNet
""" Parts of the U-Net model """ import torch import torch.nn as nn import torch.nn.functional as F class DoubleConv(nn.Module): """(convolution => [BN] => ReLU) * 2""" def __init__(self, in_channels, out_channels, mid_channels=None): super().__init__() if not mid_channels: mid_c...
""" Full assembly of the parts to form the complete network """ from .unet_parts import * class UNet(nn.Module): def __init__(self, n_channels, n_classes, bilinear=True): super(UNet, self).__init__() self.n_channels = n_channels self.n_classes = n_classes self.bilinear = bilinear ...
from torchbenchmark.util.framework.vision.model_factory import TorchVisionModel from torchbenchmark.tasks import COMPUTER_VISION import torchvision.models as models class Model(TorchVisionModel): task = COMPUTER_VISION.CLASSIFICATION DEFAULT_TRAIN_BSIZE = 32 DEFAULT_EVAL_BSIZE = 32 def __init__(self, ...
from torchbenchmark.util.framework.huggingface.model_factory import HuggingFaceGenerationModel class Model(HuggingFaceGenerationModel): def __init__(self, test, device, batch_size=None, extra_args=[]): super().__init__(name="hf_T5_generate", test=test, device=device, batch_size=batch_size, extra_args=extra...
from torchbenchmark.util.framework.vision.model_factory import TorchVisionModel from torchbenchmark.tasks import COMPUTER_VISION import torchvision.models as models class Model(TorchVisionModel): task = COMPUTER_VISION.CLASSIFICATION DEFAULT_TRAIN_BSIZE = 16 DEFAULT_EVAL_BSIZE = 8 def __init__(self, t...
import numpy as np import torch import torchvision import cv2, pdb def composite4(fg, bg, a): fg = np.array(fg, np.float32) alpha= np.expand_dims(a / 255,axis=2) im = alpha * fg + (1 - alpha) * bg im = im.astype(np.uint8) return im def compose_image_withshift(alpha_pred,fg_pred,bg,seg): image_sh=torch.zero...
import torch import torch.nn as nn import torch.nn.functional as F import numpy as np #import matplotlib.pyplot as plt import pdb from torch.nn.modules.loss import _Loss from torch.autograd import Function, Variable #import scipy.io as sio class alpha_loss(_Loss): def __init__(self): super(alpha_loss,self).__init_...
import os from io import BytesIO import tarfile import tempfile from six.moves import urllib import numpy as np from PIL import Image import cv2, pdb, glob, argparse import tensorflow as tf class DeepLabModel(object): """Class to load deeplab model and run inference.""" INPUT_TENSOR_NAME = 'ImageTensor:0' OUTP...
import numpy as np import cv2, pdb, glob, argparse MAX_FEATURES = 500 GOOD_MATCH_PERCENT = 0.15 def alignImages(im1, im2,masksDL): # Convert images to grayscale im1Gray = cv2.cvtColor(im1, cv2.COLOR_BGR2GRAY) im2Gray = cv2.cvtColor(im2, cv2.COLOR_BGR2GRAY) akaze = cv2.AKAZE_create() keypoints1, descriptors1 =...
from __future__ import print_function import torch from torch.autograd import Variable import torch.nn as nn import torch.optim as optim from tensorboardX import SummaryWriter import os import time import argparse from data_loader import AdobeDataAffineHR from functions import * from networks import ResnetCondition...
import numpy as np import cv2, pdb, glob, argparse MAX_FEATURES = 500 GOOD_MATCH_PERCENT = 0.15 def alignImages(im1, im2,masksDL): # Convert images to grayscale im1Gray = cv2.cvtColor(im1, cv2.COLOR_BGR2GRAY) im2Gray = cv2.cvtColor(im2, cv2.COLOR_BGR2GRAY) akaze = cv2.AKAZE_create() keypoints1, descriptors1 =...
from __future__ import print_function, division import os import torch import pandas as pd import skimage from skimage import io import numpy as np import matplotlib.pyplot as plt import pdb, random from torch.utils.data import Dataset, DataLoader import random, os, cv2 unknown_code=128 class VideoData(Dataset): def...